Skip to content

New cmdlets to create/enter PSSession in remote container app. New cmdlet for getting container continuous deployment url #7307

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 17 commits into from
Sep 25, 2018
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 @@ -2394,6 +2394,7 @@
"Restore-AzWebAppSnapshot": "Restore-AzureRmWebAppSnapshot",
"Get-AzDeletedWebApp": "Get-AzureRmDeletedWebApp",
"Restore-AzDeletedWebApp": "Restore-AzureRmDeletedWebApp",
"Get-AzWebAppContainerContinuousDeploymentUrl": "Get-AzureRmWebAppContainerContinuousDeploymentUrl",
"Swap-AzWebAppSlot": "Swap-AzureRmWebAppSlot"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestCreateNewWebAppSimple.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestEnableContainerContinuousDeploymentAndGetUrl.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestRemoveWebApp.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -224,4 +227,4 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public void TestCreateNewWebAppHyperV()
WebsitesController.NewInstance.RunPsTest(_logger, "Test-CreateNewWebAppHyperV");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestEnableContainerContinuousDeploymentAndGetUrl()
{
WebsitesController.NewInstance.RunPsTest(_logger, "Test-EnableContainerContinuousDeploymentAndGetUrl");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateNewAppOnAse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,80 @@ function Test-CreateNewWebAppHyperV
Remove-AzureRmResourceGroup -Name $rgname -Force
}
}

<#
.SYNOPSIS
Tests enagbling continuous deployment for container and getting continuous deployment url.
.DESCRIPTION
SmokeTest
#>
function Test-EnableContainerContinuousDeploymentAndGetUrl
{
# Setup
$rgname = Get-ResourceGroupName
$wname = Get-WebsiteName
$location = Get-WebLocation
$whpName = Get-WebHostPlanName
$tier = "PremiumContainer"
$apiversion = "2015-08-01"
$resourceType = "Microsoft.Web/sites"
$containerImageName = "microsoft/iis"
$containerRegistryUrl = "https://testcontainer.azurecr.io"
$ontainerRegistryUser = "testregistry"
$pass = "7Dxo9p79Ins2K3ZU"
$containerRegistryPassword = ConvertTo-SecureString -String $pass -AsPlainText -Force
$dockerPrefix = "DOCKER|"
try
{
#Setup
New-AzureRmResourceGroup -Name $rgname -Location $location
$serverFarm = New-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Location $location -Tier $tier -WorkerSize Small -HyperV

# Create new web app
$job = New-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Location $location -AppServicePlan $whpName -ContainerImageName $containerImageName -ContainerRegistryUrl $containerRegistryUrl -ContainerRegistryUser $ontainerRegistryUser -ContainerRegistryPassword $containerRegistryPassword -EnableContainerContinuousDeployment -AsJob
$job | Wait-Job
$actual = $job | Receive-Job

# Assert
Assert-AreEqual $wname $actual.Name
Assert-AreEqual $serverFarm.Id $actual.ServerFarmId
# Get new web app
$result = Get-AzureRmWebApp -ResourceGroupName $rgname -Name $wname

# Assert
Assert-AreEqual $wname $result.Name
Assert-AreEqual $serverFarm.Id $result.ServerFarmId
Assert-AreEqual $true $result.IsXenon
Assert-AreEqual ($dockerPrefix + $containerImageName) $result.SiteConfig.WindowsFxVersion
$appSettings = @{
"DOCKER_REGISTRY_SERVER_URL" = $containerRegistryUrl;
"DOCKER_REGISTRY_SERVER_USERNAME" = $ontainerRegistryUser;
"DOCKER_REGISTRY_SERVER_PASSWORD" = $pass;
"DOCKER_ENABLE_CI" = "true"}
foreach($nvp in $webApp.SiteConfig.AppSettings)
{
Assert-True { $appSettings.Keys -contains $nvp.Name }
Assert-True { $appSettings[$nvp.Name] -match $nvp.Value }
}

$ci_url = Get-AzureRmWebAppContainerContinuousDeploymentUrl -ResourceGroupName $rgname -Name $wname

$expression = "https://" + $wname + ":(.*)@" + $wname + ".scm.azurewebsites.net/docker/hook"
$sanitizedCiUrl = { $ci_url -replace '$','' }

$matchResult = { $sanitizedCiUrl -match $expression }

Assert-AreEqual $true $matchResult
}
finally
{
# Cleanup
Remove-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Force
Remove-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
Remove-AzureRmResourceGroup -Name $rgname -Force
}
}

<#
.SYNOPSIS
Tests creating a new website on an ase
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ CmdletsToExport = 'Get-AzAppServicePlan', 'Set-AzAppServicePlan',
'Reset-AzWebAppPublishingProfile', 'Restart-AzWebApp',
'Set-AzWebApp', 'Start-AzWebApp', 'Stop-AzWebApp',
'Get-AzWebAppSnapshot', 'Restore-AzWebAppSnapshot',
'Get-AzDeletedWebApp', 'Restore-AzDeletedWebApp'
'Get-AzDeletedWebApp', 'Restore-AzDeletedWebApp',
'Get-AzWebAppContainerContinuousDeploymentUrl'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ CmdletsToExport = 'Get-AzureRmAppServicePlan', 'Set-AzureRmAppServicePlan',
'Reset-AzureRmWebAppPublishingProfile', 'Restart-AzureRmWebApp',
'Set-AzureRmWebApp', 'Start-AzureRmWebApp', 'Stop-AzureRmWebApp',
'Get-AzureRmWebAppSnapshot', 'Restore-AzureRmWebAppSnapshot',
'Get-AzureRmDeletedWebApp', 'Restore-AzureRmDeletedWebApp'
'Get-AzureRmDeletedWebApp', 'Restore-AzureRmDeletedWebApp',
'Get-AzureRmWebAppContainerContinuousDeploymentUrl'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
3 changes: 2 additions & 1 deletion src/ResourceManager/Websites/Commands.Websites/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
- Additional information about change #1
-->
## Current Release
* New Cmdlet Get-AzureRMWebAppContainerContinuousDeploymentUrl - Gets the Container Continuous Deployment Webhook URL

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

