Skip to content

Commit 70e9ab1

Browse files
author
Ashraf Farok (PALASH)
committed
New cmdlets to create/enter PSSession in remote container app. New cmdlet for getting container continuous deployment url
1 parent 55c88ad commit 70e9ab1

17 files changed

+2420
-47
lines changed

src/ResourceManager/Profile/Commands.Profile/AzureRmAlias/Mappings.cs

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,4 @@
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-
using Newtonsoft.Json;
16-
using System;
17-
using System.Collections.Generic;
18-
19-
namespace Microsoft.Azure.Commands.Profile.AzureRmAlias
20-
{
21-
public class Mappings
22-
{
23-
public static Dictionary<string, object> GetCaseInsensitiveMapping()
24-
{
25-
string jsonmapping = jsonMappings;
26-
Dictionary<string, object> caseSensitiveMapping = (Dictionary<string, object>)JsonConvert.DeserializeObject(jsonmapping, typeof(Dictionary<string, object>));
27-
var mapping = new Dictionary<string, object>(StringComparer.CurrentCultureIgnoreCase);
28-
foreach (var key in caseSensitiveMapping.Keys)
29-
{
30-
mapping.Add(key, caseSensitiveMapping[key]);
31-
}
32-
33-
return mapping;
34-
}
35-
36-
public static string jsonMappings = @"
37-
{
1+
{
382
'Az.ApiManagement': {
393
'Add-AzApiManagementProductToGroup': 'Add-AzureRmApiManagementProductToGroup',
404
'Get-AzApiManagementOperation': 'Get-AzureRmApiManagementOperation',
@@ -1210,7 +1174,6 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
12101174
'Remove-AzStorageFile': 'Remove-AzureStorageFile',
12111175
'Set-AzCurrentStorageAccount': 'Set-AzureRmCurrentStorageAccount',
12121176
'Get-AzStorageUsage': 'Get-AzureRmStorageUsage',
1213-
'Enable-AzStorageStaticWebsite': 'Enable-AzureStorageStaticWebsite',
12141177
'Get-AzStorageQueue': 'Get-AzureStorageQueue',
12151178
'Enable-AzStorageDeleteRetentionPolicy': 'Enable-AzureStorageDeleteRetentionPolicy',
12161179
'Update-AzStorageServiceProperty': 'Update-AzureStorageServiceProperty',
@@ -1266,7 +1229,6 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
12661229
'Remove-AzStorageAccount': 'Remove-AzureRmStorageAccount',
12671230
'Get-AzStorageServiceMetricsProperty': 'Get-AzureStorageServiceMetricsProperty',
12681231
'New-AzStorageContainerStoredAccessPolicy': 'New-AzureStorageContainerStoredAccessPolicy',
1269-
'Disable-AzStorageStaticWebsite': 'Disable-AzureStorageStaticWebsite',
12701232
'Lock-AzRmStorageContainerImmutabilityPolicy': 'Lock-AzureRmStorageContainerImmutabilityPolicy',
12711233
'Add-AzRmStorageContainerLegalHold': 'Add-AzureRmStorageContainerLegalHold',
12721234
'Remove-AzStorageBlob': 'Remove-AzureStorageBlob',
@@ -1464,6 +1426,7 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
14641426
'Switch-AzWebAppSlot': 'Switch-AzureRmWebAppSlot',
14651427
'Get-AzAppServicePlanMetrics': 'Get-AzureRmAppServicePlanMetrics',
14661428
'Get-AzAppServicePlan': 'Get-AzureRmAppServicePlan',
1429+
'Enter-AzWebAppContainerPSSession': 'Enter-AzureRmWebAppContainerPSSession',
14671430
'New-AzAppServicePlan': 'New-AzureRmAppServicePlan',
14681431
'Get-AzWebAppSlot': 'Get-AzureRmWebAppSlot',
14691432
'Reset-AzWebAppSlotPublishingProfile': 'Reset-AzureRmWebAppSlotPublishingProfile',
@@ -1473,6 +1436,7 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
14731436
'Restore-AzWebAppBackup': 'Restore-AzureRmWebAppBackup',
14741437
'New-AzWebAppDatabaseBackupSetting': 'New-AzureRmWebAppDatabaseBackupSetting',
14751438
'New-AzWebApp': 'New-AzureRmWebApp',
1439+
'Get-AzWebAppContainerContinuousDeploymentUrl': 'Get-AzureRMWebAppContainerContinuousDeploymentUrl',
14761440
'Remove-AzWebApp': 'Remove-AzureRmWebApp',
14771441
'Get-AzWebAppMetrics': 'Get-AzureRmWebAppMetrics',
14781442
'Get-AzWebAppSSLBinding': 'Get-AzureRmWebAppSSLBinding',
@@ -1485,6 +1449,7 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
14851449
'Edit-AzWebAppBackupConfiguration': 'Edit-AzureRmWebAppBackupConfiguration',
14861450
'Restart-AzWebApp': 'Restart-AzureRmWebApp',
14871451
'Stop-AzWebApp': 'Stop-AzureRmWebApp',
1452+
'New-AzWebAppContainerPSSession': 'New-AzureRmWebAppContainerPSSession',
14881453
'Stop-AzWebAppSlot': 'Stop-AzureRmWebAppSlot'
14891454
},
14901455
'Az.StorageSync': {
@@ -1829,14 +1794,18 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
18291794
},
18301795
'Az.IotHub': {
18311796
'Get-AzIotHubValidSku': 'Get-AzureRmIotHubValidSku',
1797+
'Test-AzIotHubRoute': 'Test-AzureRmIotHubRoute',
18321798
'Get-AzIotHub': 'Get-AzureRmIotHub',
18331799
'Get-AzIotHubKey': 'Get-AzureRmIotHubKey',
1800+
'Add-AzIotHubRoutingEndpoint': 'Add-AzureRmIotHubRoutingEndpoint',
18341801
'Add-AzIotHubKey': 'Add-AzureRmIotHubKey',
18351802
'Set-AzIotHubVC': 'Set-AzureRmIotHubVC',
18361803
'Remove-AzIotHubCertificate': 'Remove-AzureRmIotHubCertificate',
18371804
'Set-AzIotHub': 'Set-AzureRmIotHub',
1805+
'Get-AzIotHubRoutingEndpoint': 'Get-AzureRmIotHubRoutingEndpoint',
18381806
'Remove-AzIotHubEventHubConsumerGroup': 'Remove-AzureRmIotHubEventHubConsumerGroup',
18391807
'Get-AzIotHubEventHubConsumerGroup': 'Get-AzureRmIotHubEventHubConsumerGroup',
1808+
'Remove-AzIotHubRoutingEndpoint': 'Remove-AzureRmIotHubRoutingEndpoint',
18401809
'Get-AzIotHubCertificate': 'Get-AzureRmIotHubCertificate',
18411810
'Get-AzIotHubQuotaMetric': 'Get-AzureRmIotHubQuotaMetric',
18421811
'Add-AzIotHubCertificate': 'Add-AzureRmIotHubCertificate',
@@ -1851,11 +1820,15 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
18511820
'New-AzIotHubImportDevices': 'New-AzureRmIotHubImportDevices',
18521821
'New-AzIotHubExportDevices': 'New-AzureRmIotHubExportDevices',
18531822
'Remove-AzIotHubEHCG': 'Remove-AzureRmIotHubEHCG',
1823+
'Remove-AzIotHubRoute': 'Remove-AzureRmIotHubRoute',
1824+
'Add-AzIotHubRoute': 'Add-AzureRmIotHubRoute',
1825+
'Get-AzIotHubRoute': 'Get-AzureRmIotHubRoute',
18541826
'Get-AzIotHubCVC': 'Get-AzureRmIotHubCVC',
18551827
'Get-AzIotHubRegistryStatistic': 'Get-AzureRmIotHubRegistryStatistic',
18561828
'Get-AzIotHubConnectionString': 'Get-AzureRmIotHubConnectionString',
18571829
'Get-AzIotHubEHCG': 'Get-AzureRmIotHubEHCG',
1858-
'Remove-AzIotHub': 'Remove-AzureRmIotHub'
1830+
'Remove-AzIotHub': 'Remove-AzureRmIotHub',
1831+
'Set-AzIotHubRoute': 'Set-AzureRmIotHubRoute'
18591832
},
18601833
'Az.Resources': {
18611834
'Remove-AzPolicySetDefinition': 'Remove-AzureRmPolicySetDefinition',
@@ -2349,7 +2322,3 @@ public static Dictionary<string, object> GetCaseInsensitiveMapping()
23492322
'Remove-AzApplicationInsightsContinuousExport': 'Remove-AzureRmApplicationInsightsContinuousExport'
23502323
}
23512324
}
2352-
2353-
";
2354-
}
2355-
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@
185185
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCreateNewWebAppSimple.json">
186186
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
187187
</None>
188+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestEnableContainerContiniousDeploymentAndGetUrl.json">
189+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
190+
</None>
188191
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestRemoveWebApp.json">
189192
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
190193
</None>

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public void TestCreateNewWebAppHyperV()
4545
WebsitesController.NewInstance.RunPsTest(_logger, "Test-CreateNewWebAppHyperV");
4646
}
4747

48+
[Fact]
49+
[Trait(Category.AcceptanceType, Category.CheckIn)]
50+
public void TestEnableContainerContiniousDeploymentAndGetUrl()
51+
{
52+
WebsitesController.NewInstance.RunPsTest(_logger, "Test-EnableContainerContiniousDeploymentAndGetUrl");
53+
}
54+
4855
[Fact]
4956
[Trait(Category.AcceptanceType, Category.CheckIn)]
5057
public void TestCreateNewAppOnAse()

src/ResourceManager/Websites/Commands.Websites.Test/ScenarioTests/WebAppTests.ps1

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,81 @@ function Test-CreateNewWebAppHyperV
589589
Remove-AzureRmResourceGroup -Name $rgname -Force
590590
}
591591
}
592+
593+
<#
594+
.SYNOPSIS
595+
Tests enagbling continious deployment for container and getting continious deployment url.
596+
.DESCRIPTION
597+
SmokeTest
598+
#>
599+
function Test-EnableContainerContiniousDeploymentAndGetUrl
600+
{
601+
# Setup
602+
$rgname = Get-ResourceGroupName
603+
$wname = Get-WebsiteName
604+
$location = Get-WebLocation
605+
$whpName = Get-WebHostPlanName
606+
$tier = "PremiumContainer"
607+
$apiversion = "2015-08-01"
608+
$resourceType = "Microsoft.Web/sites"
609+
$containerImageName = "microsoft/iis"
610+
$containerRegistryUrl = "https://testcontainer.azurecr.io"
611+
$ontainerRegistryUser = "testregistry"
612+
$pass = "7Dxo9p79Ins2K3ZU"
613+
$containerRegistryPassword = ConvertTo-SecureString -String $pass -AsPlainText -Force
614+
$dockerPrefix = "DOCKER|"
615+
$expected_ci_url = "https://`$ps7234:dBm0r9w8PeZiv0rPyteQdmgrjCgljKz0QzDk448zg61gfgG90vdfoEuB2kSh@ps7234.scm.azurewebsites.net/docker/hook"
616+
617+
try
618+
{
619+
#Setup
620+
New-AzureRmResourceGroup -Name $rgname -Location $location
621+
$serverFarm = New-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Tier $tier -WorkerSize Small -HyperV
622+
623+
# Create new web app
624+
$job = New-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Location $location -AppServicePlan $whpName -ContainerImageName $containerImageName -ContainerRegistryUrl $containerRegistryUrl -ContainerRegistryUser $ontainerRegistryUser -ContainerRegistryPassword $containerRegistryPassword -EnableContainerContinuousDeployment -AsJob
625+
$job | Wait-Job
626+
$actual = $job | Receive-Job
627+
628+
# Assert
629+
Assert-AreEqual $wname $actual.Name
630+
Assert-AreEqual $serverFarm.Id $actual.ServerFarmId
631+
632+
# Get new web app
633+
$result = Get-AzureRmWebApp -ResourceGroupName $rgname -Name $wname
634+
635+
# Assert
636+
Assert-AreEqual $wname $result.Name
637+
Assert-AreEqual $serverFarm.Id $result.ServerFarmId
638+
Assert-AreEqual $true $result.IsXenon
639+
Assert-AreEqual ($dockerPrefix + $containerImageName) $result.SiteConfig.WindowsFxVersion
640+
641+
$appSettings = @{
642+
"DOCKER_REGISTRY_SERVER_URL" = $containerRegistryUrl;
643+
"DOCKER_REGISTRY_SERVER_USERNAME" = $ontainerRegistryUser;
644+
"DOCKER_REGISTRY_SERVER_PASSWORD" = $pass;
645+
"DOCKER_ENABLE_CI" = "true"}
646+
647+
foreach($nvp in $webApp.SiteConfig.AppSettings)
648+
{
649+
Assert-True { $appSettings.Keys -contains $nvp.Name }
650+
Assert-True { $appSettings[$nvp.Name] -match $nvp.Value }
651+
}
652+
653+
$ci_url = Get-AzureRmWebAppContainerContinuousDeploymentUrl -ResourceGroupName $rgname -Name $wname
654+
655+
Assert-AreEqual $expected_ci_url $ci_url
656+
657+
}
658+
finally
659+
{
660+
# Cleanup
661+
Remove-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Force
662+
Remove-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
663+
Remove-AzureRmResourceGroup -Name $rgname -Force
664+
}
665+
}
666+
592667
<#
593668
.SYNOPSIS
594669
Tests creating a new website on an ase

