Try reloading this page, or reviewing your browser settings
This video segment discusses and demos continuous deployment with Azure functions.
- Azure Devops
- Azure Functions
About this video
- Sahil Malik
- First online
- 21 December 2018
- Online ISBN
- Copyright information
- © Sahil Malik 2019
Sahil Malik: Azure Functions supports continuous deployment from numerous source control repositories. So Bitbucket, Dropbox, Git or Mercurial, Git local repository, GitHub, certainly Azure DevOps, but even OneDrive. All of these are welcome to be used with continuous deployment with Azure Functions. Let’s see how this works.
So you see I have a project there, PlayWithFunctions. Let’s go inside it. And here under Repos, I’ve chosen to add this PlayWithFunctions repo and you see here that I’ve checked in this code using basically just simple git and I’ve gone through a couple of commands just playing around with. There’s nothing special. Okay, so this code is set up in a repository that understands Git. Remember that Bitbucket, GitHub, all of those can work as well, but I’m demoing this using Azure DevOps.
In about a minute or so, you’ll see that your function app got deployed successfully, so let’s go ahead and click on this. Go to resource button and let’s look at our function app. So currently as expected, I have an empty function app and there are no functions in it because we haven’t created any functions. I can choose to click this plus button and create a function, but that’s not what we’re here for. What we want to do is that we want to deploy our function from this DevOps repository that I have, PlayWithFunctions. So how do we do that?
Go to Platform features and look for Deployment Center. And here you see, it’s just a Wizard that you have to go through. So there are a number of choices here. I’m going to go with Azure Repos. So it says you need to configure it, that’s easy enough. So let’s give ourselves a little more space here. So click on Continue. So I’m going to point it to the DevOps organization when logged in on both sides using the same LiveID. Let’s pick the brand so you can have staging and master and you can deploy it accordingly. I’m going to click on Continue and I’m going to click on Finish.
So in a moment it says setting up deployment and here it is pointed itself to this repo. You can see that under Deployment Credentials, it went ahead and created an App Credential using which it is getting all the details. You can also choose to specify User Credentials. Let’s close this because there’s something interesting going on back here. It says it was able to pull in the last commit, which I simply called another commit and it is now running the deployment or my function. Let’s give it a second. Hit the refresh button here and you see here, this function shows up here. The code in this function is identical to the code that I’ve checked in this code over here, that code that has been checked in into the repo. So let’s give a moment for this to load.
And once this load, notice that it is Read only. You can choose to make it Read/Write if you want to play with it. But the idea is that the next time I push an update into my source control repo, it will overwrite this. But right now, it’s Read only and that’s fine for me to test. So I’m going to click on this Run button. And on the right-hand side, you should see my function running. So it says Bad Request because I did not pass in a query string or the request body. Well, that’s actually according to the logic I have here. So I have to pass in the name. This is the default function code that gets generated for me. So let me go ahead and pass in the name header and let’s go ahead and run this again.
I’m sorry, actually, it’s in the request body like this, we don’t need that. Let’s click on Run and you see it says Hello Sahil. Now what’s really cool is that I’m going to go into VSCode now and here I’m going to make a little change. So instead of Hello, I’m going to say Good morning. Okay, so just a minor code change, just to try this out. And I’m going to go here and I’m going to take git status. So I’ve made a change to one file, so I’m going to say git add . && git commit -m “Small change” && git push.
Now, if you’re using DevOps, you would probably make this change in a branch and you would have all sorts of policies and pipelines run, all sorts of interesting stuff run and then things get committed into master. I’m just taking a shortcut here by committing directly to master but check this out. Now there’s the code showed up in master, let’s go back here into my function app and you see that the small change that was able to pick it up on its own and the code shows up here. And if I run this, let’s scroll to the right. You should see that my function app has got updated and this is how you can connect continuous deployment with Azure Functions.