I am here again with a new article. In this article, I am going to talk about the deployment of websites on Azure. There are lots of articles available regarding this topic. I am trying to document all the different ways of the deployment of a website. You will be able to see the different techniques of the deployment of a website on Azure, in this single article. I hope it will be helpful for Azure developers.
There are various ways to deploy a website on Azure WebApp. Some of the common techniques are given below.
- Deployment using GIT.
- Visual Studio Publish method.
- Deployment using FTP.
- PowerShell command to deploy the website.
Deployment using GIT
Prerequisites
- Azure subscription.
- Create a web app using portal.azure.com. The AppService tab provides web app option to create the website.
The following steps are required to deploy the website using GIT.
Step 1
Select the created web app in Azure. One of the tabs “Deployment Credential” is available using which we can set the deployment credentials for FTP and GIT. Provide the Username and Password.
Step 2
Set the “Deployment Option” to configure the GIT as a source.
Step 3
After completing the above step, we can see the GIT Clone URL on web app dashboard. This URL is used to push the code on GIT from the local system.
Step 4
We can use the following command in GIT bash to clone the repository on the local system using GIT clone URL.
c:\myfolder> git clone <<URL>>
Step5
A folder will be created on the local system drive "C:\myfolder'. Create the web application in this folder using Visual Studio. We can also copy the code of the existing application in this folder.
Step 6
Use the following command in GIT to push the code from local system to the remote GIT repository.
- git add .
- git commit –m “message”
- git push origin master.
All the steps are completed now. We can test the website using the provided URL in the browser.
Deployment using FTP
Prerequisite
- Azure subscription.
- FTP Client.
- Create web apps using portal.azure.com. The AppSservice tab provides web app option to create the website.
Step 1
Select the created web app. One of the tabs “Deployment Credentials” is available using which we can set the deployment credentials for FTP and GIT. Provide Username and Password.
Step 2
We can get the FTP Host URL from the dashboard page of the created website.
Step 3
Open FTP client and provide the information FTP URL and username and password to connect to the file system of the created website. Now, copy the website.
Deployment Using Visual Studio
Prerequisite
- Azure subscription.
- Visual Studio Application.
- Create web app using portal.azure.com. The AppService tab provides web app option to create the website.
The following steps are required to deploy the website using GIT.
Step 1
Create a web application using Visual Studio application. We can also open the existing application in Visual Studio for deployment.
Step 2
Down the published profile from the dashboard page of the created web app using portal.azure.com.
Step 3
Right click on the website and click on the Publish option. The following dialog box will appear:
Step 4
Click on the Import option in the dialog box. Select the "Publish file" from the local systems.
Step 5
Click on the "Publish" button to deploy the website.
Deployment using PowerShell command
Prerequisites
- Azure subscription.
- PowerShell.
Step 1
Use the following PowerShell command to create the new website.
New-AzureRmWebApp -location "East US" -name "portalname"
Step 2
Create a new application or open an existing application in Visual Studio 2015.
Step 3
Create the package of the application using “MSBuild” command using command prompt.
C:\Windows\Microsoft.NET\Framework\v4.0.30319>MSBuild "D:\TestDeployApp.csproj" /T:Package /P:Configuration=Debug;PackageLocation="D:\Package.zip"
Step-4
Now, we can deploy the application package on the target website on Azure using PowerShell command.
Publish-AzureWebsiteProject -Name testmyportal -Package "D:\package.zip"
Possible issues
It may possible the above command throws an error, like below.
“Publish-AzureWebsiteProject : The application pool that you are trying to use has the 'managedRuntimeVersion' property set to 'v4.0'. This application requires 'v4.5'.”
Solution
We can fix this issue by adding the following tags in the .csproj file.
<IgnoreDeployManagedRuntimeVersion>True</IgnoreDeployManagedRuntimeVersion>
The .csproj file of the project can be edited using Notepad or any other text editor.
For more detail, please click on the link below.
https://stackoverflow.com/questions/19834307/msdeploy-cannot-deploy-net-v4-5-package-to-v4-0-application-pool