我想编写一个脚本,使用Azure PowerShell来自动添加Web应用程序配置。
Azure > MyWebApp > 应用程序设置 > 应用设置
它看起来像是 键 = "值"
我编写了这个脚本
编辑: 此脚本可以自动创建新的 Web 应用程序并向其添加应用设置。
Azure > MyWebApp > 应用程序设置 > 应用设置
它看起来像是 键 = "值"
我编写了这个脚本
###########################
# MyApp Config Automation #
###########################
#Begin
$subscriptionName="MySubscriptionName"
$webSiteName="MyWebAppName"
$storageAccountName="StorageAccountName"
########################################
$userName = "myaccount@outlook.com"
$securePassword = ConvertTo-SecureString -String "mypass" -AsPlainText -Force
#####################################
$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
#####################################
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionName $subscriptionName -Default
#####################################
Get-AzureWebsite -Name $webSiteName
#End
但我知道上面的脚本只能获取我的 Web 应用程序,现在我需要访问 MyWebApp > 应用设置 > 应用设置,并提供我的新应用设置的脚本文件/数组,然后脚本会检查是否有任何新的应用设置键,如果有它将把它添加到应用设置中,如果有任何现有的键它将覆盖其值。有什么步骤或 API 可以做到这一点,或者我可以使用 Azure PowerShell 吗?编辑: 此脚本可以自动创建新的 Web 应用程序并向其添加应用设置。
##############################################
# Creating website and Adding Configs Script #
##############################################
$webSiteName="mywebsite"
$storageAccountName="storageaccount"
$subscriptionName="mysubsc"
$userName = "myaccount"
$securePassword = ConvertTo-SecureString -String "mypass" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionName $subscriptionName -Default
New-AzureWebsite -Name $webSiteName
New-AzureStorageAccount –StorageAccountName $storageAccountName -Location "South Central US"
$ClientId="dfgdf6"
$Password="ffefe"
$StorageAccountKey = Get-AzureStorageKey -StorageAccountName $storageAccountName
$AppSettings = @{"StorageAccountPrimary" = $StorageAccountKey.Primary;"StorageAccountSecondary" = $StorageAccountKey.Secondary;"ida:ClientId"=$ClientId;"ida:Password"=$Password}
Set-AzureWebsite -Name $webSiteName -AppSettings $AppSettings