Skip to content

Fixed the storage cmdlets alias not in resource mode bug #1391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions setup/azurecmdfiles.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<Component Id="cmp0761C025FCF8EF027A5BC23C72777C52" Guid="*">
<File Id="fil80798000B169AC6D62DD8331A55CF6FF" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Azure.Storage\Azure.Storage.psd1" />
</Component>
<Component Id="cmpCC0D4240D3640D2D425852E0F2A4D31E" Guid="*">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should not be added - the shortcut should not be added to ASM cmdlets

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a script to define cmdlet aliases.Is there any particular reason that we cannot call script when loading a module?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EmmaZhu @blueww No, I'm saying the script should only be copied into the folder you need it, not into 3 folders. To be clear, it should only be copied into ResourceManager\Azure.Storage...

<File Id="fil12F99A3166EFE4DC83A3FA8C7EBCF53F" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Azure.Storage\AzureStorageStartup.ps1" />
</Component>
<Component Id="cmp658F4F28B5894F240AF3AE214E228C7A" Guid="*">
<File Id="fil73B16246DA5417876E50086E40C8A00A" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Azure.Storage\Hyak.Common.dll" />
</Component>
Expand Down Expand Up @@ -2803,6 +2806,9 @@
<Component Id="cmpA4896332D2E9278A5CFFC76462E3D397" Guid="*">
<File Id="filB992523DF0C46B6B6E8C09B1BB31B817" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Azure.Storage\Azure.Storage.psd1" />
</Component>
<Component Id="cmp4E5F2CFF9BC468A2A8873B7D3261F7AE" Guid="*">
<File Id="fil56B4216361B8FAE2391F878C1BBEE9A4" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Azure.Storage\AzureStorageStartup.ps1" />
</Component>
<Component Id="cmp1D11794D4DE13CD2849C407A7736B398" Guid="*">
<File Id="fil96E9CABBEC4A47800C1290A56CCB4839" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Azure.Storage\Hyak.Common.dll" />
</Component>
Expand Down Expand Up @@ -4764,6 +4770,7 @@
<Fragment>
<ComponentGroup Id="azurecmdfiles">
<ComponentRef Id="cmp0761C025FCF8EF027A5BC23C72777C52" />
<ComponentRef Id="cmpCC0D4240D3640D2D425852E0F2A4D31E" />
<ComponentRef Id="cmp658F4F28B5894F240AF3AE214E228C7A" />
<ComponentRef Id="cmpBE01F246267602912E7BB7FAC7C89B62" />
<ComponentRef Id="cmp12AAE81384B3AF67B8D558AB9941F111" />
Expand Down Expand Up @@ -5675,6 +5682,7 @@
<ComponentRef Id="cmp01E003A3FA26FB81C6B89817FE7250BE" />
<ComponentRef Id="cmp5E7A927FFF2CD1AC2D9A4D4746132F63" />
<ComponentRef Id="cmpA4896332D2E9278A5CFFC76462E3D397" />
<ComponentRef Id="cmp4E5F2CFF9BC468A2A8873B7D3261F7AE" />
<ComponentRef Id="cmp1D11794D4DE13CD2849C407A7736B398" />
<ComponentRef Id="cmpCCBFA5B04DFD985227AF6B654A18F375" />
<ComponentRef Id="cmp9F56F57F285139F1E6B4A645E24EA274" />
Expand Down
22 changes: 22 additions & 0 deletions src/Common/Storage/Commands.Storage/AzureStorageStartup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

$script:aliases = @{
# Storage aliases
"Get-AzureStorageContainerAcl" = "Get-AzureStorageContainer";
"Start-CopyAzureStorageBlob" = "Start-AzureStorageBlobCopy";
"Stop-CopyAzureStorageBlob" = "Stop-AzureStorageBlobCopy";
}

$aliases.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
{
using System;
using System.IO;
using System.Collections.Generic;
using System.Management.Automation;
using System.Security.Permissions;
Expand All @@ -28,10 +29,12 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.DataMovement;
using Microsoft.WindowsAzure.Storage.File;
using Microsoft.Azure.Common.Authentication;
using System.Reflection;

[Cmdlet(VerbsLifecycle.Start, StorageNouns.CopyBlob, ConfirmImpact = ConfirmImpact.High, DefaultParameterSetName = ContainerNameParameterSet),
OutputType(typeof(AzureStorageBlob))]
public class StartAzureStorageBlobCopy : StorageDataMovementCmdletBase
public class StartAzureStorageBlobCopy : StorageDataMovementCmdletBase, IModuleAssemblyInitializer
{
/// <summary>
/// Blob Pipeline parameter set name
Expand Down Expand Up @@ -620,5 +623,23 @@ private CloudBlob GetDestinationBlobWithCopyId(IStorageBlobManagement destChanne
CloudBlob blob = destChannel.GetBlobReferenceFromServer(container, blobName, accessCondition, options, OperationContext);
return blob;
}

public void OnImport()
{
try
{
System.Management.Automation.PowerShell invoker = null;
invoker = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
invoker.AddScript(File.ReadAllText(FileUtilities.GetContentFilePath(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"AzureStorageStartup.ps1")));
invoker.Invoke();
}
catch
{
// Ignore exception.
}
}

}
}
3 changes: 3 additions & 0 deletions src/Common/Storage/Commands.Storage/Commands.Storage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@
<Link>Azure.Storage.psd1</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="AzureStorageStartup.ps1" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Microsoft.WindowsAzure.Commands.Storage.format.ps1xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
Expand Down