Skip to content

Adding Get-AzureRmWebAppSlotConfigName and Set-AzureRmWebAppSlotConfigName cmdlets #2248

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
May 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestGetWebAppSlotMetrics.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestManageSlotSlotConfigName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppSlotTests\TestSetWebAppSlot.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -317,4 +320,4 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,12 @@ public void TestSetWebAppSlot()
{
WebsitesController.NewInstance.RunPsTest("Test-SetWebAppSlot");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestManageSlotSlotConfigName()
{
WebsitesController.NewInstance.RunPsTest("Test-ManageSlotSlotConfigName");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -703,4 +703,49 @@ function Test-WebAppSlotPublishingProfile
Remove-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $planName -Force
Remove-AzureRmResourceGroup -Name $rgname -Force
}
}
}

<#
.SYNOPSIS
Tests managing slot config names for a web app
#>
function Test-ManageSlotSlotConfigName
{
$rgname = "Default-Web-EastAsia"
$appname = "webappslottest"

# Retrive Web App
$webApp = Get-AzureRmWebApp -ResourceGroupName $rgname -Name $appname

$slotConfigNames = $webApp | Get-AzureRmWebAppSlotConfigName

# Make sure that None of the settings are currently marked as slot setting
Assert-AreEqual 0 $slotConfigNames.AppSettingNames.Count
Assert-AreEqual 0 $slotConfigNames.ConnectionStringNames.Count

# Test - Mark all app settings as slot setting
$appSettingNames = $webApp.SiteConfig.AppSettings | Select-Object -ExpandProperty Name
$webApp | Set-AzureRmWebAppSlotConfigName -AppSettingNames $appSettingNames
$slotConfigNames = $webApp | Get-AzureRmWebAppSlotConfigName
Assert-AreEqual $webApp.SiteConfig.AppSettings.Count $slotConfigNames.AppSettingNames.Count
Assert-AreEqual 0 $slotConfigNames.ConnectionStringNames.Count

# Test- Mark all connection strings as slot setting
$connectionStringNames = $webApp.SiteConfig.ConnectionStrings | Select-Object -ExpandProperty Name
Set-AzureRmWebAppSlotConfigName -ResourceGroupName $rgname -Name $appname -ConnectionStringNames $connectionStringNames
$slotConfigNames = Get-AzureRmWebAppSlotConfigName -ResourceGroupName $rgname -Name $appname
Assert-AreEqual $webApp.SiteConfig.AppSettings.Count $slotConfigNames.AppSettingNames.Count
Assert-AreEqual $webApp.SiteConfig.ConnectionStrings.Count $slotConfigNames.ConnectionStringNames.Count

# Test- Clear slot app setting names
$webApp | Set-AzureRmWebAppSlotConfigName -RemoveAllAppSettingNames
$slotConfigNames = $webApp | Get-AzureRmWebAppSlotConfigName
Assert-AreEqual 0 $slotConfigNames.AppSettingNames.Count
Assert-AreEqual $webApp.SiteConfig.ConnectionStrings.Count $slotConfigNames.ConnectionStringNames.Count

# Test - Clear slot connection string names
Set-AzureRmWebAppSlotConfigName -ResourceGroupName $rgname -Name $appname -RemoveAllConnectionStringNames
$slotConfigNames = Get-AzureRmWebAppSlotConfigName -ResourceGroupName $rgname -Name $appname
Assert-AreEqual 0 $slotConfigNames.AppSettingNames.Count
Assert-AreEqual 0 $slotConfigNames.ConnectionStringNames.Count
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using System.Management.Automation;
using Microsoft.Azure.Commands.WebApps.Utilities;
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.DeploymentSlots
{
[Cmdlet(VerbsCommon.Get, "AzureRmWebAppSlotConfigName")]
public class GetAzureWebAppSlotConfigName : WebAppBaseCmdlet
{
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
WriteObject(WebsitesClient.GetSlotConfigNames(ResourceGroupName, Name));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using System.Management.Automation;
using Microsoft.Azure.Commands.WebApps.Models;
using Microsoft.Azure.Commands.WebApps.Utilities;

namespace Microsoft.Azure.Commands.WebApps.Cmdlets.DeploymentSlots
{
[Cmdlet(VerbsCommon.Set, "AzureRmWebAppSlotConfigName")]
public class SetAzureWebAppSlotConfigName : WebAppBaseCmdlet
{
[Parameter(Position = 2, Mandatory = false, HelpMessage = "Names of app settings that need to marked as slot settings", ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string[] AppSettingNames { get; set; }

[Parameter(Position = 3, Mandatory = false, HelpMessage = "Names of connection strings that need to marked as slot settings", ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string[] ConnectionStringNames { get; set; }

[Parameter(Position = 4, Mandatory = false, HelpMessage = "Remove all app settings")]
[ValidateNotNullOrEmpty]
public SwitchParameter RemoveAllAppSettingNames { get; set; }

[Parameter(Position = 5, Mandatory = false, HelpMessage = "Remove all connection string names")]
[ValidateNotNullOrEmpty]
public SwitchParameter RemoveAllConnectionStringNames { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
if ((RemoveAllAppSettingNames)
&& AppSettingNames != null)
{
throw new ValidationMetadataException("Please either provide a list of app setting names or set RemoveAllSettingNames option to true");
}

if((RemoveAllConnectionStringNames)
&& ConnectionStringNames != null)
{
throw new ValidationMetadataException("Please either provide a list of connection string names or set RemoveAllConnectionStringNames option to true");
}

var appSettingNames = RemoveAllAppSettingNames.IsPresent ? new string[0] : AppSettingNames;
var connectionStringNames = RemoveAllConnectionStringNames.IsPresent ? new string[0] : ConnectionStringNames;
WriteObject(WebsitesClient.SetSlotConfigNames(ResourceGroupName, Name, appSettingNames, connectionStringNames));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@
<Compile Include="Cmdlets\Certificates\NewAzureWebAppSSLBinding.cs" />
<Compile Include="Cmdlets\Certificates\RemoveAzureWebAppSSLBinding.cs" />
<Compile Include="Cmdlets\DeploymentSlots\GetAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\DeploymentSlots\GetAzureWebAppSlotConfigName.cs" />
<Compile Include="Cmdlets\DeploymentSlots\GetAzureWebAppSlotMetrics.cs" />
<Compile Include="Cmdlets\DeploymentSlots\GetAzureWebAppSlotPublishingProfile.cs" />
<Compile Include="Cmdlets\DeploymentSlots\NewAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\DeploymentSlots\RemoveAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\DeploymentSlots\ResetAzureWebAppSlotPublishingProfile.cs" />
<Compile Include="Cmdlets\DeploymentSlots\RestartAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\DeploymentSlots\SetAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\DeploymentSlots\SetAzureWebAppSlotConfigName.cs" />
<Compile Include="Cmdlets\DeploymentSlots\StartAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\DeploymentSlots\StopAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\BackupRestore\EditAzureWebAppBackupConfiguration.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ FormatsToProcess = @()

# Modules to import as nested modules of the module specified in ModuleToProcess
NestedModules = @(
'..\..\..\Package\Debug\ResourceManager\AzureResourceManager\Websites\Microsoft.Azure.Commands.Websites.dll'
'..\..\..\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Websites\Microsoft.Azure.Commands.Websites.dll'
)

# Functions to export from this module
Expand Down
Loading