Skip to content

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

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 26 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2a4acc9
support byos for Windows containers
Sep 13, 2018
cbb5a49
Add Azure storage accounts to slots + Tests
Sep 14, 2018
caf7a4a
Help for support bring your own storage for Windows containers
Sep 19, 2018
3648204
Updating change log
Sep 19, 2018
6eed2a0
merging from preview
Oct 1, 2018
e1b9d0c
removing AzureRM.psm1 from PR added by mistake
Oct 1, 2018
8143019
Updating slot tests
Oct 1, 2018
84d0ac4
Fixing Changelog entries
Oct 1, 2018
fb91e63
Fixing static analysis and design review comments
Oct 1, 2018
1e90be6
Solving merge conflicts and getting latest from preview
Oct 2, 2018
0f8fa79
Supporting Azure Storage Accounts (a.k.a. "bring your own storage")
Oct 9, 2018
9877475
Getting latest from preview
Oct 9, 2018
057cd15
Fixing Static Analysis issues
Oct 9, 2018
69100f9
Fixing Az alias
Oct 9, 2018
2112ad7
Adding comments to specify why the slot test is skipped for now
Oct 9, 2018
6cda3b4
Merge remote-tracking branch 'main/preview' into latest
Oct 10, 2018
d919632
fixing changelog and markup file
Oct 11, 2018
3be3982
Merge remote-tracking branch 'main/preview' into latest
Oct 12, 2018
951770d
Removing unused validation class and updating chengelog
Oct 12, 2018
f896cb4
undoing AzureRM.ps1 deletion
Oct 12, 2018
98b4298
re-ignoring /tools/AzureRM/AzureRM.psm1
Oct 12, 2018
31d6ce4
Adding support to "Bring your own storage" for Windows Containers web…
Nov 21, 2018
646b92a
Enabling Slot test
Nov 21, 2018
dfd03dc
Including test recording
Nov 21, 2018
f086c2f
Adding missing license headers and other review comments
Nov 26, 2018
5caee0b
Update WebAppAzureStoragePath.cs
cormacpayne Nov 27, 2018
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 @@ -2470,6 +2470,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 @@ -158,6 +158,9 @@
<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\TestSetAzureStorageWebAppHyperVSlot.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 @@ -194,6 +197,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]
[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
Loading