Training
Module
Publish a web app to Azure with Visual Studio - Training
Learn how to use Azure App Service to create a new ASP.NET-based web app, then publish and update directly from Visual Studio.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
by Ben Byrd
So far, we have installed Web Deploy on a web server and enabled non-administrators to deploy applications to IIS 7. In this walkthrough, we will learn how developers can create Web Deploy packages, which can be deployed by users who have access to the web server (such as administrators, or IT / ops teams). A package contains the files (binaries and static content), databases, and IIS settings that you want to deploy.
In this tutorial, we will deploy the package to our server from the development computer and we will also explore importing it on the server using Web Deploy UI in IIS Manager.
In Visual Studio 2010, you can create Web Deploy packages through the UI or by using MSBuild on the command line. Both of these methods will generate 1) a standard Web Deploy package and 2) a batch (.cmd) file that will help you deploy the package.
Start Visual Studio 2010 and load up the Contoso University C# solution.
In Solution Explorer, expand the ContosoUniversity node and double click Properties (C#)
Choose the Configuration for the package.
Packages are configuration specific and settings are per configuration, so you need to choose the configuration and configure the setting before creating a package.
Configure Items to deploy (applies to all deployment methods)
These options will be used regardless of whether you publish with Web Deploy or a different publishing method.
Configure Items to deploy (applies to Web Deploy only)
These options only apply when you create a Web Deploy package, or use the Web Deploy protocol for publishing.
Configure Web Deployment Package Settings
There are scenarios in which you will want to deploy a database along with your application. For example, when deploying your application for the very first time, you may want to deploy the database with schema and data.
Note that Visual Studio 2010 does NOT support incremental database deployment.
If you want to include databases in your package, click the Package/Publish SQL tab.
Choose the configuration for the package.
Packages are configuration specific, so you need to choose the configuration setting for the package before you create it.
If your Web.config file has a database connection string, you can click Import from Web.Config. A message will appear when the import is complete.
The following will appear if no connection string was found:
If you see this error, check that the Web.Config file has the desired connection string and that the file has not been modified (an asterisk in the editor tab will indicate that the file has been altered and that the changes have not been saved.)
If a database that you want to add to your deployment package is not listed under Database Entries, click the Add button to add the connection.
Once all of your connections are added, you can select an entry and adjust its order in the list to specify the order in which it will added to the package, and thus deployed, by using the up and down arrows.
Clicking a database entry will allow you to remove it.
Next, configure the details for each database in the Database Entry Details section.
Now that we have configured the packaging settings, we can create a package.
In VS 2010, select your WAP from the solution explorer.
Right-click the WAP.
Note that if you have never logged on to Contoso University, the aspnetdb.mdf file does not exist. Package creation will fail with an error similar to this one: "Cannot connect to the database'C:\code\ContosoUniversity\ContosoUniversity\ContosoUniversity\App_Data\aspnetdb.mdf'. A connection was successfully established with the server, but then an error occurred during the login process."
The output window will give updates as packaging progresses. When it finishes, the output will contain a link to the package location.
All the settings we configured above are stored in the project file for the WAP. You can now build a WAP or solution and have the package created that uses the settings above.
Open a command prompt with MSBuild in the path (for example, the VS command prompt, which is under Start -> All Programs -> Microsoft Visual Studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt (2010))
Navigate to your solution or project file.
If you are building a solution, the command will look like this:
msbuild {solution file} /p:CreatePackageOnPublish=true /p:DeployOnBuild=true
If you are building the project file, the command will look like this:
msbuild {project file} /t:Package
If you would like to build a configuration other than the default, add the following to the above commands:
/p:Configuration={Configuration Name}
Now that we have a package, we can deploy it from the command prompt. We will deploy it as an administrator.
To deploy the package as an administrator using the Remote Agent Service:
For more information on deploying using the command file you can type {project name}.deploy.cmd to open the associated readme or visit the article located here.
We can also use Internet Information Services (IIS) manager to install our newly created package.
To deploy the package using Internet Information Services manager (inetmgr):
Run inetmgr.exe
Expand the server node in inetmgr.
Expand the Sites node.
Right-click on the site you want to import the application to.
Enter the location of the package into the Package path: text box.
Click Next
You will now be at Select the Contents of the Package screen. By checking and unchecking items you can customize what is installed. In this screenshot you see:
After selecting the desired items to install, click Next.
You will now need to verify the set the package parameters.
Click Next.
If the application exists you will be prompted if you would like to delete extra files. Choose the desired option and click Next.
You will know be at the summary page. Review the information and click Finish.
Now in inetmgr you can click the Browse link under Manage Application to view your site
Training
Module
Publish a web app to Azure with Visual Studio - Training
Learn how to use Azure App Service to create a new ASP.NET-based web app, then publish and update directly from Visual Studio.