For deployment purposes I created a PowerShell script to set App Settings. This works fine via
$currentAppSettings = $app.SiteConfig.AppSettings
$appSettings = @{}
# Add existing App Settings
ForEach ($currentAppSetting in $currentAppSettings) {
$appSettings[$currentAppSetting.Name] = $currentAppSetting.Value
}
# Add new App Settings
$appSettings["someKey"] = "someValue"
# Update App Settings
Set-AzWebApp -ResourceGroupName $resourceGroupName -Name $appName -AppSettings $appSettings
As I am using now Entity Framework I also need to set the Connection Strings. First I thought this should work like with App Settings and just adding the ConnectionStrings Argument:
$currentConnectionStrings = $app.SiteConfig.ConnectionStrings
$connectionStrings = @{}
ForEach ($currentConnectionString in $currentConnectionStrings) {
$connectionStrings[$currentConnectionString.Name] = $currentConnectionString.ConnectionString
}
$connectionStrings["someKey"] = "someValue"
Set-AzWebApp -ResourceGroupName $resourceGroupName -Name $appName -ConnectionStrings $connectionStrings
But this fails with the error
Set-AzWebApp : Cannot validate argument on parameter 'ConnectionStrings'. Connection string type value pair must be of type 'System.Collections.Hashtable'
despite the fact that $connectionStrings
is of type System.Collections.Hashtable
Also trying to work with Custom Objects, arrays and so on failed.
How do I pass the connection strings correctly? And how do I specify the Type (e.g. SQLAZURE)?
Thanks