我想部署通过pulumi启用了docker CD的Azure Web App。 AFAIK我必须在我的容器注册表中创建一个Webhook。但是我不知道如何从Web应用程序获取Webhook URL。
这是我设置基础结构的方式
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
});
读取webhook URL的azure CLI命令是:
az webapp deployment container config -n sname -g rgname -e true
如果网络挂钩不是正确的方式:如何从Azure容器注册表中实现对Azure Web应用程序的连续部署?
答案 0 :(得分:2)
尝试使用listWebAppPublishingCredentials
。我对Azure CLI的功能进行了反向工程:
const webhook = pulumi.all([resourceGroup.name, webApp.name])
.apply(([resourceGroupName, name]) =>
web.listWebAppPublishingCredentials({ resourceGroupName, name }))
.apply(creds => creds.scmUri + "/docker/hook");