Skip to content

Commit 023c914

Browse files
authored
Merge pull request Azure#7307 from vinisoto/asfarok-container-newcmdlets
New cmdlets to create/enter PSSession in remote container app. New cmdlet for getting container continuous deployment url
2 parents 41be466 + d3c31f8 commit 023c914

File tree

14 files changed

+2014
-5
lines changed

14 files changed

+2014
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,6 +2394,7 @@
23942394
"Restore-AzWebAppSnapshot": "Restore-AzureRmWebAppSnapshot",
23952395
"Get-AzDeletedWebApp": "Get-AzureRmDeletedWebApp",
23962396
"Restore-AzDeletedWebApp": "Restore-AzureRmDeletedWebApp",
2397+
"Get-AzWebAppContainerContinuousDeploymentUrl": "Get-AzureRmWebAppContainerContinuousDeploymentUrl",
23972398
"Swap-AzWebAppSlot": "Swap-AzureRmWebAppSlot"
23982399
}
23992400
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@
188188
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCreateNewWebAppSimple.json">
189189
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
190190
</None>
191+
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestEnableContainerContinuousDeploymentAndGetUrl.json">
192+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
193+
</None>
191194
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestRemoveWebApp.json">
192195
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
193196
</None>
@@ -224,4 +227,4 @@
224227
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
225228
</ItemGroup>
226229
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
227-
</Project>
230+
</Project>

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 TestEnableContainerContinuousDeploymentAndGetUrl()
51+
{
52+
WebsitesController.NewInstance.RunPsTest(_logger, "Test-EnableContainerContinuousDeploymentAndGetUrl");
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: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,80 @@ function Test-CreateNewWebAppHyperV
589589
Remove-AzureRmResourceGroup -Name $rgname -Force
590590
}
591591
}
592+
593+
<#
594+
.SYNOPSIS
595+
Tests enagbling continuous deployment for container and getting continuous deployment url.
596+
.DESCRIPTION
597+
SmokeTest
598+
#>
599+
function Test-EnableContainerContinuousDeploymentAndGetUrl
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+
try
616+
{
617+
#Setup
618+
New-AzureRmResourceGroup -Name $rgname -Location $location
619+
$serverFarm = New-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Tier $tier -WorkerSize Small -HyperV
620+
621+
# Create new web app
622+
$job = New-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Location $location -AppServicePlan $whpName -ContainerImageName $containerImageName -ContainerRegistryUrl $containerRegistryUrl -ContainerRegistryUser $ontainerRegistryUser -ContainerRegistryPassword $containerRegistryPassword -EnableContainerContinuousDeployment -AsJob
623+
$job | Wait-Job
624+
$actual = $job | Receive-Job
625+
626+
# Assert
627+
Assert-AreEqual $wname $actual.Name
628+
Assert-AreEqual $serverFarm.Id $actual.ServerFarmId
629+
# Get new web app
630+
$result = Get-AzureRmWebApp -ResourceGroupName $rgname -Name $wname
631+
632+
# Assert
633+
Assert-AreEqual $wname $result.Name
634+
Assert-AreEqual $serverFarm.Id $result.ServerFarmId
635+
Assert-AreEqual $true $result.IsXenon
636+
Assert-AreEqual ($dockerPrefix + $containerImageName) $result.SiteConfig.WindowsFxVersion
637+
$appSettings = @{
638+
"DOCKER_REGISTRY_SERVER_URL" = $containerRegistryUrl;
639+
"DOCKER_REGISTRY_SERVER_USERNAME" = $ontainerRegistryUser;
640+
"DOCKER_REGISTRY_SERVER_PASSWORD" = $pass;
641+
"DOCKER_ENABLE_CI" = "true"}
642+
foreach($nvp in $webApp.SiteConfig.AppSettings)
643+
{
644+
Assert-True { $appSettings.Keys -contains $nvp.Name }
645+
Assert-True { $appSettings[$nvp.Name] -match $nvp.Value }
646+
}
647+
648+
$ci_url = Get-AzureRmWebAppContainerContinuousDeploymentUrl -ResourceGroupName $rgname -Name $wname
649+
650+
$expression = "https://" + $wname + ":(.*)@" + $wname + ".scm.azurewebsites.net/docker/hook"
651+
$sanitizedCiUrl = { $ci_url -replace '$','' }
652+
653+
$matchResult = { $sanitizedCiUrl -match $expression }
654+
655+
Assert-AreEqual $true $matchResult
656+
}
657+
finally
658+
{
659+
# Cleanup
660+
Remove-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Force
661+
Remove-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
662+
Remove-AzureRmResourceGroup -Name $rgname -Force
663+
}
664+
}
665+
592666
<#
593667
.SYNOPSIS
594668
Tests creating a new website on an ase

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

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ CmdletsToExport = 'Get-AzAppServicePlan', 'Set-AzAppServicePlan',
9696
'Reset-AzWebAppPublishingProfile', 'Restart-AzWebApp',
9797
'Set-AzWebApp', 'Start-AzWebApp', 'Stop-AzWebApp',
9898
'Get-AzWebAppSnapshot', 'Restore-AzWebAppSnapshot',
99-
'Get-AzDeletedWebApp', 'Restore-AzDeletedWebApp'
99+
'Get-AzDeletedWebApp', 'Restore-AzDeletedWebApp',
100+
'Get-AzWebAppContainerContinuousDeploymentUrl'
100101

101102
# Variables to export from this module
102103
# VariablesToExport = @()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ CmdletsToExport = 'Get-AzureRmAppServicePlan', 'Set-AzureRmAppServicePlan',
9696
'Reset-AzureRmWebAppPublishingProfile', 'Restart-AzureRmWebApp',
9797
'Set-AzureRmWebApp', 'Start-AzureRmWebApp', 'Stop-AzureRmWebApp',
9898
'Get-AzureRmWebAppSnapshot', 'Restore-AzureRmWebAppSnapshot',
99-
'Get-AzureRmDeletedWebApp', 'Restore-AzureRmDeletedWebApp'
99+
'Get-AzureRmDeletedWebApp', 'Restore-AzureRmDeletedWebApp',
100+
'Get-AzureRmWebAppContainerContinuousDeploymentUrl'
100101

101102
# Variables to export from this module
102103
# VariablesToExport = @()

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* New Cmdlet Get-AzureRMWebAppContainerContinuousDeploymentUrl - Gets the Container Continuous Deployment Webhook URL
2122

2223
## Version 5.1.0
2324
* Updating to use the latest .NET SDK version (2.0.0)
2425
* Added two new cmdlets: Get-AzureRmDeletedWebApp and Restore-AzureRmDeletedWebApp
2526
* New-AzureRmAppServicePlan -HyperV switch is added for create app service plan with windows container
26-
* New-AzureRmWebApp/ New-AzureRmWebAppSlot/ Set-AzureRmWebApp/ Set-AzureRmWebAppSlot - New parameters (–ContainerRegistryUser string -ContainerRegistryPassword secureString -EnableContainerContinuousDeployment) added for creating and managing windows container app
27+
* New-AzureRmWebApp/ New-AzureRmWebAppSlot/ Set-AzureRmWebApp/ Set-AzureRmWebAppSlot - New parameters (–ContainerRegistryUser string -ContainerRegistryPassword secureString -EnableContainerContinuousDeployment) added for creating and managing windows container app
2728

