如何使用脚本对Azure EventGrid API连接进行身份验证?

时间:2018-09-21 13:44:31

标签: azure azure-powershell arm-template azureportal azure-eventgrid

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

这是我的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. 我是否缺少模板中负责立即验证连接的某些内容?

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

1 个答案:

答案 0 :(得分:2)

  

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

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

do $$
declare
    var_A numeric;
begin
    var_A := 14.141244804178488; 
    var_A := trunc(var_A ,2); 
    raise notice '%', var_A;
end;
$$ language plpgsql

Parameters.json

"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": []
    }
  ]