我们使用 Azure API 管理和 Powershell 通过脚本导入门户上的配置,但是无论何时导入 API,都会启用门户中的“需要订阅”检查(API 需要订阅密钥)。我们现在没有在 API 上使用订阅功能,因此我们需要在导入时禁用它。我们正在使用Import-AzApiManagementApi
和Set-AzApiManagementApi
使用以下代码:
Set-AzApiManagementApi -ApiId $apiId -Context $context -Protocols @('https') -ServiceUrl $serviceBase$path -Name $api.Name
Set-AzApiManagementPolicy -Context $context -ApiId $apiId -PolicyFilePath "$pwd/src/private/security_policy.xml"
我们还没有在文档中找到没有这个检查就导入 API 的方法。是否有任何脚本可以通过 powershell 禁用此功能?
您可以使用 Arm 模块命令 Set-AzureRmApiManagementProduct 或 Az 模块命令 Set-AzApiManagementProduct 禁用所需的订阅选项
检查以下文件
更新
我可以看到 set-azapimanagementapi 现在支持 SubscriptionRequired 参数
Set-AzApiManagementApi
-Context <PsApiManagementContext>
-ApiId <String>
[-Name <String>]
[-Description <String>]
[-ServiceUrl <String>]
[-Path <String>]
[-Protocols <PsApiManagementSchema[]>]
[-AuthorizationServerId <String>]
[-AuthorizationScope <String>]
[-OpenIdProviderId <String>]
[-BearerTokenSendingMethod <String[]>]
[-SubscriptionKeyHeaderName <String>]
[-SubscriptionKeyQueryParamName <String>]
[-SubscriptionRequired]
[-PassThru]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句