

$DB = Get-AzureRmResource -ResourceGroupName "GROUPNAME" -Name "SERVER/DATABASENAME" $Result = $Resource | Get-AzureRmMetric -MetricName 'storage' -WarningAction Silentl圜ontinue If you want to collect the database size without connecting directly to SQL Server you can query Property DatabaseDataSpaceAllocatedUnusedInMB ` Write-Output $databaseStorageMetrics | Sort ` Write-Output "`n" "ElasticPoolName: $poolName" # Display databases in descending order of space allocated unused (Invoke-Sqlcmd -ServerInstance $serverFqdn ` $databaseStorageMetrics = $databaseStorageMetrics + SUM(size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0) AS DatabaseDataSpaceAllocatedUnusedInMB ` SUM(size/128.0) AS DatabaseDataSpaceAllocatedInMB, ` $sqlCommand = "SELECT DB_NAME() as DatabaseName, ` # get its space allocated in MB and space allocated unused in MB. $databaseStorageMetrics = For each database in the elastic pool, $databasesInPool = Get-AzureRmSqlElasticPoolDatabase ` SELECT TOP 1 elastic_pool_storage_limit_mb AS ElasticPoolMaxSizeInMB SELECT TOP 1 avg_storage_percent / 100.0 * elastic_pool_storage_limit_mb AS ElasticPoolDataSpaceUsedInMB SELECT DATABASEPROPERTYEX('db1', 'MaxSizeInBytes') AS DatabaseDataMaxSizeInBytes SUM(size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0) AS DatabaseDataSpaceAllocatedUnusedInMB SELECT SUM(size/128.0) AS DatabaseDataSpaceAllocatedInMB, Database data space allocated in MB and database data space allocated unused in MB

SELECT TOP 1 storage_in_megabytes AS DatabaseDataSpaceUsedInMB

Is the easiest way to get this for a single database in the There are multiple methods to query this data The amount of data space allocated cannot grow beyond the data max size. The maximum amount of space that can be used for storing database data.
Azure database free#
This quantity represents the maximum amount of free space that can be reclaimed by shrinking database data files. The difference between the amount of data space allocated and data space used. This behavior ensures that future inserts are faster since space does not need to be reformatted. The amount of space allocated grows automatically, but never decreases after deletes.

The amount of formatted file space made available for storing database data. For example, deleting one row from every data page does not necessarily decrease the space used. In some cases, the space used does not change on inserts or deletes depending on the amount and pattern of data involved in the operation and any fragmentation. Generally, space used increases (decreases) on inserts (deletes). The amount of space used to store database data in 8 KB pages. Understanding the following storage space quantities are important for managing the file space of a database. There are multiple ways to achieve this and there are also some