## Version 5.0.9
* Fixed issue with default resource groups not being set.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// ----------------------------------------------------------------------------------
//
// 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;
namespace Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps
{
/// <summary>
/// this commandlet will return ContainerContinuousDeploymentUrl
/// </summary>
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "WebAppContainerContinuousDeploymentUrl", DefaultParameterSetName = ParameterSet1Name)]
[OutputType(typeof(string))]
public class GetAzureRMWebAppContainerContinuousDeploymentUrl : WebAppBaseCmdlet
{
[Parameter(ParameterSetName = ParameterSet1Name, Position = 1, Mandatory = false, HelpMessage = "The name of the web app slot.", ValueFromPipelineByPropertyName = true)]
[ValidateNotNullOrEmpty]
public string SlotName { get; set; }
public override void ExecuteCmdlet()
{
if (ParameterSetName == ParameterSet2Name)
{
string rg, name, slot;
Utilities.CmdletHelpers.TryParseWebAppMetadataFromResourceId(WebApp.Id, out rg, out name, out slot);
ResourceGroupName = rg;
Name = name;
SlotName = slot;
}
WriteObject(WebsitesClient.GetPublishingCredentials(ResourceGroupName, Name).ScmUri + "/docker/hook");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupConfiguration.cs" />
<Compile Include="Cmdlets\BackupRestore\GetAzureWebAppBackupList.cs" />
<Compile Include="Cmdlets\DeploymentSlots\SwitchAzureWebAppSlot.cs" />
<Compile Include="Cmdlets\WebApps\GetAzureRMWebAppContainerContinuousDeploymentUrl.cs" />
<Compile Include="Cmdlets\WebApps\GetAzureWebAppMetrics.cs" />
<Compile Include="Cmdlets\WebApps\GetAzureWebAppPublishingProfile.cs" />
<Compile Include="Cmdlets\WebApps\GetAzureWebApp.cs" />
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
using Microsoft.Azure.Management.WebSites;
using Microsoft.Azure.Management.WebSites.Models;
using Microsoft.Rest.Azure;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Xml.Linq;

Expand Down Expand Up @@ -271,6 +273,14 @@ public string GetWebAppPublishingProfile(string resourceGroupName, string webSit
return doc.ToString();
}

public User GetPublishingCredentials(string resourceGroupName, string webSiteName, string slotName = null)
{
string qualifiedSiteName;
return CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName) ?
WrappedWebsitesClient.WebApps().ListPublishingCredentialsSlot(resourceGroupName, webSiteName, slotName)
: WrappedWebsitesClient.WebApps().ListPublishingCredentials(resourceGroupName, webSiteName);
}

public string ResetWebAppPublishingCredentials(string resourceGroupName, string webSiteName, string slotName)
{
string qualifiedSiteName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ Gets all backups of an Azure Web App.
### [Get-AzureRmWebAppCertificate](Get-AzureRmWebAppCertificate.md)
Gets an Azure Web App certificate.

### [Get-AzureRmWebAppContainerContinuousDeploymentUrl](Get-AzureRmWebAppContainerContinuousDeploymentUrl.md)
Gets the continuous deployment url for a container web app

### [Get-AzureRmWebAppMetrics](Get-AzureRmWebAppMetrics.md)
Gets Azure Web App metrics.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
external help file: Microsoft.Azure.Commands.Websites.dll-Help.xml
Module Name: AzureRM.Websites
online version: https://docs.microsoft.com/en-us/powershell/module/azurerm.websites/?view=azurermps-6.8.1
schema: 2.0.0
---

# Get-AzureRmWebAppContainerContinuousDeploymentUrl

## SYNOPSIS
Get-AzureRMWebAppContainerContinuousDeploymentUrl will return container continuous deployment url

## SYNTAX

### S1
```
Get-AzureRmWebAppContainerContinuousDeploymentUrl [[-SlotName] <String>] [-ResourceGroupName] <String>
[-Name] <String> [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
```

### S2
```
Get-AzureRmWebAppContainerContinuousDeploymentUrl [-WebApp] <PSSite> [-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
```

## DESCRIPTION
Get-AzureRMWebAppContainerContinuousDeploymentUrl will return container continuous deployment url

## EXAMPLES

### Example 1
```
PS C:\> Get-AzureRmWebAppContainerContinuousDeploymentUrl -ResourceGroupName "Default-Web-WestUS" -Name "ContosoASP"
```

This command will return container continuous deployment url.

## PARAMETERS

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

```yaml
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Parameter Sets: (All)
Aliases: AzureRmContext, AzureCredential

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Name
The name of the web app.

```yaml
Type: System.String
Parameter Sets: S1
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ResourceGroupName
The name of the resource group.

```yaml
Type: System.String
Parameter Sets: S1
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -SlotName
The name of the web app slot.

```yaml
Type: System.String
Parameter Sets: S1
Aliases:

Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -WebApp
The web app object

```yaml
Type: Microsoft.Azure.Commands.WebApps.Models.PSSite
Parameter Sets: S2
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```

### CommonParameters
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).

## INPUTS

### System.String
### Microsoft.Azure.Commands.WebApps.Models.PSSite
## OUTPUTS

### System.String
## NOTES

## RELATED LINKS