I want to deploy an Azure Web App with docker CD enabled via pulumi. AFAIK I have to create a webhook in my container registry for it. But I can't figure out how to get the webhook URL from the web app.
Here is how I setup my infrastructure
const config = new pulumi.Config();
const location = config.require("location");
const resourceGroup = new resources.ResourceGroup("rootResourceGroup", { ... });
const registry = new container.Registry("containerRegistry", { ... });
const appServicePlan = new web.AppServicePlan("appserviceplan", { ... });
const suffix = new random.RandomString("suffix", { ... });
const credentials = pulumi.all([resourceGroup.name, registry.name])
.apply(([resourceGroupName, registryName]) => container.listRegistryCredentials({
resourceGroupName: resourceGroupName,
registryName: registryName,
}));
const adminUsername = credentials.apply(credentials => credentials.username!);
const adminPassword = credentials.apply(credentials => credentials.passwords![0].value!);
const app = { name: "foo-demo", container: "foo/demo" };
const webApp = new web.WebApp(app.name, {
name: pulumi.interpolate`${app.name}-${suffix.result}`,
resourceGroupName: resourceGroup.name,
location,
serverFarmId: appServicePlan.id,
siteConfig: {
appSettings: [{
name: "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
value: "false"
}, {
name: "DOCKER_ENABLE_CI",
value: "true"
}, {
name: "DOCKER_REGISTRY_SERVER_URL",
value: pulumi.interpolate`https://${registry.loginServer}`,
}, {
name: "DOCKER_REGISTRY_SERVER_USERNAME",
value: adminUsername,
}, {
name: "DOCKER_REGISTRY_SERVER_PASSWORD",
value: adminPassword,
}],
alwaysOn: true,
linuxFxVersion: registry.loginServer.apply(url => `DOCKER|${url}/${app.container}:latest`)
}});
const webHookName = `${app.name}-webhook`;
const hook = new container.Webhook(webHookName, {
resourceGroupName: resourceGroup.name,
location,
registryName: registry.name,
actions: ["push"],
scope: `${app.container}:latest`,
status: "enabled",
serviceUri: "TODO", // <----- HOW!?!?
webhookName: webHookName
});
The azure CLI command, that reads the webhook URL is:
az webapp deployment container config -n sname -g rgname -e true
If the webhook is not the correct way: How can I achieve continuous deployment to an Azure Web App from an Azure Container Registry?
Try using listWebAppPublishingCredentials
. I reverse-engineered what the Azure CLI does:
const webhook = pulumi.all([resourceGroup.name, webApp.name])
.apply(([resourceGroupName, name]) =>
web.listWebAppPublishingCredentials({ resourceGroupName, name }))
.apply(creds => creds.scmUri + "/docker/hook");