Yeni bir veritabanı oluşturur veya mevcut bir veritabanını güncelleştirir.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}?api-version=2025-01-01
URI Parametreleri
| Name |
İçinde |
Gerekli |
Tür |
Description |
|
databaseName
|
path |
True
|
string
|
Veritabanının adı.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
Kaynak grubunun adı. İsim büyük/küçük harfe duyarsızdır.
|
|
serverName
|
path |
True
|
string
|
Sunucunun adı.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
Hedef aboneliğin kimliği. Değer bir UUID olmalıdır.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
Bu işlem için kullanılacak API sürümü.
|
İstek Gövdesi
| Name |
Gerekli |
Tür |
Description |
|
location
|
True
|
string
|
Kaynağın bulunduğu coğrafi konum
|
|
identity
|
|
DatabaseIdentity
|
Veritabanının Azure Active Directory kimliği.
|
|
properties.autoPauseDelay
|
|
integer
(int32)
|
Veritabanının otomatik olarak duraklatıldığı dakika cinsinden süre. -1 değeri, otomatik duraklatma'nın devre dışı bırakıldığını gösterir
|
|
properties.availabilityZone
|
|
AvailabilityZoneType
|
Veritabanının sabitlendiği kullanılabilirlik bölgesini belirtir.
|
|
properties.catalogCollation
|
|
CatalogCollationType
|
Meta veri kataloğu harmanlaması.
|
|
properties.collation
|
|
string
|
Veritabanının harmanlaması.
|
|
properties.createMode
|
|
CreateMode
|
Veritabanı oluşturma modunu belirtir.
Varsayılan: normal veritabanı oluşturma.
Kopyala: Mevcut bir veritabanının kopyası olarak bir veritabanı oluşturur. sourceDatabaseId, kaynak veritabanının kaynak kimliği olarak belirtilmelidir.
İkincil: Var olan bir veritabanının ikincil çoğaltması olarak bir veritabanı oluşturur. sourceDatabaseId, mevcut birincil veritabanının kaynak kimliği olarak belirtilmelidir.
PointInTimeRestore: Mevcut bir veritabanının belirli bir noktaya yedeklemesini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId, mevcut veritabanının kaynak kimliği olarak belirtilmelidir ve restorePointInTime belirtilmelidir.
Kurtarma: Coğrafi olarak çoğaltılmış bir yedeklemeyi geri yükleyerek bir veritabanı oluşturur. geri yüklenecek kurtarılabilir veritabanı kaynak kimliği olarak sourceDatabaseId belirtilmelidir.
Geri Yükleme: Silinen bir veritabanının yedeğini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId belirtilmelidir. sourceDatabaseId veritabanının özgün kaynak kimliğiyse sourceDatabaseDeletionDate belirtilmelidir. Aksi takdirde sourceDatabaseId geri yüklenebilir bırakılan veritabanı kaynak kimliği olmalıdır ve sourceDatabaseDeletionDate yoksayılır. restorePointInTime, zamanın önceki bir noktasından geri yüklemek için de belirtilebilir.
RestoreLongTermRetentionBackup: Uzun süreli saklama kasasından geri yükleyerek bir veritabanı oluşturur. recoveryServicesRecoveryPointResourceId, kurtarma noktası kaynak kimliği olarak belirtilmelidir.
Copy, Secondary ve RestoreLongTermRetentionBackup, DataWarehouse sürümü için desteklenmez.
|
|
properties.elasticPoolId
|
|
string
(arm-id)
|
Bu veritabanını içeren elastik havuzun kaynak tanımlayıcısı.
|
|
properties.encryptionProtector
|
|
string
|
Veritabanı Müşteri Tarafından Yönetilen Anahtarlar başına ile yapılandırılmışsa veritabanının azure anahtar kasası URI'si.
|
|
properties.encryptionProtectorAutoRotation
|
|
boolean
|
Veritabanı şifreleme koruyucusu AKV anahtarının otomatik döndürmesini etkinleştirme veya devre dışı bırakma bayrağı.
|
|
properties.federatedClientId
|
|
string
(uuid)
|
Veritabanı başına kiracılar arası CMK senaryosu için kullanılan İstemci kimliği
|
|
properties.freeLimitExhaustionBehavior
|
|
FreeLimitExhaustionBehavior
|
Ücretsiz veritabanı için aylık ücretsiz sınırlar tükendiğinde davranışı belirtir.
Otomatik Kullan: Veritabanı, ayın geri kalanında ücretsiz sınırların tükenmesi üzerine otomatik olarak duraklatılır.
BillForUsage: Veritabanı, ücretsiz sınırların tükenmesi üzerine çevrimiçi olmaya devam eder ve fazla kullanım faturalandırılır.
|
|
properties.highAvailabilityReplicaCount
|
|
integer
(int32)
|
yüksek kullanılabilirlik sağlamak için kullanılan İş Açısından Kritik, Premium veya Hiper Ölçek sürümü veritabanıyla ilişkili ikincil çoğaltmaların sayısı. Elastik havuz içindeki hiper ölçek veritabanı için geçerli değildir.
|
|
properties.isLedgerOn
|
|
boolean
|
Bu veritabanının bir kayıt defteri veritabanı olup olmadığı, veritabanındaki tüm tabloların kayıt defteri tabloları olduğu anlamına gelir. Not: Veritabanı oluşturulduktan sonra bu özelliğin değeri değiştirilemez.
|
|
properties.keys
|
|
<string,
DatabaseKey>
|
Kullanılacak kullanıcı tarafından atanan kimliklerin kaynak kimlikleri
|
|
properties.licenseType
|
|
DatabaseLicenseType
|
Bu veritabanı için uygulanacak lisans türü. Lisansa ihtiyacınız varsa LicenseIncluded veya lisansınız olup olmadığını ve Azure Hibrit Avantajı'na uygun olup olmadığınızı BasePrice.
|
|
properties.longTermRetentionBackupResourceId
|
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili uzun süreli saklama yedeklemesinin kaynak tanımlayıcısı.
|
|
properties.maintenanceConfigurationId
|
|
string
|
Veritabanına atanan bakım yapılandırma kimliği. Bu yapılandırma, bakım güncelleştirmelerinin gerçekleşeceği dönemi tanımlar.
|
|
properties.manualCutover
|
|
boolean
|
Veritabanını Hiper Ölçek katmanına güncelleştirme işlemi sırasında müşteri tarafından denetlenen el ile tam geçişin yapılması gerekip gerekmediği.
Bu özellik yalnızca veritabanını İş Açısından Kritik/Genel Amaçlı/Premium/Standart katmandan Hiper Ölçek katmanına ölçeklendirirken geçerlidir.
manualCutover belirtildiğinde, ölçeklendirme işlemi kullanıcı girişinin Hiper Ölçek veritabanına tam geçişi tetiklemesini bekler.
Tam geçişi tetikleyebilmek için ölçeklendirme işlemi Bekleme durumundayken lütfen 'performCutover' parametresini sağlayın.
|
|
properties.maxSizeBytes
|
|
integer
(int64)
|
Veritabanının bayt cinsinden ifade edilen en büyük boyutu.
|
|
properties.minCapacity
|
|
number
(double)
|
Duraklatılmadıysa veritabanının her zaman ayıracağı en düşük kapasite
|
|
properties.performCutover
|
|
boolean
|
Ölçeklendirme işlemi devam ederken bekleme durumunda müşteri tarafından denetlenen el ile tam geçişi tetikleme.
Bu özellik parametresi yalnızca 'manualCutover' parametresiyle birlikte başlatılan ölçeklendirme işlemleri için geçerlidir.
Bu özellik yalnızca veritabanını İş Açısından Kritik/Genel Amaçlı/Premium/Standart katmandan Hiper Ölçek katmanına ölçeklendirme işlemi devam ederken geçerlidir.
performCutover belirtildiğinde ölçeklendirme işlemi tam geçişi tetikler ve Hiper Ölçek veritabanında rol değişikliği gerçekleştirir.
|
|
properties.preferredEnclaveType
|
|
AlwaysEncryptedEnclaveType
|
Veritabanında istenen kapanım türü; örneğin, Varsayılan veya VBS kuşatmaları.
|
|
properties.readScale
|
|
DatabaseReadScale
|
Salt okunur yönlendirmenin durumu. Etkinleştirilirse, bağlantı dizesinde uygulama amacı salt okunur olarak ayarlanmış bağlantılar aynı bölgedeki salt okunur ikincil çoğaltmaya yönlendirilebilir. Elastik havuz içindeki hiper ölçek veritabanı için geçerli değildir.
|
|
properties.recoverableDatabaseId
|
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kurtarılabilir veritabanının kaynak tanımlayıcısı.
|
|
properties.recoveryServicesRecoveryPointId
|
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kurtarma noktasının kaynak tanımlayıcısı.
|
|
properties.requestedBackupStorageRedundancy
|
|
BackupStorageRedundancy
|
Bu veritabanına yönelik yedeklemeleri depolamak için kullanılacak depolama hesabı türü.
|
|
properties.restorableDroppedDatabaseId
|
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili geri yüklenebilir bırakılan veritabanının kaynak tanımlayıcısı.
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
Yeni veritabanını oluşturmak için geri yüklenecek kaynak veritabanının zaman noktasını (ISO8601 biçimi) belirtir.
|
|
properties.sampleName
|
|
SampleName
|
Bu veritabanı oluşturulurken uygulanacak örnek şemanın adı.
|
|
properties.secondaryType
|
|
SecondaryType
|
İkincil bir veritabanıysa veritabanının ikincil türü. Geçerli değerler Coğrafi, Adlandırılmış ve Beklemede değerleridir.
|
|
properties.sourceDatabaseDeletionDate
|
|
string
(date-time)
|
Veritabanının silindiği saati belirtir.
|
|
properties.sourceDatabaseId
|
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kaynak veritabanının kaynak tanımlayıcısı.
|
|
properties.sourceResourceId
|
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kaynağın kaynak tanımlayıcısı.
Bu özellik yalnızca DataWarehouse sürümü için desteklenir ve abonelikler arasında geri yüklemeye izin verir.
sourceResourceId belirtildiğinde sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId ve sourceDatabaseDeletionDate belirtilmemeli ve CreateMode pointInTimeRestore, Restore veya Recover olmalıdır.
createMode PointInTimeRestore olduğunda, sourceResourceId mevcut veritabanının veya mevcut SQL havuzunun kaynak kimliği olmalı ve restorePointInTime belirtilmelidir.
createMode Geri Yükle olduğunda sourceResourceId geri yüklenebilir bırakılan veritabanının veya geri yüklenebilir bırakılan sql havuzunun kaynak kimliği olmalıdır.
createMode Kurtar olduğunda sourceResourceId kurtarılabilir veritabanının veya kurtarılabilir SQL havuzunun kaynak kimliği olmalıdır.
Kaynak abonelik hedef abonelikten farklı bir kiracıya aitse, "x-ms-authorization-auxiliary" üst bilgisi kaynak kiracı için kimlik doğrulama belirteci içermelidir. "x-ms-authorization-auxiliary" üst bilgisi hakkında daha fazla bilgi için bkz. https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.useFreeLimit
|
|
boolean
|
Veritabanının ücretsiz aylık sınırları kullanıp kullanmadığı. Abonelikteki bir veritabanında izin verilir.
|
|
properties.zoneRedundant
|
|
boolean
|
Bu veritabanının alanlar arası yedekli olup olmadığı, bu veritabanının çoğaltmalarının birden çok kullanılabilirlik alanına yayılacağı anlamına gelir.
|
|
sku
|
|
Sku
|
Veritabanı SKU'su.
SKU'ların listesi bölgeye ve destek teklifine göre farklılık gösterebilir. Azure bölgesindeki aboneliğiniz için kullanılabilen SKU'ları (SKU adı, katman/sürüm, aile ve kapasite dahil) belirlemek için Capabilities_ListByLocation REST API'sini veya aşağıdaki komutlardan birini kullanın:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
tags
|
|
object
|
Kaynak etiketleri.
|
Yanıtlar
| Name |
Tür |
Description |
|
200 OK
|
Database
|
Kaynak 'Veritabanı' güncelleştirme işlemi başarılı oldu
|
|
201 Created
|
Database
|
Kaynak 'Veritabanı' oluşturma işlemi başarılı oldu
Üst Bilgiler
Azure-AsyncOperation: string
|
|
202 Accepted
|
|
Kaynak işlemi kabul edildi.
Üst Bilgiler
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
Beklenmeyen bir hata yanıtı.
|
Güvenlik
azure_auth
Azure Active Directory OAuth2 Akışı.
Tür:
oauth2
Akış:
implicit
Yetkilendirme URL’si:
https://login.microsoftonline.com/common/oauth2/authorize
Kapsamlar
| Name |
Description |
|
user_impersonation
|
kullanıcı hesabınızı taklit etme
|
Örnekler
Creates a data warehouse database as a cross-subscription restore from a backup of a dropped database.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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.
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Örnek isteği
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
Örnek yanıt
{
"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
Tanımlar
| Name |
Description |
|
AlwaysEncryptedEnclaveType
|
Veritabanında istenen kapanım türü; örneğin, Varsayılan veya VBS kuşatmaları.
|
|
AvailabilityZoneType
|
Veritabanının sabitlendiği kullanılabilirlik bölgesini belirtir.
|
|
BackupStorageRedundancy
|
Bu veritabanı için yedeklemeleri depolamak için kullanılan depolama hesabı türü.
|
|
CatalogCollationType
|
Meta veri kataloğu harmanlaması.
|
|
createdByType
|
Kaynağı oluşturan kimliğin türü.
|
|
CreateMode
|
Veritabanı oluşturma modunu belirtir.
Varsayılan: normal veritabanı oluşturma.
Kopyala: Mevcut bir veritabanının kopyası olarak bir veritabanı oluşturur. sourceDatabaseId, kaynak veritabanının kaynak kimliği olarak belirtilmelidir.
İkincil: Var olan bir veritabanının ikincil çoğaltması olarak bir veritabanı oluşturur. sourceDatabaseId, mevcut birincil veritabanının kaynak kimliği olarak belirtilmelidir.
PointInTimeRestore: Mevcut bir veritabanının belirli bir noktaya yedeklemesini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId, mevcut veritabanının kaynak kimliği olarak belirtilmelidir ve restorePointInTime belirtilmelidir.
Kurtarma: Coğrafi olarak çoğaltılmış bir yedeklemeyi geri yükleyerek bir veritabanı oluşturur. geri yüklenecek kurtarılabilir veritabanı kaynak kimliği olarak sourceDatabaseId belirtilmelidir.
Geri Yükleme: Silinen bir veritabanının yedeğini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId belirtilmelidir. sourceDatabaseId veritabanının özgün kaynak kimliğiyse sourceDatabaseDeletionDate belirtilmelidir. Aksi takdirde sourceDatabaseId geri yüklenebilir bırakılan veritabanı kaynak kimliği olmalıdır ve sourceDatabaseDeletionDate yoksayılır. restorePointInTime, zamanın önceki bir noktasından geri yüklemek için de belirtilebilir.
RestoreLongTermRetentionBackup: Uzun süreli saklama kasasından geri yükleyerek bir veritabanı oluşturur. recoveryServicesRecoveryPointResourceId, kurtarma noktası kaynak kimliği olarak belirtilmelidir.
Copy, Secondary ve RestoreLongTermRetentionBackup, DataWarehouse sürümü için desteklenmez.
|
|
Database
|
Veritabanı kaynağı.
|
|
DatabaseIdentity
|
Bir kaynak için Azure Active Directory kimlik yapılandırması.
|
|
DatabaseIdentityType
|
Kimlik türü
|
|
DatabaseKey
|
Bekleyen şifreleme için kullanılan veritabanı düzeyi anahtarı.
|
|
DatabaseKeyType
|
Veritabanı anahtar türü. Yalnızca desteklenen değer 'AzureKeyVault' değeridir.
|
|
DatabaseLicenseType
|
Bu veritabanı için uygulanacak lisans türü. Lisansa ihtiyacınız varsa LicenseIncluded veya lisansınız olup olmadığını ve Azure Hibrit Avantajı'na uygun olup olmadığınızı BasePrice.
|
|
DatabaseReadScale
|
Salt okunur yönlendirmenin durumu. Etkinleştirilirse, bağlantı dizesinde uygulama amacı salt okunur olarak ayarlanmış bağlantılar aynı bölgedeki salt okunur ikincil çoğaltmaya yönlendirilebilir. Elastik havuz içindeki hiper ölçek veritabanı için geçerli değildir.
|
|
DatabaseStatus
|
Veritabanının durumu.
|
|
DatabaseUserIdentity
|
Bir kaynak için Azure Active Directory kimlik yapılandırması.
|
|
ErrorAdditionalInfo
|
Kaynak yönetimi hatası ek bilgileri.
|
|
ErrorDetail
|
Hata ayrıntısı.
|
|
ErrorResponse
|
Hata yanıtı
|
|
FreeLimitExhaustionBehavior
|
Ücretsiz veritabanı için aylık ücretsiz sınırlar tükendiğinde davranışı belirtir.
Otomatik Kullan: Veritabanı, ayın geri kalanında ücretsiz sınırların tükenmesi üzerine otomatik olarak duraklatılır.
BillForUsage: Veritabanı, ücretsiz sınırların tükenmesi üzerine çevrimiçi olmaya devam eder ve fazla kullanım faturalandırılır.
|
|
SampleName
|
Bu veritabanı oluşturulurken uygulanacak örnek şemanın adı.
|
|
SecondaryType
|
İkincil bir veritabanıysa veritabanının ikincil türü. Geçerli değerler Coğrafi, Adlandırılmış ve Beklemede değerleridir.
|
|
Sku
|
SKU'yu temsil eden kaynak modeli tanımı
|
|
SkuTier
|
Hizmetin birden fazla katmanı varsa, ancak PUT üzerinde gerekli değilse, bu alanın Kaynak Sağlayıcısı tarafından uygulanması gerekir.
|
|
systemData
|
Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.
|
AlwaysEncryptedEnclaveType
Numaralandırma
Veritabanında istenen kapanım türü; örneğin, Varsayılan veya VBS kuşatmaları.
| Değer |
Description |
|
Default
|
Varsayılan
|
|
VBS
|
VBS
|
AvailabilityZoneType
Numaralandırma
Veritabanının sabitlendiği kullanılabilirlik bölgesini belirtir.
| Değer |
Description |
|
NoPreference
|
Tercih Yok
|
|
1
|
1
|
|
2
|
2
|
|
3
|
3
|
BackupStorageRedundancy
Numaralandırma
Bu veritabanı için yedeklemeleri depolamak için kullanılan depolama hesabı türü.
| Değer |
Description |
|
Geo
|
Coğrafya
|
|
Local
|
Local
|
|
Zone
|
Bölge
|
|
GeoZone
|
GeoZone
|
CatalogCollationType
Numaralandırma
Meta veri kataloğu harmanlaması.
| Değer |
Description |
|
DATABASE_DEFAULT
|
DATABASE_DEFAULT
|
|
SQL_Latin1_General_CP1_CI_AS
|
SQL_Latin1_General_CP1_CI_AS
|
createdByType
Numaralandırma
Kaynağı oluşturan kimliğin türü.
| Değer |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
CreateMode
Numaralandırma
Veritabanı oluşturma modunu belirtir.
Varsayılan: normal veritabanı oluşturma.
Kopyala: Mevcut bir veritabanının kopyası olarak bir veritabanı oluşturur. sourceDatabaseId, kaynak veritabanının kaynak kimliği olarak belirtilmelidir.
İkincil: Var olan bir veritabanının ikincil çoğaltması olarak bir veritabanı oluşturur. sourceDatabaseId, mevcut birincil veritabanının kaynak kimliği olarak belirtilmelidir.
PointInTimeRestore: Mevcut bir veritabanının belirli bir noktaya yedeklemesini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId, mevcut veritabanının kaynak kimliği olarak belirtilmelidir ve restorePointInTime belirtilmelidir.
Kurtarma: Coğrafi olarak çoğaltılmış bir yedeklemeyi geri yükleyerek bir veritabanı oluşturur. geri yüklenecek kurtarılabilir veritabanı kaynak kimliği olarak sourceDatabaseId belirtilmelidir.
Geri Yükleme: Silinen bir veritabanının yedeğini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId belirtilmelidir. sourceDatabaseId veritabanının özgün kaynak kimliğiyse sourceDatabaseDeletionDate belirtilmelidir. Aksi takdirde sourceDatabaseId geri yüklenebilir bırakılan veritabanı kaynak kimliği olmalıdır ve sourceDatabaseDeletionDate yoksayılır. restorePointInTime, zamanın önceki bir noktasından geri yüklemek için de belirtilebilir.
RestoreLongTermRetentionBackup: Uzun süreli saklama kasasından geri yükleyerek bir veritabanı oluşturur. recoveryServicesRecoveryPointResourceId, kurtarma noktası kaynak kimliği olarak belirtilmelidir.
Copy, Secondary ve RestoreLongTermRetentionBackup, DataWarehouse sürümü için desteklenmez.
| Değer |
Description |
|
Default
|
Varsayılan
|
|
Copy
|
Copy
|
|
Secondary
|
Secondary
|
|
PointInTimeRestore
|
PointInTimeRestore
|
|
Restore
|
Restore
|
|
Recovery
|
Kurtarma
|
|
RestoreExternalBackup
|
RestoreExternalBackup
|
|
RestoreExternalBackupSecondary
|
RestoreExternalBackupSecondary
|
|
RestoreLongTermRetentionBackup
|
Uzun SüreliTutmaYedekleme Geri YüklemeT
|
|
OnlineSecondary
|
OnlineSecondary
|
Database
Nesne
Veritabanı kaynağı.
| Name |
Tür |
Description |
|
id
|
string
(arm-id)
|
Kaynağın tam nitelikli kaynak kimliği. Örneğin, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
DatabaseIdentity
|
Veritabanının Azure Active Directory kimliği.
|
|
kind
|
string
|
Veritabanı türü. Bu, Azure portalı deneyimi için kullanılan meta verilerdir.
|
|
location
|
string
|
Kaynağın bulunduğu coğrafi konum
|
|
managedBy
|
string
|
Veritabanını yöneten kaynak.
|
|
name
|
string
|
Kaynağın adı
|
|
properties.autoPauseDelay
|
integer
(int32)
|
Veritabanının otomatik olarak duraklatıldığı dakika cinsinden süre. -1 değeri, otomatik duraklatma'nın devre dışı bırakıldığını gösterir
|
|
properties.availabilityZone
|
AvailabilityZoneType
|
Veritabanının sabitlendiği kullanılabilirlik bölgesini belirtir.
|
|
properties.catalogCollation
|
CatalogCollationType
|
Meta veri kataloğu harmanlaması.
|
|
properties.collation
|
string
|
Veritabanının harmanlaması.
|
|
properties.createMode
|
CreateMode
|
Veritabanı oluşturma modunu belirtir.
Varsayılan: normal veritabanı oluşturma.
Kopyala: Mevcut bir veritabanının kopyası olarak bir veritabanı oluşturur. sourceDatabaseId, kaynak veritabanının kaynak kimliği olarak belirtilmelidir.
İkincil: Var olan bir veritabanının ikincil çoğaltması olarak bir veritabanı oluşturur. sourceDatabaseId, mevcut birincil veritabanının kaynak kimliği olarak belirtilmelidir.
PointInTimeRestore: Mevcut bir veritabanının belirli bir noktaya yedeklemesini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId, mevcut veritabanının kaynak kimliği olarak belirtilmelidir ve restorePointInTime belirtilmelidir.
Kurtarma: Coğrafi olarak çoğaltılmış bir yedeklemeyi geri yükleyerek bir veritabanı oluşturur. geri yüklenecek kurtarılabilir veritabanı kaynak kimliği olarak sourceDatabaseId belirtilmelidir.
Geri Yükleme: Silinen bir veritabanının yedeğini geri yükleyerek bir veritabanı oluşturur. sourceDatabaseId belirtilmelidir. sourceDatabaseId veritabanının özgün kaynak kimliğiyse sourceDatabaseDeletionDate belirtilmelidir. Aksi takdirde sourceDatabaseId geri yüklenebilir bırakılan veritabanı kaynak kimliği olmalıdır ve sourceDatabaseDeletionDate yoksayılır. restorePointInTime, zamanın önceki bir noktasından geri yüklemek için de belirtilebilir.
RestoreLongTermRetentionBackup: Uzun süreli saklama kasasından geri yükleyerek bir veritabanı oluşturur. recoveryServicesRecoveryPointResourceId, kurtarma noktası kaynak kimliği olarak belirtilmelidir.
Copy, Secondary ve RestoreLongTermRetentionBackup, DataWarehouse sürümü için desteklenmez.
|
|
properties.creationDate
|
string
(date-time)
|
Veritabanının oluşturulma tarihi (ISO8601 biçimi).
|
|
properties.currentBackupStorageRedundancy
|
BackupStorageRedundancy
|
Bu veritabanı için yedeklemeleri depolamak için kullanılan depolama hesabı türü.
|
|
properties.currentServiceObjectiveName
|
string
|
Veritabanının geçerli hizmet düzeyi hedef adı.
|
|
properties.currentSku
|
Sku
|
SKU'nun adı ve katmanı.
|
|
properties.databaseId
|
string
(uuid)
|
Veritabanının kimliği.
|
|
properties.defaultSecondaryLocation
|
string
|
Bu veritabanı için varsayılan ikincil bölge.
|
|
properties.earliestRestoreDate
|
string
(date-time)
|
Bu, bu veritabanı için geri yüklemenin kullanılabilir olduğu en erken başlangıç tarihini ve saatini kaydeder (ISO8601 biçimi).
|
|
properties.elasticPoolId
|
string
(arm-id)
|
Bu veritabanını içeren elastik havuzun kaynak tanımlayıcısı.
|
|
properties.encryptionProtector
|
string
|
Veritabanı Müşteri Tarafından Yönetilen Anahtarlar başına ile yapılandırılmışsa veritabanının azure anahtar kasası URI'si.
|
|
properties.encryptionProtectorAutoRotation
|
boolean
|
Veritabanı şifreleme koruyucusu AKV anahtarının otomatik döndürmesini etkinleştirme veya devre dışı bırakma bayrağı.
|
|
properties.failoverGroupId
|
string
|
Bu veritabanının ait olduğu Yük Devretme Grubu kaynak tanımlayıcısı.
|
|
properties.federatedClientId
|
string
(uuid)
|
Veritabanı başına kiracılar arası CMK senaryosu için kullanılan İstemci kimliği
|
|
properties.freeLimitExhaustionBehavior
|
FreeLimitExhaustionBehavior
|
Ücretsiz veritabanı için aylık ücretsiz sınırlar tükendiğinde davranışı belirtir.
Otomatik Kullan: Veritabanı, ayın geri kalanında ücretsiz sınırların tükenmesi üzerine otomatik olarak duraklatılır.
BillForUsage: Veritabanı, ücretsiz sınırların tükenmesi üzerine çevrimiçi olmaya devam eder ve fazla kullanım faturalandırılır.
|
|
properties.highAvailabilityReplicaCount
|
integer
(int32)
|
yüksek kullanılabilirlik sağlamak için kullanılan İş Açısından Kritik, Premium veya Hiper Ölçek sürümü veritabanıyla ilişkili ikincil çoğaltmaların sayısı. Elastik havuz içindeki hiper ölçek veritabanı için geçerli değildir.
|
|
properties.isInfraEncryptionEnabled
|
boolean
|
Bu veritabanı için infra şifrelemesi etkinleştirildi.
|
|
properties.isLedgerOn
|
boolean
|
Bu veritabanının bir kayıt defteri veritabanı olup olmadığı, veritabanındaki tüm tabloların kayıt defteri tabloları olduğu anlamına gelir. Not: Veritabanı oluşturulduktan sonra bu özelliğin değeri değiştirilemez.
|
|
properties.keys
|
<string,
DatabaseKey>
|
Kullanılacak kullanıcı tarafından atanan kimliklerin kaynak kimlikleri
|
|
properties.licenseType
|
DatabaseLicenseType
|
Bu veritabanı için uygulanacak lisans türü. Lisansa ihtiyacınız varsa LicenseIncluded veya lisansınız olup olmadığını ve Azure Hibrit Avantajı'na uygun olup olmadığınızı BasePrice.
|
|
properties.longTermRetentionBackupResourceId
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili uzun süreli saklama yedeklemesinin kaynak tanımlayıcısı.
|
|
properties.maintenanceConfigurationId
|
string
|
Veritabanına atanan bakım yapılandırma kimliği. Bu yapılandırma, bakım güncelleştirmelerinin gerçekleşeceği dönemi tanımlar.
|
|
properties.manualCutover
|
boolean
|
Veritabanını Hiper Ölçek katmanına güncelleştirme işlemi sırasında müşteri tarafından denetlenen el ile tam geçişin yapılması gerekip gerekmediği.
Bu özellik yalnızca veritabanını İş Açısından Kritik/Genel Amaçlı/Premium/Standart katmandan Hiper Ölçek katmanına ölçeklendirirken geçerlidir.
manualCutover belirtildiğinde, ölçeklendirme işlemi kullanıcı girişinin Hiper Ölçek veritabanına tam geçişi tetiklemesini bekler.
Tam geçişi tetikleyebilmek için ölçeklendirme işlemi Bekleme durumundayken lütfen 'performCutover' parametresini sağlayın.
|
|
properties.maxLogSizeBytes
|
integer
(int64)
|
Bu veritabanı için en büyük günlük boyutu.
|
|
properties.maxSizeBytes
|
integer
(int64)
|
Veritabanının bayt cinsinden ifade edilen en büyük boyutu.
|
|
properties.minCapacity
|
number
(double)
|
Duraklatılmadıysa veritabanının her zaman ayıracağı en düşük kapasite
|
|
properties.pausedDate
|
string
(date-time)
|
Veritabanının kullanıcı yapılandırması veya eylemi (ISO8601 biçimi) tarafından duraklatıldığı tarih. Veritabanı hazırsa null.
|
|
properties.performCutover
|
boolean
|
Ölçeklendirme işlemi devam ederken bekleme durumunda müşteri tarafından denetlenen el ile tam geçişi tetikleme.
Bu özellik parametresi yalnızca 'manualCutover' parametresiyle birlikte başlatılan ölçeklendirme işlemleri için geçerlidir.
Bu özellik yalnızca veritabanını İş Açısından Kritik/Genel Amaçlı/Premium/Standart katmandan Hiper Ölçek katmanına ölçeklendirme işlemi devam ederken geçerlidir.
performCutover belirtildiğinde ölçeklendirme işlemi tam geçişi tetikler ve Hiper Ölçek veritabanında rol değişikliği gerçekleştirir.
|
|
properties.preferredEnclaveType
|
AlwaysEncryptedEnclaveType
|
Veritabanında istenen kapanım türü; örneğin, Varsayılan veya VBS kuşatmaları.
|
|
properties.readScale
|
DatabaseReadScale
|
Salt okunur yönlendirmenin durumu. Etkinleştirilirse, bağlantı dizesinde uygulama amacı salt okunur olarak ayarlanmış bağlantılar aynı bölgedeki salt okunur ikincil çoğaltmaya yönlendirilebilir. Elastik havuz içindeki hiper ölçek veritabanı için geçerli değildir.
|
|
properties.recoverableDatabaseId
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kurtarılabilir veritabanının kaynak tanımlayıcısı.
|
|
properties.recoveryServicesRecoveryPointId
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kurtarma noktasının kaynak tanımlayıcısı.
|
|
properties.requestedBackupStorageRedundancy
|
BackupStorageRedundancy
|
Bu veritabanına yönelik yedeklemeleri depolamak için kullanılacak depolama hesabı türü.
|
|
properties.requestedServiceObjectiveName
|
string
|
Veritabanının istenen hizmet düzeyi hedef adı.
|
|
properties.restorableDroppedDatabaseId
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili geri yüklenebilir bırakılan veritabanının kaynak tanımlayıcısı.
|
|
properties.restorePointInTime
|
string
(date-time)
|
Yeni veritabanını oluşturmak için geri yüklenecek kaynak veritabanının zaman noktasını (ISO8601 biçimi) belirtir.
|
|
properties.resumedDate
|
string
(date-time)
|
Veritabanının kullanıcı eylemi veya veritabanı oturum açma (ISO8601 biçimi) tarafından sürdürüldiği tarih. Veritabanı duraklatıldıysa null.
|
|
properties.sampleName
|
SampleName
|
Bu veritabanı oluşturulurken uygulanacak örnek şemanın adı.
|
|
properties.secondaryType
|
SecondaryType
|
İkincil bir veritabanıysa veritabanının ikincil türü. Geçerli değerler Coğrafi, Adlandırılmış ve Beklemede değerleridir.
|
|
properties.sourceDatabaseDeletionDate
|
string
(date-time)
|
Veritabanının silindiği saati belirtir.
|
|
properties.sourceDatabaseId
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kaynak veritabanının kaynak tanımlayıcısı.
|
|
properties.sourceResourceId
|
string
(arm-id)
|
Bu veritabanının oluşturma işlemiyle ilişkili kaynağın kaynak tanımlayıcısı.
Bu özellik yalnızca DataWarehouse sürümü için desteklenir ve abonelikler arasında geri yüklemeye izin verir.
sourceResourceId belirtildiğinde sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId ve sourceDatabaseDeletionDate belirtilmemeli ve CreateMode pointInTimeRestore, Restore veya Recover olmalıdır.
createMode PointInTimeRestore olduğunda, sourceResourceId mevcut veritabanının veya mevcut SQL havuzunun kaynak kimliği olmalı ve restorePointInTime belirtilmelidir.
createMode Geri Yükle olduğunda sourceResourceId geri yüklenebilir bırakılan veritabanının veya geri yüklenebilir bırakılan sql havuzunun kaynak kimliği olmalıdır.
createMode Kurtar olduğunda sourceResourceId kurtarılabilir veritabanının veya kurtarılabilir SQL havuzunun kaynak kimliği olmalıdır.
Kaynak abonelik hedef abonelikten farklı bir kiracıya aitse, "x-ms-authorization-auxiliary" üst bilgisi kaynak kiracı için kimlik doğrulama belirteci içermelidir. "x-ms-authorization-auxiliary" üst bilgisi hakkında daha fazla bilgi için bkz. https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.status
|
DatabaseStatus
|
Veritabanının durumu.
|
|
properties.useFreeLimit
|
boolean
|
Veritabanının ücretsiz aylık sınırları kullanıp kullanmadığı. Abonelikteki bir veritabanında izin verilir.
|
|
properties.zoneRedundant
|
boolean
|
Bu veritabanının alanlar arası yedekli olup olmadığı, bu veritabanının çoğaltmalarının birden çok kullanılabilirlik alanına yayılacağı anlamına gelir.
|
|
sku
|
Sku
|
Veritabanı SKU'su.
SKU'ların listesi bölgeye ve destek teklifine göre farklılık gösterebilir. Azure bölgesindeki aboneliğiniz için kullanılabilen SKU'ları (SKU adı, katman/sürüm, aile ve kapasite dahil) belirlemek için Capabilities_ListByLocation REST API'sini veya aşağıdaki komutlardan birini kullanın:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
systemData
|
systemData
|
createdBy ve modifiedBy bilgilerini içeren Azure Resource Manager meta verileri.
|
|
tags
|
object
|
Kaynak etiketleri.
|
|
type
|
string
|
Kaynağın türü. Örneğin, "Microsoft.Compute/virtualMachines" veya "Microsoft.Storage/storageAccounts"
|
DatabaseIdentity
Nesne
Bir kaynak için Azure Active Directory kimlik yapılandırması.
| Name |
Tür |
Description |
|
tenantId
|
string
(uuid)
|
Azure Active Directory kiracı kimliği.
|
|
type
|
DatabaseIdentityType
|
Kimlik türü
|
|
userAssignedIdentities
|
<string,
DatabaseUserIdentity>
|
Kullanılacak kullanıcı tarafından atanan kimliklerin kaynak kimlikleri
|
DatabaseIdentityType
Numaralandırma
Kimlik türü
| Değer |
Description |
|
None
|
Hiç kimse
|
|
UserAssigned
|
UserAssigned
|
DatabaseKey
Nesne
Bekleyen şifreleme için kullanılan veritabanı düzeyi anahtarı.
| Name |
Tür |
Description |
|
creationDate
|
string
(date-time)
|
Veritabanı anahtarı oluşturma tarihi.
|
|
keyVersion
|
string
|
Veritabanı anahtarının sürümü.
|
|
subregion
|
string
|
Sunucu anahtarının alt kaydı.
|
|
thumbprint
|
string
|
Veritabanı anahtarının parmak izi.
|
|
type
|
DatabaseKeyType
|
Veritabanı anahtar türü. Yalnızca desteklenen değer 'AzureKeyVault' değeridir.
|
DatabaseKeyType
Numaralandırma
Veritabanı anahtar türü. Yalnızca desteklenen değer 'AzureKeyVault' değeridir.
| Değer |
Description |
|
AzureKeyVault
|
AzureKeyVault
|
DatabaseLicenseType
Numaralandırma
Bu veritabanı için uygulanacak lisans türü. Lisansa ihtiyacınız varsa LicenseIncluded veya lisansınız olup olmadığını ve Azure Hibrit Avantajı'na uygun olup olmadığınızı BasePrice.
| Değer |
Description |
|
LicenseIncluded
|
Lisans Dahil
|
|
BasePrice
|
BasePrice
|
DatabaseReadScale
Numaralandırma
Salt okunur yönlendirmenin durumu. Etkinleştirilirse, bağlantı dizesinde uygulama amacı salt okunur olarak ayarlanmış bağlantılar aynı bölgedeki salt okunur ikincil çoğaltmaya yönlendirilebilir. Elastik havuz içindeki hiper ölçek veritabanı için geçerli değildir.
| Değer |
Description |
|
Enabled
|
Enabled
|
|
Disabled
|
Disabled
|
DatabaseStatus
Numaralandırma
Veritabanının durumu.
| Değer |
Description |
|
Online
|
Çevrimiçi
|
|
Restoring
|
Geri Yükleme
|
|
RecoveryPending
|
RecoveryPending
|
|
Recovering
|
Kurtarma
|
|
Suspect
|
Şüphelenmek
|
|
Offline
|
Offline
|
|
Standby
|
Bekleme modu
|
|
Shutdown
|
Kapatma işlemi
|
|
EmergencyMode
|
Acil Durum
|
|
AutoClosed
|
AutoClosed
|
|
Copying
|
Kopyalama
|
|
Creating
|
Oluşturma
|
|
Inaccessible
|
Erişilemez
|
|
OfflineSecondary
|
Çevrimdışıİkincil
|
|
Pausing
|
Duraklatılıyor
|
|
Paused
|
Duraklatıldı
|
|
Resuming
|
Sürdürülüyor
|
|
Scaling
|
Scaling
|
|
OfflineChangingDwPerformanceTiers
|
OfflineChangingDwPerformanceTiers
|
|
OnlineChangingDwPerformanceTiers
|
OnlineChangingDwPerformanceTiers
|
|
Disabled
|
Disabled
|
|
Stopping
|
Durduruluyor
|
|
Stopped
|
Durduruldu
|
|
Starting
|
Starting
|
DatabaseUserIdentity
Nesne
Bir kaynak için Azure Active Directory kimlik yapılandırması.
| Name |
Tür |
Description |
|
clientId
|
string
(uuid)
|
Azure Active Directory istemci kimliği.
|
|
principalId
|
string
(uuid)
|
Azure Active Directory asıl kimliği.
|
ErrorAdditionalInfo
Nesne
Kaynak yönetimi hatası ek bilgileri.
| Name |
Tür |
Description |
|
info
|
object
|
Ek bilgiler.
|
|
type
|
string
|
Ek bilgi türü.
|
ErrorDetail
Nesne
Hata ayrıntısı.
| Name |
Tür |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
Hata ek bilgileri.
|
|
code
|
string
|
Hata kodu.
|
|
details
|
ErrorDetail[]
|
Hata ayrıntıları.
|
|
message
|
string
|
Hata iletisi.
|
|
target
|
string
|
Hata hedefi
|
ErrorResponse
Nesne
Hata yanıtı
FreeLimitExhaustionBehavior
Numaralandırma
Ücretsiz veritabanı için aylık ücretsiz sınırlar tükendiğinde davranışı belirtir.
Otomatik Kullan: Veritabanı, ayın geri kalanında ücretsiz sınırların tükenmesi üzerine otomatik olarak duraklatılır.
BillForUsage: Veritabanı, ücretsiz sınırların tükenmesi üzerine çevrimiçi olmaya devam eder ve fazla kullanım faturalandırılır.
| Değer |
Description |
|
AutoPause
|
Otomatik Duraklama
|
|
BillOverUsage
|
BillOverUsage
|
SampleName
Numaralandırma
Bu veritabanı oluşturulurken uygulanacak örnek şemanın adı.
| Değer |
Description |
|
AdventureWorksLT
|
AdventureWorksLT
|
|
WideWorldImportersStd
|
WideWorldImportersStd
|
|
WideWorldImportersFull
|
WideWorldImportersFull
|
SecondaryType
Numaralandırma
İkincil bir veritabanıysa veritabanının ikincil türü. Geçerli değerler Coğrafi, Adlandırılmış ve Beklemede değerleridir.
| Değer |
Description |
|
Geo
|
Coğrafya
|
|
Named
|
Adlı
|
|
Standby
|
Bekleme modu
|
Sku
Nesne
SKU'yu temsil eden kaynak modeli tanımı
| Name |
Tür |
Description |
|
capacity
|
integer
(int32)
|
SKU ölçeği genişletmeyi/genişletmeyi destekliyorsa kapasite tamsayısı dahil edilmelidir. Kaynak için ölçeği genişletme/daraltma mümkün değilse bu atlanabilir.
|
|
family
|
string
|
Hizmetin aynı SKU için farklı donanım nesilleri varsa, bu burada yakalanabilir.
|
|
name
|
string
|
SKU'nun adı. Örneğin P3. Bu genellikle bir harf+sayı kodudur
|
|
size
|
string
|
SKU boyutu. Ad alanı katman ile başka bir değerin birleşimi olduğunda, bu tek başına kod olacaktır.
|
|
tier
|
SkuTier
|
Hizmetin birden fazla katmanı varsa, ancak PUT üzerinde gerekli değilse, bu alanın Kaynak Sağlayıcısı tarafından uygulanması gerekir.
|
SkuTier
Numaralandırma
Hizmetin birden fazla katmanı varsa, ancak PUT üzerinde gerekli değilse, bu alanın Kaynak Sağlayıcısı tarafından uygulanması gerekir.
| Değer |
Description |
|
Free
|
|
|
Basic
|
|
|
Standard
|
|
|
Premium
|
|
systemData
Nesne
Kaynağın oluşturulması ve son değiştirilmesiyle ilgili meta veriler.
| Name |
Tür |
Description |
|
createdAt
|
string
(date-time)
|
Kaynak oluşturmanın zaman damgası (UTC).
|
|
createdBy
|
string
|
Kaynağı oluşturan kimlik.
|
|
createdByType
|
createdByType
|
Kaynağı oluşturan kimliğin türü.
|
|
lastModifiedAt
|
string
(date-time)
|
Kaynağın son değişikliğinin zaman damgası (UTC)
|
|
lastModifiedBy
|
string
|
Kaynağı en son değiştiren kimlik.
|
|
lastModifiedByType
|
createdByType
|
Kaynağı en son değiştiren kimlik türü.
|