Skip to content

Latest commit

 

History

History
60 lines (38 loc) · 3.51 KB

Publish to Azure.md

File metadata and controls

60 lines (38 loc) · 3.51 KB

Publish to Azure

To publish an ASP.NET Core application to Azure App Service, follow these steps:

  1. Create an Azure App Service:

    First, you need to create an Azure App Service instance in the Azure portal:

    • Sign in to the Azure portal (https://portal.azure.com/).
    • Click on "Create a resource" in the left-hand menu.
    • In the search bar, type "App Service" and select it from the results.
    • Click the "Create" button to start creating a new App Service instance.
    • Fill in the required information, such as subscription, resource group, name, operating system (Windows or Linux), runtime stack (select ".NET" or ".NET Core"), and region. You can leave other settings at their default values or customize them as needed.
    • Click the "Review + create" button to review your settings, and then click "Create" to start deploying the App Service.
  2. Configure Deployment Credentials:

    To deploy your application to Azure App Service, you need to set up deployment credentials:

    • In the Azure portal, go to your App Service's "Overview" page.
    • Click on "Deployment Center" in the left-hand menu.
    • Choose the "FTP" option, and then click "Dashboard."
    • Click on "User Credentials" and set a username and password. These credentials will be used to authenticate when deploying your application. Save your changes.
  3. Publish Your Application:

    There are several ways to publish your ASP.NET Core application to Azure App Service, including Visual Studio, the Azure CLI, or the .NET CLI. We'll cover the .NET CLI method here:

    • Open a terminal or command prompt, and navigate to the root folder of your ASP.NET Core project.

    • Run the following command to publish your application to a local folder:

      dotnet publish -c Release -o <output-folder>
      

      Replace <output-folder> with the desired output folder path, such as ./publish.

    • Install the Azure CLI, if you haven't already, by following the instructions here: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli

    • Log in to your Azure account using the Azure CLI with the following command:

      az login
      

      This will open a web page for you to enter your Azure credentials.

    • Deploy your application to Azure App Service using the following command:

      az webapp deployment source config-zip --resource-group <resource-group> --name <app-service-name> --src <path-to-zip-file>
      

      Replace <resource-group> with the name of the resource group you used when creating the App Service, <app-service-name> with the name of your App Service, and <path-to-zip-file> with the path to a ZIP archive containing your published application files. To create a ZIP archive from the published folder, you can use a tool like 7-Zip or the built-in ZIP functionality in Windows or macOS.

  4. Access Your Application:

    After the deployment is complete, your ASP.NET Core application should be running in Azure App Service and accessible via the URL provided in the "Overview" section of your App Service in the Azure portal (e.g., https://<app-service-name>.azurewebsites.net).

By deploying your ASP.NET Core application to Azure App Service, you can take advantage of Azure's scalable and fully managed platform for hosting web apps, REST APIs, and mobile backends. Azure App Service provides features like custom domains and SSL certificates, continuous deployment, monitoring and diagnostics, and autoscaling to ensure that your application remains performant and available as traffic