Roman Alekseiev
Roman Alekseiev

Reputation: 1920

Is it possible to list all databases in Azure via REST API

I need to receive list of existed databases in Microsoft Azure account. I do see REST API for example MySQL servers and databases, PostgeSQL servers and databases and so on. My question is there any action that lists all databases in one request or do I need to search them one by one? Thanks in advance

Upvotes: 1

Views: 749

Answers (1)

Leon Yue
Leon Yue

Reputation: 16401

You can use this REST API: Resources - List

GET https://management.azure.com/subscriptions/{subscriptionId}/resources?$filter={$filter}&api-version=2019-05-10 

Add the $filter like this:

ResourceType eq 'Microsoft.DBforPostgreSQL/servers' or ResourceType eq 'Microsoft.Sql/servers/databases'

enter image description here

If you want to list other type of Azure SQL database, just follow the format above the filter.

Note:

If your resources are too more, you will need to call the API in the 'nextLink'. enter image description here

Using the API can help you lists all databases in one request.

Hope this helps.

Upvotes: 5

Related Questions