Cria um novo banco de dados ou atualiza um banco de dados existente.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}?api-version=2025-01-01
Parâmetros de URI
| Nome |
Em |
Obrigatório |
Tipo |
Description |
|
databaseName
|
path |
True
|
string
|
O nome do banco de dados.
|
|
managedInstanceName
|
path |
True
|
string
|
O nome da instância gerenciada.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
O nome do grupo de recursos. O nome não diferencia maiúsculas de minúsculas.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
A ID da assinatura de destino. O valor deve ser uma UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
A versão da API a ser usada para esta operação.
|
Corpo da solicitação
| Nome |
Obrigatório |
Tipo |
Description |
|
location
|
True
|
string
|
A localização geográfica onde o recurso reside
|
|
properties.autoCompleteRestore
|
|
boolean
|
Se deseja concluir automaticamente a restauração desse banco de dados gerenciado.
|
|
properties.catalogCollation
|
|
CatalogCollationType
|
Ordenação do catálogo de metadados.
|
|
properties.collation
|
|
string
|
Ordenação do banco de dados gerenciado.
|
|
properties.createMode
|
|
ManagedDatabaseCreateMode
|
Modo de criação de banco de dados gerenciado. PointInTimeRestore: crie um banco de dados restaurando um backup pontual de um banco de dados existente. SourceDatabaseName, SourceManagedInstanceName e PointInTime devem ser especificados. RestoreExternalBackup: crie um banco de dados restaurando a partir de arquivos de backup externos. Collation, StorageContainerUri e StorageContainerSasToken devem ser especificados. Recuperação: cria um banco de dados restaurando um backup replicado geograficamente. RecoverableDatabaseId deve ser especificado como a ID do recurso de banco de dados recuperável a ser restaurada. RestoreLongTermRetentionBackup: crie um banco de dados restaurando de um backup de retenção de longo prazo (longTermRetentionBackupResourceId necessário).
|
|
properties.crossSubscriptionRestorableDroppedDatabaseId
|
|
string
|
A ID de recurso de banco de dados removida da assinatura cruzada restaurável para restaurar ao criar esse banco de dados.
|
|
properties.crossSubscriptionSourceDatabaseId
|
|
string
|
O identificador de recurso do banco de dados de origem entre assinaturas associado à operação de criação desse banco de dados.
|
|
properties.crossSubscriptionTargetManagedInstanceId
|
|
string
|
ID da instância gerenciada de destino usada na restauração entre assinaturas.
|
|
properties.isLedgerOn
|
|
boolean
|
Se esse banco de dados é ou não um banco de dados do razão, o que significa que todas as tabelas no banco de dados são tabelas do razão. Observação: o valor dessa propriedade não pode ser alterado após a criação do banco de dados.
|
|
properties.lastBackupName
|
|
string
|
Sobrenome do arquivo de backup para restauração desse banco de dados gerenciado.
|
|
properties.longTermRetentionBackupResourceId
|
|
string
|
O nome do backup de Retenção de Longo Prazo a ser usado para restauração desse banco de dados gerenciado.
|
|
properties.recoverableDatabaseId
|
|
string
|
O identificador de recurso do banco de dados recuperável associado à operação de criação desse banco de dados.
|
|
properties.restorableDroppedDatabaseId
|
|
string
|
A ID de recurso de banco de dados descartada restaurável a ser restaurada ao criar esse banco de dados.
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
Conditional. Se createMode for PointInTimeRestore, esse valor será necessário. Especifica o ponto no tempo (formato ISO8601) do banco de dados de origem que será restaurado para criar o novo banco de dados.
|
|
properties.sourceDatabaseId
|
|
string
|
O identificador de recurso do banco de dados de origem associado à operação de criação deste banco de dados.
|
|
properties.storageContainerIdentity
|
|
string
|
Conditional. Se createMode for RestoreExternalBackup, esse valor será usado. Especifica a identidade usada para autenticação de contêiner de armazenamento. Pode ser 'SharedAccessSignature' ou 'ManagedIdentity'; se não for especificado 'SharedAccessSignature' será assumido.
|
|
properties.storageContainerSasToken
|
|
string
|
Conditional. Se createMode for RestoreExternalBackup e storageContainerIdentity não for ManagedIdentity, esse valor será necessário. Especifica o token sas do contêiner de armazenamento.
|
|
properties.storageContainerUri
|
|
string
|
Conditional. Se createMode for RestoreExternalBackup, esse valor será necessário. Especifica o uri do contêiner de armazenamento em que os backups para essa restauração são armazenados.
|
|
tags
|
|
object
|
Tags de recursos.
|
Respostas
| Nome |
Tipo |
Description |
|
200 OK
|
ManagedDatabase
|
Operação de atualização do recurso 'ManagedDatabase' bem-sucedida
|
|
201 Created
|
ManagedDatabase
|
Recurso 'ManagedDatabase' criar operação bem-sucedida
Cabeçalhos
- Location: string
- Retry-After: integer
|
|
202 Accepted
|
|
Operação de recurso aceita.
Cabeçalhos
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Uma resposta de erro inesperada.
|
Segurança
azure_auth
Azure Active Directory OAuth2 Flow.
Tipo:
oauth2
Flow:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Escopos
| Nome |
Description |
|
user_impersonation
|
representar sua conta de usuário
|
Exemplos
Creates a new managed database by restoring from an external backup
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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.
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Solicitação de exemplo
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://dotnet.territoriali.olinfo.it/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
Resposta de exemplo
{
"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
Definições
| Nome |
Description |
|
CatalogCollationType
|
Ordenação do catálogo de metadados.
|
|
createdByType
|
O tipo de identidade que criou o recurso.
|
|
ErrorAdditionalInfo
|
As informações adicionais do erro de gerenciamento de recursos.
|
|
ErrorDetail
|
O detalhe do erro.
|
|
ErrorResponse
|
Resposta de erro
|
|
InaccessibilityReason
|
Tipo de causa raiz. Os valores permitidos são "TransparentDataEncryption", "DatabaseReplication" e "Unknown".
|
|
ManagedDatabase
|
Um recurso de banco de dados gerenciado.
|
|
ManagedDatabaseCreateMode
|
Modo de criação de banco de dados gerenciado. PointInTimeRestore: crie um banco de dados restaurando um backup pontual de um banco de dados existente. SourceDatabaseName, SourceManagedInstanceName e PointInTime devem ser especificados. RestoreExternalBackup: crie um banco de dados restaurando a partir de arquivos de backup externos. Collation, StorageContainerUri e StorageContainerSasToken devem ser especificados. Recuperação: cria um banco de dados restaurando um backup replicado geograficamente. RecoverableDatabaseId deve ser especificado como a ID do recurso de banco de dados recuperável a ser restaurada. RestoreLongTermRetentionBackup: crie um banco de dados restaurando de um backup de retenção de longo prazo (longTermRetentionBackupResourceId necessário).
|
|
ManagedDatabaseExtendedAccessibilityInfo
|
Informações de acessibilidade estendida do banco de dados gerenciado
|
|
ManagedDatabaseStatus
|
Status do banco de dados.
|
|
systemData
|
Metadados relativos à criação e última modificação do recurso.
|
CatalogCollationType
Enumeração
Ordenação do catálogo de metadados.
| Valor |
Description |
|
DATABASE_DEFAULT
|
DATABASE_DEFAULT
|
|
SQL_Latin1_General_CP1_CI_AS
|
SQL_Latin1_General_CP1_CI_AS
|
createdByType
Enumeração
O tipo de identidade que criou o recurso.
| Valor |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Objeto
As informações adicionais do erro de gerenciamento de recursos.
| Nome |
Tipo |
Description |
|
info
|
object
|
As informações adicionais.
|
|
type
|
string
|
O tipo de informação adicional.
|
ErrorDetail
Objeto
O detalhe do erro.
| Nome |
Tipo |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
As informações adicionais do erro.
|
|
code
|
string
|
O código de erro.
|
|
details
|
ErrorDetail[]
|
Os detalhes do erro.
|
|
message
|
string
|
A mensagem de erro.
|
|
target
|
string
|
O destino do erro.
|
ErrorResponse
Objeto
Resposta de erro
| Nome |
Tipo |
Description |
|
error
|
ErrorDetail
|
O objeto de erro.
|
InaccessibilityReason
Enumeração
Tipo de causa raiz. Os valores permitidos são "TransparentDataEncryption", "DatabaseReplication" e "Unknown".
| Valor |
Description |
|
Unknown
|
Unknown
|
|
TransparentDataEncryption
|
TransparentDataEncryption
|
|
DatabaseReplication
|
Replicação de Banco de Dados
|
ManagedDatabase
Objeto
Um recurso de banco de dados gerenciado.
| Nome |
Tipo |
Description |
|
id
|
string
(arm-id)
|
ID de recurso totalmente qualificada para o recurso. Por exemplo, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
location
|
string
|
A localização geográfica onde o recurso reside
|
|
name
|
string
|
O nome do recurso
|
|
properties.autoCompleteRestore
|
boolean
|
Se deseja concluir automaticamente a restauração desse banco de dados gerenciado.
|
|
properties.catalogCollation
|
CatalogCollationType
|
Ordenação do catálogo de metadados.
|
|
properties.collation
|
string
|
Ordenação do banco de dados gerenciado.
|
|
properties.createMode
|
ManagedDatabaseCreateMode
|
Modo de criação de banco de dados gerenciado. PointInTimeRestore: crie um banco de dados restaurando um backup pontual de um banco de dados existente. SourceDatabaseName, SourceManagedInstanceName e PointInTime devem ser especificados. RestoreExternalBackup: crie um banco de dados restaurando a partir de arquivos de backup externos. Collation, StorageContainerUri e StorageContainerSasToken devem ser especificados. Recuperação: cria um banco de dados restaurando um backup replicado geograficamente. RecoverableDatabaseId deve ser especificado como a ID do recurso de banco de dados recuperável a ser restaurada. RestoreLongTermRetentionBackup: crie um banco de dados restaurando de um backup de retenção de longo prazo (longTermRetentionBackupResourceId necessário).
|
|
properties.creationDate
|
string
(date-time)
|
Data de criação do banco de dados.
|
|
properties.crossSubscriptionRestorableDroppedDatabaseId
|
string
|
A ID de recurso de banco de dados removida da assinatura cruzada restaurável para restaurar ao criar esse banco de dados.
|
|
properties.crossSubscriptionSourceDatabaseId
|
string
|
O identificador de recurso do banco de dados de origem entre assinaturas associado à operação de criação desse banco de dados.
|
|
properties.crossSubscriptionTargetManagedInstanceId
|
string
|
ID da instância gerenciada de destino usada na restauração entre assinaturas.
|
|
properties.defaultSecondaryLocation
|
string
|
Região emparelhada geograficamente.
|
|
properties.earliestRestorePoint
|
string
(date-time)
|
Ponto de restauração mais antigo no tempo para restauração pontual.
|
|
properties.extendedAccessibilityInfo
|
ManagedDatabaseExtendedAccessibilityInfo
|
Informações adicionais de observabilidade e solução de problemas para bancos de dados no estado "Inacessível".
|
|
properties.failoverGroupId
|
string
|
Identificador de recurso do Grupo de Failover de Instância ao qual esse banco de dados gerenciado pertence.
|
|
properties.isLedgerOn
|
boolean
|
Se esse banco de dados é ou não um banco de dados do razão, o que significa que todas as tabelas no banco de dados são tabelas do razão. Observação: o valor dessa propriedade não pode ser alterado após a criação do banco de dados.
|
|
properties.lastBackupName
|
string
|
Sobrenome do arquivo de backup para restauração desse banco de dados gerenciado.
|
|
properties.longTermRetentionBackupResourceId
|
string
|
O nome do backup de Retenção de Longo Prazo a ser usado para restauração desse banco de dados gerenciado.
|
|
properties.recoverableDatabaseId
|
string
|
O identificador de recurso do banco de dados recuperável associado à operação de criação desse banco de dados.
|
|
properties.restorableDroppedDatabaseId
|
string
|
A ID de recurso de banco de dados descartada restaurável a ser restaurada ao criar esse banco de dados.
|
|
properties.restorePointInTime
|
string
(date-time)
|
Conditional. Se createMode for PointInTimeRestore, esse valor será necessário. Especifica o ponto no tempo (formato ISO8601) do banco de dados de origem que será restaurado para criar o novo banco de dados.
|
|
properties.sourceDatabaseId
|
string
|
O identificador de recurso do banco de dados de origem associado à operação de criação deste banco de dados.
|
|
properties.status
|
ManagedDatabaseStatus
|
Status do banco de dados.
|
|
properties.storageContainerIdentity
|
string
|
Conditional. Se createMode for RestoreExternalBackup, esse valor será usado. Especifica a identidade usada para autenticação de contêiner de armazenamento. Pode ser 'SharedAccessSignature' ou 'ManagedIdentity'; se não for especificado 'SharedAccessSignature' será assumido.
|
|
properties.storageContainerSasToken
|
string
|
Conditional. Se createMode for RestoreExternalBackup e storageContainerIdentity não for ManagedIdentity, esse valor será necessário. Especifica o token sas do contêiner de armazenamento.
|
|
properties.storageContainerUri
|
string
|
Conditional. Se createMode for RestoreExternalBackup, esse valor será necessário. Especifica o uri do contêiner de armazenamento em que os backups para essa restauração são armazenados.
|
|
systemData
|
systemData
|
Metadados do Azure Resource Manager contendo informações createdBy e modifiedBy.
|
|
tags
|
object
|
Tags de recursos.
|
|
type
|
string
|
O tipo do recurso. Por exemplo, "Microsoft. Compute/virtualMachines" ou "Microsoft. ContasArmazenamento/Armazenamento"
|
ManagedDatabaseCreateMode
Enumeração
Modo de criação de banco de dados gerenciado. PointInTimeRestore: crie um banco de dados restaurando um backup pontual de um banco de dados existente. SourceDatabaseName, SourceManagedInstanceName e PointInTime devem ser especificados. RestoreExternalBackup: crie um banco de dados restaurando a partir de arquivos de backup externos. Collation, StorageContainerUri e StorageContainerSasToken devem ser especificados. Recuperação: cria um banco de dados restaurando um backup replicado geograficamente. RecoverableDatabaseId deve ser especificado como a ID do recurso de banco de dados recuperável a ser restaurada. RestoreLongTermRetentionBackup: crie um banco de dados restaurando de um backup de retenção de longo prazo (longTermRetentionBackupResourceId necessário).
| Valor |
Description |
|
Default
|
Default
|
|
RestoreExternalBackup
|
RestoreExternalBackup
|
|
PointInTimeRestore
|
PointInTimeRestore
|
|
Recovery
|
Recuperação
|
|
RestoreLongTermRetentionBackup
|
RestoreLongtermRetentionBackup
|
ManagedDatabaseExtendedAccessibilityInfo
Objeto
Informações de acessibilidade estendida do banco de dados gerenciado
| Nome |
Tipo |
Description |
|
inaccessibilityReasonDescription
|
string
|
Explicação da causa raiz e ação de mitigação.
|
|
inaccessibilityReasonErrorCode
|
string
|
Código de erro do SQL Server ligado à causa raiz da inacessibilidade.
|
|
inaccessibilityReasonKind
|
InaccessibilityReason
|
Tipo de causa raiz. Os valores permitidos são "TransparentDataEncryption", "DatabaseReplication" e "Unknown".
|
|
inaccessibilityReasonTdeKeyUri
|
string
|
Para o tipo de causa raiz "TransparentDataEncryption", o URI da CMK.
|
ManagedDatabaseStatus
Enumeração
Status do banco de dados.
| Valor |
Description |
|
Online
|
Online
|
|
Offline
|
Offline
|
|
Shutdown
|
Desligamento
|
|
Creating
|
Criando
|
|
Inaccessible
|
Inacessível
|
|
Restoring
|
Restaurar
|
|
Updating
|
Atualização
|
|
Stopping
|
Parar
|
|
Stopped
|
Parado
|
|
Starting
|
Iniciando
|
|
DbMoving
|
DbMoving
|
|
DbCopying
|
DbCopying
|
systemData
Objeto
Metadados relativos à criação e última modificação do recurso.
| Nome |
Tipo |
Description |
|
createdAt
|
string
(date-time)
|
O carimbo de data/hora da criação de recursos (UTC).
|
|
createdBy
|
string
|
A identidade que criou o recurso.
|
|
createdByType
|
createdByType
|
O tipo de identidade que criou o recurso.
|
|
lastModifiedAt
|
string
(date-time)
|
O carimbo de data/hora da última modificação do recurso (UTC)
|
|
lastModifiedBy
|
string
|
A identidade que modificou o recurso pela última vez.
|
|
lastModifiedByType
|
createdByType
|
O tipo de identidade que modificou o recurso pela última vez.
|