Publishing A Website To Azure, The Visual Studio Method

Publishing a website or a Webapp technically means copying files from one location to  another. Take your local file and upload it to an Azure storage and from there; it will be accessible through the Azure Website.

There are three different ways to publish your Azure Websites, which are given below.

  1. IDE – Visual Studio and WebMatrix
  2. CLI – Powershell
  3. Repository – Microsoft TFS and Git

By using Visual Studio, you can create and publish your Web app to Azure. Here, I will show you how to create a simple Webpage and publish to the site, which we already created in the previous article.

Open Visual Studio and follow the steps given below.

Step 1

File - New - Website - Visual C# and select ASP.NET Empty Website Template

You can customize the name of the Website. Here, I am giving rameesweb and clicking OK.

 

Now, you can see a solution called rameesweb has been created, which has nothing with it. Thus, let us add a new Web page by right clicking on the project name in Solution Explorer and Adding New Item from which you can select an HTML page and give a name to it. Here, I am giving default.html because we need not to call the Webpage as default.html as the Website will pick it up directly.

 

It will bring up a basic HTML page, where you can add your own content. Here, I am just adding a sample text “This is my new Website created by Visual Studio”. You can test it by running it locally to see how it looks. Local host is something like a tiny Web Server.

 

Let us stop working on the Website now and we can see how to publish it to Azure. Right click on your project on Solution Explorer and select Publish Website, which will open the wizard given below to select the target, which has the built-in Azure Web Apps.

 

On selecting Publish, it will ask you to sign in, as I have already signed in Visual Studio; it is asking me to re-enter the credentials.

 

On giving the credentials, it will link to my Azure account linked to it and will show the existing Web apps there. Here, I have already created a Webapp, using the portal in the previous article, which is shown here.

 

It is possible to create a new we app here on clicking new tab, which will open the wizard given below to which you can add the details as the same which we gave in the portal.

 

I have selected the one I did already had and in the next step, it downloaded the publish profile and prompted the wizard given below in which we can just validate the connection.

 

If the validation passed, click Publish and it will be published to the domain. You can check if the domain will be accessible from any other device anywhere in the world.