【问题标题】:Azure API Management with Key Rotation使用密钥轮换的 Azure API 管理
【发布时间】:2018-07-30 11:32:43
【问题描述】:

我正在使用 KeyVault 来存储 Ocp-Apim-Subscription-Key。应用程序正在从 KeyVault 获取此密钥并成功向 API 管理发出请求。

但现在,我想在 Runbooks 中经常使用 powershell 脚本来旋转这个 Ocp-Apim-Subscription-Key。我找不到通过 powershell 重新生成Ocp-Apim-Subscription-Key 的方法。这可能吗 ?如果还有其他选项可以轮换此密钥,请告诉我。

【问题讨论】:

    标签: azure-api-management azure-keyvault azure-runbook


    【解决方案1】:
    【解决方案2】:
    # 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 
      }
    }  
    

    【讨论】:

      猜你喜欢
      • 2021-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-05
      • 2019-07-30
      • 2018-04-12
      • 2021-10-27
      • 1970-01-01
      相关资源
      最近更新 更多