Skip to content

Adding -AzureStorageAccounts parameter to Set-AzureRmWebApp and Set-AzureRmWebAppSlot #7295

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

Closed
wants to merge 21 commits into from
Closed
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 @@ -2418,6 +2418,7 @@
"Get-AzWebAppContainerContinuousDeploymentUrl": "Get-AzureRmWebAppContainerContinuousDeploymentUrl",
"Enter-AzWebAppContainerPSSession": "Enter-AzureRmWebAppContainerPSSession",
"New-AzWebAppContainerPSSession": "New-AzureRmWebAppContainerPSSession",
"Swap-AzWebAppSlot": "Swap-AzureRmWebAppSlot"
"Swap-AzWebAppSlot": "Swap-AzureRmWebAppSlot",
"New-AzWebAppAzureStoragePath": "New-AzureRmWebAppAzureStoragePath"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestRemoveWebApp.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestSetAzureStorageWebAppHyperV.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Websites.Test.ScenarioTests.WebAppTests\TestSetWebApp.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,12 @@ public void TestWebAppSwapWithPreviewCompleteSlotSwap()
{
WebsitesController.NewInstance.RunPsTest(_logger, "Test-WebAppSwapWithPreviewCompleteSlotSwap");
}

[Fact(Skip = "Currently the API fails when adding Azure Storage Accounts for slots. Will enable this test when the API is fixed")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't merge this PR until the API is fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maddieclayton - I will ping you once the API is fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinosoto still waiting for this change

[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestSetAzureStorageWebAppHyperVSlot()
{
WebsitesController.NewInstance.RunPsTest(_logger, "Test-SetAzureStorageWebAppHyperVSlot");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,152 @@ function Test-SlotSwapWithPreview($swapWithPreviewAction)

}

<#
.SYNOPSIS
Tests setting and Azure Storage Account in a new Windows container app. Currently the API fails when adding Azure Storage Accounts for slots. Will enable this test when the API is fixed.
.DESCRIPTION
SmokeTest
#>
function Test-SetAzureStorageWebAppHyperVSlot
{
# Setup
$rgname = Get-ResourceGroupName
$wname = Get-WebsiteName
$slotname = "staging"
$location = Get-WebLocation
$whpName = Get-WebHostPlanName
$tier = "PremiumContainer"
$apiversion = "2015-08-01"
$resourceType = "Microsoft.Web/sites"
$containerImageName = "testcontainer.io/test/iis"
$containerRegistryUrl = "https://testcontainer.azurecr.io"
$ontainerRegistryUser = "testregistry"
$pass = "7Dxo9p79Ins2K3ZU"
$containerRegistryPassword = ConvertTo-SecureString -String $pass -AsPlainText -Force
$dockerPrefix = "DOCKER|"
$azureStorageAccountCustomId1 = "mystorageaccount"
$azureStorageAccountType1 = "AzureFiles"
$azureStorageAccountName1 = "myaccountname.file.core.windows.net"
$azureStorageAccountShareName1 = "myremoteshare"
$azureStorageAccountAccessKey1 = "AnAccessKey"
$azureStorageAccountMountPath1 = "C:\mymountpath"
$azureStorageAccountCustomId2 = "mystorageaccount2"
$azureStorageAccountType2 = "AzureFiles"
$azureStorageAccountName2 = "myaccountname2.file.core.windows.net"
$azureStorageAccountShareName2 = "myremoteshare2"
$azureStorageAccountAccessKey2 = "AnAccessKey2"
$azureStorageAccountMountPath2 = "C:\mymountpath2"

try
{
###
# Currently the API fails when adding Azure Storage Accounts for slots. Will enable this test when the API is fixed.
###

#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 -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

Write-Debug "Created the web app"

# Assert
Assert-AreEqual $wname $result.Name
Assert-AreEqual $serverFarm.Id $result.ServerFarmId
Assert-AreEqual $true $result.IsXenon
Assert-AreEqual ($dockerPrefix + $containerImageName) $result.SiteConfig.WindowsFxVersion

# Create deployment slot
$job = New-AzureRmWebAppSlot -ResourceGroupName $rgname -Name $wname -Slot $slotname -AsJob
$job | Wait-Job
$slot1 = $job | Receive-Job

Write-Debug "Created the slot"

$appWithSlotName = "$wname/$slotname"

Write-Debug $appWithSlotName

# Assert
Assert-AreEqual $appWithSlotName $slot1.Name
Assert-AreEqual $serverFarm.Id $slot1.ServerFarmId

$testStorageAccount1 = New-AzureRmWebAppAzureStoragePath -Name $azureStorageAccountCustomId1 -Type $azureStorageAccountType1 -AccountName $azureStorageAccountName1 -ShareName $azureStorageAccountShareName1 -AccessKey $azureStorageAccountAccessKey1 -MountPath $azureStorageAccountMountPath1
$testStorageAccount2 = New-AzureRmWebAppAzureStoragePath -Name $azureStorageAccountCustomId2 -Type $azureStorageAccountType2 -AccountName $azureStorageAccountName2 -ShareName $azureStorageAccountShareName2 -AccessKey $azureStorageAccountAccessKey2 -MountPath $azureStorageAccountMountPath2

Write-Debug "Created the new storage account paths"

Write-Debug $testStorageAccount1.Name
Write-Debug $testStorageAccount2.Name


# set Azure Storage accounts
$webApp = Set-AzureRmWebAppSlot -ResourceGroupName $rgname -Name $wname -Slot $slotname -AzureStoragePath $testStorageAccount1, $testStorageAccount2

Write-Debug "Set the new storage account paths"


# get the web app
$result = Get-AzureRmWebAppSlot -ResourceGroupName $rgname -Name $wname -Slot $slotname
$azureStorageAccounts = $result.AzureStoragePath

# Assert
Write-Debug $azureStorageAccounts[0].Name
Assert-AreEqual $azureStorageAccounts[0].Name $azureStorageAccountCustomId1

Write-Debug $azureStorageAccounts[0].Type
Assert-AreEqual $azureStorageAccounts[0].Type $azureStorageAccountType1

Write-Debug $azureStorageAccounts[0].AccountName
Assert-AreEqual $azureStorageAccounts[0].AccountName $azureStorageAccountName1

Write-Debug $azureStorageAccounts[0].ShareName
Assert-AreEqual $azureStorageAccounts[0].ShareName $azureStorageAccountShareName1

Write-Debug $azureStorageAccounts[0].AccessKey
Assert-AreEqual $azureStorageAccounts[0].AccessKey $azureStorageAccountAccessKey1

Write-Debug $azureStorageAccounts[0].MountPath
Assert-AreEqual $azureStorageAccounts[0].MountPath $azureStorageAccountMountPath1

Write-Debug $azureStorageAccounts[1].Name
Assert-AreEqual $azureStorageAccounts[1].Name $azureStorageAccountCustomId2

Write-Debug $azureStorageAccounts[1].Type
Assert-AreEqual $azureStorageAccounts[1].Type $azureStorageAccountType2

Write-Debug $azureStorageAccounts[1].AccountName
Assert-AreEqual $azureStorageAccounts[1].AccountName $azureStorageAccountName2

Write-Debug $azureStorageAccounts[1].ShareName
Assert-AreEqual $azureStorageAccounts[1].ShareName $azureStorageAccountShareName2

Write-Debug $azureStorageAccounts[1].AccessKey
Assert-AreEqual $azureStorageAccounts[1].AccessKey $azureStorageAccountAccessKey2

Write-Debug $azureStorageAccounts[1].MountPath
Assert-AreEqual $azureStorageAccounts[1].MountPath $azureStorageAccountMountPath2
}
finally
{
# Cleanup
Remove-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -Force
Remove-AzureRmAppServicePlan -ResourceGroupName $rgname -Name $whpName -Force
Remove-AzureRmResourceGroup -Name $rgname -Force
}
}

<#
.SYNOPSIS
Validates slot app setting for slot swap tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public void TestEnableContainerContinuousDeploymentAndGetUrl()
WebsitesController.NewInstance.RunPsTest(_logger, "Test-EnableContainerContinuousDeploymentAndGetUrl");
}

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateNewAppOnAse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,130 @@ function Test-WindowsContainerWebAppPSSessionOpened
}
}

