首页 文章

如何使用Azure API管理门户或API在请求标头中编辑Ocp-Apim-Subscription-Key的描述字符串?

提问于
浏览
1

我正在寻找一种方法来使用Azure API管理(管理门户或API调用)来编辑 Ocp-Apim-Subscription-Key Request标头字段的文本描述 . 此字符串显示在自动生成的文档中,但我可以设置_729721 . 到目前为止,我已经尝试在swagger文件和API Management Publisher Portal中查找 Ocp-Apim-Subscription-Key 的描述字符串,但一直无法找到它 .

以下是突出显示我要编辑的生成的API文档中的字段的屏幕截图:

enter image description here

以下是Azure API Management Publisher门户中的页面,其中我查找了“请求标头”部分,但找不到它:
enter image description here

关于Azure API Management问题的其他答案让我想知道是否有一个REST API调用来编辑这个字符串(如果它在Publisher Portal中不可用),但我似乎无法找到关于它的API文档的活动链接 .

1 回答

  • 0

    我使用Azure PowerShell . 先决条件是您已登录(Login-AzureRmAccount)并选择了您的订阅(Select-AzureRmSubscription) .

    $ApiMgmtContext = New-AzureRmApiManagementContext -ResourceGroupName $resourceGroup -ServiceName $serviceName
    
    if($ApiMgmtContext)
    {
        foreach($apiEntry in (Get-AzureRmApiManagementApi -Context $ApiMgmtContext))
        {
            $api = Get-AzureRmApiManagementApi -Context $ApiMgmtContext -ApiId $apiEntry.ApiId
    
            Write-Host "setting header for" $api.Name
    
            $api.SubscriptionKeyHeaderName = "MyApi-Subscription-Key"
            $api | Set-AzureRmApiManagementApi -Context $ApiMgmtContext
        }
    }
    

相关问题