0

我试图在给定订阅中收集我的 Azure 资源的完整 JSON 表示,但无法弄清楚我如何枚举给定资源类型的可用子资源。

例如,我可以获得 Microsoft.Web/sites/{name} 资源,但该响应中没有任何内容告诉我 Microsoft.Web/sites/{name}/config 存在。我也无法在 Provider 对象中找到对 /config 资源的任何引用。

Azure 资源资源管理器似乎以很少的性能开销动态枚举它们,所以我相信可以做到这一点。我只是不知道怎么做。使用 azure-arm-resource nom 包的 NodeJS 示例:

// Returns a data structure, but nothing about subtypes.
let p = client.providers.get("Microsoft.Web");
// Contains the resource, but not the resources subtypes (e.g. config/appsettings
let r = client.resources.getById(resourceId, apiVersion);

我在 API 中寻找可以给我一系列子类型的东西;在 Microsoft.Web/sites 的情况下,这将类似于 ["config"、"containerlogs"、"diagnostics"...] 等。

4

1 回答 1

0

这将是您正在寻找的电话:

https://management.azure.com/subscriptions/xxx/providers/Microsoft.Web?api-version=2019-05-10

它返回如下内容:

{
    "resourceTypes": [
        {
            "resourceType": "components",
            "locations": [ xxx ],
            "apiVersions": [ yyy ],
        },
        xxx,
        yyy
    ]
}

因此,您需要更仔细地检查调用的输出。或者只是做一个简单的休息请求并解析输出。但老实说,components()不要改变太多,你不妨硬编码列表。

于 2019-10-04T05:35:06.840 回答