Skip to content

Commit 3c31b93

Browse files
authored
Merge pull request Azure#3003 from markcowl/release-3.0.0
Update Swap-AzureRmWebAppSlot cmdlet to use a common verb name
2 parents 3d4a098 + 6f77449 commit 3c31b93

File tree

6 files changed

+57
-8
lines changed

6 files changed

+57
-8
lines changed

setup/azurecmdfiles.wxi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,6 +3445,9 @@
34453445
<Component Id="cmpC84155BCEC352235456F36314798DEB6" Guid="*">
34463446
<File Id="fil3C07A3FCD79F4E195B1E0F363C1D912D" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Websites\System.Net.Http.Primitives.dll" />
34473447
</Component>
3448+
<Component Id="cmpDFB87EBE10120BEA0EE0E65B1CA9BBFE" Guid="*">
3449+
<File Id="filF6BB7994B63BABCF5598ACDF7BFABA06" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Websites\WebsitesStartup.ps1" />
3450+
</Component>
34483451
</Directory>
34493452
</Directory>
34503453
</Directory>
@@ -6570,6 +6573,7 @@
65706573
<ComponentRef Id="cmp9C45E87E06D911D61AAC3019BA99FB0C" />
65716574
<ComponentRef Id="cmp4E4BAFA8406471B1D2FFA4860A8AEAA7" />
65726575
<ComponentRef Id="cmpC84155BCEC352235456F36314798DEB6" />
6576+
<ComponentRef Id="cmpDFB87EBE10120BEA0EE0E65B1CA9BBFE" />
65736577
<ComponentRef Id="cmp5DFC4ECCB8BBF842D8069F3036386B84" />
65746578
<ComponentRef Id="cmp215D8C03C711DF4FF42B3D06ED14C790" />
65756579
<ComponentRef Id="cmpE75B6D337DC4A69EC4CB3C70C4607514" />

src/ResourceManager/Websites/AzureRM.Websites.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ CmdletsToExport = '*'
7474
VariablesToExport = '*'
7575

7676
# Aliases to export from this module
77-
AliasesToExport = @()
77+
AliasesToExport = @('Swap-AzureRmWebAppSlot')
7878

7979
# List of all modules packaged with this module
8080
ModuleList = @()

src/ResourceManager/Websites/Commands.Websites/Cmdlets/DeploymentSlots/SwapAzureWebAppSlot.cs renamed to src/ResourceManager/Websites/Commands.Websites/Cmdlets/DeploymentSlots/SwitchAzureWebAppSlot.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@
1414
// ----------------------------------------------------------------------------------
1515

1616

17+
using System.IO;
1718
using Microsoft.Azure.Commands.WebApps.Utilities;
1819
using System.Management.Automation;
20+
using System.Reflection;
21+
using Microsoft.Azure.Commands.Common.Authentication;
1922

2023
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.DeploymentSlots
2124
{
2225
/// <summary>
2326
/// this commandlet will let you swap two web app slots using ARM APIs
2427
/// </summary>
25-
[Cmdlet("Swap", "AzureRmWebAppSlot", SupportsShouldProcess = true)]
26-
public class SwapAzureWebAppSlot : WebAppBaseCmdlet
28+
[Cmdlet(VerbsCommon.Switch, "AzureRmWebAppSlot", SupportsShouldProcess = true)]
29+
public class SwitchAzureWebAppSlot : WebAppBaseCmdlet, IModuleAssemblyInitializer
2730
{
2831
[Parameter(Position = 0, Mandatory = true, HelpMessage = "Name of the source slot.")]
2932
[ValidateNotNullOrEmpty]
@@ -118,5 +121,27 @@ private void GetConfirmActionMessages(out string actionMessage, out string proce
118121
}
119122
}
120123
}
124+
125+
126+
/// <summary>
127+
/// Load global aliases for ARM
128+
/// </summary>
129+
public void OnImport()
130+
{
131+
try
132+
{
133+
System.Management.Automation.PowerShell invoker = null;
134+
invoker = System.Management.Automation.PowerShell.Create(RunspaceMode.CurrentRunspace);
135+
invoker.AddScript(File.ReadAllText(FileUtilities.GetContentFilePath(
136+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
137+
"WebsitesStartup.ps1")));
138+
invoker.Invoke();
139+
}
140+
catch
141+
{
142+
// This will throw exception for tests, ignore.
143+
}
144+
}
145+
121146
}
122147
}

src/ResourceManager/Websites/Commands.Websites/Commands.Websites.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackup.cs" />
164164
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupConfiguration.cs" />
165165
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupList.cs" />
166-
<Compile Include="Cmdlets\DeploymentSlots\SwapAzureWebAppSlot.cs" />
166+
<Compile Include="Cmdlets\DeploymentSlots\SwitchAzureWebAppSlot.cs" />
167167
<Compile Include="Cmdlets\WebApps\GetAzureWebAppMetrics.cs" />
168168
<Compile Include="Cmdlets\WebApps\GetAzureWebAppPublishingProfile.cs" />
169169
<Compile Include="Cmdlets\WebApps\GetAzureWebApp.cs" />
@@ -210,6 +210,9 @@
210210
<None Include="packages.config">
211211
<SubType>Designer</SubType>
212212
</None>
213+
<None Include="WebsitesStartup.ps1">
214+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
215+
</None>
213216
</ItemGroup>
214217
<ItemGroup>
215218
<EmbeddedResource Include="Properties\Resources.resx">
@@ -242,4 +245,4 @@
242245
</None>
243246
</ItemGroup>
244247
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
245-
</Project>
248+
</Project>

src/ResourceManager/Websites/Commands.Websites/Microsoft.Azure.Commands.Websites.dll-Help.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8250,7 +8250,7 @@
82508250
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
82518251
<!--Generated by PS Cmdlet Help Editor-->
82528252
<command:details>
8253-
<command:name>Swap-AzureRmWebAppSlot</command:name>
8253+
<command:name>Switch-AzureRmWebAppSlot</command:name>
82548254
<maml:description>
82558255
<maml:para>Swap two slots with a Web App</maml:para>
82568256
</maml:description>
@@ -8266,7 +8266,7 @@
82668266
</maml:description>
82678267
<command:syntax>
82688268
<command:syntaxItem>
8269-
<maml:name>Swap-AzureRmWebAppSlot</maml:name>
8269+
<maml:name>Switch-AzureRmWebAppSlot</maml:name>
82708270
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
82718271
<maml:name>SourceSlotName</maml:name>
82728272
<maml:description>
@@ -8311,7 +8311,7 @@
83118311
</command:parameter>
83128312
</command:syntaxItem>
83138313
<command:syntaxItem>
8314-
<maml:name>Swap-AzureRmWebAppSlot</maml:name>
8314+
<maml:name>Switch-AzureRmWebAppSlot</maml:name>
83158315
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
83168316
<maml:name>SourceSlotName</maml:name>
83178317
<maml:description>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
@{
16+
"Swap-AzureRmWebAppSlot" = "Switch-AzureRmWebAppSlot";
17+
}.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"

0 commit comments

Comments
 (0)