1. Home
  2. Training Library
  3. Microsoft Azure
  4. Courses
  5. Getting Started with Azure App Service

Deploy to App Service from Visual Studio

The course is part of these learning paths

Microsoft Azure for Solution Architects
27
10
15
AZ-104 Exam Preparation: Microsoft Azure Administrator
21
7
17
1
more_horizSee 2 more
Start course
Overview
Difficulty
Beginner
Duration
1h 22m
Students
4708
Ratings
3.6/5
starstarstarstar-halfstar-border
Description

You’ve got an idea for a great web app, or maybe you’ve already started building it. The next question is how are you going to get it out there on the Internet?

In this course, you will learn how you can quickly and easily set up a website and publish your app to the world with Azure App Service. Of course, web apps are a lot more complex and varied than just HTML pages and we will see how App Service supports a range of programming languages, frameworks, and even operating systems. We will explore features that greatly simplify application deployment and management, as well as those that will increase your app’s functionality like authentication and accessing on-premise data. App Service as with other Azure products has a raft of tools for monitoring and logging so you can make sure your app is performing optimally.

For any feedback, queries, or suggestions relating to this course, please contact us at support@cloudacademy.com.

Learning Objectives

  • Deploy apps using the Azure App Service
  • Create a web app using the Azure Portal
  • Create a web app using Visual Studio
  • Understand the configuration and diagnostic capabilities available from Azure App Service
  • Understand the advanced features of the service such as container deployment and deployment slots

Intended Audience

This is a beginner level course suited developers or anyone wanting to know how to deploy web apps to the Azure cloud.

Prerequisites

To get the most from this course, you should have a basic understanding of the software development lifecycle, while knowing how to code would be a plus.

Course source code

.NET 5.0 demo code

https://github.com/cloudacademy/get-started-app-service-net5.git

 

Docker Hub

https://hub.docker.com/r/hallamw/lorrymobileapi

 

.NET Core 3.1 demo code

https://github.com/cloudacademy/azure-get-started-app-service.git

 

 

 

Transcript

I'm going to deploy a simple web API app from Visual Studio to Azure App Services. First, I'll download the lorrylogapi code from the Cloud academy get-started-app-service-net5 repository on Github. After unzipping the file, I can double click on the project file,  LorryLogAPI.csproj, to open it in Visual Studio. Once the project is loaded, we can look at appsettings.json to see the database connection string to enable the app to connect to the Azure SQL database. For those that are curious, this is a C# MVC, model-view-controller app, and it's the vehicles controller's default HttpGet method that will return our data.  Let's run the application locally to see the result. Even though this is running on my PC, I can retrieve the data from Azure SQL because I set a firewall rule on the lorrylogserver.database.windows.net server allowing my IP address access. Clicking the green debug arrow will compile and run the app. Here we can see it's running on my localhost web server, and because I had the vehicles controller open when I ran the app Visual Studio has defaulted to the vehicles URL.

Now let's publish to Azure App Service. Azure and Visual Studio are both Microsoft products, so there is excellent integration between them, meaning the publishing process can be done seamlessly from within Visual Studio if you're logged into both with the same Microsoft account. Select publish from the Build menu. We have several target options, with the top one being Azure. Import profile allows you to import a publish profile from the App Service resource, enabling you to easily publish when you aren't logged into the Azure portal and Visual Studio with the same account. In the profile document, you can see an Azure generated user name and password for connecting via FTP to the publishing URL. We won't be using the publishing profile, so let's go back to Visual Studio. Having selected Azure as the generic target, we are then prompted for an Azure specific target. Here I'll select App Service Windows and click Next. On the App Service tab, we can see my subscription has been detected from my account, and because the view is Resource group, the lorrylog app service in the NewWebApp resource group is displayed. I'll select lorrylog and click finish. 

We're almost ready to publish, with critical resource details such as framework, resource group, and site URL correctly displayed. Before we do, I want to configure the SQL server dependency. You might be thinking, why would I need to do that when I have the database connection string in the app settings file? Developers don't always have access to the login details of production or QA databases and maybe working with their own local databases. Connection strings can be saved in a number of locations, as we can see here. Saving to Azure App Settings will create a connection string entry under configuration that will be used by the app once deployed. The connection string is retrieved by name, so when deploying, you can enter a different connection string name than the one you have locally as long as it exists in the App Service configuration. I'll click next, leave the default selections and click Finish to deploy the relevant software libraries to support database functionality. Now let's publish to the cloud. This is not an error. A web API doesn't have a home page, and the only URL that returns a result is vehicles, so I'll have to type that into the address bar. There we go. A web API app up and running on Azure App Services.

About the Author
Avatar
Hallam Webber
Software Architect
Students
14700
Courses
27
Learning Paths
3

Hallam is a software architect with over 20 years experience across a wide range of industries. He began his software career as a  Delphi/Interbase disciple but changed his allegiance to Microsoft with its deep and broad ecosystem. While Hallam has designed and crafted custom software utilizing web, mobile and desktop technologies, good quality reliable data is the key to a successful solution. The challenge of quickly turning data into useful information for digestion by humans and machines has led Hallam to specialize in database design and process automation. Showing customers how leverage new technology to change and improve their business processes is one of the key drivers keeping Hallam coming back to the keyboard.