I want to set an existing Azure function's app settings from Powershell. I have the following script
$FunctionSettings = @{
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING" = "*******";
"WEBSITE_CONTENTSHARE" = "TestFunction123";
"AzureWebJobsStorage" = "*******";
"FUNCTIONS_EXTENSION_VERSION" = "~2";
"FUNCTIONS_WORKER_RUNTIME" = "dotnet";
"WEBSITE_NODE_DEFAULT_VERSION" = "10.14.1";
}
Set-AzureRmWebApp -ResourceGroupName "RGN" -AppSettings $FunctionSettings -Name "TestFunction"
Running this script returns this error
Set-AzureRmWebApp : Operation returned an invalid status code 'BadRequest' At C:\Users******\Source\Repos*******\Create Azure infrastructure.ps1:101 char:1 + Set-AzureRmWebApp -ResourceGroupName $AzureResourceGroupName -AppSett ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Set-AzureRmWebApp], DefaultErrorResponseException + FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.SetAzureWebAppCmdlet
If I remove the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE from $FunctionSettings then the script runs successfully but I get errors in the Azure UI because those properties are required.
How can I fix this?
Set-AzWebApp
? I tried it with a consumption function app, it works fine. – Joy Wang-MSFT