--- title: Deploy an app to App Service - DevOps with ASP.NET Core and Azure author: CamSoper description: Deploy an ASP.NET Core app to Azure App Service, the first step for DevOps with ASP.NET Core and Azure. ms.author: casoper ms.custom: "mvc, seodec18" ms.date: 10/24/2018 uid: azure/devops/deploy-to-app-service --- # Deploy an app to App Service [Azure App Service](/azure/app-service/) is Azure's web hosting platform. Deploying a web app to Azure App Service can be done manually or by an automated process. This section of the guide discusses deployment methods that can be triggered manually or by script using the command line, or triggered manually using Visual Studio. In this section, you'll accomplish the following tasks: * Download and build the sample app. * Create an Azure App Service Web App using the Azure Cloud Shell. * Deploy the sample app to Azure using Git. * Deploy a change to the app using Visual Studio. * Add a staging slot to the web app. * Deploy an update to the staging slot. * Swap the staging and production slots. ## Download and test the app The app used in this guide is a pre-built ASP.NET Core app, [Simple Feed Reader](https://github.com/Azure-Samples/simple-feed-reader/). It's a Razor Pages app that uses the `Microsoft.SyndicationFeed.ReaderWriter` API to retrieve an RSS/Atom feed and display the news items in a list. Feel free to review the code, but it's important to understand that there's nothing special about this app. It's just a simple ASP.NET Core app for illustrative purposes. From a command shell, download the code, build the project, and run it as follows. > *Note: Linux/macOS users should make appropriate changes for paths, e.g., using forward slash (`/`) rather than back slash (`\`).* 1. Clone the code to a folder on your local machine. ```console git clone https://github.com/Azure-Samples/simple-feed-reader/ ``` 2. Change your working folder to the *simple-feed-reader* folder that was created. ```console cd .\simple-feed-reader\SimpleFeedReader ``` 3. Restore the packages, and build the solution. ```console dotnet build ``` 4. Run the app. ```console dotnet run ``` ![The dotnet run command is successful](./media/deploying-to-app-service/dotnet-run.png) 5. Open a browser and navigate to `http://localhost:5000`. The app allows you to type or paste a syndication feed URL and view a list of news items. ![The app displaying the contents of an RSS feed](./media/deploying-to-app-service/app-in-browser.png) 6. Once you're satisfied the app is working correctly, shut it down by pressing **Ctrl**+**C** in the command shell. ## Create the Azure App Service Web App To deploy the app, you'll need to create an App Service [Web App](/azure/app-service/app-service-web-overview). After creation of the Web App, you'll deploy to it from your local machine using Git. 1. Sign in to the [Azure Cloud Shell](https://shell.azure.com/bash). Note: When you sign in for the first time, Cloud Shell prompts to create a storage account for configuration files. Accept the defaults or provide a unique name. 2. Use the Cloud Shell for the following steps. a. Declare a variable to store your web app's name. The name must be unique to be used in the default URL. Using the `$RANDOM` Bash function to construct the name guarantees uniqueness and results in the format `webappname99999`. ```console webappname=mywebapp$RANDOM ``` b. Create a resource group. Resource groups provide a means to aggregate Azure resources to be managed as a group. ```azure-cli az group create --location centralus --name AzureTutorial ``` The `az` command invokes the [Azure CLI](/cli/azure/). The CLI can be run locally, but using it in the Cloud Shell saves time and configuration. c. Create an App Service plan in the S1 tier. An App Service plan is a grouping of web apps that share the same pricing tier. The S1 tier isn't free, but it's required for the staging slots feature. ```azure-cli az appservice plan create --name $webappname --resource-group AzureTutorial --sku S1 ``` d. Create the web app resource using the App Service plan in the same resource group. ```azure-cli az webapp create --name $webappname --resource-group AzureTutorial --plan $webappname ``` e. Set the deployment credentials. These deployment credentials apply to all the web apps in your subscription. Don't use special characters in the user name. ```azure-cli az webapp deployment user set --user-name REPLACE_WITH_USER_NAME --password REPLACE_WITH_PASSWORD ``` f. Configure the web app to accept deployments from local Git and display the *Git deployment URL*. **Note this URL for reference later**. ```azure-cli echo Git deployment URL: $(az webapp deployment source config-local-git --name $webappname --resource-group AzureTutorial --query url --output tsv) ``` g. Display the *web app URL*. Browse to this URL to see the blank web app. **Note this URL for reference later**. ```console echo Web app URL: http://$webappname.azurewebsites.net ``` 3. Using a command shell on your local machine, navigate to the web app's project folder (for example, `.\simple-feed-reader\SimpleFeedReader`). Execute the following commands to set up Git to push to the deployment URL: a. Add the remote URL to the local repository. ```console git remote add azure-prod GIT_DEPLOYMENT_URL ``` b. Push the local *master* branch to the *azure-prod* remote's *master* branch. ```console git push azure-prod master ``` You'll be prompted for the deployment credentials you created earlier. Observe the output in the command shell. Azure builds the ASP.NET Core app remotely. 4. In a browser, navigate to the *Web app URL* and note the app has been built and deployed. Additional changes can be committed to the local Git repository with `git commit`. These changes are pushed to Azure with the preceding `git push` command. ## Deployment with Visual Studio > *Note: This section applies to Windows only. Linux and macOS users should make the change described in step 2 below. Save the file, and commit the change to the local repository with `git commit`. Finally, push the change with `git push`, as in the first section.* The app has already been deployed from the command shell. Let's use Visual Studio's integrated tools to deploy an update to the app. Behind the scenes, Visual Studio accomplishes the same thing as the command line tooling, but within Visual Studio's familiar UI. 1. Open *SimpleFeedReader.sln* in Visual Studio. 2. In Solution Explorer, open *Pages\Index.cshtml*. Change `