<#
.SYNOPSIS
Tests setting and Azure Storage Account in a new Windows container app.
.DESCRIPTION
SmokeTest
#>
function Test-SetAzureStorageWebAppHyperV
{
# Setup
$rgname = Get-ResourceGroupName
$wname = Get-WebsiteName
$location = Get-WebLocation
$whpName = Get-WebHostPlanName
$tier = "PremiumContainer"
$apiversion = "2015-08-01"
$resourceType = "Microsoft.Web/sites"
$containerImageName = "testcontainer.io/test/iis"
$containerRegistryUrl = "https://testcontainer.azurecr.io"
$ontainerRegistryUser = "testregistry"
$pass = "7Dxo9p79Ins2K3ZU"
$containerRegistryPassword = ConvertTo-SecureString -String $pass -AsPlainText -Force
$dockerPrefix = "DOCKER|"
$azureStorageAccountCustomId1 = "mystorageaccount"
$azureStorageAccountType1 = "AzureFiles"
$azureStorageAccountName1 = "myaccountname.file.core.windows.net"
$azureStorageAccountShareName1 = "myremoteshare"
$azureStorageAccountAccessKey1 = "AnAccessKey"
$azureStorageAccountMountPath1 = "C:\mymountpath"
$azureStorageAccountCustomId2 = "mystorageaccount2"
$azureStorageAccountType2 = "AzureFiles"
$azureStorageAccountName2 = "myaccountname2.file.core.windows.net"
$azureStorageAccountShareName2 = "myremoteshare2"
$azureStorageAccountAccessKey2 = "AnAccessKey2"
$azureStorageAccountMountPath2 = "C:\mymountpath2"

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 -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

$testStorageAccount1 = New-AzureRmWebAppAzureStoragePath -Name $azureStorageAccountCustomId1 -Type $azureStorageAccountType1 -AccountName $azureStorageAccountName1 -ShareName $azureStorageAccountShareName1 -AccessKey $azureStorageAccountAccessKey1 -MountPath $azureStorageAccountMountPath1
$testStorageAccount2 = New-AzureRmWebAppAzureStoragePath -Name $azureStorageAccountCustomId2 -Type $azureStorageAccountType2 -AccountName $azureStorageAccountName2 -ShareName $azureStorageAccountShareName2 -AccessKey $azureStorageAccountAccessKey2 -MountPath $azureStorageAccountMountPath2

Write-Debug "Created the new storage account paths"

Write-Debug $testStorageAccount1.Name
Write-Debug $testStorageAccount2.Name


# set Azure Storage accounts
$webApp = Set-AzureRmWebApp -ResourceGroupName $rgname -Name $wname -AzureStoragePath $testStorageAccount1, $testStorageAccount2

Write-Debug "Set the new storage account paths"


# get the web app
$result = Get-AzureRmWebApp -ResourceGroupName $rgname -Name $wname
$azureStorageAccounts = $result.AzureStoragePath

# Assert
Write-Debug $azureStorageAccounts[0].Name
Assert-AreEqual $azureStorageAccounts[0].Name $azureStorageAccountCustomId1

Write-Debug $azureStorageAccounts[0].Type
Assert-AreEqual $azureStorageAccounts[0].Type $azureStorageAccountType1

Write-Debug $azureStorageAccounts[0].AccountName
Assert-AreEqual $azureStorageAccounts[0].AccountName $azureStorageAccountName1

Write-Debug $azureStorageAccounts[0].ShareName
Assert-AreEqual $azureStorageAccounts[0].ShareName $azureStorageAccountShareName1

Write-Debug $azureStorageAccounts[0].AccessKey
Assert-AreEqual $azureStorageAccounts[0].AccessKey $azureStorageAccountAccessKey1

Write-Debug $azureStorageAccounts[0].MountPath
Assert-AreEqual $azureStorageAccounts[0].MountPath $azureStorageAccountMountPath1

Write-Debug $azureStorageAccounts[1].Name
Assert-AreEqual $azureStorageAccounts[1].Name $azureStorageAccountCustomId2

Write-Debug $azureStorageAccounts[1].Type
Assert-AreEqual $azureStorageAccounts[1].Type $azureStorageAccountType2

Write-Debug $azureStorageAccounts[1].AccountName
Assert-AreEqual $azureStorageAccounts[1].AccountName $azureStorageAccountName2

Write-Debug $azureStorageAccounts[1].ShareName
Assert-AreEqual $azureStorageAccounts[1].ShareName $azureStorageAccountShareName2

Write-Debug $azureStorageAccounts[1].AccessKey
Assert-AreEqual $azureStorageAccounts[1].AccessKey $azureStorageAccountAccessKey2

Write-Debug $azureStorageAccounts[1].MountPath
Assert-AreEqual $azureStorageAccounts[1].MountPath $azureStorageAccountMountPath2
}
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 Expand Up @@ -1005,7 +1129,8 @@ function Test-SetWebApp

