Matt Cook
Matt Cook

Reputation: 3

Updating Stack Settings for Azure Functions using an ARM Template or Bicep file

I am updating an Azure Functions project from .NET 7 to .NET 8 and it is not picking up any of the HTTP Handlers in the Azure Portal when it previously would when targeting .NET 7.

I added the environment variable FUNCTIONS_WORKER_RUNTIME with the value dotnet-isolated as mentioned in the answer on this other question states and this makes the ability to change the stack settings through the Azure Portal possible but I want to be able to set this in configuration, either through an ARM template or a Bicep file

Upvotes: 0

Views: 1365

Answers (1)

Ikhtesam Afrin
Ikhtesam Afrin

Reputation: 6484

To create an isolated function along with the configuration settings using Arm template, you can either refer to this MS Doc or check the code below-

"resources": [
  {
    "type": "Microsoft.Web/sites",
    "apiVersion": "2022-03-01",
    "name": "[parameters('functionAppName')]",
    "location": "[parameters('location')]",
    "kind": "functionapp",
    "dependsOn": [
      "[resourceId('Microsoft.Insights/components', parameters('applicationInsightsName'))]",
      "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
      "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
    ],
    "properties": {
      "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
      "siteConfig": {
        "appSettings": [
          {
            "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
            "value": "[reference(resourceId('Microsoft.Insights/components', parameters('applicationInsightsName')), '2020-02-02').ConnectionString]"
          },
          {
            "name": "AzureWebJobsStorage",
            "value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix={1};AccountKey={2}', parameters('storageAccountName'), environment().suffixes.storage, listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2021-09-01').keys[0].value)]"
          },
          {
            "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
            "value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix={1};AccountKey={2}', parameters('storageAccountName'), environment().suffixes.storage, listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2021-09-01').keys[0].value)]"
          },
          {
            "name": "WEBSITE_CONTENTSHARE",
            "value": "[toLower(parameters('functionAppName'))]"
          },
          {
            "name": "FUNCTIONS_EXTENSION_VERSION",
            "value": "~4"
          },
          {
            "name": "FUNCTIONS_WORKER_RUNTIME",
            "value": "dotnet-isolated"
          },
          {
            "name": "WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED",
            "value": "1"
            }
        ],
        "netFrameworkVersion": "[parameters('netFrameworkVersion')]"
      }
    }
  }
]

Please make sure, you have created the related resources like Application Insight, storage account and hosting plan before executing the given script.

Upvotes: 0

Related Questions