0

I can get a database usage report (including DB actual and maximum size) for a single database using REST API:

https://learn.microsoft.com/en-us/rest/api/sql/2021-05-01-preview/database-usages/list-by-database?tabs=HTTP

I want to get the same database usage report by server name for all the databases on that server. Is it possible using the Azure REST API?

1 Answer 1

1

You can list of all databases contained on that Azure SQL logical server using this REST API.

GET https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases?api-version=2021-05-01-preview

You can then iterate through the list returned and get the database usage for each database using the REST API you referenced in your question.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, Alberto. It returns maxSizeBytes of each database, I was looking for the actual size. I could achieve the same using the SQL query but would be nice if I could get it using restapi. Qry - Select * from ( select @@serverName as ServerName, db.name as DatabaseName, (select top 1 s.storage_in_megabytes from sys.resource_stats s where s.database_name = db.name order by s.start_time desc) as DatabaseMB from sys.databases db )t order by DatabaseMB desc
Use the following endpoint: management.azure.com/subscriptions//resourceGroups//providers/… The result is a json that looks like the following: name : database_size resourceName : displayName : Database Size currentValue : 2324692992.0 limit : 268435456000.0 unit : Bytes nextResetTime :

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.