# Create new web app
$webApp = New-AzureRmWebApp -ResourceGroupName $rgname -Name $webAppName -Location $location -AppServicePlan $appServicePlanName1

Write-Debug "DEBUG: Created the Web App"

# Assert
Assert-AreEqual $webAppName $webApp.Name
Assert-AreEqual $serverFarm1.Id $webApp.ServerFarmId
Expand All @@ -1017,6 +1142,8 @@ function Test-SetWebApp
$job | Wait-Job
$webApp = $job | Receive-Job

Write-Debug "DEBUG: Changed service plan"

# Assert
Assert-AreEqual $webAppName $webApp.Name
Assert-AreEqual $serverFarm2.Id $webApp.ServerFarmId
Expand All @@ -1029,6 +1156,8 @@ function Test-SetWebApp
# Set site properties
$webApp = $webApp | Set-AzureRmWebApp

Write-Debug "DEBUG: Changed site properties"

# Assert
Assert-AreEqual $webAppName $webApp.Name
Assert-AreEqual $serverFarm2.Id $webApp.ServerFarmId
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ CmdletsToExport = 'Get-AzAppServicePlan', 'Set-AzAppServicePlan',
'Get-AzWebAppSnapshot', 'Restore-AzWebAppSnapshot',
'Get-AzDeletedWebApp', 'Restore-AzDeletedWebApp',
'Get-AzWebAppContainerContinuousDeploymentUrl',
'Enter-AzWebAppContainerPSSession', 'New-AzWebAppContainerPSSession'
'Enter-AzWebAppContainerPSSession', 'New-AzWebAppContainerPSSession',
'New-AzWebAppAzureStoragePath'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ CmdletsToExport = 'Get-AzureRmAppServicePlan', 'Set-AzureRmAppServicePlan',
'Get-AzureRmDeletedWebApp', 'Restore-AzureRmDeletedWebApp',
'Get-AzureRmWebAppContainerContinuousDeploymentUrl',
'Enter-AzureRmWebAppContainerPSSession',
'New-AzureRmWebAppContainerPSSession'
'New-AzureRmWebAppContainerPSSession',
'New-AzureRmWebAppAzureStoragePath'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* Set-AzureRmWebApp and Set-AzureRmWebAppSlot - New parameter (-AzureStoragePath) added to specify Azure Storage paths to be mounted in Windows and Linux container apps. Use the output of the new cmdlet New-AzureRmWebAppAzureStoragePath as a parameter to set the Azure Storage paths.

## Version 5.2.0
* New Cmdlet Get-AzureRMWebAppContainerContinuousDeploymentUrl - Gets the Container Continuous Deployment Webhook URL
Expand Down
Loading