Deploy, Secure and Manage Azure Functions

Zip Deployment

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

This video segment discusses and demos how to use zip based deployment with Azure functions.

Keywords

  • Azure functions
  • deployment
  • zip
  • run from package

About this video

Author(s)
Sahil Malik
First online
21 December 2018
DOI
https://doi.org/10.1007/978-1-4842-4409-8_6
Online ISBN
978-1-4842-4409-8
Publisher
Apress
Copyright information
© Sahil Malik 2019

Video Transcript

Sahil Malik: Azure Functions also support Zip deployment. Zip deployment is quite simple. You can download an existing function app as a zip file and then using simple REST APIs, you can upload that and deploy it therefore in a new function app. So you can do this using Azure CLI, PowerShell, Bash, Azure Functions core tools–really behind the scenes, it’s just a REST call. So as long as you can make a REST call using the zip deployment, you can deploy Azure Functions.

Let’s see how zip deployment works in practice. So remember zip deployment means that I need to have my code exported as a zip file in a particular format and then I can deploy it using REST API. And the easiest way to do that is Azure CLI. So I have a function here as you can see, and what I’m going to do is that I’m going to export this very function app and you can choose to deploy it into a new function app. But what I’ll do is I’ll delete this function after I exported and then I’ll redeploy it with zip deployment. So let’s see how that works.

So in order to export the function app, go to your function app and click on the Download app content button. Certainly this is not the only way of doing this, as long as you craft up your zip file in a compatible format, it can come from anywhere. In fact, your source code maps very closely to the format we need. So I’m going to click on Download app content and choose download site content and just click on the Download button. So it went ahead and downloaded this sahilfunctionapp for me. Let me find it over here. That’s the file right there, and I’m going to place it in a folder that I recognize which is C: Developer.

Next, I’ve already set up Azure CLI on this machine. So I’m going to go to terminal and I’m going to type az login and log into Azure CLI. This pops up in the browser. Let’s go ahead and sign in. And basically in a moment, I’m signed in. Let’s go back to my terminal. And now that I’m signed in, I’m going to simply say az function app deployment source config-zip -g for the group, I’m going to deploy it to the resource sahil, which already have. Give it a name of sahilfunctionapp. That’s the function app in which we’re deploying this function. –src sahilfunctionappzip. Now, I’m not going to hit enter yet because what I’m going to do instead is that I’m going to come up to my function app that already exists, and I want to delete this function out of here.

So how do I do that? First, I have to go to the functional app settings. Since this was deployed from source control, it is Read Only now. I will change it to Read/Write. Like that. Then I’ll go to the Functions tab here, wait for this to load, and this trash bin is now enabled. Go ahead and click on it to get rid of that function. So you see right now, I have no function here. Let’s refresh and make sure there’s nothing here. Okay, good. Now let’s come back here and I’m logged in using Azure CLI. Let me hit enter. I have a small typo. Let’s quickly fix it. Source. Hit enter and give it about a minute or so. Let’s come back here. Let’s hit refresh, and you’ll see that the function appears here. And exactly the code that I had exported into that good morning message. Exactly that code reappears over here.