Coder Perfect

How can I use Bicep or ARM templates to control the version of an Azure site extension?


We’re working on an Azure C# ASP.NET Core application (.NET 5). We offer both production and test environments that are always available. We also establish short-lived Azure environments on a frequent basis during development (where we run tests and then delete all the Azure resources when done). We’ve run across issues with Azure site extensions and their various versions.

It’s possible that our custom code (to be run on Azure) is dependent on a specific version of a site extension. A runtime error may occur if the Azure environment has an incompatible version of the site extension installed.

Bicep/ARM templates are used to create Azure resources. When an Azure environment is built and a site extension is specified in the template, Azure appears to automatically download the most recent version of the site extensions. (There may be a way to choose which version we receive, but we haven’t discovered it yet.) As an example, consider the following from our Bicep:

resource aspNetCore_AzureAppServices_SiteExtension_resource 'Microsoft.Web/sites/siteextensions@2021-01-15' = {
    parent: webApp_resource
    name: 'Microsoft.AspNetCore.AzureAppServices.SiteExtension'

As a result, our short-lived environments (which are built and destroyed on a regular basis) may become out of sync with the long-lived environments as newer versions of site extensions are sent to the short-lived ones.

According to reports, the following can occur:

To summarize, we’d like to be able to choose which version of a site extension is installed when we create/update Azure resources using Bicep/ARM templates. Is that even possible?

Asked by Claus Appel

Post is based on