3

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.

Tomas Kubes
  • 23,880
  • 18
  • 111
  • 148

3 Answers3

0

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.

0

we can certainly get details from Azure Metrics. I haven't tried for Managed Instance though. Please check this: https://learn.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" }

Biplab Sah
  • 81
  • 3
0

Try with this powershell:

Get-AzSqlInstance -ResourceGroupName "ResourceGroupOfYourSQLMI"

https://learn.microsoft.com/en-us/powershell/module/az.sql/get-azsqlinstance?view=azps-5.7.0

and this one:

Get-AzSqlInstanceDatabase -InstanceName "managedInstance1" -ResourceGroupName "resourcegroup01"
Juanma Feliu
  • 1,298
  • 4
  • 16