Skip to content

Commit eaa63d3

Browse files
committed
Merge pull request #1391 from wastoresh/dev
Fixed the storage cmdlets alias not in resource mode bug
2 parents 2163773 + 5ea475e commit eaa63d3

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

setup/azurecmdfiles.wxi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<Component Id="cmp0761C025FCF8EF027A5BC23C72777C52" Guid="*">
99
<File Id="fil80798000B169AC6D62DD8331A55CF6FF" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Azure.Storage\Azure.Storage.psd1" />
1010
</Component>
11+
<Component Id="cmpCC0D4240D3640D2D425852E0F2A4D31E" Guid="*">
12+
<File Id="fil12F99A3166EFE4DC83A3FA8C7EBCF53F" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Azure.Storage\AzureStorageStartup.ps1" />
13+
</Component>
1114
<Component Id="cmp658F4F28B5894F240AF3AE214E228C7A" Guid="*">
1215
<File Id="fil73B16246DA5417876E50086E40C8A00A" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\Azure.Storage\Hyak.Common.dll" />
1316
</Component>
@@ -2806,6 +2809,9 @@
28062809
<Component Id="cmpA4896332D2E9278A5CFFC76462E3D397" Guid="*">
28072810
<File Id="filB992523DF0C46B6B6E8C09B1BB31B817" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Azure.Storage\Azure.Storage.psd1" />
28082811
</Component>
2812+
<Component Id="cmp4E5F2CFF9BC468A2A8873B7D3261F7AE" Guid="*">
2813+
<File Id="fil56B4216361B8FAE2391F878C1BBEE9A4" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Azure.Storage\AzureStorageStartup.ps1" />
2814+
</Component>
28092815
<Component Id="cmp1D11794D4DE13CD2849C407A7736B398" Guid="*">
28102816
<File Id="fil96E9CABBEC4A47800C1290A56CCB4839" KeyPath="yes" Source="$(var.sourceDir)\ServiceManagement\Azure\Azure.Storage\Hyak.Common.dll" />
28112817
</Component>
@@ -4767,6 +4773,7 @@
47674773
<Fragment>
47684774
<ComponentGroup Id="azurecmdfiles">
47694775
<ComponentRef Id="cmp0761C025FCF8EF027A5BC23C72777C52" />
4776+
<ComponentRef Id="cmpCC0D4240D3640D2D425852E0F2A4D31E" />
47704777
<ComponentRef Id="cmp658F4F28B5894F240AF3AE214E228C7A" />
47714778
<ComponentRef Id="cmpBE01F246267602912E7BB7FAC7C89B62" />
47724779
<ComponentRef Id="cmp12AAE81384B3AF67B8D558AB9941F111" />
@@ -5679,6 +5686,7 @@
56795686
<ComponentRef Id="cmp01E003A3FA26FB81C6B89817FE7250BE" />
56805687
<ComponentRef Id="cmp5E7A927FFF2CD1AC2D9A4D4746132F63" />
56815688
<ComponentRef Id="cmpA4896332D2E9278A5CFFC76462E3D397" />
5689+
<ComponentRef Id="cmp4E5F2CFF9BC468A2A8873B7D3261F7AE" />
56825690
<ComponentRef Id="cmp1D11794D4DE13CD2849C407A7736B398" />
56835691
<ComponentRef Id="cmpCCBFA5B04DFD985227AF6B654A18F375" />
56845692
<ComponentRef Id="cmp9F56F57F285139F1E6B4A645E24EA274" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
$script:aliases = @{
16+
# Storage aliases
17+
"Get-AzureStorageContainerAcl" = "Get-AzureStorageContainer";
18+
"Start-CopyAzureStorageBlob" = "Start-AzureStorageBlobCopy";
19+
"Stop-CopyAzureStorageBlob" = "Stop-AzureStorageBlobCopy";
20+
}
21+
22+
$aliases.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"

src/Common/Storage/Commands.Storage/Blob/Cmdlet/StartAzureStorageBlobCopy.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
1616
{
1717
using System;
18+
using System.IO;
1819
using System.Collections.Generic;
1920
using System.Management.Automation;
2021
using System.Security.Permissions;
@@ -28,10 +29,12 @@ namespace Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet
2829
using Microsoft.WindowsAzure.Storage.Blob;
2930
using Microsoft.WindowsAzure.Storage.DataMovement;
3031
using Microsoft.WindowsAzure.Storage.File;
32+
using Microsoft.Azure.Common.Authentication;
33+
using System.Reflection;
3134

3235
[Cmdlet(VerbsLifecycle.Start, StorageNouns.CopyBlob, ConfirmImpact = ConfirmImpact.High, DefaultParameterSetName = ContainerNameParameterSet),
3336
OutputType(typeof(AzureStorageBlob))]
34-
public class StartAzureStorageBlobCopy : StorageDataMovementCmdletBase
37+
public class StartAzureStorageBlobCopy : StorageDataMovementCmdletBase, IModuleAssemblyInitializer
3538
{
3639
/// <summary>
3740
/// Blob Pipeline parameter set name
@@ -620,5 +623,23 @@ private CloudBlob GetDestinationBlobWithCopyId(IStorageBlobManagement destChanne
620623
CloudBlob blob = destChannel.GetBlobReferenceFromServer(container, blobName, accessCondition, options, OperationContext);
621624
return blob;
622625
}
626+
627+
public void OnImport()
628+
{
629+
try
630+
{
631+
System.Management.Automation.PowerShell invoker = null;
632+
invoker = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
633+
invoker.AddScript(File.ReadAllText(FileUtilities.GetContentFilePath(
634+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
635+
"AzureStorageStartup.ps1")));
636+
invoker.Invoke();
637+
}
638+
catch
639+
{
640+
// Ignore exception.
641+
}
642+
}
643+
623644
}
624645
}

src/Common/Storage/Commands.Storage/Commands.Storage.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@
293293
<Link>Azure.Storage.psd1</Link>
294294
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
295295
</None>
296+
<None Include="AzureStorageStartup.ps1" >
297+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
298+
</None>
296299
<None Include="Microsoft.WindowsAzure.Commands.Storage.format.ps1xml">
297300
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
298301
<SubType>Designer</SubType>

0 commit comments

Comments
 (0)