Deploying Your WebAPI on Azure through Visual Studio
A free video tutorial from Packt Publishing
Tech Knowledge in Motion
3.9 instructor rating • 1587 courses • 308,749 students
In this video, we will use Visual Studio to publish our API to Azure and make it publicly available.
Learn more from the full courseRESTful Web services with ASP.NET Core
Leveraging ASP.NET Core and Visual Studio 17
03:33:54 of on-demand video • Updated August 2017
- Explore basic REST principles
- Build an ASP .NET core project using Visual Studio 2017
- Work with different environments such as development and production
- Implement a service interface to read, manipulate, and delete data
- Extend API functionality with more features
- Deploy the WebAPI
English [Auto] Well come to the fifth section deploying the web API in this video we will take a look at how we can deploy a web API to Azure with Video Studio 2017 in the upcoming demo we will prepare a deployment to Azure. So first we have to add some new bid packages again. Then we have to at the end of deferring work migrations again after that we will create a publish profile to deploy a web API to Azure and then the last step we will publish or Abey to Azure with Visual Studio. Let's go straight to the code in our packed web application. The first thing we have to do is installing some new good packages. Therefore we will browse for Microsoft and a different car. We're installing it explicitly because we need a specific version at the time we are recording this course. So if you click on it we select the version 1 1 1 to install. Once we have finished we have to install a specific version of Microsoft Entity Framework core. Esky of server. I know we previously installed that but I encountered errors while deploying to acha with this version we installed previously. So for this video we will install the version 1 1 1 and last but not least we will install the Microsoft and the different call tools to have everything on board here. Please select the version 1 1 0. So when this is installed we can take a look at this see approach file and he can see again the versions which we are deploying to measure with. And did you frame or call 1 1 1 and 2 different Richar ask yourselves 1 1 1 and 2 different McChord tools 1 1 0 at the time of recording these were the versions which are playing very nicely with our Espina that call web app. The next thing to do is adding some migrations. We already did that so we can open up the package manager console and like we did in the previous video we can do it add migration follow up by the name so you can see in the background the immigration was added and we have our immigration folder with the migration files. So now we can do a right click on our project and select publish in the menu. After that you will see some deployment options. We will take the Microsoft Azure app service and create a new click publish. After that you will see some options to fill in. The first is the web app name. We can leave it like that. Then you can choose your subscription you have an azure. Then you have to see which resource you want to have and you can choose the service plan for a demo. We will add in new app service plan as this is only a demo. We will take the free one here clicking OK then you can take a look at the services tab as we have a database which we target over and do the firmware core as an escrow server. We were creating a new one then we will take an administrator a user name and we will choose an administrator password. Clicking OK clicking OK again. Then you can see like a summary of what we are planning to publish. The first one is a packed Web site plan. This is the app's service plan. Our application will run and then we have the DV server and your Esco database. Now you can click Create your studio. We now publish our API to Azure and scaffold everything for us. If the deployment is ready you can see that it opens up the browser and browses to the web app. In this case we can see our HMO page. It works. Now we can show up the Swager page here you can see are endpoints customers and customers too. Let's try it out. Let's try get all the customers sitting the texture application Jason and just try it out and you can see we're getting our data. So even as the service is running let's try add a new customer sending a post request. Jason try it out and you can see that we have an ID and our customer was at it. Let's copy this link here and tried from postman and Postman you can simply paste the your eye and just hit it get request and then you can see we're getting back our data with our new added customer. Hello there. So this is how you can deploy your web app to Azure in the pack web app you now can see on the Properties folder which is called publish profiles. Here you can see the published profiles which were added through browsers to do so that you can easily redeploy. Let's change something on our current. Now we can simply do a right click on the project and select publish again. We already have the Publish profile but we can go through the settings here. We can click validate connection and under settings you can see when we open up the databases tab that it should use this connection string and run time and this is the connection string we added with a user ID and the password which is used to connect to the database so you can check this one here to make sure it uses that when the app is running on Azure can save that and simply had published again. You can see the it works again because the browser pops up automatically. If Now now to swaggerer again and you can see my second web API. Now let's log to Azure and see your web app and some detailed information about it. If you logon to Azure. The first thing you can see is your dashboard. You can customize it as you want. If you click on all resources on the left hand side you can flip to your web apps you can filter all your resources you can running on Azure. Now let's filter by Pak here you can see all the resources which are connected with our packed web app. Richard you did everything for us and Skeff folded all the resources for us. Here we see the service plan the secure database the SQL Server itself and the app service. Let's click on the app service to see some more detailed information you can stop or restart the web app. You can delete it. You can download the Publish profile or you can reset the Publish profile if you want. Then you've got some essential information about it like the DPD Promina username or the euro. When we scroll down you can see some graphic information about the HSDPA 500 requests data in data out requests response time and stuff like that. I would recommend you to go through all the settings but I would like to point out the application settings here under settings. If you click on it you get some detailed information what Dot Net framework is running there. Maybe you want to switch web sockets on if you're using signal or or you can customize some app settings or the connection strings for your web app. You've got a lot of things to configure and there's as your portal here. So I would recommend you to really dive into it and just take a look. So this is how you can deploy your web app from Visual Studio 2017 to Azure. Now let's summarize this video. So in this video we saw how we can deploy our core web app to Azure. We saw how we can add new good packages and here you got to pay attention to the versions that they're compatible with Azure and between each other. Then we added migrations from entity from a core. Then we did the right click and publish to Azure with Visual Studio and we took a sneak peek at the as your portal just to see our web app is going in the next video. I want to show how we can deploy our ace peered at Code web app to a darker container.