简体   繁体   English

Pulumi:添加Azure Web App Service web hook到Azure Container Registry进行持续部署

[英]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.

相关问题 Azure容器注册表中的Azure App Service连续部署 - Azure App Service continuous deployment from Azure Container Registry 使用Github的Azure&#39;Linux Web App&#39;应用服务连续部署被破坏 - Azure 'Web App on Linux' app service continuous deployment with Github is broken Azure 容器注册表授权 Azure Web 应用程序 - Azure Container Registry authorization for Azure Web App GitLab 持续部署到 Azure Web 应用程序 - GitLab Continuous Deployment to Azure Web App Azure Web App(MVC 6)持续部署失败 - Azure Web App (MVC 6) continuous deployment fails 使用 CLI 将 Azure Web 应用程序(容器)连接到 Azure 容器注册表 - Connecting an Azure Web app (container) to an Azure container registry using the CLI "Azure Web 应用容器专用终结点部署不适用于专用终结点容器注册表" - Azure web app container private Endpoint deployment doesn't work with private endpoint container registry 用于配置Azure Web App(Web站点)的持续部署的脚本 - Script to configure continuous deployment for an Azure Web App (Web Site) Azure Web App for Containers 中跨订阅的 Azure 容器注册表 - Azure Container Registry in Azure Web App for Containers across subscriptions 使用Azure容器注册表的容器CI的Azure Web App - Azure Web App for containers CI with Azure Container Registry
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM