How to get size of Database in Azure SQL Managed Instance using Azure Management Fluent API?

Viewed 1068

Is there any way to get size of database in SQL Managed Instance in Azure using API for Azure management (Microsoft.Azure.Management.ResourceManager.Fluent.dll)?

Or maybe with another API?

The way of SQL queries is not possible for us, because we cannot connect to SQL Server directly.

Thank You.

3 Answers

You can use Managed Instances - Get API to retrieve information about an instance; which provide response property of size properties.storageSizeInGB.

Check this sample request for more reference.

we can certainly get details from Azure Metrics. I haven't tried for Managed Instance though. Please check this: https://docs.microsoft.com/en-us/powershell/module/az.monitor/get-azmetric?view=azps-5.7.0

Something like this: (Got from https://fonsecasergio.wordpress.com/2019/03/27/how-to-get-azure-sql-database-size/)

$Databases = Get-AzureRmResource -ResourceGroupName "GROUPNAME" -ResourceType Microsoft.Sql/servers/databases foreach ($DB in $Databases) { $DBSize = Get-TotalDatabaseSizeKb $DB "DB ($($DB.Name)) $($DBSize)Kb or $($DBSize / 1024)Mb" }

Related