Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <#
  2. .SYNOPSIS
  3. Set Azure app service specific application settings (not web.config)
  4. .DESCRIPTION
  5. Set Azure app service specific application settings (not web.config)
  6. .EXAMPLE
  7. AzureSetAppSettings -ResourceGroupName "cmc-scm-tst-us-e-rg" -WebAppName "888888sisclientweb01"
  8. .EXAMPLE
  9. AzureSetAppSettings -ResourceGroupName "cmc-scm-tst-us-e-rg" -WebAppName "888888sisclientweb01" -Slot "qa"
  10. .PARAMETER ResourceGroupName
  11. Resource group name
  12. .PARAMETER WebAppName
  13. Web app name
  14. .PARAMETER Slot
  15. Optional slot name
  16. #>
  17.  
  18. [CmdletBinding()]
  19. param(
  20. [Parameter(Mandatory=$True)]
  21. [string]
  22. $ResourceGroupName,
  23. [Parameter(Mandatory=$True)]
  24. [string]
  25. $WebAppName,
  26. [Parameter(Mandatory=$False)]
  27. [string]
  28. $Slot
  29. )
  30.  
  31. $hash = @{}
  32.  
  33. if([string]::IsNullOrEmpty($Slot)) {
  34. Write-Host "Using standard (non-slot) deployment"
  35. $website = Get-AzureRmWebApp -Name $WebAppName -ResourceGroupName $ResourceGroupName
  36. $currentAppSettings = $website.SiteConfig.AppSettings
  37.  
  38. ForEach ($kvp in $currentAppSettings) {
  39. $hash[$kvp.Name] = $kvp.Value
  40. }
  41.  
  42. $hash['WEBSITE_LOAD_CERTIFICATES'] = "*"
  43. $hash['CertificateStoreLocation'] = "CurrentUser"
  44.  
  45. Set-AzureRmWebApp -Name $WebAppName -ResourceGroupName $ResourceGroupName -AppSettings $hash
  46. }
  47. else {
  48. Write-Host "Using slot deployment"
  49. $website = Get-AzureRmWebAppSlot -Name $WebAppName -ResourceGroupName $ResourceGroupName -Slot $Slot
  50. $currentAppSettings = $website.SiteConfig.AppSettings
  51.  
  52. ForEach ($kvp in $currentAppSettings) {
  53. $hash[$kvp.Name] = $kvp.Value
  54. }
  55.  
  56. $hash['WEBSITE_LOAD_CERTIFICATES'] = "*"
  57. $hash['CertificateStoreLocation'] = "CurrentUser"
  58. Set-AzureRmWebAppSlot -Name $WebAppName -ResourceGroupName $ResourceGroupName -AppSettings $hash -Slot $Slot
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement