Database Usages - List By Database

Gets database usages.

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/usages?api-version=2021-11-01

URI Parameters

Name In Required Type Description
databaseName
path True

string

The name of the database.

resourceGroupName
path True

string

The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.

serverName
path True

string

The name of the server.

subscriptionId
path True

string

The subscription ID that identifies an Azure subscription.

api-version
query True

string

The API version to use for the request.

Responses

Name Type Description
200 OK

DatabaseUsageListResult

Successfully retrieved the database usages.

Other Status Codes

*** Error Responses: ***

  • 400 InvalidStandbyGeoReadScale - User attempted to enable read scale on a standby geo database that does not support it.

  • 400 PerDatabaseCMKKeyRotationAttemptedWhileOldThumbprintInUse - Key Rotation for the TDE Protector at the database level is blocked when active transactions are holding up the log encrypted with old keys. Please refer to aka.ms/azuresqldbkeyrotation for possible strategies to workaround this issue.

  • 400 TierChangeUnsupportedDueToMemoryOptimizedObject - The database cannot update its sku because it has memory-optimized objects.

  • 400 PerDBCMKNotSupportedWithLTR - Database-level CMK is not supported when Long-term Backup Retention is enabled on the database.

  • 400 SourceServerNotFound - The server part of a source database id provided in a CreateDatabaseAsCopy API call doesn't map to an existing server.

  • 400 ElasticPoolOverStorageUsage - Attempting to write data to a database when the storage limit of the elastic pool has been reached.

  • 400 InvalidDatabaseCreateMode - Invalid request to create a database.

  • 400 MissingAsymmetricKeyOnTargetServer - Target server does not have access to an asymmetric key.

  • 400 MismatchingSubscriptionWithUrl - The provided subscription did not match the subscription in the Url.

  • 400 MultipleDroppedDatabasesWithTheSameName - Found multiple dropped databases with the same name on server.

  • 400 InvalidAddSecondaryPermission - User does not have sufficient permission to add secondary on the specified server.

  • 400 AzureKeyVaultClientError - The Azure Key Vault client encountered an error.

  • 400 UnsupportedServiceName - The specified name is an invalid name because it contains one or more unsupported unicode characters.

  • 400 AzureKeyVaultClientInfoError - An error occurred while obtaining information for the Azure Key Vault client.

  • 400 CurrentDatabaseLogSizeExceedsMaxSize - User attempted to change the database to a sku with lower max log size than the current usage.

  • 400 IsLedgerDatabaseIsNotSupportedOnResourceType - Changing the ledger property is not supported for this resource type.

  • 400 InvalidBackupStorageAccountType - User passed zrs/lrs during create/update of a database but it failed either because the customer is not whitelisted or because zrs is not available in the specified region.

  • 400 CannotUpdateToFreeDatabase - Updating a database to the free sku is not supported.

  • 400 DatabaseInvalidSkuPropertyCombination - The properties of the requested sku are inconsistent. Please check that a valid combination is specified. See https://docs.microsoft.com/en-us/rest/api/sql/capabilities/listbylocation#serviceobjectivecapability for more details.

  • 400 DatabaseNamedReplicaPerDatabaseLimitExceeded - User tried create a named replica that would exceed the allowed number per primary database

  • 400 UnsupportedBackupStorageRedundancyForEdition - The requested backup storage redundancy is not supported for edition

  • 400 DatabaseIsCurrentlyPinned - Microsoft has pinned your database SQL Server engine version. To ensure your database does not hit production issues, any future scale operations on your database will be blocked until it has been un-pinned. Please contact Microsoft support for assistance with scaling.

  • 400 RestoreTargetEditionSizeInsufficient - User attempted to restore a database to an edition that is a smaller size than the current allocated size of the source.

  • 400 InvalidSku - The user specified an invalid sku.

  • 400 InvalidTierSkuCombination - The specified tier does not support the specified sku.

  • 400 ServerNotFound - The requested server was not found.

  • 400 UnsupportedBackupStorageRedundancy - Specified Backup Storage Redundancy is not supported in target region.

  • 400 InvalidIdentityId - One or more identity id(s) provided are not valid ARM resource id(s). Please input valid id(s) and try again.

  • 400 LTRSterlingToVldbMigrationNotSupported - Cannot change service objective for database to Hyperscale as long-term retention is not yet supported on Hyperscale. Please disable long-term retention on the database and retry.

  • 400 TokenTooLong - The provided token is too long.

  • 400 FeatureDisabledOnSelectedEdition - User attempted to use a feature which is disabled on current database edition.

  • 400 OfferDisabledOnSubscription - Subscription offer type is restricted from provisioning the requested resource.

  • 400 UnableToCreateGeoChain - User attempted to create secondary database (chaining) even though automatic upload of ledger digests has been configured

  • 400 InvalidNumberOfIdentities - Only one user assigned managed identity is supported at the Database Level.

  • 400 DatabaseNamedReplicaChainingNotAllowed - User tried to create a named replica of a named replica which is not allowed.

  • 400 DatabaseNamedReplicaInvalidOperation - User attempted an unsupported operation on a named replica.

  • 400 DatabaseNamedReplicaInvalidSourceDatabase - User attempted to create a named replica in a different subscription or region than the source database.

  • 400 InvalidTargetSubregion - The target server of a non-readable secondary is not in a DR paired Azure region.

  • 400 CannotAssignIdentityToMaster - Cannot assign an identity to a system database. Database identity cannot be assigned to 'master', 'model', 'tempdb', 'msdb', or 'resource' databases.

  • 400 PerDatabaseCMKDWNotSupported - Database-level CMK in preview is not supported for Datawarehouse edition.

  • 400 DatabaseCreationBlockedForNonActivatedCMKServer - SQL Pool creations are blocked for CMK enabled workspaces until the workspace is activated. First, enable purge protection and grant the workspace Managed Identity the required permissions (Get, Wrap Key, Unwrap Key) on the Azure Key Vault of the workspace key. Next, activate your workspace after you have granted access.

  • 400 PartnerServerNotCompatible - The user is attempting to copy a database from a SAWA V1 server to a Sterling server or vice versa.

  • 400 IncorrectReplicationLinkState - The operation expects the database to be in an expected state on the replication link.

  • 400 TargetElasticPoolDoesNotExist - The elastic pool does not exist on a server.

  • 400 ElasticPoolSkuCombinationInvalid - Elastic pool and sku can be specified together only if sku is specified as 'ElasticPool'.

  • 400 ElasticPoolTierCombinationInvalid - The database tier is different than the elastic pool service tier.

  • 400 ElasticPoolNameRequired - User tried to create or update database to elastic pool service objective without specifying the name of the elastic pool.

  • 400 MissingThumbprintCrm - The restore operation of a CRM database failed because a required TDE certificate was missing. Please retry the restore operation to an existing elastic pool.

  • 400 ElasticPoolOverStorage - Attempting to write data to a database when the storage limit of the elastic pool has been reached.

  • 400 ElasticPoolInconsistentDtuGuaranteeSettings - Attempting to provide DTU min for databases in the elastic pool that exceeds requested DTUs of the elastic pool.

  • 400 RestoreTargetEditionSizeInsufficientV2 - User attempted to restore a database to an edition that is a smaller size than the allocated size of the restored database.

  • 400 TierChangeUnsupportedDueToCDCEnabledDatabase - The database cannot update its sku because it is enabled for CDC.

  • 400 ElasticPoolDatabaseCountOverLimit - Attempting to create or add database to elastic pool when the database count limit of the elastic pool has been reached.

  • 400 ResourcePoolStorageLimitHitDuringRestore - The restored database can't be restored into the resource pool due to the remaining storage capacity in the pool.

  • 400 CannotChangeToOrFromDataWarehouseTier - User attempted to change the sku of a database from DataWarehouse tier to non DataWarehouse tiers or vice versa.

  • 400 CurrentDatabaseSizeExceedsMaxSize - User attempted to reduce the max size for a database to a size smaller than the current usage.

  • 400 PerDatabaseCMKRestoreNotSupported - Database restore is not supported when Database-level CMK is configured in preview.

  • 400 PerDatabaseCMKHSNotSupported - Database-level CMK in preview is not supported for Hyperscale edition.

  • 400 AzureKeyVaultKeyDisabled - The operation could not be completed on the server because the Azure Key Vault key is disabled.

  • 400 PerDatabaseCMKGeoReplicationNotSupported - Geo Replication and Database Copy is not supported when Database-level CMK is configured in preview.

  • 400 ElasticPoolDecreaseStorageLimitBelowUsage - Attempting to decrease the storage limit of the elastic pool below its storage usage.

  • 400 AzureKeyVaultInvalidExpirationDate - The operation could not be completed because the Azure Key Vault key expiration date is invalid.

  • 400 InvalidStandbyGeoEdition - User attempted to create a DTU based standby geo.

  • 400 SecurityAzureKeyVaultUrlNullOrEmpty - The operation could not be completed because the Azure Key Vault Uri is null or empty.

  • 400 ElasticPoolInconsistentVcoreGuaranteeSettings - The number of databases and VCore min per database cannot exceed requested VCores of the elastic pool.

  • 400 UpdateNotAllowedOnPausedDatabase - User attempted to perform an update on a paused database.

  • 400 GeoRestoreBackupStorageTypeNotSupported - Database recovery requests are invalid when issued against a database that is not configured to use geo-redundant backup storage.

  • 400 RestoreHyperscaleToNonHyperscale - Restoring a Hyperscale database backup to a non-Hyperscale service tier or vice versa is not supported.

  • 400 SubscriptionDoesNotHaveAccessToServer - The subscription does not have access to the specified server(s)

  • 400 RecoveryPointDoesNotExist - The specified recovery point either does not exist or is not valid.

  • 400 AzureKeyVaultNoServerIdentity - The server identity is not correctly configured.

  • 400 InvalidMaxSizeTierCombination - The specified tier does not support the specified database max size.

  • 400 LtrBackupNotFound - The specified long term retention backup does not exist.

  • 400 AzureKeyVaultInvalidUri - An invalid response from Azure Key Vault. Please use a valid Azure Key Vault URI.

  • 400 InvalidPointInTime - The specified point in time is not valid for the database.

  • 400 AzureKeyVaultMissingPermissions - The server is missing required permissions on the Azure Key Vault.

  • 400 GeoRestoreCannotResolveTargetCluster - Cannot resolve target cluster for server

  • 400 InvalidReadScaleEdition - User attempted to enable read scale on a database type that does not support it.

  • 400 CannotSpecifyEditionOrSloWhenRestoringToPool - Specifying the target service level objective or edition is not supported when restoring to an elastic pool.

  • 400 InvalidReadScaleUnits - User attempted to provide a read scale value that is not supported.

  • 400 RestoreNotSupportedForGeoDrSecondary - Point-in-time restore and database recovery operations are not supported on databases that are currently configured as geo-secondaries.

  • 400 SecurityAzureKeyVaultInvalidKeyName - The operation could not be completed because of an invalid Server Key name.

  • 400 RegionDoesNotSupportVersion - A user attempted to create a server of a specified version in a location where that server version isn't supported.

  • 400 GeoSecondaryMaxSizeUpdateFailed - The geo-secondary database is of a SLO that does not support the requested maxsize value or the geo-secondary is in an unsupported region or an update operation is already in progress on the geo-secondary database.

  • 400 AdalGenericError - The operation could not be completed because an Azure Active Directory error was encountered.

  • 400 AdalServicePrincipalNotFound - The operation could not be completed because an Azure Active Directory library Service Principal not found error was encountered.

  • 400 InvalidTier - The user specified an invalid tier.

  • 400 AzureKeyVaultMalformedVaultUri - The provided Key Vault uri is not valid.

  • 400 CannotUseReservedDatabaseName - Cannot use reserved database name in this operation.

  • 400 RequestedDatabaseSizeRequiresShrink - User attempted to ALTER DATABASE MODIFY MAXSIZE to modify the MAXSIZE for a database to a smaller size then the current size.

  • 400 CurrentDatabaseSizeExceedsDbMaxSize - User attempted to reduce the max size for a database to a size smaller than the current usage.

  • 400 InvalidServerName - Invalid server name specified.

  • 400 CannotUseTrailingWhitespacesInDatabaseName - The database name validation failed.

  • 400 SourceDatabaseEditionCouldNotBeUpgraded - The source database cannot have higher edition than the target database.

  • 400 SecurityAdalPrincipalCertExpiredError - The operation could not be completed because the Azure Key Vault principal certificate has expired.

  • 400 TargetDatabaseEditionCouldNotBeDowngraded - The target database cannot have lower edition than the source database.

  • 400 UpdateNotAllowedIfGeoDrOperationInProgress - The operation is disallowed because copy or failover operation for database '{0}' on server '{1}' is currently in progress.

  • 400 InvalidCollation - Collation is not recognized by the server.

  • 400 SecurityInvalidAzureKeyVaultRecoveryLevel - The provided Key Vault uri is not valid.

  • 400 KeyMaterialNotFoundOnRemoteServer - Remote server does not have access to key material used as a TDE protector.

  • 400 AzureKeyVaultRsaKeyNotSupported - The provided key vault uses unsupported RSA Key Size or Key Type. The supported RSA key size is 2048 or 3072 and Key Type is RSA or RSA-HSM.

  • 400 SameKeyMaterialNotFoundOnRemoteServer - Secondary server does not have the key material of the primary server's encryption protector.

  • 400 ElasticPoolOverFileSpace - Insufficient file space in the elastic pool.

  • 400 PartnerDBNotCompatibleForSGXEnclave - Attempt to set GeoDR link or update SLO for enclave enabled database is only supported when both database are running on DC-series hardware.

  • 400 UpdateNotAllowedInCurrentReplicationState - The operation is disallowed on the database in its current replication state.

  • 400 InvalidLicenseType - User tried to create or update a database or elastic pool with unsupported license type.

  • 400 GeoReplicaLimitReached - The per-replica replication limit was reached.

  • 400 UnsupportedCapacity - User tried to create or update database with capacity which is not supported.

  • 400 ReplicationSourceAndTargetMustHaveSameName - The replication source and target databases must have the same name.

  • 400 ProvisioningDisabled - Displays error message from resources operation authorizer as is, without changes

  • 400 ReplicationSourceAndTargetMustBeInDifferentServers - The replication source and target databases must be in different logical servers.

  • 400 CannotUpdateIsLedgerDatabase - The ledger property of an existing database cannot be updated.

  • 400 UnableToResolveRemoteServer - The remote partner server name could not be resolved due to an invalid server name or DNS connectivity issues.

  • 400 RemoteDatabaseCopyPermission - User does not have sufficient permission to create a database copy on the specified server.

  • 400 CannotMoveOrDropSyncMetadataDatabase - Cannot drop database used as sync metadata database.

  • 400 SecurityAzureKeyVaultGeoChainError - Creating secondary of secondary (a process known as chaining) is not supported when enabling Transparent Data Encryption using Azure Key Vault (BYOK).

  • 400 RestoreToFreeEditionNotSupported - Restore and GeoRestore target cannot be free database.

  • 400 CannotMoveOrDropJobAccountDatabase - Cannot drop database associated with job account.

  • 400 RestoreNotSupportedForFreeEdition - Restore and GeoRestore are not supported for free database.

  • 400 JobAgentDatabaseEditionUnsupported - The specified database's service level objective is not supported for use as a job agent database.

  • 400 InvalidDroppedDatabase - Source database dropped does not exist on server within the supported recovery period.

  • 400 InvalidLiveDatabase - Source database does not exist on server within the supported recovery period. If restoring a dropped database, please specify its deletion date.

  • 400 InvalidVldbRecoverySlo - The Hyperscale edition recovery requires both source and target databases to use Hyperscale service level objective.

  • 400 SourceDatabaseNotFound - The source database does not exist.

  • 400 InvalidVldbRestoreSlo - The Hyperscale edition Point-In-Time restore requires both source and target databases to use Hyperscale service level objective.

  • 400 CannotSpecifyPoolOrSlo - Specifying an elastic pool and/or changing the service level objective or edition is not supported for edition.

  • 400 InvalidPublicMaintenanceConfiguration - User tried to specify public maintenance configuration which cannot be converted to internal id (malformed or wrong region).

  • 400 MaintenanceWindowNotSupportedForNamedReplica - User tried to create or update named replica with non-default maintenance window which is not supported.

  • 400 ChangeUnsupportedOnEntity - User attempted an unsupported create/update/delete operation on a given entity.

  • 404 SubscriptionDoesNotHaveServer - The requested server was not found

  • 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

  • 404 DatabaseDoesNotExist - User has specified a database name that does not exist on this server instance.

  • 404 ServerNotInSubscriptionResourceGroup - Specified server does not exist in the specified resource group and subscription.

  • 404 SubscriptionNotFound - The requested subscription was not found.

  • 404 ServerNotInSubscription - Specified server does not exist on the specified subscription.

  • 404 CannotFindObject - Cannot find the object because it does not exist or you do not have permissions

  • 405 UnsupportedReplicationOperation - An unsupported replication operation was initiated on the database.

  • 409 FreeDbAlreadyExists - Only one free database can exist for a subscription per region.

  • 409 ConflictingServerOperation - An operation is currently in progress for the server.

  • 409 SubscriptionDisabled - Subscription is disabled.

  • 409 ConflictingSystemOperationInProgress - A system maintenance operation is in progress on the database and further operations need to wait until it is completed.

  • 409 ConflictRequestToUpdateBackupRedundancy - A conflict request to change backup storage redundancy is still in progress.

  • 409 SkuAssignmentInProgress - The current assignment request cannot be processed because a previous request has not completed.

  • 409 DatabaseElasticPoolMaintenanceConflict - User tried to create or update a database with a specified maintenance configuration that conflicted with that of the elastic pool of the database.

  • 409 ServerDtuQuotaExceeded - Could not perform the operation because server would exceed the allowed Database Throughput Unit quota.

  • 409 UnableToAlterDatabaseInReplication - User altered edition on a database in a replication relationship.

  • 409 SubscriptionVcoreQuotaExceeded - Could not perform the operation because subscription would exceed the allowed vCore quota.

  • 409 CurrentMemoryUsageExceedsSkuQuota - User attempted an sku update operation that cannot be completed due to the higher resource consumption.

  • 409 ServerKeyNameAlreadyExists - The server key already exists on the server.

  • 409 ServerKeyUriAlreadyExists - The server key URI already exists on the server.

  • 409 ServerKeyDoesNotExists - The server key does not exist.

  • 409 UpdateSloInProgress - User tried to initiate an incompatible operation while a SLO update was in progress.

  • 409 UpdateSloFailedDatabaseTooBusy - Update SLO operation could not complete because database was too busy.

  • 409 ElasticPoolBusy - A management operation was attempted on an elastic pool which is busy.

  • 409 AzureKeyVaultKeyNameNotFound - The operation could not be completed because the Azure Key Vault Key name does not exist.

  • 409 AzureKeyVaultKeyInUse - The key is currently being used by the server.

  • 409 ServerDisabled - Server is disabled.

  • 409 ConflictingDatabaseOperation - There is already some operation on the database and the current operation should wait till it is done.

  • 409 SimultaneousSkuChangeNotAllowed - Service objective change operations cannot run on both databases of a replication relationship at the same time.

  • 409 TargetElasticPoolBeingUpdated - The update of elastic pool cannot be started because there is copy operation in progress for one of the databases in this elastic pool

  • 409 InvalidOperationForDatabaseNotInReplicationRelationship - A replication seeding operation was performed on a database that is already in a replication relationship.

  • 409 InvalidOperationForDatabaseInReplicationRelationship - A replication seeding operation was performed on a database that is already in a replication relationship.

  • 409 DuplicateGeoDrRelation - The databases are already in a replication relation. This is a duplicate request.

  • 409 DatabaseCopyLimitPerReplicaReached - User reached the limit of concurrent database copies.

  • 409 RemoteDatabaseExists - The destination database name already exists on the destination server.

  • 429 SubscriptionTooManyCreateUpdateRequests - Requests beyond max requests that can be processed by available resources.

  • 429 SubscriptionTooManyRequests - Requests beyond max requests that can be processed by available resources.

  • 500 ActivateOrDeactivateWorkflowThrottling - Activation or deactivation workflow failed because there are too many concurrent workflows

  • 503 TooManyRequests - Requests beyond max requests that can be processed by available resources.

  • 503 AzureKeyVaultConnectionFailed - The operation could not be completed on the server because attempts to connect to Azure Key Vault have failed

  • 503 AzureKeyVaultGenericConnectionError - The operation could not be completed because an error was encountered when attempting to retrieve Key Vault information .

  • 503 DatabaseUnavailable - The operation failed because the database is unavailable.

  • 504 RequestTimeout - Service request exceeded the allowed timeout.

Examples

Gets database usages.

Sample Request

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

Sample Response

{
  "value": [
    {
      "properties": {
        "displayName": "Database Size",
        "currentValue": 4194304,
        "limit": 268435456000,
        "unit": "Bytes"
      },
      "id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb/usages/database_size",
      "name": "database_size",
      "type": "Microsoft.Sql/servers/databases/usages"
    }
  ]
}

Definitions

Name Description
DatabaseUsage

Usage metric of a database.

DatabaseUsageListResult

A list of database usage metrics.

DatabaseUsage

Usage metric of a database.

Name Type Description
id

string

Resource ID.

name

string

Resource name.

properties.currentValue

number

Current value of the metric.

properties.displayName

string

User-readable name of the metric.

properties.limit

number

Boundary value of the metric.

properties.unit

string

Unit of the metric.

type

string

Resource type.

DatabaseUsageListResult

A list of database usage metrics.

Name Type Description
nextLink

string

Link to retrieve next page of results.

value

DatabaseUsage[]

Array of results.