【发布时间】:2015-09-12 21:11:49
【问题描述】:
我想编写一个使用 azure power shell 运行的脚本来自动添加 Web 应用程序配置
Azure > MyWebApp > 应用程序设置 > 应用程序设置
看起来像 key = "value"
我写这个脚本
###########################
# 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
但我知道上面的脚本只是获取我的网络应用程序,现在我需要访问 MyWebApp > 应用程序设置 > 应用程序设置并提供我的新应用程序设置的脚本文件/数组,并检查是否有任何新的脚本App Settings 键会将其添加到 App Settings,如果有任何现有键,它将覆盖它的值。 步骤或 APIS 是什么,或者我可以使用 azure power shell 做到这一点吗?
编辑: 此脚本可以自动创建新的 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
【问题讨论】:
-
您的编辑是否回答了您的问题?
-
@ShaunLuttin 我认为没有
标签: powershell azure azure-powershell