Skip to content

Update Swap-AzureRmWebAppSlot cmdlet to use a common verb name #3003

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 1 commit into from
Sep 23, 2016
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
4 changes: 4 additions & 0 deletions setup/azurecmdfiles.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -3445,6 +3445,9 @@
<Component Id="cmpC84155BCEC352235456F36314798DEB6" Guid="*">
<File Id="fil3C07A3FCD79F4E195B1E0F363C1D912D" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Websites\System.Net.Http.Primitives.dll" />
</Component>
<Component Id="cmpDFB87EBE10120BEA0EE0E65B1CA9BBFE" Guid="*">
<File Id="filF6BB7994B63BABCF5598ACDF7BFABA06" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Websites\WebsitesStartup.ps1" />
</Component>
</Directory>
</Directory>
</Directory>
Expand Down Expand Up @@ -6570,6 +6573,7 @@
<ComponentRef Id="cmp9C45E87E06D911D61AAC3019BA99FB0C" />
<ComponentRef Id="cmp4E4BAFA8406471B1D2FFA4860A8AEAA7" />
<ComponentRef Id="cmpC84155BCEC352235456F36314798DEB6" />
<ComponentRef Id="cmpDFB87EBE10120BEA0EE0E65B1CA9BBFE" />
<ComponentRef Id="cmp5DFC4ECCB8BBF842D8069F3036386B84" />
<ComponentRef Id="cmp215D8C03C711DF4FF42B3D06ED14C790" />
<ComponentRef Id="cmpE75B6D337DC4A69EC4CB3C70C4607514" />
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Websites/AzureRM.Websites.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ CmdletsToExport = '*'
VariablesToExport = '*'

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

# List of all modules packaged with this module
ModuleList = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@
// ----------------------------------------------------------------------------------


using System.IO;
using Microsoft.Azure.Commands.WebApps.Utilities;
using System.Management.Automation;
using System.Reflection;
using Microsoft.Azure.Commands.Common.Authentication;

namespace Microsoft.Azure.Commands.WebApps.Cmdlets.DeploymentSlots
{
/// <summary>
/// this commandlet will let you swap two web app slots using ARM APIs
/// </summary>
[Cmdlet("Swap", "AzureRmWebAppSlot", SupportsShouldProcess = true)]
public class SwapAzureWebAppSlot : WebAppBaseCmdlet
[Cmdlet(VerbsCommon.Switch, "AzureRmWebAppSlot", SupportsShouldProcess = true)]
public class SwitchAzureWebAppSlot : WebAppBaseCmdlet, IModuleAssemblyInitializer
{
[Parameter(Position = 0, Mandatory = true, HelpMessage = "Name of the source slot.")]
[ValidateNotNullOrEmpty]
Expand Down Expand Up @@ -118,5 +121,27 @@ private void GetConfirmActionMessages(out string actionMessage, out string proce
}
}
}


/// <summary>
/// Load global aliases for ARM
/// </summary>
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),
"WebsitesStartup.ps1")));
invoker.Invoke();
}
catch
{
// This will throw exception for tests, ignore.
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackup.cs" />
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupConfiguration.cs" />
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupList.cs" />
<Compile Include="Cmdlets\DeploymentSlots\SwapAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\DeploymentSlots\SwitchAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\WebApps\GetAzureWebAppMetrics.cs" />
<Compile Include="Cmdlets\WebApps\GetAzureWebAppPublishingProfile.cs" />
<Compile Include="Cmdlets\WebApps\GetAzureWebApp.cs" />
Expand Down Expand Up @@ -210,6 +210,9 @@
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="WebsitesStartup.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
Expand Down Expand Up @@ -242,4 +245,4 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8250,7 +8250,7 @@
<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">
<!--Generated by PS Cmdlet Help Editor-->
<command:details>
<command:name>Swap-AzureRmWebAppSlot</command:name>
<command:name>Switch-AzureRmWebAppSlot</command:name>
<maml:description>
<maml:para>Swap two slots with a Web App</maml:para>
</maml:description>
Expand All @@ -8266,7 +8266,7 @@
</maml:description>
<command:syntax>
<command:syntaxItem>
<maml:name>Swap-AzureRmWebAppSlot</maml:name>
<maml:name>Switch-AzureRmWebAppSlot</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
<maml:name>SourceSlotName</maml:name>
<maml:description>
Expand Down Expand Up @@ -8311,7 +8311,7 @@
</command:parameter>
</command:syntaxItem>
<command:syntaxItem>
<maml:name>Swap-AzureRmWebAppSlot</maml:name>
<maml:name>Switch-AzureRmWebAppSlot</maml:name>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="0">
<maml:name>SourceSlotName</maml:name>
<maml:description>
Expand Down
17 changes: 17 additions & 0 deletions src/ResourceManager/Websites/Commands.Websites/WebsitesStartup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

@{
"Swap-AzureRmWebAppSlot" = "Switch-AzureRmWebAppSlot";
}.GetEnumerator() | Select @{Name='Name'; Expression={$_.Key}}, @{Name='Value'; Expression={$_.Value}} | New-Alias -Description "AzureAlias"