如何使用 Yaml 在 devops 管道中添加绑定

How to add bindings in devops pipeline with Yaml

如何使用 yaml 在 "IIS web app manage" 任务中添加绑定? 我试过像经典管道一样放置绑定但不起作用

您需要使用如下所有信息创建一个 JSon:

                                {
                                        "bindings":[{
                                            "protocol":"http",
                                            "ipAddress":"*",
                                            "port":"xxxxx",
                                            "sslThumbprint":"",
                                            "sniFlag":false
                                        },
                                        {
                                            "protocol":"http",
                                            "ipAddress":"*",
                                            "hostname":"yyyyyy.com",
                                            "port":"80",
                                            "sslThumbprint":"",
                                            "sniFlag":false
                                        },
                                        {
                                            "protocol":"http",
                                            "ipAddress":"*",
                                            "hostname":"xxxxxxxx.com",
                                            "port":"80",
                                            "sslThumbprint":"",
                                            "sniFlag":false
                                        }
                                    ]
                                } 

已接受的答案没有给出很好的用法示例。 Bindings 输入接受格式化为特定 JSON 对象的多行字符串。还要确保设置 AddBinding: true,因为它看起来会忽略没有它的 Bindings 输入。

相关说明,如果您将证书存储在 WebHosting(而不是 MY)中,部署将失败,因为任务将无法找到您的证书。 Here's the relevant github enhancement to fix this

task: IISWebAppManagementOnMachineGroup@0
displayName: 'IIS Web App Manage'
inputs:
    IISDeploymentType: 'IISWebsite'
    ActionIISWebsite: 'CreateOrUpdateWebsite'
    ...
    AddBinding: true
    Bindings: |
        {
            bindings:[
                {
                    "protocol":"http",
                    "ipAddress":"*",
                    "hostname":"mywebsite.com",
                    "port":"80",
                    "sslThumbprint":"",
                    "sniFlag":false
                },
                {
                    "protocol":"https",
                    "ipAddress":"*",
                    "hostname":"mywebsite.com",
                    "port":"443",
                    "sslThumbprint":"...",
                    "sniFlag":true
                 }
            ]
        }