使用 Az CLI/PowerShell 从 Function App 重新导入 API 管理 API

问题描述 投票:0回答:2

我使用“从 Azure Functions 导入”将 Azure Functions 实例添加到 API 管理 API。
当我更新我的 Azure Functions 实例时,API 管理 API 不会自动更新。 我到处搜索能够将我的 Azure 函数重新导入我的 API 管理 API 的命令,但我找不到任何解决方案/解决方法。

这就是我想要自动化的:

azure azure-devops azure-functions azure-api-management azure-cli
2个回答
0
投票

没有内置的 Azure Powershell/CLI 命令来执行此操作,在这种情况下,您可以直接使用 powershell

Apis - Create Or Update
或 CLI
Invoke-AzRestMethod
直接调用 REST API -
az rest

Powershell示例:

$groupname = "xxxxxxx"
$APIMname = "joyapim"
$FullApiVersionName = "joyfunapim-v2"
$sourceApiName = "joyfunapim"
$apiVersion = "v2"

$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName $groupname -ServiceName $APIMname
$Api = Get-AzApiManagementApi -Context $ApiMgmtContext -ApiId $sourceApiName
$apiVersionSetId = (Get-AzApiManagementApiVersionSet -Context $ApiMgmtContext | Where-Object {$_.DisplayName -eq $sourceApiName}).ApiVersionSetId
$Apim = Get-AzApiManagement -ResourceGroupName $groupname -Name $APIMname
$path = $Apim.Id + "/apis/" + $ApiFullVersionName + ";rev=1?api-version=2019-12-01"
$payload = @{
    "properties" = @{
        "sourceApiId" = $Api.Id
        "apiVersion" = $apiVersion
        "apiVersionSetId" = "/apiVersionSets/"+ $apiVersionSetId
        "apiVersionSet" = @{
            "versioningScheme" = "Segment"
            "name" = $sourceApiName
        }

    }
} | ConvertTo-Json -Depth 10

Invoke-AzRestMethod -Path $path -Method PUT -Payload $payload

门户查看:


-2
投票

上面的场景有什么解决方案吗?

© www.soinside.com 2019 - 2024. All rights reserved.