src/ResourceManager/Websites/Commands.Websites.Test/SessionRecords/Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests/TestEnableContainerContiniousDeploymentAndGetUrl.json

Lines changed: 1739 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Websites/Commands.Websites/Az.Websites.psd1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ CmdletsToExport = 'Get-AzAppServicePlan', 'Set-AzAppServicePlan',
9595
'New-AzWebApp', 'Remove-AzWebAppBackup',
9696
'Reset-AzWebAppPublishingProfile', 'Restart-AzWebApp',
9797
'Set-AzWebApp', 'Start-AzWebApp', 'Stop-AzWebApp',
98-
'Get-AzWebAppSnapshot', 'Restore-AzWebAppSnapshot'
98+
'Get-AzWebAppSnapshot', 'Restore-AzWebAppSnapshot',
99+
'Enter-AzureRmWebAppContainerPSSession', 'Get-AzureRMWebAppContainerContinuousDeploymentUr',
100+
'New-AzureRmWebAppContainerPSSession'
101+
102+
99103

100104
# Variables to export from this module
101105
# VariablesToExport = @()

src/ResourceManager/Websites/Commands.Websites/AzureRM.Websites.psd1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ CmdletsToExport = 'Get-AzureRmAppServicePlan', 'Set-AzureRmAppServicePlan',
9595
'New-AzureRmWebApp', 'Remove-AzureRmWebAppBackup',
9696
'Reset-AzureRmWebAppPublishingProfile', 'Restart-AzureRmWebApp',
9797
'Set-AzureRmWebApp', 'Start-AzureRmWebApp', 'Stop-AzureRmWebApp',
98-
'Get-AzureRmWebAppSnapshot', 'Restore-AzureRmWebAppSnapshot'
98+
'Get-AzureRmWebAppSnapshot', 'Restore-AzureRmWebAppSnapshot',
99+
'Enter-AzureRmWebAppContainerPSSession', 'Get-AzureRMWebAppContainerContinuousDeploymentUrl',
100+
'New-AzureRmWebAppContainerPSSession'
101+
99102

