Erstellt eine neue Datenbank oder aktualisiert eine bereits vorhandene Datenbank.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}?api-version=2025-01-01
URI-Parameter
| Name |
In |
Erforderlich |
Typ |
Beschreibung |
|
databaseName
|
path |
True
|
string
|
Der Name der Datenbank.
|
|
managedInstanceName
|
path |
True
|
string
|
Der Name der verwalteten Instanz.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Der Name der Ressourcengruppe. Bei dem Namen wird die Groß-/Kleinschreibung nicht beachtet.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
Die ID des Zielabonnements. Der Wert muss eine UUID sein.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Die API-Version, die für diesen Vorgang verwendet werden soll.
|
Anforderungstext
| Name |
Erforderlich |
Typ |
Beschreibung |
|
location
|
True
|
string
|
Der geografische Standort, an dem sich die Ressource befindet
|
|
properties.autoCompleteRestore
|
|
boolean
|
Gibt an, ob die Wiederherstellung dieser verwalteten Datenbank automatisch abgeschlossen werden soll.
|
|
properties.catalogCollation
|
|
CatalogCollationType
|
Sortierung des Metadatenkatalogs.
|
|
properties.collation
|
|
string
|
Sortierung der verwalteten Datenbank.
|
|
properties.createMode
|
|
ManagedDatabaseCreateMode
|
Verwalteter Datenbankerstellungsmodus. PointInTimeRestore: Erstellen Sie eine Datenbank, indem Sie eine Zeitsicherung einer vorhandenen Datenbank wiederherstellen. SourceDatabaseName, SourceManagedInstanceName und PointInTime müssen angegeben werden. RestoreExternalBackup: Erstellen Sie eine Datenbank, indem Sie aus externen Sicherungsdateien wiederherstellen. Sortierung, StorageContainerUri und StorageContainerSasToken müssen angegeben werden. Wiederherstellung: Erstellt eine Datenbank, indem eine georeplizierte Sicherung wiederhergestellt wird. RecoverableDatabaseId muss als wiederherstellbare Datenbankressourcen-ID angegeben werden, um wiederherzustellen. RestoreLongTermRetentionBackup: Erstellen Einer Datenbank durch Wiederherstellen einer langfristigen Aufbewahrungssicherung (longTermRetentionBackupResourceId erforderlich).
|
|
properties.crossSubscriptionRestorableDroppedDatabaseId
|
|
string
|
Die wiederherstellbare, abonnementübergreifende Datenbankressourcen-ID, die beim Erstellen dieser Datenbank wiederhergestellt werden soll.
|
|
properties.crossSubscriptionSourceDatabaseId
|
|
string
|
Der Ressourcenbezeichner der abonnementübergreifenden Quelldatenbank, die dem Erstellungsvorgang dieser Datenbank zugeordnet ist.
|
|
properties.crossSubscriptionTargetManagedInstanceId
|
|
string
|
Ziel-ID für verwaltete Instanzen, die bei der Wiederherstellung des Abonnements verwendet werden.
|
|
properties.isLedgerOn
|
|
boolean
|
Ob es sich bei dieser Datenbank um eine Ledgerdatenbank handelt, was bedeutet, dass alle Tabellen in der Datenbank Sachtabellen sind. Hinweis: Der Wert dieser Eigenschaft kann nicht geändert werden, nachdem die Datenbank erstellt wurde.
|
|
properties.lastBackupName
|
|
string
|
Letzter Sicherungsdateiname für die Wiederherstellung dieser verwalteten Datenbank.
|
|
properties.longTermRetentionBackupResourceId
|
|
string
|
Der Name der Langfristigen Aufbewahrungssicherung, die für die Wiederherstellung dieser verwalteten Datenbank verwendet werden soll.
|
|
properties.recoverableDatabaseId
|
|
string
|
Der Ressourcenbezeichner der wiederherstellbaren Datenbank, die dem Erstellungsvorgang dieser Datenbank zugeordnet ist.
|
|
properties.restorableDroppedDatabaseId
|
|
string
|
Die wiederherstellbare verworfene Datenbankressourcen-ID, die beim Erstellen dieser Datenbank wiederhergestellt werden soll.
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
Conditional. Wenn createMode PointInTimeRestore ist, ist dieser Wert erforderlich. Gibt den Zeitpunkt (ISO8601 Format) der Quelldatenbank an, die wiederhergestellt wird, um die neue Datenbank zu erstellen.
|
|
properties.sourceDatabaseId
|
|
string
|
Der Ressourcenbezeichner der Quelldatenbank, die dem Erstellungsvorgang dieser Datenbank zugeordnet ist.
|
|
properties.storageContainerIdentity
|
|
string
|
Conditional. Wenn createMode "RestoreExternalBackup" ist, wird dieser Wert verwendet. Gibt die Identität an, die für die Speichercontainerauthentifizierung verwendet wird. Kann "SharedAccessSignature" oder "ManagedIdentity" sein; wenn "SharedAccessSignature" nicht angegeben wird, wird angenommen.
|
|
properties.storageContainerSasToken
|
|
string
|
Conditional. Wenn createMode "RestoreExternalBackup" ist und "storageContainerIdentity" nicht "ManagedIdentity" ist, ist dieser Wert erforderlich. Gibt das Sas-Token des Speichercontainers an.
|
|
properties.storageContainerUri
|
|
string
|
Conditional. Wenn createMode "RestoreExternalBackup" ist, ist dieser Wert erforderlich. Gibt den URI des Speichercontainers an, in dem Sicherungen für diese Wiederherstellung gespeichert werden.
|
|
tags
|
|
object
|
Ressourcentags.
|
Antworten
| Name |
Typ |
Beschreibung |
|
200 OK
|
ManagedDatabase
|
Die Aktualisierung der Ressource 'ManagedDatabase' war erfolgreich
|
|
201 Created
|
ManagedDatabase
|
Resource 'ManagedDatabase'-Erstellungsoperation erfolgreich
Header
- Location: string
- Retry-After: integer
|
|
202 Accepted
|
|
Ressourcenvorgang akzeptiert.
Header
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Unerwartete Fehlerantwort.
|
Sicherheit
azure_auth
Azure Active Directory OAuth2 Flow.
Typ:
oauth2
Ablauf:
implicit
Autorisierungs-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiche
| Name |
Beschreibung |
|
user_impersonation
|
Identitätswechsel ihres Benutzerkontos
|
Beispiele
Creates a new managed database by restoring from an external backup
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"autoCompleteRestore": true,
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "RestoreExternalBackup",
"lastBackupName": "last_backup_name",
"storageContainerSasToken": "sv=2015-12-11&sr=c&sp=rl&sig=1234",
"storageContainerUri": "https://myaccountname.blob.core.windows.net/backups"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_restore_external_backup.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={
"location": "southeastasia",
"properties": {
"autoCompleteRestore": True,
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "RestoreExternalBackup",
"lastBackupName": "last_backup_name",
"storageContainerSasToken": "sv=2015-12-11&sr=c&sp=rl&sig=1234",
"storageContainerUri": "https://myaccountname.blob.core.windows.net/backups",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreateRestoreExternalBackup.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreateRestoreExternalBackup.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
Collation = "SQL_Latin1_General_CP1_CI_AS",
CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup,
StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"),
StorageContainerSasToken = "sv=2015-12-11&sr=c&sp=rl&sig=1234",
AllowAutoCompleteRestore = true,
LastBackupName = "last_backup_name",
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Creates a new managed database by restoring from an external backup using managed identity
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"autoCompleteRestore": true,
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "RestoreExternalBackup",
"lastBackupName": "last_backup_name",
"storageContainerIdentity": "ManagedIdentity",
"storageContainerUri": "https://myaccountname.blob.core.windows.net/backups"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_restore_external_backup_managed_identity.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={
"location": "southeastasia",
"properties": {
"autoCompleteRestore": True,
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "RestoreExternalBackup",
"lastBackupName": "last_backup_name",
"storageContainerIdentity": "ManagedIdentity",
"storageContainerUri": "https://myaccountname.blob.core.windows.net/backups",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreateRestoreExternalBackupManagedIdentity.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreateRestoreExternalBackupManagedIdentity.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
Collation = "SQL_Latin1_General_CP1_CI_AS",
CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup,
StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"),
StorageContainerIdentity = "ManagedIdentity",
AllowAutoCompleteRestore = true,
LastBackupName = "last_backup_name",
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Creates a new managed database from restoring a geo-replicated backup
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/server1/databases/testdb_recovered?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "Recovery",
"recoverableDatabaseId": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-WestEurope/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_recovery.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="server1",
database_name="testdb_recovered",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "Recovery",
"recoverableDatabaseId": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-WestEurope/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreateRecovery.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreateRecovery.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "server1";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "testdb_recovered";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
CreateMode = ManagedDatabaseCreateMode.Recovery,
RecoverableDatabaseId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-WestEurope/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb"),
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb_recovered",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/server1/recoverableDatabases/testdb_recovered",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2018-11-07T04:41:33.937Z",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb_recovered",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb_recovered",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2018-11-07T04:41:33.937Z",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Creates a new managed database from restoring a long term retention backup
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "RestoreExternalBackup",
"storageContainerSasToken": "sv=2015-12-11&sr=c&sp=rl&sig=1234",
"storageContainerUri": "https://myaccountname.blob.core.windows.net/backups"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_restore_ltr_backup.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "RestoreExternalBackup",
"storageContainerSasToken": "sv=2015-12-11&sr=c&sp=rl&sig=1234",
"storageContainerUri": "https://myaccountname.blob.core.windows.net/backups",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreateRestoreLtrBackup.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreateRestoreLtrBackup.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
Collation = "SQL_Latin1_General_CP1_CI_AS",
CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup,
StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"),
StorageContainerSasToken = "sv=2015-12-11&sr=c&sp=rl&sig=1234",
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Creates a new managed database using cross subscription point in time restore
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"crossSubscriptionSourceDatabaseId": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr2/databases/testdb",
"crossSubscriptionTargetManagedInstanceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr",
"restorePointInTime": "2017-07-14T05:35:31.503Z"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_cross_subscription_point_in_time_restore.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"crossSubscriptionSourceDatabaseId": "/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr2/databases/testdb",
"crossSubscriptionTargetManagedInstanceId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr",
"restorePointInTime": "2017-07-14T05:35:31.503Z",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreateCrossSubscriptionPointInTimeRestore.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreateCrossSubscriptionPointInTimeRestore.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
RestorePointInTime = DateTimeOffset.Parse("2017-07-14T05:35:31.503Z"),
CreateMode = ManagedDatabaseCreateMode.PointInTimeRestore,
CrossSubscriptionSourceDatabaseId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr2/databases/testdb"),
CrossSubscriptionTargetManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr"),
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Creates a new managed database using point in time restore
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2017-07-14T05:35:31.503Z",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_point_in_time_restore.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2017-07-14T05:35:31.503Z",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreatePointInTimeRestore.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreatePointInTimeRestore.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
RestorePointInTime = DateTimeOffset.Parse("2017-07-14T05:35:31.503Z"),
CreateMode = ManagedDatabaseCreateMode.PointInTimeRestore,
SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb"),
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Creates a new managed database with ledger on.
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"isLedgerOn": true
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_managed_database_ledger.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={"location": "southeastasia", "properties": {"isLedgerOn": True}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateManagedDatabaseLedger.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/CreateManagedDatabaseLedger.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
IsLedgerOn = true,
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testcl/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": true,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testcl/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": true,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Location: https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/operationStatus/default/operationId/00000000-0000-0000-0000-000000000000?api-version=2022-08-01
Creates a new managed database with maximal properties
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia",
"tags": {
"tagKey1": "TagValue1"
}
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_max.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={"location": "southeastasia", "tags": {"tagKey1": "TagValue1"}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreateMax.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreateMax.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"))
{
Tags =
{
["tagKey1"] = "TagValue1"
},
};
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
},
"tags": {
"tagKey1": "TagValue1"
}
}
Location: https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/operationStatus/default/operationId/00000000-0000-0000-0000-000000000000?api-version=2017-03-01
Creates a new managed database with minimal properties
Beispielanforderung
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/managedInstance/databases/managedDatabase?api-version=2025-01-01
{
"location": "southeastasia"
}
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python managed_database_create_min.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SqlManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.managed_databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
managed_instance_name="managedInstance",
database_name="managedDatabase",
parameters={"location": "southeastasia"},
).result()
print(response)
# x-ms-original-file: 2025-01-01/ManagedDatabaseCreateMin.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Sql.Models;
using Azure.ResourceManager.Sql;
// Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/SQL/stable/2025-01-01/examples/ManagedDatabaseCreateMin.json
// this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ManagedInstanceResource created on azure
// for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string managedInstanceName = "managedInstance";
ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName);
ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId);
// get the collection of this ManagedDatabaseResource
ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases();
// invoke the operation
string databaseName = "managedDatabase";
ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia"));
ArmOperation<ManagedDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
ManagedDatabaseResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ManagedDatabaseData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"name": "testdb1",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb1",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
}
}
{
"name": "testdb2",
"type": "Microsoft.Sql/managedInstances/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb2",
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"defaultSecondaryLocation": "North Europe",
"isLedgerOn": false,
"status": "Online"
}
}
Location: https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/operationStatus/default/operationId/00000000-0000-0000-0000-000000000000?api-version=2017-03-01
Definitionen
| Name |
Beschreibung |
|
CatalogCollationType
|
Sortierung des Metadatenkatalogs.
|
|
createdByType
|
Der Identitätstyp, der die Ressource erstellt hat.
|
|
ErrorAdditionalInfo
|
Der Ressourcenverwaltungsfehler zusätzliche Informationen.
|
|
ErrorDetail
|
Das Fehlerdetails.
|
|
ErrorResponse
|
Fehlerantwort
|
|
InaccessibilityReason
|
Ursache Art. Zulässige Werte sind "TransparentDataEncryption", "DatabaseReplication" und "Unknown".
|
|
ManagedDatabase
|
Eine verwaltete Datenbankressource.
|
|
ManagedDatabaseCreateMode
|
Verwalteter Datenbankerstellungsmodus. PointInTimeRestore: Erstellen Sie eine Datenbank, indem Sie eine Zeitsicherung einer vorhandenen Datenbank wiederherstellen. SourceDatabaseName, SourceManagedInstanceName und PointInTime müssen angegeben werden. RestoreExternalBackup: Erstellen Sie eine Datenbank, indem Sie aus externen Sicherungsdateien wiederherstellen. Sortierung, StorageContainerUri und StorageContainerSasToken müssen angegeben werden. Wiederherstellung: Erstellt eine Datenbank, indem eine georeplizierte Sicherung wiederhergestellt wird. RecoverableDatabaseId muss als wiederherstellbare Datenbankressourcen-ID angegeben werden, um wiederherzustellen. RestoreLongTermRetentionBackup: Erstellen Einer Datenbank durch Wiederherstellen einer langfristigen Aufbewahrungssicherung (longTermRetentionBackupResourceId erforderlich).
|
|
ManagedDatabaseExtendedAccessibilityInfo
|
Informationen zur erweiterten Barrierefreiheit verwalteter Datenbanken
|
|
ManagedDatabaseStatus
|
Status der Datenbank.
|
|
systemData
|
Metadaten zur Erstellung und letzten Änderung der Ressource.
|
CatalogCollationType
Enumeration
Sortierung des Metadatenkatalogs.
| Wert |
Beschreibung |
|
DATABASE_DEFAULT
|
DATABASE_DEFAULT
|
|
SQL_Latin1_General_CP1_CI_AS
|
SQL_Latin1_General_CP1_CI_AS
|
createdByType
Enumeration
Der Identitätstyp, der die Ressource erstellt hat.
| Wert |
Beschreibung |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Objekt
Der Ressourcenverwaltungsfehler zusätzliche Informationen.
| Name |
Typ |
Beschreibung |
|
info
|
object
|
Die zusätzlichen Informationen.
|
|
type
|
string
|
Der zusätzliche Informationstyp.
|
ErrorDetail
Objekt
Das Fehlerdetails.
| Name |
Typ |
Beschreibung |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Die zusätzlichen Informationen des Fehlers.
|
|
code
|
string
|
Der Fehlercode.
|
|
details
|
ErrorDetail[]
|
Die Fehlerdetails.
|
|
message
|
string
|
Die Fehlermeldung.
|
|
target
|
string
|
Das Fehlerziel.
|
ErrorResponse
Objekt
Fehlerantwort
| Name |
Typ |
Beschreibung |
|
error
|
ErrorDetail
|
Das Fehlerobjekt.
|
InaccessibilityReason
Enumeration
Ursache Art. Zulässige Werte sind "TransparentDataEncryption", "DatabaseReplication" und "Unknown".
| Wert |
Beschreibung |
|
Unknown
|
Unbekannt
|
|
TransparentDataEncryption
|
TransparentDataEncryption
|
|
DatabaseReplication
|
DatenbankReplikation
|
ManagedDatabase
Objekt
Eine verwaltete Datenbankressource.
| Name |
Typ |
Beschreibung |
|
id
|
string
(arm-id)
|
Vollqualifizierte Ressourcen-ID für die Ressource. Z. B. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
location
|
string
|
Der geografische Standort, an dem sich die Ressource befindet
|
|
name
|
string
|
Der Name der Ressource
|
|
properties.autoCompleteRestore
|
boolean
|
Gibt an, ob die Wiederherstellung dieser verwalteten Datenbank automatisch abgeschlossen werden soll.
|
|
properties.catalogCollation
|
CatalogCollationType
|
Sortierung des Metadatenkatalogs.
|
|
properties.collation
|
string
|
Sortierung der verwalteten Datenbank.
|
|
properties.createMode
|
ManagedDatabaseCreateMode
|
Verwalteter Datenbankerstellungsmodus. PointInTimeRestore: Erstellen Sie eine Datenbank, indem Sie eine Zeitsicherung einer vorhandenen Datenbank wiederherstellen. SourceDatabaseName, SourceManagedInstanceName und PointInTime müssen angegeben werden. RestoreExternalBackup: Erstellen Sie eine Datenbank, indem Sie aus externen Sicherungsdateien wiederherstellen. Sortierung, StorageContainerUri und StorageContainerSasToken müssen angegeben werden. Wiederherstellung: Erstellt eine Datenbank, indem eine georeplizierte Sicherung wiederhergestellt wird. RecoverableDatabaseId muss als wiederherstellbare Datenbankressourcen-ID angegeben werden, um wiederherzustellen. RestoreLongTermRetentionBackup: Erstellen Einer Datenbank durch Wiederherstellen einer langfristigen Aufbewahrungssicherung (longTermRetentionBackupResourceId erforderlich).
|
|
properties.creationDate
|
string
(date-time)
|
Erstellungsdatum der Datenbank.
|
|
properties.crossSubscriptionRestorableDroppedDatabaseId
|
string
|
Die wiederherstellbare, abonnementübergreifende Datenbankressourcen-ID, die beim Erstellen dieser Datenbank wiederhergestellt werden soll.
|
|
properties.crossSubscriptionSourceDatabaseId
|
string
|
Der Ressourcenbezeichner der abonnementübergreifenden Quelldatenbank, die dem Erstellungsvorgang dieser Datenbank zugeordnet ist.
|
|
properties.crossSubscriptionTargetManagedInstanceId
|
string
|
Ziel-ID für verwaltete Instanzen, die bei der Wiederherstellung des Abonnements verwendet werden.
|
|
properties.defaultSecondaryLocation
|
string
|
Geo-gekoppelte Region.
|
|
properties.earliestRestorePoint
|
string
(date-time)
|
Frühester Wiederherstellungspunkt für punkt in der Zeitwiederherstellung.
|
|
properties.extendedAccessibilityInfo
|
ManagedDatabaseExtendedAccessibilityInfo
|
Zusätzliche Informationen zur Beobachtbarkeit und Problembehandlung für Datenbanken mit dem Status "Nicht zugänglich".
|
|
properties.failoverGroupId
|
string
|
Ressourcenbezeichner der Instanzfailovergruppe, zu der diese verwaltete Datenbank gehört.
|
|
properties.isLedgerOn
|
boolean
|
Ob es sich bei dieser Datenbank um eine Ledgerdatenbank handelt, was bedeutet, dass alle Tabellen in der Datenbank Sachtabellen sind. Hinweis: Der Wert dieser Eigenschaft kann nicht geändert werden, nachdem die Datenbank erstellt wurde.
|
|
properties.lastBackupName
|
string
|
Letzter Sicherungsdateiname für die Wiederherstellung dieser verwalteten Datenbank.
|
|
properties.longTermRetentionBackupResourceId
|
string
|
Der Name der Langfristigen Aufbewahrungssicherung, die für die Wiederherstellung dieser verwalteten Datenbank verwendet werden soll.
|
|
properties.recoverableDatabaseId
|
string
|
Der Ressourcenbezeichner der wiederherstellbaren Datenbank, die dem Erstellungsvorgang dieser Datenbank zugeordnet ist.
|
|
properties.restorableDroppedDatabaseId
|
string
|
Die wiederherstellbare verworfene Datenbankressourcen-ID, die beim Erstellen dieser Datenbank wiederhergestellt werden soll.
|
|
properties.restorePointInTime
|
string
(date-time)
|
Conditional. Wenn createMode PointInTimeRestore ist, ist dieser Wert erforderlich. Gibt den Zeitpunkt (ISO8601 Format) der Quelldatenbank an, die wiederhergestellt wird, um die neue Datenbank zu erstellen.
|
|
properties.sourceDatabaseId
|
string
|
Der Ressourcenbezeichner der Quelldatenbank, die dem Erstellungsvorgang dieser Datenbank zugeordnet ist.
|
|
properties.status
|
ManagedDatabaseStatus
|
Status der Datenbank.
|
|
properties.storageContainerIdentity
|
string
|
Conditional. Wenn createMode "RestoreExternalBackup" ist, wird dieser Wert verwendet. Gibt die Identität an, die für die Speichercontainerauthentifizierung verwendet wird. Kann "SharedAccessSignature" oder "ManagedIdentity" sein; wenn "SharedAccessSignature" nicht angegeben wird, wird angenommen.
|
|
properties.storageContainerSasToken
|
string
|
Conditional. Wenn createMode "RestoreExternalBackup" ist und "storageContainerIdentity" nicht "ManagedIdentity" ist, ist dieser Wert erforderlich. Gibt das Sas-Token des Speichercontainers an.
|
|
properties.storageContainerUri
|
string
|
Conditional. Wenn createMode "RestoreExternalBackup" ist, ist dieser Wert erforderlich. Gibt den URI des Speichercontainers an, in dem Sicherungen für diese Wiederherstellung gespeichert werden.
|
|
systemData
|
systemData
|
Azure Resource Manager-Metadaten, die createdBy und modifiedBy-Informationen enthalten.
|
|
tags
|
object
|
Ressourcentags.
|
|
type
|
string
|
Der Typ der Ressource. Zum Beispiel "Microsoft. Compute/virtualMachines" oder "Microsoft. Speicher/Speicherkonten"
|
ManagedDatabaseCreateMode
Enumeration
Verwalteter Datenbankerstellungsmodus. PointInTimeRestore: Erstellen Sie eine Datenbank, indem Sie eine Zeitsicherung einer vorhandenen Datenbank wiederherstellen. SourceDatabaseName, SourceManagedInstanceName und PointInTime müssen angegeben werden. RestoreExternalBackup: Erstellen Sie eine Datenbank, indem Sie aus externen Sicherungsdateien wiederherstellen. Sortierung, StorageContainerUri und StorageContainerSasToken müssen angegeben werden. Wiederherstellung: Erstellt eine Datenbank, indem eine georeplizierte Sicherung wiederhergestellt wird. RecoverableDatabaseId muss als wiederherstellbare Datenbankressourcen-ID angegeben werden, um wiederherzustellen. RestoreLongTermRetentionBackup: Erstellen Einer Datenbank durch Wiederherstellen einer langfristigen Aufbewahrungssicherung (longTermRetentionBackupResourceId erforderlich).
| Wert |
Beschreibung |
|
Default
|
Vorgabe
|
|
RestoreExternalBackup
|
RestoreExternalBackup
|
|
PointInTimeRestore
|
PointInTimeRestore
|
|
Recovery
|
Wiederherstellung
|
|
RestoreLongTermRetentionBackup
|
RestoreLongTermRetentionBackup
|
ManagedDatabaseExtendedAccessibilityInfo
Objekt
Informationen zur erweiterten Barrierefreiheit verwalteter Datenbanken
| Name |
Typ |
Beschreibung |
|
inaccessibilityReasonDescription
|
string
|
Erklärung der Ursache und Maßnahmen zur Risikominderung.
|
|
inaccessibilityReasonErrorCode
|
string
|
Der SQL Server-Fehlercode ist mit der Ursache der Unzugänglichkeit verbunden.
|
|
inaccessibilityReasonKind
|
InaccessibilityReason
|
Ursache Art. Zulässige Werte sind "TransparentDataEncryption", "DatabaseReplication" und "Unknown".
|
|
inaccessibilityReasonTdeKeyUri
|
string
|
Für die Ursachenart "TransparentDataEncryption" wird der CMK-URI verwendet.
|
ManagedDatabaseStatus
Enumeration
Status der Datenbank.
| Wert |
Beschreibung |
|
Online
|
Online
|
|
Offline
|
Offline
|
|
Shutdown
|
Herunterfahren
|
|
Creating
|
Erstellen
|
|
Inaccessible
|
Unzugänglich
|
|
Restoring
|
Wiederherstellen
|
|
Updating
|
Aktualisieren
|
|
Stopping
|
Anhalten
|
|
Stopped
|
Angehalten
|
|
Starting
|
Wird gestartet
|
|
DbMoving
|
DbMoving
|
|
DbCopying
|
DbCopying
|
systemData
Objekt
Metadaten zur Erstellung und letzten Änderung der Ressource.
| Name |
Typ |
Beschreibung |
|
createdAt
|
string
(date-time)
|
Der Zeitstempel der Ressourcenerstellung (UTC).
|
|
createdBy
|
string
|
Die Identität, die die Ressource erstellt hat.
|
|
createdByType
|
createdByType
|
Der Identitätstyp, der die Ressource erstellt hat.
|
|
lastModifiedAt
|
string
(date-time)
|
Der Zeitstempel der letzten Änderung der Ressource (UTC)
|
|
lastModifiedBy
|
string
|
Die Identität, die die Ressource zuletzt geändert hat.
|
|
lastModifiedByType
|
createdByType
|
Der Identitätstyp, der die Ressource zuletzt geändert hat.
|