Admittedly, the Function that we created last month didn't do a whole lot. We sent in a "name" and got a welcome message back. That's okay though as we have something that can be added to source control. If you haven't completed the exercise now would be a decent time to do so as we will be adding the "Hello World" function to source control and making some modifications, checking into source control and verifying that our changes were made.
Prerequisites
- For this demo is the Function we created last month in either Visual Studio or VS Code
- Additionally, you will need to have an account with one of the following Source Control options. Note: they all have free options
Source Control Options
- Visual Studio Team Services
- Local Git Repository
- GitHub
- BitBucket
- Dropbox
Azure Functions gives the developer a wide range of options to choose from for their deployment options. In the past I have set up my Git repositories to use Visual Studio Team Services but it is just as easy to use something like GitHub so let's go that route!
If you are not yet familiar with Git-based source control solutions I would recommend that you take a look at this before continuing: Continuous Deployment For Azure Functions. It's a bit out of scope for this post to get into the workings of Git or it's tooling.
To dive into this, open the Azure Portal and click on the Resource Group containing your Function App. Then click on the name of your Function App and the first section you see should be the Overview section of the App itself:

Select "Deployment Options" under Code Deployment and a new blade will appear called "Deployments." Click Setup and then you'll have another new blade appear where you can configure your source.
For this demo I selected GitHub, walked through the necessary authorization and then added some Performance Testing (this will simulate 20 users for approximately 5 minutes).
Once you are done with configuration the deployment will begin. The deployment itself is fairly quick and once it's done you'll get the following message:

After we've deployed we can close the Deployments blade and we should be able to see our Functions. But wait, mine aren't showing up...

Next we can send requests using Postman. I covered how to debug your Function last month using Postman and the steps are the same except you will use your local URL (the one we copied to the text editor) to send requests to.
What's Next?
So, now that we have our CI/CD working we can add a little complexity. If we open our run.csx file using Visual Studio Code (see this post if you forgot) we can make a simple edit to prove that everything is working right.
In Powershell I will do the following to open VS Code:
code .\run.csx
Once VS Code opens we will make a similar change to line 20 in run.csx.
Update to line 20 in run.csx
: req.CreateResponse(HttpStatusCode.OK, "Hello " + name + " from Azure deployed from GitHub.");
Now, we're ready to make a commit from Powershell which will trigger another deployment.
git add -A
git commit -m "Update showing that when we make a change we will get an
updated message."
git push origin master
It should take a minute or so and then your function will be updated. If you send in the same request you should now get back a different response.

Conclusion
Our webhook is still a bit basic but we are getting somewhere. We have the webhook hosted on Github and we are able to make changes, push them to source control and see the change immediately in our Function. Also, we can now work on the Functions in a team setting.
What's next:
- Once we have these steps down we will be ready to add a layer of complexity to our functions where we will parse an incoming request to an Object, log the object to Azure Table Storage, trigger an event in Azure Storage Queue, and respond to the user's request.
- After that we will take a look at how we can beautify our API and add testability to our API using Swagger. Additionally, we'll take a look at the Microsoft recommendations for testing an Azure Function.
Further Reading
- Azure Docs: Functions Best Practices
- Continuous Deployment for Azure Functions
- For those that are looking for more granular control of the CI/CD experience Shayne Boyer has a guide about Functions deployment using the Azure CLI. Shane's article walks you through setting up an Azure Resource Manager template for your function.