gpt4 book ai didi

azure - 在 Azure 管道上使用 `originalSwaggerUrl` 进行自定义 API 连接器部署期间,API 定义不会更新

转载 作者:行者123 更新时间:2023-12-03 05:17:55 27 4
gpt4 key购买 nike

我有一个 ARM 模板,可以在 Azure 管道上部署自定义连接器(或更新),

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
...
"swaggerSpec": {
"type": "string",
"defaultValue": "http://someapi/v1/swagger/docs/v1"
}
...
},
"resources": [
{
"type": "Microsoft.Web/customApis",
"apiVersion": "2016-06-01",
"name": "[parameters('connectorName')]",
"location": "[parameters('location')]",
"properties": {
...
"apiType": "rest",
"apiDefinitions": {
"originalSwaggerUrl": "[parameters('swaggerSpec')]"
}
...
},
...
}
]
}

可以成功部署(没有错误),但 API 定义未更新到最新。不确定发生了什么或者我使用的是 originalSwaggerUrl 是否正确?

干杯

最佳答案

查看documentation ,您可以使用 swagger 属性:

Name: swagger
Description: The JSON representation of the swagger
Value: For Bicep, you can use the any() function.

如果您可以在本地访问 swagger 文件,则几乎没有选择

  1. 将 json 定义作为对象参数传递:

    param connectorName string
    param location string
    param swagger object

    resource customApi 'Microsoft.Web/customApis@2016-06-01' = {
    name: connectorName
    location: location
    properties: {
    ...
    apiType: 'apiType'
    swagger: swagger
    ...
    }
    }

    然后您可以像这样部署模板(此处使用 az cli 和 powershell):

    $swaggerPath="full/path/of/the/swagger/file.json"
    az deployment group create `
    --resource-group "resource group name" `
    --template-file "full/path/of/the/main.bicep" `
    --parameters connectorName="connector name" `
    --parameters location="resource location" `
    --parameters swagger=@$swaggerPath
  2. 使用二头肌 loadJsonContent

    The maximum allowed size of the file is 1,048,576 characters, including line endings.

    param connectorName string
    param location string

    var swagger = loadJsonContent('path/to/swagger/file/')

    resource customApi 'Microsoft.Web/customApis@2016-06-01' = {
    name: connectorName
    location: location
    properties: {
    ...
    apiType: 'apiType'
    swagger: swagger
    ...
    }
    }

关于azure - 在 Azure 管道上使用 `originalSwaggerUrl` 进行自定义 API 连接器部署期间,API 定义不会更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74104733/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com