How do I deploy a Docker container on Azure App Service?
In this guide, we will demonstrate how to deploy a Docker container on Azure App Service using Pulumi. We will create an Azure Resource Group, an App Service Plan, and an App Service that runs a Docker container from a public Docker Hub image.
Key Points
- We will use the
azure-native
package to interact with Azure resources. - We will create a resource group to contain all the resources.
- We will create an App Service Plan that defines the underlying compute resources.
- We will create an App Service that uses a Docker container from Docker Hub.
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure-native";
// Create an Azure Resource Group
const resourceGroup = new azure.resources.ResourceGroup("resourceGroup", {
location: "WestUS",
});
// Create an App Service Plan
const appServicePlan = new azure.web.AppServicePlan("appServicePlan", {
resourceGroupName: resourceGroup.name,
location: resourceGroup.location,
sku: {
name: "B1",
tier: "Basic",
},
});
// Create an App Service that runs a Docker container
const appService = new azure.web.WebApp("appService", {
resourceGroupName: resourceGroup.name,
location: resourceGroup.location,
serverFarmId: appServicePlan.id,
siteConfig: {
appSettings: [
{ name: "WEBSITES_ENABLE_APP_SERVICE_STORAGE", value: "false" },
{ name: "DOCKER_REGISTRY_SERVER_URL", value: "https://index.docker.io" },
],
linuxFxVersion: "DOCKER|nginx:latest", // Specify the Docker image from Docker Hub
},
});
// Export the endpoint of the App Service
export const endpoint = pulumi.interpolate`https://${appService.defaultHostName}`;
Summary
In this guide, we successfully deployed a Docker container on Azure App Service using Pulumi. We created a resource group, an App Service Plan, and an App Service that runs a Docker container from Docker Hub. This setup allows you to run containerized applications on Azure with ease.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.