如何使用脚本对Azure EventGrid API连接进行身份验证? [英] How to authenticate an Azure EventGrid API Connection using a script?

查看:64
本文介绍了如何使用脚本对Azure EventGrid API连接进行身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ARM模板创建EventGrid API连接.它创建成功,但是,我仍然必须通过Azure门户手动对其进行身份验证.

I am creating an EventGrid API Connection using an ARM Template. It gets created successfully, however, i still have to authenticate it by hand via Azure Portal.

这是我的ARM模板:

    "resources": [
    {
        "type": "Microsoft.Web/connections",
        "apiVersion": "2016-06-01",
        "name": "[parameters('azureEventGridConnectionAPIName')]",
        "location": "[resourceGroup().location]",
        "properties": {
            "api": {
                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'azureeventgrid')]"
            },
            "displayName": "[parameters('azureEventGridConnectionAPIName')]"
        },
        "dependsOn": []
    }
]

  1. 我是否丢失了模板中负责立即验证连接的某些内容?

  1. Am i missing something in the template that is responsible for authenticating the Connection right away?

是否可以使用例如Azure PowerShell对连接进行身份验证,以便我可以使该过程自动化?

Is there a way to authenticate that connection using for example Azure PowerShell so i can automate that process?

推荐答案

我是否丢失了模板中负责立即验证连接的某些内容?

Am i missing something in the template that is responsible for authenticating the Connection right away?

是的,我们可以在部署期间创建服务主体身份验证.以下是演示代码.

Yes, we could create a service principal authentication during deploy. Following is the demo code.

"resources": [
    {
      "type": "Microsoft.Web/connections",
      "apiVersion": "2016-06-01",
      "name": "[parameters('azureEventGridConnectionAPIName')]",
      "location": "[resourceGroup().location]",
      "properties": {
        "api": {
          "id": "[concat('/subscriptions/subscriptionId', '/providers/Microsoft.Web/locations/', 'eastasia', '/managedApis/', 'azureeventgrid')]"

        },
        "parameterValues": {
          "token:clientId": "[parameters('clientId')]",
          "token:clientSecret": "[parameters('clientSecret')]",
          "token:TenantId": "[parameters('TenantId')]",
          "token:grantType": "[parameters('grantType')]"
        },
        "displayName": "[parameters('azureEventGridConnectionAPIName')]"

      },
      "dependsOn": []
    }
  ]

Parameters.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "azureEventGridConnectionAPIName": {
      "value": "azureEventGridConnectionAPIName"
    },
    "clientId": {
      "value": "clientId"
    },
    "clientSecret": {
      "value": "secret key"
    },
    "TenantId": {
      "value": "tenant id"
    },
    "grantType": {
      "value": "client_credentials"
    }
  }
}

这篇关于如何使用脚本对Azure EventGrid API连接进行身份验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