I have an Azure Function I would like to deploy using Octopus Deploy. How do I go about doing that?
If you would like to use the built-in functionality then continue reading. This answer is going to borrow extensively from this blog post was written earlier in 2018.
I have a pretty simple function app, it has a single function, Version which returns the version from the config file.
Prep Work
You will need to do the following prep work for this to work.
Upgrade Octopus Deploy
Ensure you are on a recent version of Octopus Deploy. This was originally setup using a instance running 2019.11.1.
Configure your Azure Functions in Azure
These functions will need to exist prior to deploying to them. They can be empty, they just need to exist.
Configure Azure Account in Octopus
You will need to add 1 to N Azure accounts in Octopus Deploy.
Add each function app as an Azure Web App in Octopus Deploy
Octopus Treats Azure Web Apps and Azure Function Apps the same. To do that go to Infrastructure -> Deployment Targets -> Add Deployment Target
Enter a name, role, and environment. Then select the account you want to use. Once you select the account you will be able to select the function app as you can see below.
Package Your Azure Function App
You will need to package up your Azure Function App into a .zip file for Octopus to deploy. If you are using the CLI tools provided by Azure to build your app, you will want to zip up the contents of the bin\output folder.
The zip file will look like:
Configure your project
In your project, you will want to add the “Deploy Azure Web App” step to your process.
You will note at the bottom of the screen the JSON Configuration Variables has been configured. This is a Configuration Feature available to Azure Web Apps.
It will allow me to replace the VersionNumber
in my settings.json file.
With a value stored in Octopus Deploy.
Set it in action
You can view the Azure Functions space in our samples instance to see this all in action: https://samples.octopus.app/app#/Spaces-1
You can try out the Azure Function by hitting one of these URLs:
Hello,
Did this work for you when Azure Insights are enabled? My deployment fails in case I’ve created a function app together with insights.
This is definitely a great tutorial, however, how can I do add environments variables from the octopus to Azure configuration section. I’ve tried differents ways but I did not get success.
Hi Rocha,
Have you got the solution for this?
I’m also facing same issue… could you please help me out?