2829
## Version 5.0.9
2930
* Fixed issue with default resource groups not being set.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
using System.Management.Automation;
15+
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
16+
{
17+
/// <summary>
18+
/// this commandlet will return ContainerContinuousDeploymentUrl
19+
/// </summary>
20+
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebAppContainerContinuousDeploymentUrl", DefaultParameterSetName = ParameterSet1Name)]
21+
[OutputType(typeof(string))]
22+
public class GetAzureRMWebAppContainerContinuousDeploymentUrl : WebAppBaseCmdlet
23+
{
24+
[Parameter(ParameterSetName = ParameterSet1Name, Position = 1, Mandatory = false, HelpMessage = "The name of the web app slot.", ValueFromPipelineByPropertyName = true)]
25+
[ValidateNotNullOrEmpty]
26+
public string SlotName { get; set; }
27+
public override void ExecuteCmdlet()
28+
{
29+
if (ParameterSetName == ParameterSet2Name)
30+
{
31+
string rg, name, slot;
32+
Utilities.CmdletHelpers.TryParseWebAppMetadataFromResourceId(WebApp.Id, out rg, out name, out slot);
33+
ResourceGroupName = rg;
34+
Name = name;
35+
SlotName = slot;
36+
}
37+
WriteObject(WebsitesClient.GetPublishingCredentials(ResourceGroupName, Name).ScmUri + "/docker/hook");
38+
}
39+
}
40+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupConfiguration.cs" />
8383
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupList.cs" />
8484
<Compile Include="Cmdlets\DeploymentSlots\SwitchAzureWebAppSlot.cs" />
85+
<Compile Include="Cmdlets\WebApps\GetAzureRMWebAppContainerContinuousDeploymentUrl.cs" />
8586
<Compile Include="Cmdlets\WebApps\GetAzureWebAppMetrics.cs" />
8687
<Compile Include="Cmdlets\WebApps\GetAzureWebAppPublishingProfile.cs" />
8788
<Compile Include="Cmdlets\WebApps\GetAzureWebApp.cs" />

src/ResourceManager/Websites/Commands.Websites/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ResourceManager/Websites/Commands.Websites/Utilities/WebsitesClient.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
using Microsoft.Azure.Management.WebSites;
1919
using Microsoft.Azure.Management.WebSites.Models;
2020
using Microsoft.Rest.Azure;
21+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2122
using System;
2223
using System.Collections.Generic;
2324
using System.Linq;
25+
using System.Management.Automation;
2426
using System.Net;
2527
using System.Xml.Linq;
2628

@@ -271,6 +273,14 @@ public string GetWebAppPublishingProfile(string resourceGroupName, string webSit
271273
return doc.ToString();
272274
}
273275

276+
public User GetPublishingCredentials(string resourceGroupName, string webSiteName, string slotName = null)
277+
{
278+
string qualifiedSiteName;
279+
return CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName) ?
280+
WrappedWebsitesClient.WebApps().ListPublishingCredentialsSlot(resourceGroupName, webSiteName, slotName)
281+
: WrappedWebsitesClient.WebApps().ListPublishingCredentials(resourceGroupName, webSiteName);
282+
}
283+
274284
public string ResetWebAppPublishingCredentials(string resourceGroupName, string webSiteName, string slotName)
275285
{
276286
string qualifiedSiteName;

src/ResourceManager/Websites/Commands.Websites/help/AzureRM.Websites.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Gets all backups of an Azure Web App.
3838
### [Get-AzureRmWebAppCertificate](Get-AzureRmWebAppCertificate.md)
3939
Gets an Azure Web App certificate.
4040

41+
### [Get-AzureRmWebAppContainerContinuousDeploymentUrl](Get-AzureRmWebAppContainerContinuousDeploymentUrl.md)
42+
Gets the continuous deployment url for a container web app
43+
4144
### [Get-AzureRmWebAppMetrics](Get-AzureRmWebAppMetrics.md)
4245
Gets Azure Web App metrics.
4346

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
external help file: Microsoft.Azure.Commands.Websites.dll-Help.xml
3+
Module Name: AzureRM.Websites
4+
online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.websites/?view=azurermps-6.8.1
5+
schema: 2.0.0
6+
---
7+
8+
# Get-AzureRmWebAppContainerContinuousDeploymentUrl
9+
10+
## SYNOPSIS
11+
Get-AzureRMWebAppContainerContinuousDeploymentUrl will return container continuous deployment url
12+
13+
## SYNTAX
14+
15+
### S1
16+
```
17+
Get-AzureRmWebAppContainerContinuousDeploymentUrl [[-SlotName] <String>] [-ResourceGroupName] <String>
18+
[-Name] <String> [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
19+
```
20+
21+
### S2
22+
```
23+
Get-AzureRmWebAppContainerContinuousDeploymentUrl [-WebApp] <PSSite> [-DefaultProfile <IAzureContextContainer>]
24+
[<CommonParameters>]
25+
```
26+
27+
## DESCRIPTION
28+
Get-AzureRMWebAppContainerContinuousDeploymentUrl will return container continuous deployment url
29+
30+
## EXAMPLES
31+
32+
### Example 1
33+
```
34+
PS C:\> Get-AzureRmWebAppContainerContinuousDeploymentUrl -ResourceGroupName "Default-Web-WestUS" -Name "ContosoASP"
35+
```
36+
37+
This command will return container continuous deployment url.
38+
39+
## PARAMETERS
40+
41+
### -DefaultProfile
42+
The credentials, account, tenant, and subscription used for communication with Azure.
43+
44+
```yaml
45+
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
46+
Parameter Sets: (All)
47+
Aliases: AzureRmContext, AzureCredential
48+
49+
Required: False
50+
Position: Named
51+
Default value: None
52+
Accept pipeline input: False
53+
Accept wildcard characters: False
54+
```
55+
56+
### -Name
57+
The name of the web app.
58+
59+
```yaml
60+
Type: System.String
61+
Parameter Sets: S1
62+
Aliases:
63+
64+
Required: True
65+
Position: 1
66+
Default value: None
67+
Accept pipeline input: True (ByPropertyName)
68+
Accept wildcard characters: False
69+
```
70+
71+
### -ResourceGroupName
72+
The name of the resource group.
73+
74+
```yaml
75+
Type: System.String
76+
Parameter Sets: S1
77+
Aliases:
78+
79+
Required: True
80+
Position: 0
81+
Default value: None
82+
Accept pipeline input: False
83+
Accept wildcard characters: False
84+
```
85+
86+
### -SlotName
87+
The name of the web app slot.
88+
89+
```yaml
90+
Type: System.String
91+
Parameter Sets: S1
92+
Aliases:
93+
94+
Required: False
95+
Position: 1
96+
Default value: None
97+
Accept pipeline input: True (ByPropertyName)
98+
Accept wildcard characters: False
99+
```
100+
101+
### -WebApp
102+
The web app object
103+
104+
```yaml
105+
Type: Microsoft.Azure.Commands.WebApps.Models.PSSite
106+
Parameter Sets: S2
107+
Aliases:
108+
109+
Required: True
110+
Position: 0
111+
Default value: None
112+
Accept pipeline input: True (ByValue)
113+
Accept wildcard characters: False
114+
```
115+
116+
### CommonParameters
117+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
118+
119+
## INPUTS
120+
121+
### System.String
122+
### Microsoft.Azure.Commands.WebApps.Models.PSSite
123+
## OUTPUTS
124+
125+
### System.String
126+
## NOTES
127+
128+
## RELATED LINKS

0 commit comments

Comments
 (0)