【问题标题】:Create SubscriptionCloudCredentials for WebSiteManagementClient without Azure AD Application为没有 Azure AD 应用程序的 WebSiteManagementClient 创建 SubscriptionCloudCredentials
【发布时间】:2017-01-27 15:58:24
【问题描述】:

我正在寻找一种简单的解决方案来验证和使用WebSiteManagementClientexamples 我见过使用 Azure AD 应用程序来创建所需的 SubscriptionCloudCredentials。我更愿意在不使用 AD 应用程序的情况下创建 SubscriptionCloudCredentials

如果可能的话,我宁愿只使用在发布配置文件设置 XML 中找到的 Web Deploy un/pw 凭据(因为我已经有使用这些凭据与具有基本身份验证的 kudu api 交互的代码)

我发现 this 潜在的解决方案改为使用 management certificate (more info)。但同样,如果可能的话,我宁愿只使用 Web Deploy un/pw。

(我了解管理证书处于订阅级别,Web Deploy un/pw 处于应用服务/网站实例级别。我只是在说明我想要的解决方案是什么样的。)

【问题讨论】:

    标签: azure azure-web-app-service azure-sdk-.net azure-management-api


    【解决方案1】:

    管理证书允许您仅使用经典部署(Azure 服务管理) 模型而不是 Azure 资源管理部署模型进行身份验证。

    如果您的 Web 应用程序不是使用经典部署模型创建的,您将需要 TokenCloudCredential 而不是 CertificateCloudCredential

    从技术上讲,您仍然可以创建 Certificate-based SubscriptionCloudCredentials,但它仅适用于使用经典部署模型创建的 Azure Web 应用。

    【讨论】:

      【解决方案2】:

      我宁愿只使用 Web Deploy un/pw。

      如果您想在 Web Deploy 期间将证书上传到 Azure WebApp,我们可以使用 ARM 模板,更多详细信息请参考document

      {
          "name": "[parameters('certificateName')]",
          "apiVersion": "2014-04-01",
          "type": "Microsoft.Web/certificates",
          "location": "[resourceGroup().location]",
          "properties": {
              "pfxBlob": "pfx base64 blob",
              "password": "some pass"
          }
      }
      

      关于如何创建带有证书的subscriptionCloudCredentials以及如何创建自定义证书,我为它做了一个demo。更多详情请参考另一位SO thread

      如果我们尝试在 Azure 上运行项目。请参阅文档Using Certificates in Azure Websites Applications。添加一个名为 WEBSITE_LOAD_CERTIFICATES 的应用设置,并将其值设置为证书的指纹,这将使您的 Web 应用程序可以访问它

      所以我们还需要在ARM模板中添加AppSetting,更多详细信息请参考document

        

      {
         "name": "appsettings",
          "type": "config",
          "apiVersion": "2015-08-01",
          "dependsOn": [
              "[concat('Microsoft.Web/sites/', variables('webSiteName'))]"
          ],
          "tags": {
              "displayName": "WebAppSettings"
          },
          "properties": {
              " WEBSITE_LOAD_CERTIFICATES ": "thumbprint "
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-01-18
        • 2019-07-17
        • 1970-01-01
        • 1970-01-01
        • 2021-10-24
        • 1970-01-01
        • 1970-01-01
        • 2017-02-11
        相关资源
        最近更新 更多