Skip to main content

managed_databases

Creates, updates, deletes, gets or lists a managed_databases resource.

Overview

Namemanaged_databases
TypeResource
Idazure.sql.managed_databases

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringFully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
namestringThe name of the resource.
autoCompleteRestorebooleanWhether to auto complete restore of this managed database.
catalogCollationstringCollation of the metadata catalog. Known values are: "DATABASE_DEFAULT" and "SQL_Latin1_General_CP1_CI_AS". (DATABASE_DEFAULT, SQL_Latin1_General_CP1_CI_AS)
collationstringCollation of the managed database.
createModestringManaged database create mode. PointInTimeRestore: Create a database by restoring a point in time backup of an existing database. SourceDatabaseName, SourceManagedInstanceName and PointInTime must be specified. RestoreExternalBackup: Create a database by restoring from external backup files. Collation, StorageContainerUri and StorageContainerSasToken must be specified. Recovery: Creates a database by restoring a geo-replicated backup. RecoverableDatabaseId must be specified as the recoverable database resource ID to restore. RestoreLongTermRetentionBackup: Create a database by restoring from a long term retention backup (longTermRetentionBackupResourceId required). Known values are: "Default", "RestoreExternalBackup", "PointInTimeRestore", "Recovery", and "RestoreLongTermRetentionBackup". (Default, RestoreExternalBackup, PointInTimeRestore, Recovery, RestoreLongTermRetentionBackup)
creationDatestring (date-time)Creation date of the database.
crossSubscriptionRestorableDroppedDatabaseIdstringThe restorable cross-subscription dropped database resource id to restore when creating this database.
crossSubscriptionSourceDatabaseIdstringThe resource identifier of the cross-subscription source database associated with create operation of this database.
crossSubscriptionTargetManagedInstanceIdstringTarget managed instance id used in cross-subscription restore.
defaultSecondaryLocationstringGeo paired region.
earliestRestorePointstring (date-time)Earliest restore point in time for point in time restore.
extendedAccessibilityInfoobjectAdditional observability and troubleshooting information for databases in ‘Inaccessible’ state.
failoverGroupIdstringInstance Failover Group resource identifier that this managed database belongs to.
isLedgerOnbooleanWhether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created.
lastBackupNamestringLast backup file name for restore of this managed database.
locationstringThe geo-location where the resource lives. Required.
longTermRetentionBackupResourceIdstringThe name of the Long Term Retention backup to be used for restore of this managed database.
recoverableDatabaseIdstringThe resource identifier of the recoverable database associated with create operation of this database.
restorableDroppedDatabaseIdstringThe restorable dropped database resource id to restore when creating this database.
restorePointInTimestring (date-time)Conditional. If createMode is PointInTimeRestore, this value is required. Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database.
sourceDatabaseIdstringThe resource identifier of the source database associated with create operation of this database.
statusstringStatus of the database. Known values are: "Online", "Offline", "Shutdown", "Creating", "Inaccessible", "Restoring", "Updating", "Stopping", "Stopped", "Starting", "DbMoving", and "DbCopying". (Online, Offline, Shutdown, Creating, Inaccessible, Restoring, Updating, Stopping, Stopped, Starting, DbMoving, DbCopying)
storageContainerIdentitystringConditional. If createMode is RestoreExternalBackup, this value is used. Specifies the identity used for storage container authentication. Can be 'SharedAccessSignature' or 'ManagedIdentity'; if not specified 'SharedAccessSignature' is assumed.
storageContainerSasTokenstringConditional. If createMode is RestoreExternalBackup and storageContainerIdentity is not ManagedIdentity, this value is required. Specifies the storage container sas token.
storageContainerUristringConditional. If createMode is RestoreExternalBackup, this value is required. Specifies the uri of the storage container where backups for this restore are stored.
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
tagsobjectResource tags.
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectresource_group_name, managed_instance_name, database_name, subscription_idGets a managed database.
list_by_instanceselectresource_group_name, managed_instance_name, subscription_idGets a list of managed databases.
create_or_updateinsertresource_group_name, managed_instance_name, database_name, subscription_id, locationCreates a new database or updates an existing database.
updateupdateresource_group_name, managed_instance_name, database_name, subscription_idUpdates an existing database.
create_or_updatereplaceresource_group_name, managed_instance_name, database_name, subscription_id, locationCreates a new database or updates an existing database.
deletedeleteresource_group_name, managed_instance_name, database_name, subscription_idDeletes a managed database.
list_inaccessible_by_instanceexecresource_group_name, managed_instance_name, subscription_idGets a list of inaccessible managed databases in a managed instance.
cancel_moveexecresource_group_name, managed_instance_name, database_name, subscription_id, destinationManagedDatabaseIdCancels a managed database move operation.
complete_moveexecresource_group_name, managed_instance_name, database_name, subscription_id, destinationManagedDatabaseIdCompletes a managed database move operation.
complete_restoreexecresource_group_name, managed_instance_name, database_name, subscription_id, lastBackupNameCompletes the restore operation on a managed database.
reevaluate_inaccessible_database_stateexecresource_group_name, managed_instance_name, database_name, subscription_idReevaluates the inaccessibility state of a managed database.
start_moveexecresource_group_name, managed_instance_name, database_name, subscription_id, destinationManagedDatabaseIdStarts a managed database move operation.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
database_namestringThe name of the database. Required.
managed_instance_namestringThe name of the managed instance. Required.
resource_group_namestringThe name of the resource group. The name is case insensitive. Required.
subscription_idstring

