Azure Functions Flex consumption plan bicep code deployment

Václav Parma 0 Reputation points
2024-12-09T18:01:43.7366667+00:00

Hello,

I’m trying to deploy an Azure Functions (python) using Bicep. I previously used a consumption plan, but due to the need for Azure Virtual Network integration, I would like to move to a Flex consumption plan. My question is how to upload code to the function from Bicep?

With the consumption plan, it could be done as follows:

resource functionZipDeploy 'Microsoft.Web/sites/extensions@2021-02-01' = {  
  name: '${function1Name}/ZipDeploy'  
  properties: {  
    packageUri: functionCodeUrl  
  }  
}

However, this is no longer supported with the Flex consumption plan.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,248 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 23,061 Reputation points Microsoft Employee
    2024-12-10T04:15:58.41+00:00

    @Václav Parma Thanks for posting your question in Microsoft Q&A, apologize for any inconvenience caused on this.

    Ideally, when you perform Zip deploy all the project files will be deployed under wwwroot folder as .zip file and function app will load the functions from that .zip file which is not same in case of Flex consumption plan.

    In flex consumption plan, deployments follow a specific process. First, your project code is built and compressed into an application package, which is then deployed to a blob storage container. When your app starts up, it retrieves the package and runs your function code from it.

    To deploy your functions code to flex consumption function app using bicep I would suggest you add a deployment script in your bicep file to upload your function code to storage account.

    Also, deployment scripts can run over the private endpoints and virtual networks.

    Refer to the below documentation for more information about deployment scripts.

    1. Deployment scripts.
    2. Access private virtual networks.
    3. Run deployment script privately over a private endpoint.

    Update from Azure Functions Engineering Team:

    For Flex consumption, we do not support “zipdeploy”. Instead, we support “OneDeploy”, which can be used as below:

    resource functionZipDeploy 'Microsoft.Web/sites/extensions@2022-09-01' = { 
      name: '${functionAppName}/OneDeploy' 
      properties: { 
        packageUri: '${packageUri}'
        remoteBuild: true 
      } 
    } 
    

    This will build the package if you pass property “remoteBuild: true” and you can skip build if you pass property “remoteBuild: false”.

    The result of this is same as what you experienced with zipdeploy as a .zip package is added to the wwwroot.

    NOTE: We strictly recommend NOT to “upload their function zip to storage account” manually.

    Hope this helps let me know if you have any further questions on this.

    Please accept as Yes if the answer is helpful so that it can help others in the community.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.