Crea un nuovo database o ne aggiorna uno esistente.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}?api-version=2025-01-01
Parametri dell'URI
| Nome |
In |
Necessario |
Tipo |
Descrizione |
|
databaseName
|
path |
True
|
string
|
Nome del database.
|
|
managedInstanceName
|
path |
True
|
string
|
Nome dell'istanza gestita.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Nome del gruppo di risorse. Il nome è insensibile alle maiuscole e minuscole.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
ID della sottoscrizione di destinazione. Il valore deve essere un UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Versione dell'API da usare per questa operazione.
|
Corpo della richiesta
| Nome |
Necessario |
Tipo |
Descrizione |
|
location
|
True
|
string
|
Posizione geografica in cui risiede la risorsa
|
|
properties.autoCompleteRestore
|
|
boolean
|
Indica se completare automaticamente il ripristino di questo database gestito.
|
|
properties.catalogCollation
|
|
CatalogCollationType
|
Regole di confronto del catalogo di metadati.
|
|
properties.collation
|
|
string
|
Regole di confronto del database gestito.
|
|
properties.createMode
|
|
ManagedDatabaseCreateMode
|
Modalità di creazione del database gestito. PointInTimeRestore: creare un database ripristinando un backup temporizzato di un database esistente. È necessario specificare SourceDatabaseName, SourceManagedInstanceName e PointInTime. RestoreExternalBackup: creare un database ripristinando da file di backup esterni. È necessario specificare regole di confronto, StorageContainerUri e StorageContainerSasToken. Ripristino: crea un database ripristinando un backup con replica geografica. RecoverableDatabaseId deve essere specificato come ID risorsa di database ripristinabile da ripristinare. RestoreLongTermRetentionBackup: creare un database ripristinando da un backup di conservazione a lungo termine (longTermRetentionBackupResourceId obbligatorio).
|
|
properties.crossSubscriptionRestorableDroppedDatabaseId
|
|
string
|
L'ID risorsa del database rimosso tra sottoscrizioni ripristinabili per il ripristino durante la creazione di questo database.
|
|
properties.crossSubscriptionSourceDatabaseId
|
|
string
|
Identificatore della risorsa del database di origine tra sottoscrizioni associato all'operazione di creazione del database.
|
|
properties.crossSubscriptionTargetManagedInstanceId
|
|
string
|
ID istanza gestita di destinazione usato nel ripristino tra sottoscrizioni.
|
|
properties.isLedgerOn
|
|
boolean
|
Indipendentemente dal fatto che questo database sia un database libro mastro, ovvero tutte le tabelle del database sono tabelle libro mastro. Nota: il valore di questa proprietà non può essere modificato dopo la creazione del database.
|
|
properties.lastBackupName
|
|
string
|
Cognome del file di backup per il ripristino di questo database gestito.
|
|
properties.longTermRetentionBackupResourceId
|
|
string
|
Nome del backup di conservazione a lungo termine da usare per il ripristino di questo database gestito.
|
|
properties.recoverableDatabaseId
|
|
string
|
Identificatore della risorsa del database ripristinabile associato all'operazione di creazione del database.
|
|
properties.restorableDroppedDatabaseId
|
|
string
|
ID risorsa del database eliminato ripristinabile da ripristinare durante la creazione del database.
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
Conditional. Se createMode è PointInTimeRestore, questo valore è obbligatorio. Specifica il punto nel tempo (formato ISO8601) del database di origine che verrà ripristinato per creare il nuovo database.
|
|
properties.sourceDatabaseId
|
|
string
|
Identificatore della risorsa del database di origine associato all'operazione di creazione del database.
|
|
properties.storageContainerIdentity
|
|
string
|
Conditional. Se createMode è RestoreExternalBackup, questo valore viene usato. Specifica l'identità usata per l'autenticazione del contenitore di archiviazione. Può essere 'SharedAccessSignature' o 'ManagedIdentity'; se non è specificato 'SharedAccessSignature' viene utilizzato.
|
|
properties.storageContainerSasToken
|
|
string
|
Conditional. Se createMode è RestoreExternalBackup e storageContainerIdentity non è ManagedIdentity, questo valore è obbligatorio. Specifica il token di firma di accesso condiviso del contenitore di archiviazione.
|
|
properties.storageContainerUri
|
|
string
|
Conditional. Se createMode è RestoreExternalBackup, questo valore è obbligatorio. Specifica l'URI del contenitore di archiviazione in cui vengono archiviati i backup per questo ripristino.
|
|
tags
|
|
object
|
Tag di risorsa.
|
Risposte
| Nome |
Tipo |
Descrizione |
|
200 OK
|
ManagedDatabase
|
Risorsa 'ManagedDatabase' con successo
|
|
201 Created
|
ManagedDatabase
|
Risorsa 'ManagedDatabase' crea operazione con successo
Intestazioni
- Location: string
- Retry-After: integer
|
|
202 Accepted
|
|
Operazione sulle risorse accettata.
Intestazioni
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Risposta di errore imprevista.
|
Sicurezza
azure_auth
Azure Active Directory OAuth2 Flow.
Tipo:
oauth2
Flow:
implicit
URL di autorizzazione:
https://login.microsoftonline.com/common/oauth2/authorize
Ambiti
| Nome |
Descrizione |
|
user_impersonation
|
rappresentare l'account utente
|
Esempio
Creates a new managed database by restoring from an external backup
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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.
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Esempio di richiesta
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
Risposta di esempio
{
"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
Definizioni
| Nome |
Descrizione |
|
CatalogCollationType
|
Regole di confronto del catalogo di metadati.
|
|
createdByType
|
Tipo di identità che ha creato la risorsa.
|
|
ErrorAdditionalInfo
|
Informazioni aggiuntive sull'errore di gestione delle risorse.
|
|
ErrorDetail
|
Dettagli dell'errore.
|
|
ErrorResponse
|
Risposta di errore
|
|
InaccessibilityReason
|
Tipo di causa principale. I valori consentiti sono "TransparentDataEncryption", "DatabaseReplication" e "Unknown".
|
|
ManagedDatabase
|
Una risorsa di database gestita.
|
|
ManagedDatabaseCreateMode
|
Modalità di creazione del database gestito. PointInTimeRestore: creare un database ripristinando un backup temporizzato di un database esistente. È necessario specificare SourceDatabaseName, SourceManagedInstanceName e PointInTime. RestoreExternalBackup: creare un database ripristinando da file di backup esterni. È necessario specificare regole di confronto, StorageContainerUri e StorageContainerSasToken. Ripristino: crea un database ripristinando un backup con replica geografica. RecoverableDatabaseId deve essere specificato come ID risorsa di database ripristinabile da ripristinare. RestoreLongTermRetentionBackup: creare un database ripristinando da un backup di conservazione a lungo termine (longTermRetentionBackupResourceId obbligatorio).
|
|
ManagedDatabaseExtendedAccessibilityInfo
|
Informazioni sull'accessibilità estesa del database gestito
|
|
ManagedDatabaseStatus
|
Stato del database.
|
|
systemData
|
Metadati relativi alla creazione e all'ultima modifica della risorsa.
|
CatalogCollationType
Enumerazione
Regole di confronto del catalogo di metadati.
| Valore |
Descrizione |
|
DATABASE_DEFAULT
|
DATABASE_DEFAULT
|
|
SQL_Latin1_General_CP1_CI_AS
|
SQL_Latin1_General_CP1_CI_AS
|
createdByType
Enumerazione
Tipo di identità che ha creato la risorsa.
| Valore |
Descrizione |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Oggetto
Informazioni aggiuntive sull'errore di gestione delle risorse.
| Nome |
Tipo |
Descrizione |
|
info
|
object
|
Informazioni aggiuntive.
|
|
type
|
string
|
Tipo di informazioni aggiuntive.
|
ErrorDetail
Oggetto
Dettagli dell'errore.
| Nome |
Tipo |
Descrizione |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Informazioni aggiuntive sull'errore.
|
|
code
|
string
|
Codice di errore.
|
|
details
|
ErrorDetail[]
|
Dettagli dell'errore.
|
|
message
|
string
|
Messaggio di errore.
|
|
target
|
string
|
Destinazione dell'errore.
|
ErrorResponse
Oggetto
Risposta di errore
InaccessibilityReason
Enumerazione
Tipo di causa principale. I valori consentiti sono "TransparentDataEncryption", "DatabaseReplication" e "Unknown".
| Valore |
Descrizione |
|
Unknown
|
Sconosciuto
|
|
TransparentDataEncryption
|
Crittografia TransparentData
|
|
DatabaseReplication
|
Replicazione del database
|
ManagedDatabase
Oggetto
Una risorsa di database gestita.
| Nome |
Tipo |
Descrizione |
|
id
|
string
(arm-id)
|
ID risorsa completo per la risorsa. Ad esempio, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
location
|
string
|
Posizione geografica in cui risiede la risorsa
|
|
name
|
string
|
Nome della risorsa
|
|
properties.autoCompleteRestore
|
boolean
|
Indica se completare automaticamente il ripristino di questo database gestito.
|
|
properties.catalogCollation
|
CatalogCollationType
|
Regole di confronto del catalogo di metadati.
|
|
properties.collation
|
string
|
Regole di confronto del database gestito.
|
|
properties.createMode
|
ManagedDatabaseCreateMode
|
Modalità di creazione del database gestito. PointInTimeRestore: creare un database ripristinando un backup temporizzato di un database esistente. È necessario specificare SourceDatabaseName, SourceManagedInstanceName e PointInTime. RestoreExternalBackup: creare un database ripristinando da file di backup esterni. È necessario specificare regole di confronto, StorageContainerUri e StorageContainerSasToken. Ripristino: crea un database ripristinando un backup con replica geografica. RecoverableDatabaseId deve essere specificato come ID risorsa di database ripristinabile da ripristinare. RestoreLongTermRetentionBackup: creare un database ripristinando da un backup di conservazione a lungo termine (longTermRetentionBackupResourceId obbligatorio).
|
|
properties.creationDate
|
string
(date-time)
|
Data di creazione del database.
|
|
properties.crossSubscriptionRestorableDroppedDatabaseId
|
string
|
L'ID risorsa del database rimosso tra sottoscrizioni ripristinabili per il ripristino durante la creazione di questo database.
|
|
properties.crossSubscriptionSourceDatabaseId
|
string
|
Identificatore della risorsa del database di origine tra sottoscrizioni associato all'operazione di creazione del database.
|
|
properties.crossSubscriptionTargetManagedInstanceId
|
string
|
ID istanza gestita di destinazione usato nel ripristino tra sottoscrizioni.
|
|
properties.defaultSecondaryLocation
|
string
|
Area geografica associata.
|
|
properties.earliestRestorePoint
|
string
(date-time)
|
Punto di ripristino meno recente nel tempo per il ripristino temporizzato.
|
|
properties.extendedAccessibilityInfo
|
ManagedDatabaseExtendedAccessibilityInfo
|
Ulteriori informazioni sull'osservabilità e sulla risoluzione dei problemi per i database in stato "Inaccessibile".
|
|
properties.failoverGroupId
|
string
|
Identificatore di risorsa gruppo di failover dell'istanza a cui appartiene il database gestito.
|
|
properties.isLedgerOn
|
boolean
|
Indipendentemente dal fatto che questo database sia un database libro mastro, ovvero tutte le tabelle del database sono tabelle libro mastro. Nota: il valore di questa proprietà non può essere modificato dopo la creazione del database.
|
|
properties.lastBackupName
|
string
|
Cognome del file di backup per il ripristino di questo database gestito.
|
|
properties.longTermRetentionBackupResourceId
|
string
|
Nome del backup di conservazione a lungo termine da usare per il ripristino di questo database gestito.
|
|
properties.recoverableDatabaseId
|
string
|
Identificatore della risorsa del database ripristinabile associato all'operazione di creazione del database.
|
|
properties.restorableDroppedDatabaseId
|
string
|
ID risorsa del database eliminato ripristinabile da ripristinare durante la creazione del database.
|
|
properties.restorePointInTime
|
string
(date-time)
|
Conditional. Se createMode è PointInTimeRestore, questo valore è obbligatorio. Specifica il punto nel tempo (formato ISO8601) del database di origine che verrà ripristinato per creare il nuovo database.
|
|
properties.sourceDatabaseId
|
string
|
Identificatore della risorsa del database di origine associato all'operazione di creazione del database.
|
|
properties.status
|
ManagedDatabaseStatus
|
Stato del database.
|
|
properties.storageContainerIdentity
|
string
|
Conditional. Se createMode è RestoreExternalBackup, questo valore viene usato. Specifica l'identità usata per l'autenticazione del contenitore di archiviazione. Può essere 'SharedAccessSignature' o 'ManagedIdentity'; se non è specificato 'SharedAccessSignature' viene utilizzato.
|
|
properties.storageContainerSasToken
|
string
|
Conditional. Se createMode è RestoreExternalBackup e storageContainerIdentity non è ManagedIdentity, questo valore è obbligatorio. Specifica il token di firma di accesso condiviso del contenitore di archiviazione.
|
|
properties.storageContainerUri
|
string
|
Conditional. Se createMode è RestoreExternalBackup, questo valore è obbligatorio. Specifica l'URI del contenitore di archiviazione in cui vengono archiviati i backup per questo ripristino.
|
|
systemData
|
systemData
|
Azure Resource Manager metadati contenenti informazioni createBy e modifiedBy.
|
|
tags
|
object
|
Tag di risorsa.
|
|
type
|
string
|
Tipo di risorsa. Ad esempio: "Microsoft. Compute/virtualMachines" oppure "Microsoft. Storage/storageAccounts"
|
ManagedDatabaseCreateMode
Enumerazione
Modalità di creazione del database gestito. PointInTimeRestore: creare un database ripristinando un backup temporizzato di un database esistente. È necessario specificare SourceDatabaseName, SourceManagedInstanceName e PointInTime. RestoreExternalBackup: creare un database ripristinando da file di backup esterni. È necessario specificare regole di confronto, StorageContainerUri e StorageContainerSasToken. Ripristino: crea un database ripristinando un backup con replica geografica. RecoverableDatabaseId deve essere specificato come ID risorsa di database ripristinabile da ripristinare. RestoreLongTermRetentionBackup: creare un database ripristinando da un backup di conservazione a lungo termine (longTermRetentionBackupResourceId obbligatorio).
| Valore |
Descrizione |
|
Default
|
Valore predefinito
|
|
RestoreExternalBackup
|
RestoreExternalBackup
|
|
PointInTimeRestore
|
PointInTimeRestore
|
|
Recovery
|
Recupero
|
|
RestoreLongTermRetentionBackup
|
RipristinoLongtermRetentionBackup
|
ManagedDatabaseExtendedAccessibilityInfo
Oggetto
Informazioni sull'accessibilità estesa del database gestito
| Nome |
Tipo |
Descrizione |
|
inaccessibilityReasonDescription
|
string
|
Spiegazione della causa principale e azione di mitigazione.
|
|
inaccessibilityReasonErrorCode
|
string
|
Codice di errore di SQL Server collegato alla causa principale dell'inaccessibilità.
|
|
inaccessibilityReasonKind
|
InaccessibilityReason
|
Tipo di causa principale. I valori consentiti sono "TransparentDataEncryption", "DatabaseReplication" e "Unknown".
|
|
inaccessibilityReasonTdeKeyUri
|
string
|
Per il tipo di causa radice "TransparentDataEncryption", l'URI CMK.
|
ManagedDatabaseStatus
Enumerazione
Stato del database.
| Valore |
Descrizione |
|
Online
|
In linea
|
|
Offline
|
Offline
|
|
Shutdown
|
Spegnimento
|
|
Creating
|
Creazione
|
|
Inaccessible
|
Inaccessibile
|
|
Restoring
|
Ripristino
|
|
Updating
|
Aggiornamento
|
|
Stopping
|
Interruzione
|
|
Stopped
|
Fermato
|
|
Starting
|
Inizio
|
|
DbMoving
|
DbMoving
|
|
DbCopying
|
Copia di DbCopiatura
|
systemData
Oggetto
Metadati relativi alla creazione e all'ultima modifica della risorsa.
| Nome |
Tipo |
Descrizione |
|
createdAt
|
string
(date-time)
|
Timestamp della creazione della risorsa (UTC).
|
|
createdBy
|
string
|
Identità che ha creato la risorsa.
|
|
createdByType
|
createdByType
|
Tipo di identità che ha creato la risorsa.
|
|
lastModifiedAt
|
string
(date-time)
|
Il timestamp dell'ultima modifica della risorsa (UTC)
|
|
lastModifiedBy
|
string
|
Identità che ha modificato l'ultima volta la risorsa.
|
|
lastModifiedByType
|
createdByType
|
Tipo di identità che ha modificato l'ultima volta la risorsa.
|