Skip to content

Latest commit

 

History

History
132 lines (84 loc) · 6.21 KB

File metadata and controls

132 lines (84 loc) · 6.21 KB
author cephalin
ms.service azure-app-service
ms.devlang java
ms.custom linux-related-content
ms.topic quickstart
ms.date 02/14/2025
ms.author cephalin

In this quickstart, you learn how to deploy an image from Azure Container Registry to Azure App Service.

Azure App Service on Linux provides predefined application stacks on Linux with support for languages such as .NET, Java, Node.js, and PHP. You can also use a custom Docker image to run your web app on an application stack that isn't already defined in Azure.

For more information about containerized applications in a serverless environment, see Azure Container Apps overview.

Prerequisites

Clone the sample repository

Clone the the .NET 6.0 sample app by using the following command:

git clone https://github.com/Azure-Samples/dotnetcore-docs-hello-world.git

Push the image to Azure Container Registry

Make sure that you're in the cloned repository's root folder, which contains a Dockerfile.linux file.

  1. Sign in to the Azure CLI.

    az login
    
  2. Sign in to Azure Container Registry.

    az acr login -n <your_registry_name>
    
  3. Build the container image. This example uses the image name dotnetcore-docs-hello-world-linux.

    docker build -f Dockerfile.linux -t <your_registry_name>.azurecr.io/dotnetcore-docs-hello-world-linux . 
    
  4. Push the container image to Azure Container Registry.

    docker push <your_registry_name>.azurecr.io/dotnetcore-docs-hello-world-linux:latest
    

    [!NOTE] The Dockerfile sets the port number to 80 internally. For more information, go to Configure custom container.

Deploy to Azure

  1. Sign in to the Azure portal.

  2. Type app services in the search. Under Services, select App Services.

    :::image type="content" source="../../media/quickstart-custom-container/portal-search.png" alt-text="Screenshot that shows how to search for app services in the Azure portal.":::

  3. On the App Services pane, select Create > Web App.

  4. On the Basics tab, under Project details, select the correct subscription. To create a new resource group, select Create new. Type myResourceGroup for the name.

    :::image type="content" source="../../media/quickstart-custom-container/project-details.png" alt-text="Screenshot that shows the project details section where you select the Azure subscription and the resource group for the web app.":::

  5. Under Instance details:

    • Enter a globally unique name for your web app.
    • Select Container.
    • For Operating System, select Linux.
    • In Region, select the region from which you plan to serve your app.

    :::image type="content" source="../../media/quickstart-custom-container/instance-details-linux.png" alt-text="Screenshot that shows the instance details section where you provide a name for the virtual machine and select its region, image, and size.":::

  6. Under App Service Plan, select Create new. Enter myAppServicePlan for the name. To change to the Free tier, select Change size > Dev/Test > F1 > Apply.

    :::image type="content" source="../../media/quickstart-custom-container/app-service-plan-details-linux.png" alt-text="Screenshot that shows plan options.":::

  7. At the top of the pane, select the Container tab.

  8. On the Container tab, for Image Source, select Azure Container Registry. Under Azure Container Registry options, set the following values:

    • Registry: Select your container registry.
    • Image: Select dotnetcore-docs-hello-world-linux.
    • Tag: Select latest.

    :::image type="content" source="../../media/quickstart-custom-container/azure-container-registry-options-linux.png" alt-text="Screenshot that shows Azure Container Registry options.":::

  9. Select Review + create at the bottom of the pane.

    :::image type="content" source="../../media/quickstart-custom-container/review-create.png" alt-text="Screenshot that shows the button at the bottom of the pane.":::

  10. After validation runs, select Create.

  11. After deployment finishes, select Go to resource.

    :::image type="content" source="../../media/quickstart-custom-container/next-steps.png" alt-text="Screenshot that shows the button to go to the resource.":::

Browse to the app

Browse to the deployed application in your web browser at the URL http://<app-name>.azurewebsites.net.

:::image type="content" source="../../media/quickstart-custom-container/browse-custom-container-linux.png" alt-text="Screenshot that shows the deployed application.":::

The App Service app pulls from the container registry each time it starts. If you rebuild your image, push it to your container registry. The app pulls in the updated image when it restarts. To tell your app to pull in the updated image immediately, restart it.

Clean up resources

[!INCLUDE Clean-up Portal web app resources]

Related content