Coder Perfect

Bicep allows you to deploy an Azure function app using nodejs code from a public github repository.

Problem

I can use bicep to create a Windows functionApp and apply a source control to it like this:

resource srcControls 'Microsoft.Web/sites/sourcecontrols@2021-01-01' = {
  name: '${functionApp.name}/web'
  properties: {
    repoUrl: 'https://github.com/Bygdrift/Warehouse.Modules.Example'
    branch: 'master'
    isManualIntegration: true
  }
}

This method allows me to import a dotnet project from a public github repository into a functionapp, which is fantastic.

I’m trying to accomplish the same thing with a node project on Linux, but it’s not working. Should I upload my code to the github repository as a zip file?

It must not be a Kubernetes container, and it must not be deployed using a github action. Everyone should be able to quickly deploy the node project to Azure using an ARM template.

Here’s what I’m trying to do, but it’s not working:

resource linuxHostingPlan 'Microsoft.Web/serverfarms@2020-10-01' = {
  name: 'Linux-${uniqueString(resourceGroup().id)}'
  location: location
  kind: 'Linux'
  sku: {
    name: 'Y1'
    tier: 'Dynamic'
  }
  properties: {
    reserved: true
  }
}

resource functionApp 'Microsoft.Web/sites@2021-02-01' = {  //Inspiration: https://docs.microsoft.com/en-us/azure/azure-functions/functions-infrastructure-as-code
  kind: 'functionapp,linux'
  name: functionAppName
  location: location
  properties: {
    serverFarmId: linuxHostingPlan.id
    siteConfig: {
      appSettings: [
        {
          name: 'AzureWebJobsStorage'
          value: appStorageConnectionString
        }
        {
          name: 'FUNCTIONS_EXTENSION_VERSION'
          value: '~4'
        }
        {
          name: 'FUNCTIONS_WORKER_RUNTIME'
          value: 'node'
        }
        {
          name: 'WEBSITE_NODE_DEFAULT_VERSION'
          value: '~14'
        }
      ]
      linuxFxVersion: 'Node|14'
    }
    reserved: true
  }
}

resource srcControls 'Microsoft.Web/sites/sourcecontrols@2021-01-01' = {
  name: '${functionApp.name}/web'
  properties: {
    repoUrl: 'https://github.com/Bygdrift/nodejsClean'
    branch: 'master'
    isManualIntegration: true
  }
}

Asked by Kenneth Bo Christensen

Post is based on https://stackoverflow.com/questions/70762871/deploy-azure-function-app-with-nodejs-code-from-a-public-github-with-bicep