SELECT examples

Gets a managed database.

SELECT
id,
name,
autoCompleteRestore,
catalogCollation,
collation,
createMode,
creationDate,
crossSubscriptionRestorableDroppedDatabaseId,
crossSubscriptionSourceDatabaseId,
crossSubscriptionTargetManagedInstanceId,
defaultSecondaryLocation,
earliestRestorePoint,
extendedAccessibilityInfo,
failoverGroupId,
isLedgerOn,
lastBackupName,
location,
longTermRetentionBackupResourceId,
recoverableDatabaseId,
restorableDroppedDatabaseId,
restorePointInTime,
sourceDatabaseId,
status,
storageContainerIdentity,
storageContainerSasToken,
storageContainerUri,
systemData,
tags,
type
FROM azure.sql.managed_databases
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND managed_instance_name = '{{ managed_instance_name }}' -- required
AND database_name = '{{ database_name }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;

INSERT examples

Creates a new database or updates an existing database.

INSERT INTO azure.sql.managed_databases (
tags,
location,
properties,
resource_group_name,
managed_instance_name,
database_name,
subscription_id
)
SELECT
'{{ tags }}',
'{{ location }}' /* required */,
'{{ properties }}',
'{{ resource_group_name }}',
'{{ managed_instance_name }}',
'{{ database_name }}',
'{{ subscription_id }}'
RETURNING
id,
name,
location,
properties,
systemData,
tags,
type
;

UPDATE examples

Updates an existing database.

UPDATE azure.sql.managed_databases
SET
properties = '{{ properties }}',
tags = '{{ tags }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND managed_instance_name = '{{ managed_instance_name }}' --required
AND database_name = '{{ database_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
RETURNING
id,
name,
location,
properties,
systemData,
tags,
type;

REPLACE examples

Creates a new database or updates an existing database.

REPLACE azure.sql.managed_databases
SET
tags = '{{ tags }}',
location = '{{ location }}',
properties = '{{ properties }}'
WHERE
resource_group_name = '{{ resource_group_name }}' --required
AND managed_instance_name = '{{ managed_instance_name }}' --required
AND database_name = '{{ database_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
AND location = '{{ location }}' --required
RETURNING
id,
name,
location,
properties,
systemData,
tags,
type;

DELETE examples

Deletes a managed database.

DELETE FROM azure.sql.managed_databases
WHERE resource_group_name = '{{ resource_group_name }}' --required
AND managed_instance_name = '{{ managed_instance_name }}' --required
AND database_name = '{{ database_name }}' --required
AND subscription_id = '{{ subscription_id }}' --required
;

Lifecycle Methods

Gets a list of inaccessible managed databases in a managed instance.

EXEC azure.sql.managed_databases.list_inaccessible_by_instance 
@resource_group_name='{{ resource_group_name }}' --required,
@managed_instance_name='{{ managed_instance_name }}' --required,
@subscription_id='{{ subscription_id }}' --required
;