gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 03:49:33 25 4
gpt4 key购买 nike


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

这就是我想要自动化的:

enter image description here

enter image description here

最佳答案

没有内置的 Azure Powershell/CLI 命令可以执行此操作,在这种情况下,您可以简单地调用 REST API - Apis - Create Or Update直接使用powershell Invoke-AzRestMethod或 CLI 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

enter image description here

检查门户:

enter image description here

关于azure - 使用 Az CLI/PowerShell 从 Function App 重新导入 API 管理 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67307116/

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