When deploying an Azure Function App and AppSettings via an ARM Template, is it possible to tell Azure not to delete AppSettings that are not declared in the template?
For example, take the following AppSettings config from the template and imagine that I'm updating an existing Function App. In this case, an AppSetting called storageaccountname_STORAGE would be deleted, which is undesirable as (for example) it has been created to facilitate a binding.
{
"apiVersion":"2016-08-01",
"name":"appsettings",
"type":"config",
"dependsOn":[
"[resourceId('Microsoft.Web/Sites/Slots', variables('functionAppName'), 'Staging')]"
],
"properties":{
"AzureWebJobsStorage":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]",
"AzureWebJobsDashboard":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]",
"APPINSIGHTS_INSTRUMENTATIONKEY":"[reference(resourceId('Microsoft.Insights/components', variables('applicationInsightsName')), '2014-04-01').InstrumentationKey]",
"FUNCTION_APP_EDIT_MODE":"readwrite",
"FUNCTIONS_EXTENSION_VERSION":"~1",
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING":"[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2015-05-01-preview').key1, ';')]",
"WEBSITE_CONTENTSHARE":"[toLower(variables('functionAppName'))]",
"WEBSITE_NODE_DEFAULT_VERSION":"6.5.0"
}
}
Is there a way to selectivly set AppSettings via an ARM Template, or are the templates simply not capale of functioning as desired for such a scenario?
Using WEBSITE_RUN_FROM_PACKAGE = URL. This section provides information about how to run your function app from a package deployed to a URL endpoint. This option is the only one supported for running from a package on Linux hosted in a Consumption plan.
AzureWebJobsStorage. The Azure Functions runtime uses this storage account connection string for normal operation. Some uses of this storage account include key management, timer trigger management, and Event Hubs checkpoints. The storage account must be a general-purpose one that supports blobs, queues, and tables.
WEBSITE_CONTENTSHARE is used along with WEBSITE_CONTENTAZUREFILECONNECTIONSTRING which represents where the configurations are stored and the storage account where the function app code is stored.
Sign in to the Azure portal, then search for and select Function App. Select the function you want to verify. In the left navigation under Functions, select App keys. This returns the host keys, which can be used to access any function in the app.
I ran into this problem also a while ago and did not find a solution within an ARM Template.
In my case I solved it by using a PowerShell Script what run after the ARM Template. Maybe you can use some parts of this:
https://gist.github.com/kirkone/2b5996a57a5610a8a41e2bfd1edc37f1
The main part is getting the current values, add or override with the new values and write back the complete list.
This Script is for use with VSTS / TFS but it should give you a hint about how it can be done.
Sorry for not having a better solution but I hope this helps also.
CU
KirK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With