Deploying Web Apps to Azure App Service using Web Deploy
This guide details how to deploy your web applications to Azure App Service using the Web Deploy (MSDeploy) tool. Web Deploy is a technology that simplifies the migration, configuration, and synchronization of Web applications between IIS servers. Azure App Service leverages this for efficient web app deployments.
Prerequisites
- An Azure account with an active subscription. If you don't have one, create a free account.
- An Azure App Service instance created for your web app.
- Web Deploy installed on your local development machine. You can download it from the official Microsoft Web Platform Installer or directly from Microsoft's download center.
- Your web application ready for deployment.
Steps to Deploy using Web Deploy
1. Obtain Deployment Credentials
You need to obtain the Web Deploy credentials for your App Service. These are different from your Azure portal sign-in credentials.
- Navigate to your App Service in the Azure portal.
- In the left-hand menu, under "Deployment", click on "Deployment Center".
- Select the "FTP" or "Local Git" tab (even though we're using Web Deploy, these tabs provide access to the necessary credentials).
- Locate the "FTP username" and "FTP password" or "Deployment credentials" section. Copy these values.
2. Configure Your Project for Web Deploy
For .NET applications, Visual Studio simplifies this process. Ensure your project is configured to publish using Web Deploy.
- In Visual Studio, right-click on your web application project in Solution Explorer.
- Select "Publish...".
- Click "New" to set up a new publishing profile.
- Choose "App Service" as the target.
- Select "Web Deploy" as the publishing method.
- Enter the connection string details obtained in Step 1. The server URL will typically be in the format
https://
..scm.azurewebsites.net - Enter the username and password obtained in Step 1.
- Configure other settings like the site name (your App Service name) and target framework.
- Click "Finish" to create the profile.
For non-.NET applications or manual configuration:
You can manually create a Web Deploy package and deploy it using the msdeploy.exe
command-line tool.
Example command to create a package:
msdeploy.exe -verb:sync -source:iisApp="MyWebAppName" -dest:package="C:\MyWebAppPackage.zip" -enableRule:AppOffline
Example command to deploy the package:
msdeploy.exe -verb:sync -source:package="C:\MyWebAppPackage.zip" -dest:autoParam=true -dest:iisApp="https://.scm.azurewebsites.net/" - sitiosite=YourSiteName -username: -password:
Note: Replace placeholders with your actual values.
3. Publish Your Application
If using Visual Studio, after configuring the publish profile:
- In the Publish window, select the profile you created.
- Click "Publish".
Visual Studio will package your application and deploy it to Azure App Service using Web Deploy.
Troubleshooting Common Issues
- Authentication Errors: Ensure you are using the correct deployment credentials (not your Azure portal login).
- Path Issues: Verify that the deployment path in your configuration matches your App Service name.
- Firewall Restrictions: If you are deploying from a restricted network, ensure outbound connections to the Azure App Service SCM site are allowed.
- Package Corruption: If the deployment fails intermittently, try deleting the App Service and recreating it, or cleaning and rebuilding your project before packaging.