question

GrahamAllwood-4295 avatar image
0 Votes"
GrahamAllwood-4295 asked azure-cxp-api edited

ARM Function Deployment

Hi,

I have a number of Functions written in dotnet. I want to start using ARM templates (or Proj Bicep) to deploy them.

Up to this point I've used he Portal and VS2019 Publish in order to get the code on Azure.

I want to start using CI/CD in Azure Dev Ops. I can build my repo for the function code easily. But, when it comes to release pipelines I want to run a template to deploy things. The problem is, what is the best practice?

I can create storage accounts and service plans and FunctionApps in my template, but how do I get my functions (code) in to the FunctionApp?

It would be nice if my template could reference the build artifacts of the built dotnet project for the functions.

Azure Release Pipelines do have a deployment step for AzFunctions but I don't know what this is doing :(

Thanks

Graham

azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

stan avatar image
1 Vote"
stan answered stan commented

Hi,
You can find example here on how to deploy a function that is located on Storage account.

A few more information you can find in this tweet as well.

Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks Stan.

I've had a quick scan through Chapter 10 of your book, as well as the temaplte code in the repo. I can see the function app and storage accounts being created, but the one thing I can't find is how the zip file is copied to the blob storage. Is this done somewhere else?

My thinking right now, is my CI/CD process would be:

  1. Build the functions project, output the artifact - a zip file.

  2. Release process:
    a. Run my arm template to configure the infrastructure
    b. Manually copy the artifact zip file from the build in to the blob storage that was created above.


0 Votes 0 ·
stan avatar image stan GrahamAllwood-4295 ·

Yes, in my case the function zip file is on GitHub so I do not have to upload it but in your case you probably want to be on private place so you will need to have a task for uploading thr zip to existing storage account, issue SAS token and pass the url and the SAS token to the arm template so you can add it as value to the app setting for run from package. You can use Azcopy or Az PS to do the upload. May be there was also builtin task in DevOps for that. In this case you first create the storage account - could be done trough arm template l, upload the zip to the storage account and issue SAS token. The SAS token better be for the time of usage of the function as every time the function restarts will take the package from storage and last step will be to deploy the function with ARM template and the setting for the location of the function.

1 Vote 1 ·