100103
# Variables to export from this module
101104
# VariablesToExport = @()

src/ResourceManager/Websites/Commands.Websites/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
* Updating to use the latest .NET SDK version (2.0.0) https://www.nuget.org/packages/Microsoft.Azure.Management.Websites
2222
* New-AzureRmAppServicePlan -HyperV switch is added for create app service plan with windows container
2323
* New-AzureRmWebApp/ New-AzureRmWebAppSlot/ Set-AzureRmWebApp/ Set-AzureRmWebAppSlot - New parameters (–ContainerRegistryUser “<string>” -ContainerRegistryPassword “<secureString>” -EnableContainerContinuousDeployment) added for creating and managing windows container app
24+
* New Cmdlets Enter-AzureRmWebAppContainerPSSession, New-AzureRmWebAppContainerPSSession for entering and creating remote PSSession in container web app
25+
* New Cmdlet Get-AzureRMWebAppContainerContinuousDeploymentUr - Gets the Container Continuous Deployment Webhook URL
2426

2527

2628
## Version 5.0.9
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+

2+
// ----------------------------------------------------------------------------------
3+
//
4+
// Copyright Microsoft Corporation
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ----------------------------------------------------------------------------------
15+
16+
using System.Management.Automation;
17+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
18+
19+
20+
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
21+
{
22+
/// <summary>
23+
/// this commandlet will create remote ps session with site
24+
/// </summary>
25+
[Cmdlet("Enter", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebAppContainerPSSession")]
26+
public class EnterAzureRmWebAppContainerPSSession : WebAppBaseCmdlet
27+
{
28+
[Parameter(ParameterSetName = ParameterSet1Name, Position = 1, Mandatory = false, HelpMessage = "The name of the web app slot.", ValueFromPipelineByPropertyName = true)]
29+
[ValidateNotNullOrEmpty]
30+
public string SlotName { get; set; }
31+
32+
public override void ExecuteCmdlet()
33+
{
34+
if (ParameterSetName == ParameterSet2Name)
35+
{
36+
string rg, name, slot;
37+
38+
Utilities.CmdletHelpers.TryParseWebAppMetadataFromResourceId(WebApp.Id, out rg, out name, out slot);
39+
ResourceGroupName = rg;
40+
Name = name;
41+
SlotName = slot;
42+
}
43+
WebsitesClient.RunWebAppContainerPSSessionScript(this, ResourceGroupName, Name, SlotName);
44+
}
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+

2+
// ----------------------------------------------------------------------------------
3+
//
4+
// Copyright Microsoft Corporation
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
// ----------------------------------------------------------------------------------
15+
16+
using System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
19+
{
20+
/// <summary>
21+
/// this commandlet will return ContainerContinuousDeploymentUrl
22+
/// </summary>
23+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebAppContainerContinuousDeploymentUrl")]
24+
[OutputType(typeof(string))]
25+
public class GetAzureRMWebAppContainerContinuousDeploymentUrl : WebAppBaseCmdlet
26+
{
27+
[Parameter(ParameterSetName = ParameterSet1Name, Position = 1, Mandatory = false, HelpMessage = "The name of the web app slot.", ValueFromPipelineByPropertyName = true)]
28+
[ValidateNotNullOrEmpty]
29+
public string SlotName { get; set; }
30+
31+
public override void ExecuteCmdlet()
32+
{
33+
if (ParameterSetName == ParameterSet2Name)
34+
{
35+
string rg, name, slot;
36+
37+
Utilities.CmdletHelpers.TryParseWebAppMetadataFromResourceId(WebApp.Id, out rg, out name, out slot);
38+
ResourceGroupName = rg;
39+
Name = name;
40+
SlotName = slot;
41+
}
42+
43+
WriteObject(WebsitesClient.GetPublishingCredentials(ResourceGroupName, Name).ScmUri + "/docker/hook");
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)