Skip to content

Commit 34e5f19

Browse files
committed
RDBug 5079671:[PSH] Storage data plane aliases are not defined in resource mode
1 parent 6721180 commit 34e5f19

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed
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)