首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带键旋转的Azure API管理

带键旋转的Azure API管理
EN

Stack Overflow用户
提问于 2018-07-30 11:32:43
回答 2查看 1.6K关注 0票数 2

我使用KeyVault存储Ocp-Apim-Subscription-Key。应用程序正在从KeyVault获得此密钥,并成功地向Applications发出请求。

但是现在,我想经常使用Runbook中的powershell脚本来旋转这个Ocp-Apim-Subscription-Key。我找不到一种通过powershell重新命名Ocp-Apim-Subscription-Key的方法。这有可能吗?如果有另一个选项来旋转这个键,那么请告诉我。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-07-31 21:04:56

Stack Overflow用户

发布于 2019-10-21 13:17:42

代码语言:javascript
复制
# Get API Management Services information and set context
$ApiManagements = Get-AzApiManagement
foreach ($ApiManagement in $ApiManagements)
{
  $ApiManagementContext = New-AzApiManagementContext -ResourceId $ApiManagement.Id

  # Get all API Management Subscriptions
  $ApiManagementSubscriptions = Get-AzApiManagementSubscription -Context $ApiManagementContext
  foreach ($ApiManagementSubscription in $ApiManagementSubscriptions)
  {
    # Update the Keys
    $PrimaryKey = (New-Guid) -replace '-',''
    $SecondaryKey = (New-Guid) -replace '-',''
    Set-AzApiManagementSubscription -Context $ApiManagementContext -SubscriptionId $ApiManagementSubscription.SubscriptionId -PrimaryKey $PrimaryKey `
                                    -SecondaryKey $SecondaryKey -State Active 
  }
}  
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51593055

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档