Crea un nuovo database o ne aggiorna uno esistente.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}?api-version=2025-01-01
Parametri dell'URI
| Nome |
In |
Necessario |
Tipo |
Descrizione |
|
databaseName
|
path |
True
|
string
|
Nome del database.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Nome del gruppo di risorse. Il nome è insensibile alle maiuscole e minuscole.
|
|
serverName
|
path |
True
|
string
|
Il nome del server.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
L'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
|
|
identity
|
|
DatabaseIdentity
|
Identità di Azure Active Directory del database.
|
|
properties.autoPauseDelay
|
|
integer
(int32)
|
Tempo in minuti dopo il quale il database viene sospeso automaticamente. Un valore di -1 indica che la sospensione automatica è disabilitata
|
|
properties.availabilityZone
|
|
AvailabilityZoneType
|
Specifica la zona di disponibilità a cui viene aggiunto il database.
|
|
properties.catalogCollation
|
|
CatalogCollationType
|
Regole di confronto del catalogo di metadati.
|
|
properties.collation
|
|
string
|
Regole di confronto del database.
|
|
properties.createMode
|
|
CreateMode
|
Specifica la modalità di creazione del database.
Impostazione predefinita: creazione regolare del database.
Copia: crea un database come copia di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database di origine.
Secondario: crea un database come replica secondaria di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database primario esistente.
PointInTimeRestore: crea un database ripristinando un backup temporizzato di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database esistente e deve essere specificato restorePointInTime.
Ripristino: crea un database ripristinando un backup con replica geografica. sourceDatabaseId deve essere specificato come ID risorsa di database recuperabile da ripristinare.
Ripristino: crea un database ripristinando un backup di un database eliminato. sourceDatabaseId deve essere specificato. Se sourceDatabaseId è l'ID risorsa originale del database, è necessario specificare sourceDatabaseDeletionDate. In caso contrario, sourceDatabaseId deve essere l'ID risorsa del database eliminato ripristinabile e sourceDatabaseDeletionDate viene ignorato. è anche possibile specificare restorePointInTime per eseguire il ripristino da un punto precedente nel tempo.
RestoreLongTermRetentionBackup: crea un database ripristinando da un insieme di credenziali di conservazione a lungo termine. recoveryServicesRecoveryPointResourceId deve essere specificato come ID risorsa del punto di ripristino.
Copia, Secondario e RestoreLongTermRetentionBackup non sono supportati per l'edizione DataWarehouse.
|
|
properties.elasticPoolId
|
|
string
(arm-id)
|
Identificatore della risorsa del pool elastico contenente il database.
|
|
properties.encryptionProtector
|
|
string
|
URI dell'insieme di credenziali delle chiavi di Azure del database se è configurato con le chiavi gestite dal cliente del database.
|
|
properties.encryptionProtectorAutoRotation
|
|
boolean
|
Flag per abilitare o disabilitare la rotazione automatica della chiave AKV della protezione di crittografia del database.
|
|
properties.federatedClientId
|
|
string
(uuid)
|
ID client usato per lo scenario cmk tra tenant per database
|
|
properties.freeLimitExhaustionBehavior
|
|
FreeLimitExhaustionBehavior
|
Specifica il comportamento quando vengono esauriti i limiti gratuiti mensili per il database gratuito.
AutoPause: il database verrà sospeso automaticamente al termine dell'esaurimento dei limiti gratuiti per il resto del mese.
BillForUsage: il database continuerà a essere online al momento dell'esaurimento dei limiti gratuiti e verranno fatturate eventuali eccedenze.
|
|
properties.highAvailabilityReplicaCount
|
|
integer
(int32)
|
Numero di repliche secondarie associate al database business critical, Premium o Hyperscale edition che vengono usate per garantire la disponibilità elevata. Non applicabile a un database Hyperscale all'interno di un pool elastico.
|
|
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.keys
|
|
<string,
DatabaseKey>
|
ID risorsa delle identità assegnate dall'utente da usare
|
|
properties.licenseType
|
|
DatabaseLicenseType
|
Tipo di licenza da applicare per questo database.
LicenseIncluded se è necessaria una licenza o BasePrice se si ha una licenza e si è idonei per il vantaggio Azure Hybrid.
|
|
properties.longTermRetentionBackupResourceId
|
|
string
(arm-id)
|
Identificatore della risorsa del backup di conservazione a lungo termine associato all'operazione di creazione del database.
|
|
properties.maintenanceConfigurationId
|
|
string
|
ID di configurazione della manutenzione assegnato al database. Questa configurazione definisce il periodo in cui verranno eseguiti gli aggiornamenti della manutenzione.
|
|
properties.manualCutover
|
|
boolean
|
Indica se il cutover manuale controllato dal cliente deve essere eseguito durante l'operazione Aggiorna database al livello Hyperscale.
Questa proprietà è applicabile solo quando si ridimensiona il database dal livello Business Critical/Per utilizzo generico/Premium/Standard al livello Hyperscale.
Quando si specifica manualCutover, l'operazione di ridimensionamento attenderà l'input dell'utente per attivare il cutover nel database Hyperscale.
Per attivare il cutover, specificare il parametro 'performCutover' quando l'operazione di ridimensionamento è in stato In attesa.
|
|
properties.maxSizeBytes
|
|
integer
(int64)
|
Dimensione massima del database espressa in byte.
|
|
properties.minCapacity
|
|
number
(double)
|
Capacità minima allocata dal database, se non sospesa
|
|
properties.performCutover
|
|
boolean
|
Per attivare il cutover manuale controllato dal cliente durante lo stato di attesa mentre è in corso l'operazione di ridimensionamento.
Questo parametro di proprietà è applicabile solo per le operazioni di ridimensionamento avviate insieme al parametro 'manualCutover'.
Questa proprietà è applicabile solo quando il database viene ridimensionato dal livello Business Critical/Per utilizzo generico/Premium/Standard al livello Hyperscale è già in corso.
Quando si specifica performCutover, l'operazione di ridimensionamento attiverà il cutover e eseguirà la modifica del ruolo nel database Hyperscale.
|
|
properties.preferredEnclaveType
|
|
AlwaysEncryptedEnclaveType
|
Tipo di enclave richiesto nel database, ad esempio enclave predefiniti o VBS.
|
|
properties.readScale
|
|
DatabaseReadScale
|
Stato del routing di sola lettura. Se abilitata, le connessioni con finalità dell'applicazione impostate su readonly nella stringa di connessione potrebbero essere indirizzate a una replica secondaria di sola lettura nella stessa area. Non applicabile a un database Hyperscale all'interno di un pool elastico.
|
|
properties.recoverableDatabaseId
|
|
string
(arm-id)
|
Identificatore della risorsa del database ripristinabile associato all'operazione di creazione del database.
|
|
properties.recoveryServicesRecoveryPointId
|
|
string
(arm-id)
|
Identificatore della risorsa del punto di ripristino associato all'operazione di creazione del database.
|
|
properties.requestedBackupStorageRedundancy
|
|
BackupStorageRedundancy
|
Tipo di account di archiviazione da usare per archiviare i backup per questo database.
|
|
properties.restorableDroppedDatabaseId
|
|
string
(arm-id)
|
Identificatore della risorsa del database eliminato ripristinabile associato all'operazione di creazione del database.
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
Specifica il punto nel tempo (formato ISO8601) del database di origine che verrà ripristinato per creare il nuovo database.
|
|
properties.sampleName
|
|
SampleName
|
Nome dello schema di esempio da applicare durante la creazione del database.
|
|
properties.secondaryType
|
|
SecondaryType
|
Tipo secondario del database se è secondario. I valori validi sono Geo, Named e Standby.
|
|
properties.sourceDatabaseDeletionDate
|
|
string
(date-time)
|
Specifica l'ora di eliminazione del database.
|
|
properties.sourceDatabaseId
|
|
string
(arm-id)
|
Identificatore della risorsa del database di origine associato all'operazione di creazione del database.
|
|
properties.sourceResourceId
|
|
string
(arm-id)
|
Identificatore della risorsa dell'origine associata all'operazione di creazione del database.
Questa proprietà è supportata solo per l'edizione DataWarehouse e consente di eseguire il ripristino tra sottoscrizioni.
Quando si specifica sourceResourceId, sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId e sourceDatabaseDeletionDate non devono essere specificati e CreateMode deve essere PointInTimeRestore, Restore o Recover.
Quando createMode è PointInTimeRestore, sourceResourceId deve essere l'ID risorsa del database esistente o del pool SQL esistente e deve essere specificato restorePointInTime.
Quando createMode è Restore, sourceResourceId deve essere l'ID risorsa del database eliminato ripristinabile o ripristinare il pool SQL eliminato.
Quando createMode è Recover, sourceResourceId deve essere l'ID risorsa del database recuperabile o del pool SQL ripristinabile.
Quando la sottoscrizione di origine appartiene a un tenant diverso rispetto alla sottoscrizione di destinazione, l'intestazione "x-ms-authorization-auxiliary" deve contenere il token di autenticazione per il tenant di origine. Per altri dettagli sull'intestazione "x-ms-authorization-auxiliary", vedere https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.useFreeLimit
|
|
boolean
|
Indica se il database utilizza limiti mensili gratuiti. Consentito in un database in una sottoscrizione.
|
|
properties.zoneRedundant
|
|
boolean
|
Indipendentemente dal fatto che il database sia con ridondanza della zona, ovvero le repliche di questo database verranno distribuite in più zone di disponibilità.
|
|
sku
|
|
Sku
|
SKU del database.
L'elenco degli SKU può variare in base all'area geografica e all'offerta di supporto. Per determinare gli SKU (inclusi il nome dello SKU, il livello/edizione, la famiglia e la capacità) disponibili per la sottoscrizione in un'area di Azure, usare l'API REST Capabilities_ListByLocation o uno dei comandi seguenti:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
tags
|
|
object
|
Tag di risorsa.
|
Risposte
| Nome |
Tipo |
Descrizione |
|
200 OK
|
Database
|
Operazione di aggiornamento della risorsa 'Database' riuscita
|
|
201 Created
|
Database
|
Operazione di creazione della risorsa 'Database' riuscita
Intestazioni
Azure-AsyncOperation: string
|
|
202 Accepted
|
|
Operazione sulle risorse accettata.
Intestazioni
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Risposta di errore imprevista.
|
Sicurezza
azure_auth
Flusso OAuth2 di Azure Active Directory.
Tipo:
oauth2
Flow:
implicit
URL di autorizzazione:
https://login.microsoftonline.com/common/oauth2/authorize
Ambiti
| Nome |
Descrizione |
|
user_impersonation
|
impersonare il tuo account utente
|
Esempio
Creates a data warehouse database as a cross-subscription restore from a backup of a dropped database.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdw?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "Restore",
"sourceResourceId": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/restorableDroppedDatabases/srcdw,131403269876900000"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionRestore.json
*/
/**
* Sample code: Creates a data warehouse database as a cross-subscription restore from a backup of a dropped
* database.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADataWarehouseDatabaseAsACrossSubscriptionRestoreFromABackupOfADroppedDatabase(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdw",
new DatabaseInner().withLocation("southeastasia").withCreateMode(CreateMode.RESTORE).withSourceResourceId(
"/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/restorableDroppedDatabases/srcdw,131403269876900000"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_dw_database_cross_subscription_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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdw",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "Restore",
"sourceResourceId": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/restorableDroppedDatabases/srcdw,131403269876900000",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionRestore.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionRestore.json
*/
async function createsADataWarehouseDatabaseAsACrossSubscriptionRestoreFromABackupOfADroppedDatabase() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdw",
{
location: "southeastasia",
createMode: "Restore",
sourceResourceId:
"/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/restorableDroppedDatabases/srcdw,131403269876900000",
},
);
console.log(result);
}
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.Models;
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/CreateDwDatabaseCrossSubscriptionRestore.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdw";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
CreateMode = SqlDatabaseCreateMode.Restore,
SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/restorableDroppedDatabases/srcdw,131403269876900000"),
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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": "testdw",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdw",
"kind": "v12.0,user,datawarehouse,gen2",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-01-24T06:46:14.99Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "DW1000c",
"currentSku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
},
"databaseId": "188784c9-d602-4684-86cf-e67b6f03551a",
"defaultSecondaryLocation": "eastus",
"maxSizeBytes": 263882790666240,
"readScale": "Disabled",
"requestedServiceObjectiveName": "DW1000c",
"status": "Online"
},
"sku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
}
}
{
"name": "testdw",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdw",
"kind": "v12.0,user,datawarehouse,gen2",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-01-24T06:46:14.99Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "DW1000c",
"currentSku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
},
"databaseId": "188784c9-d602-4684-86cf-e67b6f03551a",
"defaultSecondaryLocation": "eastus",
"maxSizeBytes": 263882790666240,
"readScale": "Disabled",
"requestedServiceObjectiveName": "DW1000c",
"status": "Online"
},
"sku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a data warehouse database as a cross-subscription restore from a geo-backup.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-WestUS/providers/Microsoft.Sql/servers/testsvr/databases/testdw?api-version=2025-01-01
{
"location": "westus",
"properties": {
"createMode": "Recovery",
"sourceResourceId": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Sql/servers/srcsvr/recoverabledatabases/srcdw"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionRecovery.json
*/
/**
* Sample code: Creates a data warehouse database as a cross-subscription restore from a geo-backup.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADataWarehouseDatabaseAsACrossSubscriptionRestoreFromAGeoBackup(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-WestUS", "testsvr", "testdw",
new DatabaseInner().withLocation("westus").withCreateMode(CreateMode.RECOVERY).withSourceResourceId(
"/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Sql/servers/srcsvr/recoverabledatabases/srcdw"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_dw_database_cross_subscription_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.databases.begin_create_or_update(
resource_group_name="Default-SQL-WestUS",
server_name="testsvr",
database_name="testdw",
parameters={
"location": "westus",
"properties": {
"createMode": "Recovery",
"sourceResourceId": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Sql/servers/srcsvr/recoverabledatabases/srcdw",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionRecovery.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionRecovery.json
*/
async function createsADataWarehouseDatabaseAsACrossSubscriptionRestoreFromAGeoBackup() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate("Default-SQL-WestUS", "testsvr", "testdw", {
location: "westus",
createMode: "Recovery",
sourceResourceId:
"/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Sql/servers/srcsvr/recoverabledatabases/srcdw",
});
console.log(result);
}
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.Models;
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/CreateDwDatabaseCrossSubscriptionRecovery.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-WestUS";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdw";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("westus"))
{
CreateMode = SqlDatabaseCreateMode.Recovery,
SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Sql/servers/srcsvr/recoverabledatabases/srcdw"),
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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": "testdw",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-WestUS/providers/Microsoft.Sql/servers/testsvr/databases/testdw",
"kind": "v12.0,user,datawarehouse,gen2",
"location": "westus",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-01-24T06:46:14.99Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "DW1000c",
"currentSku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
},
"databaseId": "188784c9-d602-4684-86cf-e67b6f03551a",
"defaultSecondaryLocation": "eastus",
"maxSizeBytes": 263882790666240,
"readScale": "Disabled",
"requestedServiceObjectiveName": "DW1000c",
"status": "Online"
},
"sku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
}
}
{
"name": "testdw",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-WestUS/providers/Microsoft.Sql/servers/testsvr/databases/testdw",
"kind": "v12.0,user,datawarehouse,gen2",
"location": "westus",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-01-24T06:46:14.99Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "DW1000c",
"currentSku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
},
"databaseId": "188784c9-d602-4684-86cf-e67b6f03551a",
"defaultSecondaryLocation": "eastus",
"maxSizeBytes": 263882790666240,
"readScale": "Disabled",
"requestedServiceObjectiveName": "DW1000c",
"status": "Online"
},
"sku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a data warehouse database as a cross-subscription restore from a restore point of an existing database.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdw?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2022-01-22T05:35:31.503Z",
"sourceResourceId": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/databases/srcdw"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionPITR.json
*/
/**
* Sample code: Creates a data warehouse database as a cross-subscription restore from a restore point of an
* existing database.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADataWarehouseDatabaseAsACrossSubscriptionRestoreFromARestorePointOfAnExistingDatabase(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdw",
new DatabaseInner().withLocation("southeastasia").withCreateMode(CreateMode.POINT_IN_TIME_RESTORE)
.withRestorePointInTime(OffsetDateTime.parse("2022-01-22T05:35:31.503Z")).withSourceResourceId(
"/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/databases/srcdw"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_dw_database_cross_subscription_pitr.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdw",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2022-01-22T05:35:31.503Z",
"sourceResourceId": "/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/databases/srcdw",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionPITR.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDwDatabaseCrossSubscriptionPITR.json
*/
async function createsADataWarehouseDatabaseAsACrossSubscriptionRestoreFromARestorePointOfAnExistingDatabase() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdw",
{
location: "southeastasia",
createMode: "PointInTimeRestore",
restorePointInTime: new Date("2022-01-22T05:35:31.503Z"),
sourceResourceId:
"/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/databases/srcdw",
},
);
console.log(result);
}
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.Models;
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/CreateDwDatabaseCrossSubscriptionPITR.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdw";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
CreateMode = SqlDatabaseCreateMode.PointInTimeRestore,
RestorePointInTime = DateTimeOffset.Parse("2022-01-22T05:35:31.503Z"),
SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/databases/srcdw"),
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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": "testdw",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdw",
"kind": "v12.0,user,datawarehouse,gen2",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-01-24T06:46:14.99Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "DW1000c",
"currentSku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
},
"databaseId": "188784c9-d602-4684-86cf-e67b6f03551a",
"defaultSecondaryLocation": "eastus",
"maxSizeBytes": 263882790666240,
"readScale": "Disabled",
"requestedServiceObjectiveName": "DW1000c",
"status": "Online"
},
"sku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
}
}
{
"name": "testdw",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdw",
"kind": "v12.0,user,datawarehouse,gen2",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-01-24T06:46:14.99Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "DW1000c",
"currentSku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
},
"databaseId": "188784c9-d602-4684-86cf-e67b6f03551a",
"defaultSecondaryLocation": "eastus",
"maxSizeBytes": 263882790666240,
"readScale": "Disabled",
"requestedServiceObjectiveName": "DW1000c",
"status": "Online"
},
"sku": {
"name": "DataWarehouse",
"capacity": 9000,
"tier": "DataWarehouse"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database as a copy.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/dbcopy?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "Copy",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseCopyMode.json
*/
/**
* Sample code: Creates a database as a copy.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseAsACopy(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "dbcopy",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withCreateMode(CreateMode.COPY).withSourceDatabaseId(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_copy_mode.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="dbcopy",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "Copy",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseCopyMode.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseCopyMode.json
*/
async function createsADatabaseAsACopy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"dbcopy",
{
location: "southeastasia",
createMode: "Copy",
sourceDatabaseId:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseCopyMode.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "dbcopy";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
CreateMode = SqlDatabaseCreateMode.Copy,
SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"),
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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": "dbcopy",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/dbcopy",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "dbcopy",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/dbcopy",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database as a standby secondary.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "Secondary",
"secondaryType": "Standby",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.SecondaryType;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseStandbyMode.json
*/
/**
* Sample code: Creates a database as a standby secondary.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseAsAStandbySecondary(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withCreateMode(CreateMode.SECONDARY)
.withSourceDatabaseId(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb")
.withSecondaryType(SecondaryType.STANDBY),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_standby_mode.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "Secondary",
"secondaryType": "Standby",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb",
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseStandbyMode.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseStandbyMode.json
*/
async function createsADatabaseAsAStandbySecondary() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
location: "southeastasia",
createMode: "Secondary",
secondaryType: "Standby",
sourceDatabaseId:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb",
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseStandbyMode.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
CreateMode = SqlDatabaseCreateMode.Secondary,
SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"),
SecondaryType = SecondaryType.Standby,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"secondaryType": "Standby",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"secondaryType": "Standby",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Creates a database as an on-line secondary.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "Secondary",
"secondaryType": "Geo",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.SecondaryType;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseSecondaryMode.json
*/
/**
* Sample code: Creates a database as an on-line secondary.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseAsAnOnLineSecondary(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withCreateMode(CreateMode.SECONDARY)
.withSourceDatabaseId(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb")
.withSecondaryType(SecondaryType.GEO),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_secondary_mode.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "Secondary",
"secondaryType": "Geo",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb",
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseSecondaryMode.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseSecondaryMode.json
*/
async function createsADatabaseAsAnOnLineSecondary() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
location: "southeastasia",
createMode: "Secondary",
secondaryType: "Geo",
sourceDatabaseId:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb",
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseSecondaryMode.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
CreateMode = SqlDatabaseCreateMode.Secondary,
SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"),
SecondaryType = SecondaryType.Geo,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"secondaryType": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"secondaryType": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database as named replica secondary.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "Secondary",
"secondaryType": "Named",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/primarydb"
},
"sku": {
"name": "HS_Gen4",
"capacity": 2,
"tier": "Hyperscale"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.SecondaryType;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseNamedReplica.json
*/
/**
* Sample code: Creates a database as named replica secondary.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseAsNamedReplicaSecondary(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia")
.withSku(new Sku().withName("HS_Gen4").withTier("Hyperscale").withCapacity(2))
.withCreateMode(CreateMode.SECONDARY)
.withSourceDatabaseId(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/primarydb")
.withSecondaryType(SecondaryType.NAMED),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_named_replica.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "Secondary",
"secondaryType": "Named",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/primarydb",
},
"sku": {"capacity": 2, "name": "HS_Gen4", "tier": "Hyperscale"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseNamedReplica.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseNamedReplica.json
*/
async function createsADatabaseAsNamedReplicaSecondary() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
location: "southeastasia",
createMode: "Secondary",
secondaryType: "Named",
sourceDatabaseId:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/primarydb",
sku: { name: "HS_Gen4", capacity: 2, tier: "Hyperscale" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseNamedReplica.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("HS_Gen4")
{
Tier = "Hyperscale",
Capacity = 2,
},
CreateMode = SqlDatabaseCreateMode.Secondary,
SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/primarydb"),
SecondaryType = SecondaryType.Named,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user,vcore,hyperscale",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "HS_Gen4_2",
"currentSku": {
"name": "HS_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "Hyperscale"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"highAvailabilityReplicaCount": 0,
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maxSizeBytes": -1,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "HS_Gen4_2",
"secondaryType": "Named",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "HS_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "Hyperscale"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user,vcore,hyperscale",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "HS_Gen4_2",
"currentSku": {
"name": "HS_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "Hyperscale"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"highAvailabilityReplicaCount": 0,
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maxSizeBytes": -1,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "HS_Gen4_2",
"secondaryType": "Named",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "HS_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "Hyperscale"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database from PointInTimeRestore.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/dbpitr?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2020-10-22T05:35:31.503Z",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabasePITRMode.json
*/
/**
* Sample code: Creates a database from PointInTimeRestore.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseFromPointInTimeRestore(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "dbpitr",
new DatabaseInner().withLocation("southeastasia").withCreateMode(CreateMode.POINT_IN_TIME_RESTORE)
.withSourceDatabaseId(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb")
.withRestorePointInTime(OffsetDateTime.parse("2020-10-22T05:35:31.503Z")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_pitr_mode.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="dbpitr",
parameters={
"location": "southeastasia",
"properties": {
"createMode": "PointInTimeRestore",
"restorePointInTime": "2020-10-22T05:35:31.503Z",
"sourceDatabaseId": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabasePITRMode.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabasePITRMode.json
*/
async function createsADatabaseFromPointInTimeRestore() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"dbpitr",
{
location: "southeastasia",
createMode: "PointInTimeRestore",
restorePointInTime: new Date("2020-10-22T05:35:31.503Z"),
sourceDatabaseId:
"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
},
);
console.log(result);
}
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.Models;
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/CreateDatabasePITRMode.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "dbpitr";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
CreateMode = SqlDatabaseCreateMode.PointInTimeRestore,
SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"),
RestorePointInTime = DateTimeOffset.Parse("2020-10-22T05:35:31.503Z"),
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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": "dbpitr",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/dbpitr",
"kind": "v12.0,user",
"location": "SoutheastAsia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2020-10-23T20:31:35.807Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "2463ef48-53e2-4c26-9781-2d7138080bfd",
"defaultSecondaryLocation": "SoutheastAsia",
"earliestRestoreDate": "2020-10-23T20:47:37Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "dbpitr",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/dbpitr",
"kind": "v12.0,user",
"location": "SoutheastAsia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2020-10-23T20:31:35.807Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "2463ef48-53e2-4c26-9781-2d7138080bfd",
"defaultSecondaryLocation": "SoutheastAsia",
"earliestRestoreDate": "2020-10-23T20:47:37Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with availability zone specified.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"availabilityZone": "1",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"maxSizeBytes": 1073741824
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.AvailabilityZoneType;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseWithAvailabilityZone.json
*/
/**
* Sample code: Creates a database with availability zone specified.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsADatabaseWithAvailabilityZoneSpecified(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withCreateMode(CreateMode.DEFAULT).withCollation("SQL_Latin1_General_CP1_CI_AS")
.withMaxSizeBytes(1073741824L).withAvailabilityZone(AvailabilityZoneType.ONE),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_with_availability_zone.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"location": "southeastasia",
"properties": {
"availabilityZone": "1",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"maxSizeBytes": 1073741824,
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseWithAvailabilityZone.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseWithAvailabilityZone.json
*/
async function createsADatabaseWithAvailabilityZoneSpecified() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
location: "southeastasia",
availabilityZone: "1",
collation: "SQL_Latin1_General_CP1_CI_AS",
createMode: "Default",
maxSizeBytes: 1073741824,
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseWithAvailabilityZone.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
CreateMode = SqlDatabaseCreateMode.Default,
Collation = "SQL_Latin1_General_CP1_CI_AS",
MaxSizeBytes = 1073741824L,
AvailabilityZone = SqlAvailabilityZoneType.One,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"availabilityZone": "1",
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"availabilityZone": "1",
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
Creates a database with database-level customer managed keys.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {}
}
},
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
"keys": {
"https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion": {},
"https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2Version": {}
},
"maxSizeBytes": 1073741824
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.DatabaseIdentity;
import com.azure.resourcemanager.sql.models.DatabaseIdentityType;
import com.azure.resourcemanager.sql.models.DatabaseKey;
import com.azure.resourcemanager.sql.models.DatabaseUserIdentity;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json
*/
/**
* Sample code: Creates a database with database-level customer managed keys.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsADatabaseWithDatabaseLevelCustomerManagedKeys(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withIdentity(new DatabaseIdentity().withType(DatabaseIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi",
new DatabaseUserIdentity())))
.withCreateMode(CreateMode.DEFAULT).withCollation("SQL_Latin1_General_CP1_CI_AS")
.withMaxSizeBytes(1073741824L)
.withKeys(mapOf("https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion", new DatabaseKey(),
"https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2Version", new DatabaseKey()))
.withEncryptionProtector("https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_default_mode_with_keys_and_encryption_protector.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {}
},
},
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
"keys": {
"https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion": {},
"https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2Version": {},
},
"maxSizeBytes": 1073741824,
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json
*/
async function createsADatabaseWithDatabaseLevelCustomerManagedKeys() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi":
{},
},
},
location: "southeastasia",
collation: "SQL_Latin1_General_CP1_CI_AS",
createMode: "Default",
encryptionProtector: "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
keys: {
"https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion": {},
"https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2Version": {},
},
maxSizeBytes: 1073741824,
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
Identity = new DatabaseIdentity
{
IdentityType = DatabaseIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi"] = new UserAssignedIdentity()
},
},
CreateMode = SqlDatabaseCreateMode.Default,
Collation = "SQL_Latin1_General_CP1_CI_AS",
MaxSizeBytes = 1073741824L,
Keys =
{
["https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion"] = new SqlDatabaseKey(),
["https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2Version"] = new SqlDatabaseKey()
},
EncryptionProtector = "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with database-level versionless customer managed keys.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {}
}
},
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey",
"keys": {
"https://your-key-vault-name.vault.azure.net/yourKey": {},
"https://your-key-vault-name.vault.azure.net/yourKey2": {}
},
"maxSizeBytes": 1073741824
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.DatabaseIdentity;
import com.azure.resourcemanager.sql.models.DatabaseIdentityType;
import com.azure.resourcemanager.sql.models.DatabaseKey;
import com.azure.resourcemanager.sql.models.DatabaseUserIdentity;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultModeWithVersionlessKeysAndVersionlessEncryptionProtector.json
*/
/**
* Sample code: Creates a database with database-level versionless customer managed keys.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseWithDatabaseLevelVersionlessCustomerManagedKeys(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withIdentity(new DatabaseIdentity().withType(DatabaseIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi",
new DatabaseUserIdentity())))
.withCreateMode(CreateMode.DEFAULT).withCollation("SQL_Latin1_General_CP1_CI_AS")
.withMaxSizeBytes(1073741824L)
.withKeys(mapOf("https://your-key-vault-name.vault.azure.net/yourKey", new DatabaseKey(),
"https://your-key-vault-name.vault.azure.net/yourKey2", new DatabaseKey()))
.withEncryptionProtector("https://your-key-vault-name.vault.azure.net/yourKey"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_default_mode_with_versionless_keys_and_versionless_encryption_protector.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {}
},
},
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey",
"keys": {
"https://your-key-vault-name.vault.azure.net/yourKey": {},
"https://your-key-vault-name.vault.azure.net/yourKey2": {},
},
"maxSizeBytes": 1073741824,
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseDefaultModeWithVersionlessKeysAndVersionlessEncryptionProtector.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultModeWithVersionlessKeysAndVersionlessEncryptionProtector.json
*/
async function createsADatabaseWithDatabaseLevelVersionlessCustomerManagedKeys() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi":
{},
},
},
location: "southeastasia",
collation: "SQL_Latin1_General_CP1_CI_AS",
createMode: "Default",
encryptionProtector: "https://your-key-vault-name.vault.azure.net/yourKey",
keys: {
"https://your-key-vault-name.vault.azure.net/yourKey": {},
"https://your-key-vault-name.vault.azure.net/yourKey2": {},
},
maxSizeBytes: 1073741824,
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseDefaultModeWithVersionlessKeysAndVersionlessEncryptionProtector.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
Identity = new DatabaseIdentity
{
IdentityType = DatabaseIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi"] = new UserAssignedIdentity()
},
},
CreateMode = SqlDatabaseCreateMode.Default,
Collation = "SQL_Latin1_General_CP1_CI_AS",
MaxSizeBytes = 1073741824L,
Keys =
{
["https://your-key-vault-name.vault.azure.net/yourKey"] = new SqlDatabaseKey(),
["https://your-key-vault-name.vault.azure.net/yourKey2"] = new SqlDatabaseKey()
},
EncryptionProtector = "https://your-key-vault-name.vault.azure.net/yourKey",
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with Default enclave type.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"preferredEnclaveType": "Default"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.AlwaysEncryptedEnclaveType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultEnclave.json
*/
/**
* Sample code: Creates a database with Default enclave type.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseWithDefaultEnclaveType(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases()
.createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb", new DatabaseInner()
.withLocation("southeastasia").withPreferredEnclaveType(AlwaysEncryptedEnclaveType.DEFAULT),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_default_enclave.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={"location": "southeastasia", "properties": {"preferredEnclaveType": "Default"}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseDefaultEnclave.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultEnclave.json
*/
async function createsADatabaseWithDefaultEnclaveType() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{ location: "southeastasia", preferredEnclaveType: "Default" },
);
console.log(result);
}
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.Models;
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/CreateDatabaseDefaultEnclave.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"maxSizeBytes": 268435456000,
"preferredEnclaveType": "Default",
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Zone",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"maxSizeBytes": 268435456000,
"preferredEnclaveType": "Default",
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Zone",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with default mode.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"maxSizeBytes": 1073741824
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultMode.json
*/
/**
* Sample code: Creates a database with default mode.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseWithDefaultMode(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withCreateMode(CreateMode.DEFAULT).withCollation("SQL_Latin1_General_CP1_CI_AS")
.withMaxSizeBytes(1073741824L),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_default_mode.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"maxSizeBytes": 1073741824,
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseDefaultMode.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseDefaultMode.json
*/
async function createsADatabaseWithDefaultMode() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
location: "southeastasia",
collation: "SQL_Latin1_General_CP1_CI_AS",
createMode: "Default",
maxSizeBytes: 1073741824,
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseDefaultMode.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
CreateMode = SqlDatabaseCreateMode.Default,
Collation = "SQL_Latin1_General_CP1_CI_AS",
MaxSizeBytes = 1073741824L,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with encryption protector auto rotation.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {}
}
},
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
"encryptionProtectorAutoRotation": true,
"maxSizeBytes": 1073741824
},
"sku": {
"name": "S0",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.DatabaseIdentity;
import com.azure.resourcemanager.sql.models.DatabaseIdentityType;
import com.azure.resourcemanager.sql.models.DatabaseUserIdentity;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseWithEncryptionProtectorAutoRotation.json
*/
/**
* Sample code: Creates a database with encryption protector auto rotation.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsADatabaseWithEncryptionProtectorAutoRotation(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S0").withTier("Standard"))
.withIdentity(new DatabaseIdentity().withType(DatabaseIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi",
new DatabaseUserIdentity())))
.withCreateMode(CreateMode.DEFAULT).withCollation("SQL_Latin1_General_CP1_CI_AS")
.withMaxSizeBytes(1073741824L)
.withEncryptionProtector("https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion")
.withEncryptionProtectorAutoRotation(true),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_with_encryption_protector_auto_rotation.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi": {}
},
},
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
"encryptionProtectorAutoRotation": True,
"maxSizeBytes": 1073741824,
},
"sku": {"name": "S0", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseWithEncryptionProtectorAutoRotation.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseWithEncryptionProtectorAutoRotation.json
*/
async function createsADatabaseWithEncryptionProtectorAutoRotation() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi":
{},
},
},
location: "southeastasia",
collation: "SQL_Latin1_General_CP1_CI_AS",
createMode: "Default",
encryptionProtector: "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
encryptionProtectorAutoRotation: true,
maxSizeBytes: 1073741824,
sku: { name: "S0", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseWithEncryptionProtectorAutoRotation.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S0")
{
Tier = "Standard",
},
Identity = new DatabaseIdentity
{
IdentityType = DatabaseIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi"] = new UserAssignedIdentity()
},
},
CreateMode = SqlDatabaseCreateMode.Default,
Collation = "SQL_Latin1_General_CP1_CI_AS",
MaxSizeBytes = 1073741824L,
EncryptionProtector = "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
EncryptionProtectorAutoRotation = true,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"encryptionProtector": "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion",
"encryptionProtectorAutoRotation": true,
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S0",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a 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/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"isLedgerOn": true
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseLedger.json
*/
/**
* Sample code: Creates a database with ledger on.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseWithLedgerOn(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withIsLedgerOn(true), com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={"location": "southeastasia", "properties": {"isLedgerOn": True}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseLedger.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseLedger.json
*/
async function createsADatabaseWithLedgerOn() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{ location: "southeastasia", isLedgerOn: true },
);
console.log(result);
}
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.Models;
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/CreateDatabaseLedger.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
IsLedgerOn = true,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isLedgerOn": true,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Zone",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Zone",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with minimum number of parameters.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia"
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseMin.json
*/
/**
* Sample code: Creates a database with minimum number of parameters.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsADatabaseWithMinimumNumberOfParameters(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia"), com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={"location": "southeastasia"},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseMin.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseMin.json
*/
async function createsADatabaseWithMinimumNumberOfParameters() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{ location: "southeastasia" },
);
console.log(result);
}
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.Models;
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/CreateDatabaseMin.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"));
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with preferred maintenance window.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1",
"maxSizeBytes": 1073741824
},
"sku": {
"name": "S2",
"tier": "Standard"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.CreateMode;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseMaintenanceConfiguration.json
*/
/**
* Sample code: Creates a database with preferred maintenance window.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsADatabaseWithPreferredMaintenanceWindow(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("S2").withTier("Standard"))
.withCreateMode(CreateMode.DEFAULT).withCollation("SQL_Latin1_General_CP1_CI_AS")
.withMaxSizeBytes(1073741824L).withMaintenanceConfigurationId(
"/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1"),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_maintenance_configuration.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"location": "southeastasia",
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"createMode": "Default",
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1",
"maxSizeBytes": 1073741824,
},
"sku": {"name": "S2", "tier": "Standard"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseMaintenanceConfiguration.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseMaintenanceConfiguration.json
*/
async function createsADatabaseWithPreferredMaintenanceWindow() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
location: "southeastasia",
collation: "SQL_Latin1_General_CP1_CI_AS",
createMode: "Default",
maintenanceConfigurationId:
"/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1",
maxSizeBytes: 1073741824,
sku: { name: "S2", tier: "Standard" },
},
);
console.log(result);
}
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.Models;
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/CreateDatabaseMaintenanceConfiguration.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("S2")
{
Tier = "Standard",
},
CreateMode = SqlDatabaseCreateMode.Default,
Collation = "SQL_Latin1_General_CP1_CI_AS",
MaxSizeBytes = 1073741824L,
MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1"),
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S2",
"currentSku": {
"name": "Standard",
"capacity": 50,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2020-08-29T06:41:18.283Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1",
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S2",
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S2",
"currentSku": {
"name": "Standard",
"capacity": 50,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2020-08-29T06:41:18.283Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1",
"maxSizeBytes": 1073741824,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "S2",
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with specified backup storage redundancy.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"requestedBackupStorageRedundancy": "Zone"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.BackupStorageRedundancy;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseConfiguredBackupStorageRedundancy.json
*/
/**
* Sample code: Creates a database with specified backup storage redundancy.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsADatabaseWithSpecifiedBackupStorageRedundancy(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases()
.createOrUpdate(
"Default-SQL-SouthEastAsia", "testsvr", "testdb", new DatabaseInner().withLocation("southeastasia")
.withRequestedBackupStorageRedundancy(BackupStorageRedundancy.ZONE),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_configured_backup_storage_redundancy.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={"location": "southeastasia", "properties": {"requestedBackupStorageRedundancy": "Zone"}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseConfiguredBackupStorageRedundancy.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseConfiguredBackupStorageRedundancy.json
*/
async function createsADatabaseWithSpecifiedBackupStorageRedundancy() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{ location: "southeastasia", requestedBackupStorageRedundancy: "Zone" },
);
console.log(result);
}
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.Models;
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/CreateDatabaseConfiguredBackupStorageRedundancy.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Zone,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Zone",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Zone",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Zone",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"maxSizeBytes": 268435456000,
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Zone",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a database with VBS enclave type.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"properties": {
"preferredEnclaveType": "VBS"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.AlwaysEncryptedEnclaveType;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateDatabaseVBSEnclave.json
*/
/**
* Sample code: Creates a database with VBS enclave type.
*
* @param manager Entry point to SqlServerManager.
*/
public static void createsADatabaseWithVBSEnclaveType(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withPreferredEnclaveType(AlwaysEncryptedEnclaveType.VBS),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_database_vbs_enclave.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={"location": "southeastasia", "properties": {"preferredEnclaveType": "VBS"}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateDatabaseVBSEnclave.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateDatabaseVBSEnclave.json
*/
async function createsADatabaseWithVBSEnclaveType() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{ location: "southeastasia", preferredEnclaveType: "VBS" },
);
console.log(result);
}
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.Models;
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/CreateDatabaseVBSEnclave.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"maxSizeBytes": 268435456000,
"preferredEnclaveType": "VBS",
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Zone",
"currentServiceObjectiveName": "S0",
"currentSku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"maxSizeBytes": 268435456000,
"preferredEnclaveType": "VBS",
"readScale": "Disabled",
"requestedBackupStorageRedundancy": "Zone",
"requestedServiceObjectiveName": "S0",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "Standard",
"capacity": 10,
"tier": "Standard"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a VCore database by specifying service objective name.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"sku": {
"name": "BC",
"capacity": 2,
"family": "Gen4"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateVCoreDatabaseByServiceObjective.json
*/
/**
* Sample code: Creates a VCore database by specifying service objective name.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsAVCoreDatabaseBySpecifyingServiceObjectiveName(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases()
.createOrUpdate(
"Default-SQL-SouthEastAsia", "testsvr", "testdb", new DatabaseInner().withLocation("southeastasia")
.withSku(new Sku().withName("BC").withFamily("Gen4").withCapacity(2)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_vcore_database_by_service_objective.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={"location": "southeastasia", "sku": {"capacity": 2, "family": "Gen4", "name": "BC"}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateVCoreDatabaseByServiceObjective.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateVCoreDatabaseByServiceObjective.json
*/
async function createsAVCoreDatabaseBySpecifyingServiceObjectiveName() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{ location: "southeastasia", sku: { name: "BC", capacity: 2, family: "Gen4" } },
);
console.log(result);
}
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.Models;
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/CreateVCoreDatabaseByServiceObjective.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("BC")
{
Family = "Gen4",
Capacity = 2,
},
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "BC_Gen4_2",
"currentSku": {
"name": "BC_Gen4",
"capacity": 2,
"tier": "BusinessCritical"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maxLogSizeBytes": 104857600,
"maxSizeBytes": 1073741824,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "BC_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "BusinessCritical"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "BC_Gen4_2",
"currentSku": {
"name": "BC_Gen4",
"capacity": 2,
"tier": "BusinessCritical"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maxLogSizeBytes": 104857600,
"maxSizeBytes": 1073741824,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "BC_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "BusinessCritical"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Creates a VCore database by specifying sku name and capacity.
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"location": "southeastasia",
"sku": {
"name": "BC_Gen4",
"capacity": 2
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/CreateVCoreDatabaseBySkuNameCapacity.json
*/
/**
* Sample code: Creates a VCore database by specifying sku name and capacity.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
createsAVCoreDatabaseBySpecifyingSkuNameAndCapacity(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withSku(new Sku().withName("BC_Gen4").withCapacity(2)),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python create_vcore_database_by_sku_name_capacity.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={"location": "southeastasia", "sku": {"capacity": 2, "name": "BC_Gen4"}},
).result()
print(response)
# x-ms-original-file: 2025-01-01/CreateVCoreDatabaseBySkuNameCapacity.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/CreateVCoreDatabaseBySkuNameCapacity.json
*/
async function createsAVCoreDatabaseBySpecifyingSkuNameAndCapacity() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{ location: "southeastasia", sku: { name: "BC_Gen4", capacity: 2 } },
);
console.log(result);
}
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.Models;
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/CreateVCoreDatabaseBySkuNameCapacity.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("BC_Gen4")
{
Capacity = 2,
},
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "BC_Gen4_2",
"currentSku": {
"name": "BC_Gen4",
"capacity": 2,
"tier": "BusinessCritical"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maxLogSizeBytes": 104857600,
"maxSizeBytes": 1073741824,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "BC_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "BusinessCritical"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2017-06-07T04:41:33.937Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "BC_Gen4_2",
"currentSku": {
"name": "BC_Gen4",
"capacity": 2,
"tier": "BusinessCritical"
},
"databaseId": "6c764297-577b-470f-9af4-96d3d41e2ba3",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2017-06-07T04:51:33.937Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maxLogSizeBytes": 104857600,
"maxSizeBytes": 1073741824,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "BC_Gen4",
"capacity": 2,
"family": "Gen4",
"tier": "BusinessCritical"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Updates a database to Hyperscale SLO with manual cutover
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi": {},
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete": null
}
},
"location": "southeastasia",
"properties": {
"manualCutover": true
},
"sku": {
"name": "HS_Gen5_2",
"tier": "Hyperscale"
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.DatabaseIdentity;
import com.azure.resourcemanager.sql.models.DatabaseIdentityType;
import com.azure.resourcemanager.sql.models.DatabaseUserIdentity;
import com.azure.resourcemanager.sql.models.Sku;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/UpdateDatabaseHyperscaleMigrationWithManualCutover.json
*/
/**
* Sample code: Updates a database to Hyperscale SLO with manual cutover.
*
* @param manager Entry point to SqlServerManager.
*/
public static void
updatesADatabaseToHyperscaleSLOWithManualCutover(com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia")
.withSku(new Sku().withName("HS_Gen5_2").withTier("Hyperscale"))
.withIdentity(new DatabaseIdentity().withType(DatabaseIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi",
new DatabaseUserIdentity(),
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete",
null)))
.withManualCutover(true),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python update_database_hyperscale_migration_with_manual_cutover.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi": {},
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete": None,
},
},
"location": "southeastasia",
"properties": {"manualCutover": True},
"sku": {"name": "HS_Gen5_2", "tier": "Hyperscale"},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/UpdateDatabaseHyperscaleMigrationWithManualCutover.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/UpdateDatabaseHyperscaleMigrationWithManualCutover.json
*/
async function updatesADatabaseToHyperscaleSLOWithManualCutover() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi":
{},
},
},
location: "southeastasia",
manualCutover: true,
sku: { name: "HS_Gen5_2", tier: "Hyperscale" },
},
);
console.log(result);
}
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.Models;
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/UpdateDatabaseHyperscaleMigrationWithManualCutover.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Sku = new SqlSku("HS_Gen5_2")
{
Tier = "Hyperscale",
},
Identity = new DatabaseIdentity
{
IdentityType = DatabaseIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi"] = new UserAssignedIdentity(),
["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete"] = default
},
},
ManualCutover = true,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user,vcore",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-12-08T12:41:23.953Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "GP_Gen5_2",
"currentSku": {
"name": "GP_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "GeneralPurpose"
},
"databaseId": "dad50ee1-9fbb-4fb9-bd2b-5786d175ce3c",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2022-12-08T12:42:00Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default",
"maxLogSizeBytes": 193273528320,
"maxSizeBytes": 34359738368,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "HS_Gen5_2",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "HS_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "Hyperscale"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user,vcore",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-12-08T12:41:23.953Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "GP_Gen5_2",
"currentSku": {
"name": "GP_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "GeneralPurpose"
},
"databaseId": "dad50ee1-9fbb-4fb9-bd2b-5786d175ce3c",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2022-12-08T12:42:00Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default",
"maxLogSizeBytes": 193273528320,
"maxSizeBytes": 34359738368,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "HS_Gen5_2",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "HS_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "Hyperscale"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Updates a database to Hyperscale tier by triggering manual cutover during Migration workflow
Esempio di richiesta
PUT https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb?api-version=2025-01-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi": {},
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete": null
}
},
"location": "southeastasia",
"properties": {
"performCutover": true
}
}
import com.azure.resourcemanager.sql.fluent.models.DatabaseInner;
import com.azure.resourcemanager.sql.models.DatabaseIdentity;
import com.azure.resourcemanager.sql.models.DatabaseIdentityType;
import com.azure.resourcemanager.sql.models.DatabaseUserIdentity;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for Databases CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2025-01-01/UpdateDatabaseHyperscaleMigrationPerformCutover.json
*/
/**
* Sample code: Updates a database to Hyperscale tier by triggering manual cutover during Migration workflow.
*
* @param manager Entry point to SqlServerManager.
*/
public static void updatesADatabaseToHyperscaleTierByTriggeringManualCutoverDuringMigrationWorkflow(
com.azure.resourcemanager.sql.SqlServerManager manager) {
manager.serviceClient().getDatabases().createOrUpdate("Default-SQL-SouthEastAsia", "testsvr", "testdb",
new DatabaseInner().withLocation("southeastasia").withIdentity(new DatabaseIdentity()
.withType(DatabaseIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi",
new DatabaseUserIdentity(),
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete",
null)))
.withPerformCutover(true),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.sql import SqlManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-sql
# USAGE
python update_database_hyperscale_migration_perform_cutover.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.databases.begin_create_or_update(
resource_group_name="Default-SQL-SouthEastAsia",
server_name="testsvr",
database_name="testdb",
parameters={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi": {},
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete": None,
},
},
"location": "southeastasia",
"properties": {"performCutover": True},
},
).result()
print(response)
# x-ms-original-file: 2025-01-01/UpdateDatabaseHyperscaleMigrationPerformCutover.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
const { SqlManagementClient } = require("@azure/arm-sql");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to creates a new database or updates an existing database.
*
* @summary creates a new database or updates an existing database.
* x-ms-original-file: 2025-01-01/UpdateDatabaseHyperscaleMigrationPerformCutover.json
*/
async function updatesADatabaseToHyperscaleTierByTriggeringManualCutoverDuringMigrationWorkflow() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-1111-2222-3333-444444444444";
const client = new SqlManagementClient(credential, subscriptionId);
const result = await client.databases.createOrUpdate(
"Default-SQL-SouthEastAsia",
"testsvr",
"testdb",
{
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi":
{},
},
},
location: "southeastasia",
performCutover: true,
},
);
console.log(result);
}
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.Models;
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/UpdateDatabaseHyperscaleMigrationPerformCutover.json
// this example is just showing the usage of "Databases_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 SqlServerResource created on azure
// for more information of creating SqlServerResource, please refer to the document of SqlServerResource
string subscriptionId = "00000000-1111-2222-3333-444444444444";
string resourceGroupName = "Default-SQL-SouthEastAsia";
string serverName = "testsvr";
ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName);
SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId);
// get the collection of this SqlDatabaseResource
SqlDatabaseCollection collection = sqlServer.GetSqlDatabases();
// invoke the operation
string databaseName = "testdb";
SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia"))
{
Identity = new DatabaseIdentity
{
IdentityType = DatabaseIdentityType.UserAssigned,
UserAssignedIdentities =
{
["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi"] = new UserAssignedIdentity(),
["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete"] = default
},
},
PerformCutover = true,
};
ArmOperation<SqlDatabaseResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data);
SqlDatabaseResource 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
SqlDatabaseData 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",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user,vcore",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-12-08T12:41:23.953Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "GP_Gen5_2",
"currentSku": {
"name": "GP_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "GeneralPurpose"
},
"databaseId": "dad50ee1-9fbb-4fb9-bd2b-5786d175ce3c",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2022-12-08T12:42:00Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default",
"maxLogSizeBytes": 193273528320,
"maxSizeBytes": 34359738368,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "HS_Gen5_2",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "HS_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "Hyperscale"
}
}
{
"name": "testdb",
"type": "Microsoft.Sql/servers/databases",
"id": "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb",
"kind": "v12.0,user,vcore",
"location": "southeastasia",
"properties": {
"catalogCollation": "SQL_Latin1_General_CP1_CI_AS",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"creationDate": "2022-12-08T12:41:23.953Z",
"currentBackupStorageRedundancy": "Geo",
"currentServiceObjectiveName": "GP_Gen5_2",
"currentSku": {
"name": "GP_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "GeneralPurpose"
},
"databaseId": "dad50ee1-9fbb-4fb9-bd2b-5786d175ce3c",
"defaultSecondaryLocation": "North Europe",
"earliestRestoreDate": "2022-12-08T12:42:00Z",
"isInfraEncryptionEnabled": false,
"isLedgerOn": false,
"licenseType": "LicenseIncluded",
"maintenanceConfigurationId": "/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default",
"maxLogSizeBytes": 193273528320,
"maxSizeBytes": 34359738368,
"readScale": "Enabled",
"requestedBackupStorageRedundancy": "Geo",
"requestedServiceObjectiveName": "HS_Gen5_2",
"status": "Online",
"zoneRedundant": false
},
"sku": {
"name": "HS_Gen5",
"capacity": 2,
"family": "Gen5",
"tier": "Hyperscale"
}
}
Location: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/locations/southeastasia/databaseOperationResults/11111111-1111-1111-1111-111111111111
Definizioni
| Nome |
Descrizione |
|
AlwaysEncryptedEnclaveType
|
Tipo di enclave richiesto nel database, ad esempio enclave predefiniti o VBS.
|
|
AvailabilityZoneType
|
Specifica la zona di disponibilità a cui viene aggiunto il database.
|
|
BackupStorageRedundancy
|
Tipo di account di archiviazione usato per archiviare i backup per questo database.
|
|
CatalogCollationType
|
Regole di confronto del catalogo di metadati.
|
|
createdByType
|
Tipo di identità che ha creato la risorsa.
|
|
CreateMode
|
Specifica la modalità di creazione del database.
Impostazione predefinita: creazione regolare del database.
Copia: crea un database come copia di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database di origine.
Secondario: crea un database come replica secondaria di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database primario esistente.
PointInTimeRestore: crea un database ripristinando un backup temporizzato di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database esistente e deve essere specificato restorePointInTime.
Ripristino: crea un database ripristinando un backup con replica geografica. sourceDatabaseId deve essere specificato come ID risorsa di database recuperabile da ripristinare.
Ripristino: crea un database ripristinando un backup di un database eliminato. sourceDatabaseId deve essere specificato. Se sourceDatabaseId è l'ID risorsa originale del database, è necessario specificare sourceDatabaseDeletionDate. In caso contrario, sourceDatabaseId deve essere l'ID risorsa del database eliminato ripristinabile e sourceDatabaseDeletionDate viene ignorato. è anche possibile specificare restorePointInTime per eseguire il ripristino da un punto precedente nel tempo.
RestoreLongTermRetentionBackup: crea un database ripristinando da un insieme di credenziali di conservazione a lungo termine. recoveryServicesRecoveryPointResourceId deve essere specificato come ID risorsa del punto di ripristino.
Copia, Secondario e RestoreLongTermRetentionBackup non sono supportati per l'edizione DataWarehouse.
|
|
Database
|
Una risorsa di database.
|
|
DatabaseIdentity
|
Configurazione dell'identità di Azure Active Directory per una risorsa.
|
|
DatabaseIdentityType
|
Tipo di identità
|
|
DatabaseKey
|
Chiave a livello di database usata per la crittografia dei dati inattivi.
|
|
DatabaseKeyType
|
Tipo di chiave del database. Solo il valore supportato è 'AzureKeyVault'.
|
|
DatabaseLicenseType
|
Tipo di licenza da applicare per questo database.
LicenseIncluded se è necessaria una licenza o BasePrice se si ha una licenza e si è idonei per il vantaggio Azure Hybrid.
|
|
DatabaseReadScale
|
Stato del routing di sola lettura. Se abilitata, le connessioni con finalità dell'applicazione impostate su readonly nella stringa di connessione potrebbero essere indirizzate a una replica secondaria di sola lettura nella stessa area. Non applicabile a un database Hyperscale all'interno di un pool elastico.
|
|
DatabaseStatus
|
Stato del database.
|
|
DatabaseUserIdentity
|
Configurazione dell'identità di Azure Active Directory per una risorsa.
|
|
ErrorAdditionalInfo
|
Informazioni aggiuntive sull'errore di gestione delle risorse.
|
|
ErrorDetail
|
Dettagli dell'errore.
|
|
ErrorResponse
|
Risposta di errore
|
|
FreeLimitExhaustionBehavior
|
Specifica il comportamento quando vengono esauriti i limiti gratuiti mensili per il database gratuito.
AutoPause: il database verrà sospeso automaticamente al termine dell'esaurimento dei limiti gratuiti per il resto del mese.
BillForUsage: il database continuerà a essere online al momento dell'esaurimento dei limiti gratuiti e verranno fatturate eventuali eccedenze.
|
|
SampleName
|
Nome dello schema di esempio da applicare durante la creazione del database.
|
|
SecondaryType
|
Tipo secondario del database se è secondario. I valori validi sono Geo, Named e Standby.
|
|
Sku
|
Definizione del modello di risorse che rappresenta lo SKU
|
|
SkuTier
|
Questo campo deve essere implementato dal provider di risorse se il servizio ha più di un livello, ma non è necessario in un PUT.
|
|
systemData
|
Metadati relativi alla creazione e all'ultima modifica della risorsa.
|
AlwaysEncryptedEnclaveType
Enumerazione
Tipo di enclave richiesto nel database, ad esempio enclave predefiniti o VBS.
| Valore |
Descrizione |
|
Default
|
Predefinito
|
|
VBS
|
VBS
|
AvailabilityZoneType
Enumerazione
Specifica la zona di disponibilità a cui viene aggiunto il database.
| Valore |
Descrizione |
|
NoPreference
|
Nessuna preferenza
|
|
1
|
1
|
|
2
|
2
|
|
3
|
3
|
BackupStorageRedundancy
Enumerazione
Tipo di account di archiviazione usato per archiviare i backup per questo database.
| Valore |
Descrizione |
|
Geo
|
Geo
|
|
Local
|
Locale
|
|
Zone
|
Zona
|
|
GeoZone
|
GeoZone
|
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
|
|
CreateMode
Enumerazione
Specifica la modalità di creazione del database.
Impostazione predefinita: creazione regolare del database.
Copia: crea un database come copia di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database di origine.
Secondario: crea un database come replica secondaria di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database primario esistente.
PointInTimeRestore: crea un database ripristinando un backup temporizzato di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database esistente e deve essere specificato restorePointInTime.
Ripristino: crea un database ripristinando un backup con replica geografica. sourceDatabaseId deve essere specificato come ID risorsa di database recuperabile da ripristinare.
Ripristino: crea un database ripristinando un backup di un database eliminato. sourceDatabaseId deve essere specificato. Se sourceDatabaseId è l'ID risorsa originale del database, è necessario specificare sourceDatabaseDeletionDate. In caso contrario, sourceDatabaseId deve essere l'ID risorsa del database eliminato ripristinabile e sourceDatabaseDeletionDate viene ignorato. è anche possibile specificare restorePointInTime per eseguire il ripristino da un punto precedente nel tempo.
RestoreLongTermRetentionBackup: crea un database ripristinando da un insieme di credenziali di conservazione a lungo termine. recoveryServicesRecoveryPointResourceId deve essere specificato come ID risorsa del punto di ripristino.
Copia, Secondario e RestoreLongTermRetentionBackup non sono supportati per l'edizione DataWarehouse.
| Valore |
Descrizione |
|
Default
|
Predefinito
|
|
Copy
|
Copia
|
|
Secondary
|
Secondary
|
|
PointInTimeRestore
|
PointInTimeRestore
|
|
Restore
|
Restore
|
|
Recovery
|
Recupero
|
|
RestoreExternalBackup
|
RestoreExternalBackup
|
|
RestoreExternalBackupSecondary
|
RipristinoBackupEsternoSecondario
|
|
RestoreLongTermRetentionBackup
|
RipristinoLongtermRetentionBackup
|
|
OnlineSecondary
|
Scuola Secondaria Online
|
Database
Oggetto
Una risorsa di database.
| Nome |
Tipo |
Descrizione |
|
id
|
string
(arm-id)
|
Identificatore di risorsa completamente qualificato per la risorsa. Ad esempio, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
DatabaseIdentity
|
Identità di Azure Active Directory del database.
|
|
kind
|
string
|
Tipo di database. Si tratta di metadati usati per l'esperienza del portale di Azure.
|
|
location
|
string
|
Posizione geografica in cui risiede la risorsa
|
|
managedBy
|
string
|
Risorsa che gestisce il database.
|
|
name
|
string
|
nome della risorsa.
|
|
properties.autoPauseDelay
|
integer
(int32)
|
Tempo in minuti dopo il quale il database viene sospeso automaticamente. Un valore di -1 indica che la sospensione automatica è disabilitata
|
|
properties.availabilityZone
|
AvailabilityZoneType
|
Specifica la zona di disponibilità a cui viene aggiunto il database.
|
|
properties.catalogCollation
|
CatalogCollationType
|
Regole di confronto del catalogo di metadati.
|
|
properties.collation
|
string
|
Regole di confronto del database.
|
|
properties.createMode
|
CreateMode
|
Specifica la modalità di creazione del database.
Impostazione predefinita: creazione regolare del database.
Copia: crea un database come copia di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database di origine.
Secondario: crea un database come replica secondaria di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database primario esistente.
PointInTimeRestore: crea un database ripristinando un backup temporizzato di un database esistente. sourceDatabaseId deve essere specificato come ID risorsa del database esistente e deve essere specificato restorePointInTime.
Ripristino: crea un database ripristinando un backup con replica geografica. sourceDatabaseId deve essere specificato come ID risorsa di database recuperabile da ripristinare.
Ripristino: crea un database ripristinando un backup di un database eliminato. sourceDatabaseId deve essere specificato. Se sourceDatabaseId è l'ID risorsa originale del database, è necessario specificare sourceDatabaseDeletionDate. In caso contrario, sourceDatabaseId deve essere l'ID risorsa del database eliminato ripristinabile e sourceDatabaseDeletionDate viene ignorato. è anche possibile specificare restorePointInTime per eseguire il ripristino da un punto precedente nel tempo.
RestoreLongTermRetentionBackup: crea un database ripristinando da un insieme di credenziali di conservazione a lungo termine. recoveryServicesRecoveryPointResourceId deve essere specificato come ID risorsa del punto di ripristino.
Copia, Secondario e RestoreLongTermRetentionBackup non sono supportati per l'edizione DataWarehouse.
|
|
properties.creationDate
|
string
(date-time)
|
Data di creazione del database (formato ISO8601).
|
|
properties.currentBackupStorageRedundancy
|
BackupStorageRedundancy
|
Tipo di account di archiviazione usato per archiviare i backup per questo database.
|
|
properties.currentServiceObjectiveName
|
string
|
Nome dell'obiettivo del livello di servizio corrente del database.
|
|
properties.currentSku
|
Sku
|
Nome e livello dello SKU.
|
|
properties.databaseId
|
string
(uuid)
|
ID del database.
|
|
properties.defaultSecondaryLocation
|
string
|
Area secondaria predefinita per questo database.
|
|
properties.earliestRestoreDate
|
string
(date-time)
|
Registra la data e l'ora di inizio meno recente disponibili per il database (ISO8601 formato).
|
|
properties.elasticPoolId
|
string
(arm-id)
|
Identificatore della risorsa del pool elastico contenente il database.
|
|
properties.encryptionProtector
|
string
|
URI dell'insieme di credenziali delle chiavi di Azure del database se è configurato con le chiavi gestite dal cliente del database.
|
|
properties.encryptionProtectorAutoRotation
|
boolean
|
Flag per abilitare o disabilitare la rotazione automatica della chiave AKV della protezione di crittografia del database.
|
|
properties.failoverGroupId
|
string
|
Identificatore di risorsa del gruppo di failover a cui appartiene il database.
|
|
properties.federatedClientId
|
string
(uuid)
|
ID client usato per lo scenario cmk tra tenant per database
|
|
properties.freeLimitExhaustionBehavior
|
FreeLimitExhaustionBehavior
|
Specifica il comportamento quando vengono esauriti i limiti gratuiti mensili per il database gratuito.
AutoPause: il database verrà sospeso automaticamente al termine dell'esaurimento dei limiti gratuiti per il resto del mese.
BillForUsage: il database continuerà a essere online al momento dell'esaurimento dei limiti gratuiti e verranno fatturate eventuali eccedenze.
|
|
properties.highAvailabilityReplicaCount
|
integer
(int32)
|
Numero di repliche secondarie associate al database business critical, Premium o Hyperscale edition che vengono usate per garantire la disponibilità elevata. Non applicabile a un database Hyperscale all'interno di un pool elastico.
|
|
properties.isInfraEncryptionEnabled
|
boolean
|
La crittografia a infrastruttura è abilitata per questo database.
|
|
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.keys
|
<string,
DatabaseKey>
|
ID risorsa delle identità assegnate dall'utente da usare
|
|
properties.licenseType
|
DatabaseLicenseType
|
Tipo di licenza da applicare per questo database.
LicenseIncluded se è necessaria una licenza o BasePrice se si ha una licenza e si è idonei per il vantaggio Azure Hybrid.
|
|
properties.longTermRetentionBackupResourceId
|
string
(arm-id)
|
Identificatore della risorsa del backup di conservazione a lungo termine associato all'operazione di creazione del database.
|
|
properties.maintenanceConfigurationId
|
string
|
ID di configurazione della manutenzione assegnato al database. Questa configurazione definisce il periodo in cui verranno eseguiti gli aggiornamenti della manutenzione.
|
|
properties.manualCutover
|
boolean
|
Indica se il cutover manuale controllato dal cliente deve essere eseguito durante l'operazione Aggiorna database al livello Hyperscale.
Questa proprietà è applicabile solo quando si ridimensiona il database dal livello Business Critical/Per utilizzo generico/Premium/Standard al livello Hyperscale.
Quando si specifica manualCutover, l'operazione di ridimensionamento attenderà l'input dell'utente per attivare il cutover nel database Hyperscale.
Per attivare il cutover, specificare il parametro 'performCutover' quando l'operazione di ridimensionamento è in stato In attesa.
|
|
properties.maxLogSizeBytes
|
integer
(int64)
|
Dimensioni massime del log per questo database.
|
|
properties.maxSizeBytes
|
integer
(int64)
|
Dimensione massima del database espressa in byte.
|
|
properties.minCapacity
|
number
(double)
|
Capacità minima allocata dal database, se non sospesa
|
|
properties.pausedDate
|
string
(date-time)
|
Data in cui il database è stato sospeso dalla configurazione utente o dall'azione (formato ISO8601). Null se il database è pronto.
|
|
properties.performCutover
|
boolean
|
Per attivare il cutover manuale controllato dal cliente durante lo stato di attesa mentre è in corso l'operazione di ridimensionamento.
Questo parametro di proprietà è applicabile solo per le operazioni di ridimensionamento avviate insieme al parametro 'manualCutover'.
Questa proprietà è applicabile solo quando il database viene ridimensionato dal livello Business Critical/Per utilizzo generico/Premium/Standard al livello Hyperscale è già in corso.
Quando si specifica performCutover, l'operazione di ridimensionamento attiverà il cutover e eseguirà la modifica del ruolo nel database Hyperscale.
|
|
properties.preferredEnclaveType
|
AlwaysEncryptedEnclaveType
|
Tipo di enclave richiesto nel database, ad esempio enclave predefiniti o VBS.
|
|
properties.readScale
|
DatabaseReadScale
|
Stato del routing di sola lettura. Se abilitata, le connessioni con finalità dell'applicazione impostate su readonly nella stringa di connessione potrebbero essere indirizzate a una replica secondaria di sola lettura nella stessa area. Non applicabile a un database Hyperscale all'interno di un pool elastico.
|
|
properties.recoverableDatabaseId
|
string
(arm-id)
|
Identificatore della risorsa del database ripristinabile associato all'operazione di creazione del database.
|
|
properties.recoveryServicesRecoveryPointId
|
string
(arm-id)
|
Identificatore della risorsa del punto di ripristino associato all'operazione di creazione del database.
|
|
properties.requestedBackupStorageRedundancy
|
BackupStorageRedundancy
|
Tipo di account di archiviazione da usare per archiviare i backup per questo database.
|
|
properties.requestedServiceObjectiveName
|
string
|
Nome dell'obiettivo del livello di servizio richiesto del database.
|
|
properties.restorableDroppedDatabaseId
|
string
(arm-id)
|
Identificatore della risorsa del database eliminato ripristinabile associato all'operazione di creazione del database.
|
|
properties.restorePointInTime
|
string
(date-time)
|
Specifica il punto nel tempo (formato ISO8601) del database di origine che verrà ripristinato per creare il nuovo database.
|
|
properties.resumedDate
|
string
(date-time)
|
Data in cui il database è stato ripreso dall'azione dell'utente o dall'account di accesso al database (ISO8601 formato). Null se il database è sospeso.
|
|
properties.sampleName
|
SampleName
|
Nome dello schema di esempio da applicare durante la creazione del database.
|
|
properties.secondaryType
|
SecondaryType
|
Tipo secondario del database se è secondario. I valori validi sono Geo, Named e Standby.
|
|
properties.sourceDatabaseDeletionDate
|
string
(date-time)
|
Specifica l'ora di eliminazione del database.
|
|
properties.sourceDatabaseId
|
string
(arm-id)
|
Identificatore della risorsa del database di origine associato all'operazione di creazione del database.
|
|
properties.sourceResourceId
|
string
(arm-id)
|
Identificatore della risorsa dell'origine associata all'operazione di creazione del database.
Questa proprietà è supportata solo per l'edizione DataWarehouse e consente di eseguire il ripristino tra sottoscrizioni.
Quando si specifica sourceResourceId, sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId e sourceDatabaseDeletionDate non devono essere specificati e CreateMode deve essere PointInTimeRestore, Restore o Recover.
Quando createMode è PointInTimeRestore, sourceResourceId deve essere l'ID risorsa del database esistente o del pool SQL esistente e deve essere specificato restorePointInTime.
Quando createMode è Restore, sourceResourceId deve essere l'ID risorsa del database eliminato ripristinabile o ripristinare il pool SQL eliminato.
Quando createMode è Recover, sourceResourceId deve essere l'ID risorsa del database recuperabile o del pool SQL ripristinabile.
Quando la sottoscrizione di origine appartiene a un tenant diverso rispetto alla sottoscrizione di destinazione, l'intestazione "x-ms-authorization-auxiliary" deve contenere il token di autenticazione per il tenant di origine. Per altri dettagli sull'intestazione "x-ms-authorization-auxiliary", vedere https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.status
|
DatabaseStatus
|
Stato del database.
|
|
properties.useFreeLimit
|
boolean
|
Indica se il database utilizza limiti mensili gratuiti. Consentito in un database in una sottoscrizione.
|
|
properties.zoneRedundant
|
boolean
|
Indipendentemente dal fatto che il database sia con ridondanza della zona, ovvero le repliche di questo database verranno distribuite in più zone di disponibilità.
|
|
sku
|
Sku
|
SKU del database.
L'elenco degli SKU può variare in base all'area geografica e all'offerta di supporto. Per determinare gli SKU (inclusi il nome dello SKU, il livello/edizione, la famiglia e la capacità) disponibili per la sottoscrizione in un'area di Azure, usare l'API REST Capabilities_ListByLocation o uno dei comandi seguenti:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
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" o "Microsoft.Storage/storageAccounts"
|
DatabaseIdentity
Oggetto
Configurazione dell'identità di Azure Active Directory per una risorsa.
| Nome |
Tipo |
Descrizione |
|
tenantId
|
string
(uuid)
|
ID tenant di Azure Active Directory.
|
|
type
|
DatabaseIdentityType
|
Tipo di identità
|
|
userAssignedIdentities
|
<string,
DatabaseUserIdentity>
|
ID risorsa delle identità assegnate dall'utente da usare
|
DatabaseIdentityType
Enumerazione
Tipo di identità
| Valore |
Descrizione |
|
None
|
Nessuno
|
|
UserAssigned
|
UserAssigned
|
DatabaseKey
Oggetto
Chiave a livello di database usata per la crittografia dei dati inattivi.
| Nome |
Tipo |
Descrizione |
|
creationDate
|
string
(date-time)
|
Data di creazione della chiave del database.
|
|
keyVersion
|
string
|
Versione della chiave del database.
|
|
subregion
|
string
|
Sottoarea della chiave del server.
|
|
thumbprint
|
string
|
Identificazione personale della chiave del database.
|
|
type
|
DatabaseKeyType
|
Tipo di chiave del database. Solo il valore supportato è 'AzureKeyVault'.
|
DatabaseKeyType
Enumerazione
Tipo di chiave del database. Solo il valore supportato è 'AzureKeyVault'.
| Valore |
Descrizione |
|
AzureKeyVault
|
AzureKeyVault
|
DatabaseLicenseType
Enumerazione
Tipo di licenza da applicare per questo database.
LicenseIncluded se è necessaria una licenza o BasePrice se si ha una licenza e si è idonei per il vantaggio Azure Hybrid.
| Valore |
Descrizione |
|
LicenseIncluded
|
LicenzaInclusa
|
|
BasePrice
|
BasePrice
|
DatabaseReadScale
Enumerazione
Stato del routing di sola lettura. Se abilitata, le connessioni con finalità dell'applicazione impostate su readonly nella stringa di connessione potrebbero essere indirizzate a una replica secondaria di sola lettura nella stessa area. Non applicabile a un database Hyperscale all'interno di un pool elastico.
| Valore |
Descrizione |
|
Enabled
|
Enabled
|
|
Disabled
|
Disattivato
|
DatabaseStatus
Enumerazione
Stato del database.
| Valore |
Descrizione |
|
Online
|
In linea
|
|
Restoring
|
Ripristino
|
|
RecoveryPending
|
RecuperoIn sospeso
|
|
Recovering
|
Ripristino
|
|
Suspect
|
Sospettare
|
|
Offline
|
Fuori rete
|
|
Standby
|
Standby
|
|
Shutdown
|
Spegnimento
|
|
EmergencyMode
|
Modalità di emergenza
|
|
AutoClosed
|
AutoChiuso
|
|
Copying
|
Copiare
|
|
Creating
|
Creazione
|
|
Inaccessible
|
Inaccessibile
|
|
OfflineSecondary
|
OfflineSecondario
|
|
Pausing
|
Sospensione
|
|
Paused
|
Pausa
|
|
Resuming
|
Resuming
|
|
Scaling
|
Scalabilità
|
|
OfflineChangingDwPerformanceTiers
|
OfflineChangingDwPerformanceTiers
|
|
OnlineChangingDwPerformanceTiers
|
OnlineChangingDwPerformanceTiers
|
|
Disabled
|
Disattivato
|
|
Stopping
|
Interruzione
|
|
Stopped
|
Fermato
|
|
Starting
|
Starting
|
DatabaseUserIdentity
Oggetto
Configurazione dell'identità di Azure Active Directory per una risorsa.
| Nome |
Tipo |
Descrizione |
|
clientId
|
string
(uuid)
|
ID client di Azure Active Directory.
|
|
principalId
|
string
(uuid)
|
ID dell'entità di sicurezza di Azure Active Directory.
|
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
FreeLimitExhaustionBehavior
Enumerazione
Specifica il comportamento quando vengono esauriti i limiti gratuiti mensili per il database gratuito.
AutoPause: il database verrà sospeso automaticamente al termine dell'esaurimento dei limiti gratuiti per il resto del mese.
BillForUsage: il database continuerà a essere online al momento dell'esaurimento dei limiti gratuiti e verranno fatturate eventuali eccedenze.
| Valore |
Descrizione |
|
AutoPause
|
Autopausa
|
|
BillOverUsage
|
Uso di FatturaOverConsumo
|
SampleName
Enumerazione
Nome dello schema di esempio da applicare durante la creazione del database.
| Valore |
Descrizione |
|
AdventureWorksLT
|
AdventureWorksLT
|
|
WideWorldImportersStd
|
WideWorldImportersStd
|
|
WideWorldImportersFull
|
WideWorldImportersFull
|
SecondaryType
Enumerazione
Tipo secondario del database se è secondario. I valori validi sono Geo, Named e Standby.
| Valore |
Descrizione |
|
Geo
|
Geo
|
|
Named
|
denominata
|
|
Standby
|
Standby
|
Sku
Oggetto
Definizione del modello di risorse che rappresenta lo SKU
| Nome |
Tipo |
Descrizione |
|
capacity
|
integer
(int32)
|
Se lo SKU supporta l'aumento o l'aumento del numero di istanze, è necessario includere l'intero della capacità. Se non è possibile aumentare o ridurre il numero di istanze per la risorsa, potrebbe essere omesso.
|
|
family
|
string
|
Se il servizio ha generazioni diverse di hardware, per lo stesso SKU, è possibile acquisire qui.
|
|
name
|
string
|
Nome dello SKU. Ad esempio P3. Si tratta in genere di un codice lettera+numero
|
|
size
|
string
|
Dimensioni dello SKU. Quando il campo nome è la combinazione di livello e un altro valore, si tratta del codice autonomo.
|
|
tier
|
SkuTier
|
Questo campo deve essere implementato dal provider di risorse se il servizio ha più di un livello, ma non è necessario in un PUT.
|
SkuTier
Enumerazione
Questo campo deve essere implementato dal provider di risorse se il servizio ha più di un livello, ma non è necessario in un PUT.
| Valore |
Descrizione |
|
Free
|
|
|
Basic
|
|
|
Standard
|
|
|
Premium
|
|
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)
|
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.
|