为什么我的 Power Automate 流返回一个空列表而不是我的 Azure 租户中的所有订阅?

Why is my Power Automate flow returning an empty list instead of all subscriptions in my Azure tenant?

我目前正在处理 Power Automate 流程,以在我组织的 Azure 租户的每个订阅中的所有资源组的 SharePoint 列表上创建一个数据库。

为了首先获取租户中的订阅列表,我使用 Azure REST API 获取租户中所有订阅的列表。这完美地工作并得到了我需要的东西,但是它使用 Bearer 令牌进行授权,我正在寻找一个不会过期的解决方案。因此,我决定沿着 Active Directory OAuth 路线进行授权,为此我在 Azure 上创建了一个应用程序注册。这是我目前所拥有的:

目前,我的流程 运行 成功,但基本上 return 没有信息:

{
  "value": [],
  "count": {
    "type": "Total",
    "value": 0
  }
}

我正在寻找的架构 return 应该是这样的:

{
    "type": "object",
    "properties": {
        "value": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "authorizationSource": {
                        "type": "string"
                    },
                    "managedByTenants": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "tenantId": {
                                    "type": "string"
                                }
                            },
                            "required": [
                                "tenantId"
                            ]
                        }
                    },
                    "subscriptionId": {
                        "type": "string"
                    },
                    "tenantId": {
                        "type": "string"
                    },
                    "displayName": {
                        "type": "string"
                    },
                    "state": {
                        "type": "string"
                    },
                    "subscriptionPolicies": {
                        "type": "object",
                        "properties": {
                            "locationPlacementId": {
                                "type": "string"
                            },
                            "quotaId": {
                                "type": "string"
                            },
                            "spendingLimit": {
                                "type": "string"
                            }
                        }
                    }
                },
                "required": [
                    "id",
                    "authorizationSource",
                    "managedByTenants",
                    "subscriptionId",
                    "tenantId",
                    "displayName",
                    "state",
                    "subscriptionPolicies"
                ]
            }
        },
        "count": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string"
                },
                "value": {
                    "type": "integer"
                }
            }
        }
    }
}

您这里的问题是您的应用注册权限问题。

如果 App 没有受到订阅中任何角色的影响,您将不会在使用其身份调用 API 时获得它们。

样本

未添加到订阅

我在创建应用注册和调用订阅列表时得到了与您相同的结果:

将应用添加为订阅的Reader后

我在 1 个订阅的 IAM 中将应用添加为 Reader:

结果:我在流程中得到了它: