問題描述
有沒有辦法從 Azure 中獲取所有 DocumentDb 資源? (Is there a way to fetch all DocumentDb resoruces from Azure?)
我的目標是將所有資源從 azure 獲取到我們的本地數據庫。我已經能夠使用 C# SDK (https://github.com/Azure/azure‑sdk‑for‑net)。但是,似乎沒有 DocumentDb 資源的包裝器,而且,我無法找到一個端點來查詢它。你知道如何獲取所有 DocumentDb 資源嗎?
參考解法
方法 1:
Try something like this powershell cmdlet
Find‑AzureRmResource ‑ResourceType "Microsoft.DocumentDB/databaseAccounts"
Unfortunately, this doesn't seem to work exactly as expected, which is kind of weird. If I run this
Find‑AzureRmResource ‑ResourceType "Microsoft.Storage/storageAccounts"
It outputs all the storage accounts. Go figure...
edit: Yes it is working fine. I was looking in the wrong subscription for docDbs... idiot.
As for doing it with REST, @macpak I haven't done it myself, but I suspect you could do something like:
GET https://management.azure.com/subscriptions/yourSubId/resourceGroups/yourResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts?api‑version=2016‑03‑31
This is how https://resources.azure.com works, check it out. Obviously you parameterise the subId and RGname and build the URI. You would also need to get a bearer token and put it in the authorisation header. Use postman and/or fiddler..
(by macpak、Edward Rixon)