[英]Pulumi: Add Azure Web App Service web hook to Azure Container Registry for continuous deployment
I want to deploy an Azure Web App with docker CD enabled via pulumi.我想部署一个 Azure Web 应用程序,通过 pulumi 启用 docker CD。 AFAIK I have to create a webhook in my container registry for it. AFAIK 我必须在我的容器注册表中为它创建一个 webhook。 But I can't figure out how to get the webhook URL from the web app.但我无法弄清楚如何从 web 应用程序获取 webhook URL。
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:读取 webhook URL 的 azure CLI 命令是:
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?如果 webhook 不是正确的方法:如何实现从 Azure Container Registry 到 Azure Web App 的持续部署?
Try using listWebAppPublishingCredentials
.尝试使用listWebAppPublishingCredentials
。 I reverse-engineered what the Azure CLI does:我对 Azure CLI 的功能进行了逆向工程:
const webhook = pulumi.all([resourceGroup.name, webApp.name])
.apply(([resourceGroupName, name]) =>
web.listWebAppPublishingCredentials({ resourceGroupName, name }))
.apply(creds => creds.scmUri + "/docker/hook");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.