Azure Function App with Deployment Slots Storage Environment

Tore Paulsson 31 Reputation points
2021-10-08T14:48:36.127+00:00

Hi,
I've tried to get an azure function app up and running with deployment slots using bicep templates. The template can create all the resources but I'm having a hard time to get the switch to work, there seem to be some issues with the environment variables.

According to documentation the variable WEBSITE_CONTENTSHARE (https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#website_contentshare) should be omitted when deploying through arm(bicep) templates. It is said to be generated. This is important since it cannot have the same value as the staging slot later. I want to ommitt this environment variable.

I can deploy everything without WEBSITE_CONTENTSHARE and WEBSITE_CONTENTAZUREFILECONNECTIONSTRING (https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#website_contentazurefileconnectionstring), but I get warnings in the portal that storage is not configured correctly.
138770-image.png

Checking that page, I see what are required parameters, and I have AzureWebJobsStorage defined.

If I try to add WEBSITE_CONTENTAZUREFILECONNECTIONSTRING, deploy complains that I'm missing required parameter WEBSITE_CONTENTSHARE. But that one I cannot define since it would lead to errors when switching production and staging slots (I've tried). Are there any other environment variables I need to specify? Some older posts and blogs have solved the issue by making the WEBSITE_CONTENTSHARE a deployment slot setting, but that is blocked now. I'm unsure what the problem is here with the function? As a side not, the API works, so as the warning states, I'm worried about scaling.

If I add both the variables WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE I don't get any warnings, but I cannot use deployment slots. What to do, anyone have any ideas?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,327 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Mike Urnun 9,761 Reputation points Microsoft Employee
    2021-11-04T21:11:19.29+00:00

    Hello @Tore Paulsson - You'll want to define the WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE settings ONLY at the first time when you are deploying. For all subsequent deployments, you'll want to make sure that the definitions are removed from your template.

    2 people found this answer helpful.

  2. Tore Paulsson 1 Reputation point
    2022-01-18T10:14:26.68+00:00

    Hi, thanks for your reply! I must have missed the e-mail notification!

    I have not tried the solution you propose, but after changing the template to not use a separate resource for the app settings (Microsoft.Web/sites/config), everything worked. It seems to be a problem with the validation that occurs for the separate app settings resource. Really odd!

    For the app to function properly (if i remember correctly) I had to also clear the existing function app that was deployed since it had a value set for WEBSITE_CONTENTSHARE by my previous deploy.

    After these changes everything worked!

    0 comments No comments