How to build Serverless APIs with Visual Studio Code & deploy to Azure Functions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone welcome to the channel in today's video I have partnered with Microsoft Canada to show you how we can utilize VS code extension for Azure Functions to develop a serverless API locally and then use that same extension to deploy it to the cloud let's get started so what I have done is I have created Azure Resume API Directory in my downloads folder here and that's where we will be storing all our code today if I open VS code there are a few things we need to make sure we have installed let's open up the directory that I just created so it's a blank directory right now so what you want installed is the Azure extensions there is Azure Functions extension that you'll need so as you can see it's installed and then I also have an Azure Account extension which helps me navigate through my subscriptions and anything related to my Azure account VS code since we have our empty directory I'll make sure to link down the extension itself that's available for VS code specifically the Azure Functions extension so once you have that extension installed if you do a Control Shift P it'll show you all the commands and then I have one for Azure function so if I type pane as your functions will give me all the commands that are available for that extension since we haven't created a function yet I'll click on create Function you can see it is asking me to create a new project we'll pick my directory that we just created for this demo purposes we'll use Python then I'll ask you what interpreter you want to use for me I have 3 dot 9 dot 2 installed so let's pick that it gives you a bunch of options on what the trigger type should be for your server less function let's go with http trigger which means it'll give us a URL and we can do get requests post depending on what methodologies we use within our function instead of SDTP trigger let's put in resume as our trigger name for the SDTP triggers authorization level let's go with anonymous because I want people to be able to do a get request for the URL that will go for this function start creating resources that are needed the code files and the configuration files that are needed to run the function so you can now see that we have an init py file that's available to us you can also see it has said finish creating project so you can already see there are few files that I'll go over so requirements dot text is we're while our item packages will live that are needed in our function here so right now we are only importing Azure Functions but I'll also import JSON because that's what we will use to create our JSON Resume API and then you can see function JSON is just some more config it's another configuration file that holds in what triggers do we have for our function so we went with SGB trigger and then what is the odds level as you can see it's anonymous right in function JSON Jose JSON is to how this function is being so what we have is just a boilerplate function what it basically does it gives you URL end point which you can call and you can pass an argument with name and it will return hello whatever you put in the argument as name would say hello in my case rishop this is STP triggered function executed successfully what I want to do is instead of giving this response I wanted to give back my JSON resume for that what I'm using is called JSON Resume Scheme I'll link this down below but basically gives you a structure for your JSON file as a resume and you can see you know name label image email phone your all of the things that you'll list on a resume are here in adjacent schema so what I have done is I have gone ahead and created one for mine we'll modify our in a Pi file now so let's get rid of the functions that we have right we are importing logging and Azure functions that do let's do another import for Jason since we will be working with Jason Data I have I'll create variable called data that will hold all of the Jason value and as I said I've already gone ahead and created my Jason formatted resume and you can do that too with the schema that I just showed previously right these are some details for myself a name website email write username and then I've shared my LinkedIn profile my work experience my certifications my skills just fill in the details the default schema that's provided and now we are storing that in data what I want to do is create a main function so what we are doing is we we are logging info saying that this Python SGTP trigger was SGTP function was triggered and then what we are doing is we are returning this as JSON data our main function just returns the JSON data and also gives us back a status code of 200 it's a pretty easy function right as you can see so now that we have developed our function locally it's time to deploy it to Azure and it can be done by using the same extension and I'll show you so if you do Control Shift the first thing we need is the resources to host this function right and you can see if you type in Azure Functions earlier we clicked on Create Function but now we need to Create Function app in Azure so they'll ask you to enter a globally unique so we'll go with Resume API demo Azure okay I think that's unique enough click on the next and it'll come up with the runtime that will pick Python 3.9 and then what the location of his resource should be let's pick East US 2 and as you can see right now it's creating a function app called Resume API Demo Azure in East US 2 with the SKU standard LRS 228 00:05:37,66 --> 00:05:37,633 so we'll wait for these resources to be created right now it's creating a storage account for our function app and now you can see it's creating new function app and it's almost done okay so it gave us a URL where our function app is running let's try going to if I open that URL in the browser should be greeted with the default functions app your functions app 4.0 is up and running and now we have to deploy our SGTB trigger function so in order to do that if I go into the Azure extension now so this was the second extension I was talking about right you can see how it already is looking at the local project and it also knows that it's looking at the structure of the project and you'll see a little icon on the right hand side which says deploy so if I click on that we'll be deploying it to the function app that we just created so we picked that option and you can already see we have our Resume API demo Azure here so we'll click on those and it'll give you a warning saying are you sure you want to deploy it to this app this will overwrite any previous deployment and cannot be undone so I'm good with that we'll click on deploy now you can see it'll be doing a deployment of the local function that we just created all through the extensions that are available for Azure and Azure Functions I haven't logged into my portal as you have seen in this demo so I really feel like you know these extensions are really powerful and gives you the ability to develop several s functions locally so you can see the deployment has been completed it's time to test our trigger here if I go to my browser tab open this up you should see adjacent response with my details and you can see that so if I zoom in can see it's a Jason you know document with all the details that I just entered our server less function has been successfully deployed so we already saw that in the browser but what if I which helps us do you know get request so I'll do a get request to this SGTP endpoint which we just received from Azure and you will see adjacent response includes all of the details that my resume has and that was exactly what we were building a server less Resume API developing a server less function locally to applying it to Azure all through VS code there are a lot of great resources available from Microsoft to learn more and get started with building service Epis go check out aka MS Forward Slash Arcade to get on demand training from Microsoft on Azure Functions and the VS code extensions that I used to live for Azure Functions and Azure I hope you really liked this demo I'll see you in the next one peace
Info
Channel: Rishab in Cloud
Views: 5,216
Rating: undefined out of 5
Keywords: serverless, visual studio code, build nodejs apis using serverless, how to build serverless apis, how to build serverless rest api, how to use visual studio code, visual studio, microservices and serverless with azure and visual studio code, serverless api, azure serverless end to end with functions, how to simplify cloud run development with visual studio code, deploy cloud run web app with visual studio code, serverless architecture, python, azure, azure functions, vscode, extensions
Id: rWLBsLprhUc
Channel Id: undefined
Length: 8min 13sec (493 seconds)
Published: Thu Feb 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.