在AzureAD中使用REST API进行放大和缩小的权限

时间:2019-02-11 18:31:58

标签: azure azure-active-directory azure-logic-apps

我已经在AzureAD中注册了一个应用程序:AnalysisService 它具有以下ID:

Application (client) ID: ID1
Directory (tenant) ID: ID2

并且我已经定义了以下权限: enter image description here

我的目标是使用以下ID在逻辑应用中放大和缩小Azure Analysis Service

Subscription ID: ID3

在逻辑应用中,我有以下要求:

{
    "uri": "https://management.azure.com/subscriptions/**ID3**/resourceGroups/ServerName/providers/Microsoft.AnalysisServices/servers/Model?api-version=2017-08-01",
    "method": "PATCH",
    "authentication": {
        "tenant": "ID2",
        "audience": "https://management.core.windows.net",
        "clientId": "ID1",
        "secret": "*sanitized*",
        "type": "ActiveDirectoryOAuth"
    },
    "body": {
        "sku": {
            "capacity": 1,
            "name": "S4",
            "tier": "Standard"
        },
        "tags": {
            "testKey": "testValue"
        }
    }
}

发送此请求后,出现以下错误:

{
    "statusCode": 403,
    "headers": {
        "Pragma": "no-cache",
        "x-ms-failure-cause": "gateway",
        "x-ms-request-id": "xxxxxx-4dea-xxx-xxxx-xxx",
        "x-ms-correlation-request-id": "xxxxxxxx-4dea-xxxx-xxxx-5dea12ba0cca",
        "x-ms-routing-request-id": "WESTEUROPE:20190211T181536Z:xxxxxx-4dea-4fa8-bccd-xxxxxx",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
        "X-Content-Type-Options": "nosniff",
        "Connection": "close",
        "Cache-Control": "no-cache",
        "Date": "Mon, 11 Feb 2019 18:15:35 GMT",
        "Content-Length": "413",
        "Content-Type": "application/json; charset=utf-8",
        "Expires": "-1"
    },
    "body": {
        "error": {
            "code": "AuthorizationFailed",
            "message": "Client \"ID4\" with the object ID \"ID4\" has no permission to run the action \"Microsoft.AnalysisServices/servers/write\" over \"/subscriptions/ID3/resourceGroups/ServerName/providers/Microsoft.AnalysisServices/servers/ModelName\"."
        }
    }
}

我应该做些什么来解决这个问题?

更新 我已经为我的服务主体(代表Azure AD应用程序)授予了对我的Analysis Services实例的以下特定权限:

enter image description here

我也已经按照here的描述在Management Studio中对其进行了控制,我也可以在这里看到serviceprincipal: enter image description here

但是我仍然收到相同的错误消息

ID4是我的逻辑应用程序的对象ID吗?我还应该在我的Analysis Service的IAM中添加逻辑应用程序吗?

1 个答案:

答案 0 :(得分:2)

您应向您的服务主体(代表Azure AD应用程序)授予对Analysis Services实例Microsoft.AnalysisServices/servers/write的这些特定权限:/subscriptions/ID3/resourceGroups/ServerName/providers/Microsoft.AnalysisServices/servers/ModelName。另外,您可以在资源组级别或订阅级别授予这些权限。

操作方法如下:https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-portal

简而言之:转到资源,单击左侧的IAM,单击刀片顶部的+ Add Role Assignment,然后选择您的角色\身份。这种特殊权限属于Analysis Services投稿人之类。

ps。您可以随时创建自定义角色以遵循最低特权原则:https://docs.microsoft.com/en-us/azure/role-based-access-control/custom-roles