Creates a new database or updates an existing database.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}?api-version=2025-01-01
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
databaseName
|
path |
True
|
string
|
The name of the database.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
|
serverName
|
path |
True
|
string
|
The name of the server.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
The ID of the target subscription. The value must be an UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Body
| Name |
Required |
Type |
Description |
|
location
|
True
|
string
|
The geo-location where the resource lives
|
|
identity
|
|
DatabaseIdentity
|
The Azure Active Directory identity of the database.
|
|
properties.autoPauseDelay
|
|
integer
(int32)
|
Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled
|
|
properties.availabilityZone
|
|
AvailabilityZoneType
|
Specifies the availability zone the database is pinned to.
|
|
properties.catalogCollation
|
|
CatalogCollationType
|
Collation of the metadata catalog.
|
|
properties.collation
|
|
string
|
The collation of the database.
|
|
properties.createMode
|
|
CreateMode
|
Specifies the mode of database creation.
Default: regular database creation.
Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database.
Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database.
PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified.
Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be specified as the recoverable database resource ID to restore.
Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must be specified. If sourceDatabaseId is the database's original resource ID, then sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may also be specified to restore from an earlier point in time.
RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource ID.
Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition.
|
|
properties.elasticPoolId
|
|
string
(arm-id)
|
The resource identifier of the elastic pool containing this database.
|
|
properties.encryptionProtector
|
|
string
|
The azure key vault URI of the database if it's configured with per Database Customer Managed Keys.
|
|
properties.encryptionProtectorAutoRotation
|
|
boolean
|
The flag to enable or disable auto rotation of database encryption protector AKV key.
|
|
properties.federatedClientId
|
|
string
(uuid)
|
The Client id used for cross tenant per database CMK scenario
|
|
properties.freeLimitExhaustionBehavior
|
|
FreeLimitExhaustionBehavior
|
Specifies the behavior when monthly free limits are exhausted for the free database.
AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the month.
BillForUsage: The database will continue to be online upon exhaustion of free limits and any overage will be billed.
|
|
properties.highAvailabilityReplicaCount
|
|
integer
(int32)
|
The number of secondary replicas associated with the Business Critical, Premium, or Hyperscale edition database that are used to provide high availability. Not applicable to a Hyperscale database within an elastic pool.
|
|
properties.isLedgerOn
|
|
boolean
|
Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created.
|
|
properties.keys
|
|
<string,
DatabaseKey>
|
The resource ids of the user assigned identities to use
|
|
properties.licenseType
|
|
DatabaseLicenseType
|
The license type to apply for this database. LicenseIncluded if you need a license, or BasePrice if you have a license and are eligible for the Azure Hybrid Benefit.
|
|
properties.longTermRetentionBackupResourceId
|
|
string
(arm-id)
|
The resource identifier of the long term retention backup associated with create operation of this database.
|
|
properties.maintenanceConfigurationId
|
|
string
|
Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur.
|
|
properties.manualCutover
|
|
boolean
|
Whether or not customer controlled manual cutover needs to be done during Update Database operation to Hyperscale tier.
This property is only applicable when scaling database from Business Critical/General Purpose/Premium/Standard tier to Hyperscale tier.
When manualCutover is specified, the scaling operation will wait for user input to trigger cutover to Hyperscale database.
To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in Waiting state.
|
|
properties.maxSizeBytes
|
|
integer
(int64)
|
The max size of the database expressed in bytes.
|
|
properties.minCapacity
|
|
number
(double)
|
Minimal capacity that database will always have allocated, if not paused
|
|
properties.performCutover
|
|
boolean
|
To trigger customer controlled manual cutover during the wait state while Scaling operation is in progress.
This property parameter is only applicable for scaling operations that are initiated along with 'manualCutover' parameter.
This property is only applicable when scaling database from Business Critical/General Purpose/Premium/Standard tier to Hyperscale tier is already in progress.
When performCutover is specified, the scaling operation will trigger cutover and perform role-change to Hyperscale database.
|
|
properties.preferredEnclaveType
|
|
AlwaysEncryptedEnclaveType
|
Type of enclave requested on the database i.e. Default or VBS enclaves.
|
|
properties.readScale
|
|
DatabaseReadScale
|
The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Not applicable to a Hyperscale database within an elastic pool.
|
|
properties.recoverableDatabaseId
|
|
string
(arm-id)
|
The resource identifier of the recoverable database associated with create operation of this database.
|
|
properties.recoveryServicesRecoveryPointId
|
|
string
(arm-id)
|
The resource identifier of the recovery point associated with create operation of this database.
|
|
properties.requestedBackupStorageRedundancy
|
|
BackupStorageRedundancy
|
The storage account type to be used to store backups for this database.
|
|
properties.restorableDroppedDatabaseId
|
|
string
(arm-id)
|
The resource identifier of the restorable dropped database associated with create operation of this database.
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database.
|
|
properties.sampleName
|
|
SampleName
|
The name of the sample schema to apply when creating this database.
|
|
properties.secondaryType
|
|
SecondaryType
|
The secondary type of the database if it is a secondary. Valid values are Geo, Named and Standby.
|
|
properties.sourceDatabaseDeletionDate
|
|
string
(date-time)
|
Specifies the time that the database was deleted.
|
|
properties.sourceDatabaseId
|
|
string
(arm-id)
|
The resource identifier of the source database associated with create operation of this database.
|
|
properties.sourceResourceId
|
|
string
(arm-id)
|
The resource identifier of the source associated with the create operation of this database.
This property is only supported for DataWarehouse edition and allows to restore across subscriptions.
When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode must be PointInTimeRestore, Restore or Recover.
When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of the existing database or existing sql pool, and restorePointInTime must be specified.
When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped database or restorable dropped sql pool.
When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or recoverable sql pool.
When source subscription belongs to a different tenant than target subscription, “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. For more details about “x-ms-authorization-auxiliary” header see https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.useFreeLimit
|
|
boolean
|
Whether or not the database uses free monthly limits. Allowed on one database in a subscription.
|
|
properties.zoneRedundant
|
|
boolean
|
Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
|
|
sku
|
|
Sku
|
The database SKU.
The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the Capabilities_ListByLocation REST API or one of the following commands:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
tags
|
|
object
|
Resource tags.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
Database
|
Resource 'Database' update operation succeeded
|
|
201 Created
|
Database
|
Resource 'Database' create operation succeeded
Headers
Azure-AsyncOperation: string
|
|
202 Accepted
|
|
Resource operation accepted.
Headers
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
An unexpected error response.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
Creates a data warehouse database as a cross-subscription restore from a backup of a dropped database.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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.
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Sample request
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
Sample response
{
"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
Definitions
| Name |
Description |
|
AlwaysEncryptedEnclaveType
|
Type of enclave requested on the database i.e. Default or VBS enclaves.
|
|
AvailabilityZoneType
|
Specifies the availability zone the database is pinned to.
|
|
BackupStorageRedundancy
|
The storage account type used to store backups for this database.
|
|
CatalogCollationType
|
Collation of the metadata catalog.
|
|
createdByType
|
The type of identity that created the resource.
|
|
CreateMode
|
Specifies the mode of database creation.
Default: regular database creation.
Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database.
Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database.
PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified.
Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be specified as the recoverable database resource ID to restore.
Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must be specified. If sourceDatabaseId is the database's original resource ID, then sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may also be specified to restore from an earlier point in time.
RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource ID.
Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition.
|
|
Database
|
A database resource.
|
|
DatabaseIdentity
|
Azure Active Directory identity configuration for a resource.
|
|
DatabaseIdentityType
|
The identity type
|
|
DatabaseKey
|
Database level key used for encryption at rest.
|
|
DatabaseKeyType
|
The database key type. Only supported value is 'AzureKeyVault'.
|
|
DatabaseLicenseType
|
The license type to apply for this database. LicenseIncluded if you need a license, or BasePrice if you have a license and are eligible for the Azure Hybrid Benefit.
|
|
DatabaseReadScale
|
The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Not applicable to a Hyperscale database within an elastic pool.
|
|
DatabaseStatus
|
The status of the database.
|
|
DatabaseUserIdentity
|
Azure Active Directory identity configuration for a resource.
|
|
ErrorAdditionalInfo
|
The resource management error additional info.
|
|
ErrorDetail
|
The error detail.
|
|
ErrorResponse
|
Error response
|
|
FreeLimitExhaustionBehavior
|
Specifies the behavior when monthly free limits are exhausted for the free database.
AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the month.
BillForUsage: The database will continue to be online upon exhaustion of free limits and any overage will be billed.
|
|
SampleName
|
The name of the sample schema to apply when creating this database.
|
|
SecondaryType
|
The secondary type of the database if it is a secondary. Valid values are Geo, Named and Standby.
|
|
Sku
|
The resource model definition representing SKU
|
|
SkuTier
|
This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
|
|
systemData
|
Metadata pertaining to creation and last modification of the resource.
|
AlwaysEncryptedEnclaveType
Enumeration
Type of enclave requested on the database i.e. Default or VBS enclaves.
| Value |
Description |
|
Default
|
Default
|
|
VBS
|
VBS
|
AvailabilityZoneType
Enumeration
Specifies the availability zone the database is pinned to.
| Value |
Description |
|
NoPreference
|
NoPreference
|
|
1
|
1
|
|
2
|
2
|
|
3
|
3
|
BackupStorageRedundancy
Enumeration
The storage account type used to store backups for this database.
| Value |
Description |
|
Geo
|
Geo
|
|
Local
|
Local
|
|
Zone
|
Zone
|
|
GeoZone
|
GeoZone
|
CatalogCollationType
Enumeration
Collation of the metadata catalog.
| Value |
Description |
|
DATABASE_DEFAULT
|
DATABASE_DEFAULT
|
|
SQL_Latin1_General_CP1_CI_AS
|
SQL_Latin1_General_CP1_CI_AS
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
CreateMode
Enumeration
Specifies the mode of database creation.
Default: regular database creation.
Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database.
Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database.
PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified.
Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be specified as the recoverable database resource ID to restore.
Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must be specified. If sourceDatabaseId is the database's original resource ID, then sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may also be specified to restore from an earlier point in time.
RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource ID.
Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition.
| Value |
Description |
|
Default
|
Default
|
|
Copy
|
Copy
|
|
Secondary
|
Secondary
|
|
PointInTimeRestore
|
PointInTimeRestore
|
|
Restore
|
Restore
|
|
Recovery
|
Recovery
|
|
RestoreExternalBackup
|
RestoreExternalBackup
|
|
RestoreExternalBackupSecondary
|
RestoreExternalBackupSecondary
|
|
RestoreLongTermRetentionBackup
|
RestoreLongTermRetentionBackup
|
|
OnlineSecondary
|
OnlineSecondary
|
Database
Object
A database resource.
| Name |
Type |
Description |
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
DatabaseIdentity
|
The Azure Active Directory identity of the database.
|
|
kind
|
string
|
Kind of database. This is metadata used for the Azure portal experience.
|
|
location
|
string
|
The geo-location where the resource lives
|
|
managedBy
|
string
|
Resource that manages the database.
|
|
name
|
string
|
The name of the resource
|
|
properties.autoPauseDelay
|
integer
(int32)
|
Time in minutes after which database is automatically paused. A value of -1 means that automatic pause is disabled
|
|
properties.availabilityZone
|
AvailabilityZoneType
|
Specifies the availability zone the database is pinned to.
|
|
properties.catalogCollation
|
CatalogCollationType
|
Collation of the metadata catalog.
|
|
properties.collation
|
string
|
The collation of the database.
|
|
properties.createMode
|
CreateMode
|
Specifies the mode of database creation.
Default: regular database creation.
Copy: creates a database as a copy of an existing database. sourceDatabaseId must be specified as the resource ID of the source database.
Secondary: creates a database as a secondary replica of an existing database. sourceDatabaseId must be specified as the resource ID of the existing primary database.
PointInTimeRestore: Creates a database by restoring a point in time backup of an existing database. sourceDatabaseId must be specified as the resource ID of the existing database, and restorePointInTime must be specified.
Recovery: Creates a database by restoring a geo-replicated backup. sourceDatabaseId must be specified as the recoverable database resource ID to restore.
Restore: Creates a database by restoring a backup of a deleted database. sourceDatabaseId must be specified. If sourceDatabaseId is the database's original resource ID, then sourceDatabaseDeletionDate must be specified. Otherwise sourceDatabaseId must be the restorable dropped database resource ID and sourceDatabaseDeletionDate is ignored. restorePointInTime may also be specified to restore from an earlier point in time.
RestoreLongTermRetentionBackup: Creates a database by restoring from a long term retention vault. recoveryServicesRecoveryPointResourceId must be specified as the recovery point resource ID.
Copy, Secondary, and RestoreLongTermRetentionBackup are not supported for DataWarehouse edition.
|
|
properties.creationDate
|
string
(date-time)
|
The creation date of the database (ISO8601 format).
|
|
properties.currentBackupStorageRedundancy
|
BackupStorageRedundancy
|
The storage account type used to store backups for this database.
|
|
properties.currentServiceObjectiveName
|
string
|
The current service level objective name of the database.
|
|
properties.currentSku
|
Sku
|
The name and tier of the SKU.
|
|
properties.databaseId
|
string
(uuid)
|
The ID of the database.
|
|
properties.defaultSecondaryLocation
|
string
|
The default secondary region for this database.
|
|
properties.earliestRestoreDate
|
string
(date-time)
|
This records the earliest start date and time that restore is available for this database (ISO8601 format).
|
|
properties.elasticPoolId
|
string
(arm-id)
|
The resource identifier of the elastic pool containing this database.
|
|
properties.encryptionProtector
|
string
|
The azure key vault URI of the database if it's configured with per Database Customer Managed Keys.
|
|
properties.encryptionProtectorAutoRotation
|
boolean
|
The flag to enable or disable auto rotation of database encryption protector AKV key.
|
|
properties.failoverGroupId
|
string
|
Failover Group resource identifier that this database belongs to.
|
|
properties.federatedClientId
|
string
(uuid)
|
The Client id used for cross tenant per database CMK scenario
|
|
properties.freeLimitExhaustionBehavior
|
FreeLimitExhaustionBehavior
|
Specifies the behavior when monthly free limits are exhausted for the free database.
AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the month.
BillForUsage: The database will continue to be online upon exhaustion of free limits and any overage will be billed.
|
|
properties.highAvailabilityReplicaCount
|
integer
(int32)
|
The number of secondary replicas associated with the Business Critical, Premium, or Hyperscale edition database that are used to provide high availability. Not applicable to a Hyperscale database within an elastic pool.
|
|
properties.isInfraEncryptionEnabled
|
boolean
|
Infra encryption is enabled for this database.
|
|
properties.isLedgerOn
|
boolean
|
Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created.
|
|
properties.keys
|
<string,
DatabaseKey>
|
The resource ids of the user assigned identities to use
|
|
properties.licenseType
|
DatabaseLicenseType
|
The license type to apply for this database. LicenseIncluded if you need a license, or BasePrice if you have a license and are eligible for the Azure Hybrid Benefit.
|
|
properties.longTermRetentionBackupResourceId
|
string
(arm-id)
|
The resource identifier of the long term retention backup associated with create operation of this database.
|
|
properties.maintenanceConfigurationId
|
string
|
Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur.
|
|
properties.manualCutover
|
boolean
|
Whether or not customer controlled manual cutover needs to be done during Update Database operation to Hyperscale tier.
This property is only applicable when scaling database from Business Critical/General Purpose/Premium/Standard tier to Hyperscale tier.
When manualCutover is specified, the scaling operation will wait for user input to trigger cutover to Hyperscale database.
To trigger cutover, please provide 'performCutover' parameter when the Scaling operation is in Waiting state.
|
|
properties.maxLogSizeBytes
|
integer
(int64)
|
The max log size for this database.
|
|
properties.maxSizeBytes
|
integer
(int64)
|
The max size of the database expressed in bytes.
|
|
properties.minCapacity
|
number
(double)
|
Minimal capacity that database will always have allocated, if not paused
|
|
properties.pausedDate
|
string
(date-time)
|
The date when database was paused by user configuration or action(ISO8601 format). Null if the database is ready.
|
|
properties.performCutover
|
boolean
|
To trigger customer controlled manual cutover during the wait state while Scaling operation is in progress.
This property parameter is only applicable for scaling operations that are initiated along with 'manualCutover' parameter.
This property is only applicable when scaling database from Business Critical/General Purpose/Premium/Standard tier to Hyperscale tier is already in progress.
When performCutover is specified, the scaling operation will trigger cutover and perform role-change to Hyperscale database.
|
|
properties.preferredEnclaveType
|
AlwaysEncryptedEnclaveType
|
Type of enclave requested on the database i.e. Default or VBS enclaves.
|
|
properties.readScale
|
DatabaseReadScale
|
The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Not applicable to a Hyperscale database within an elastic pool.
|
|
properties.recoverableDatabaseId
|
string
(arm-id)
|
The resource identifier of the recoverable database associated with create operation of this database.
|
|
properties.recoveryServicesRecoveryPointId
|
string
(arm-id)
|
The resource identifier of the recovery point associated with create operation of this database.
|
|
properties.requestedBackupStorageRedundancy
|
BackupStorageRedundancy
|
The storage account type to be used to store backups for this database.
|
|
properties.requestedServiceObjectiveName
|
string
|
The requested service level objective name of the database.
|
|
properties.restorableDroppedDatabaseId
|
string
(arm-id)
|
The resource identifier of the restorable dropped database associated with create operation of this database.
|
|
properties.restorePointInTime
|
string
(date-time)
|
Specifies the point in time (ISO8601 format) of the source database that will be restored to create the new database.
|
|
properties.resumedDate
|
string
(date-time)
|
The date when database was resumed by user action or database login (ISO8601 format). Null if the database is paused.
|
|
properties.sampleName
|
SampleName
|
The name of the sample schema to apply when creating this database.
|
|
properties.secondaryType
|
SecondaryType
|
The secondary type of the database if it is a secondary. Valid values are Geo, Named and Standby.
|
|
properties.sourceDatabaseDeletionDate
|
string
(date-time)
|
Specifies the time that the database was deleted.
|
|
properties.sourceDatabaseId
|
string
(arm-id)
|
The resource identifier of the source database associated with create operation of this database.
|
|
properties.sourceResourceId
|
string
(arm-id)
|
The resource identifier of the source associated with the create operation of this database.
This property is only supported for DataWarehouse edition and allows to restore across subscriptions.
When sourceResourceId is specified, sourceDatabaseId, recoverableDatabaseId, restorableDroppedDatabaseId and sourceDatabaseDeletionDate must not be specified and CreateMode must be PointInTimeRestore, Restore or Recover.
When createMode is PointInTimeRestore, sourceResourceId must be the resource ID of the existing database or existing sql pool, and restorePointInTime must be specified.
When createMode is Restore, sourceResourceId must be the resource ID of restorable dropped database or restorable dropped sql pool.
When createMode is Recover, sourceResourceId must be the resource ID of recoverable database or recoverable sql pool.
When source subscription belongs to a different tenant than target subscription, “x-ms-authorization-auxiliary” header must contain authentication token for the source tenant. For more details about “x-ms-authorization-auxiliary” header see https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.status
|
DatabaseStatus
|
The status of the database.
|
|
properties.useFreeLimit
|
boolean
|
Whether or not the database uses free monthly limits. Allowed on one database in a subscription.
|
|
properties.zoneRedundant
|
boolean
|
Whether or not this database is zone redundant, which means the replicas of this database will be spread across multiple availability zones.
|
|
sku
|
Sku
|
The database SKU.
The list of SKUs may vary by region and support offer. To determine the SKUs (including the SKU name, tier/edition, family, and capacity) that are available to your subscription in an Azure region, use the Capabilities_ListByLocation REST API or one of the following commands:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
tags
|
object
|
Resource tags.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
DatabaseIdentity
Object
Azure Active Directory identity configuration for a resource.
| Name |
Type |
Description |
|
tenantId
|
string
(uuid)
|
The Azure Active Directory tenant id.
|
|
type
|
DatabaseIdentityType
|
The identity type
|
|
userAssignedIdentities
|
<string,
DatabaseUserIdentity>
|
The resource ids of the user assigned identities to use
|
DatabaseIdentityType
Enumeration
The identity type
| Value |
Description |
|
None
|
None
|
|
UserAssigned
|
UserAssigned
|
DatabaseKey
Object
Database level key used for encryption at rest.
| Name |
Type |
Description |
|
creationDate
|
string
(date-time)
|
The database key creation date.
|
|
keyVersion
|
string
|
The database key's version.
|
|
subregion
|
string
|
Subregion of the server key.
|
|
thumbprint
|
string
|
Thumbprint of the database key.
|
|
type
|
DatabaseKeyType
|
The database key type. Only supported value is 'AzureKeyVault'.
|
DatabaseKeyType
Enumeration
The database key type. Only supported value is 'AzureKeyVault'.
| Value |
Description |
|
AzureKeyVault
|
AzureKeyVault
|
DatabaseLicenseType
Enumeration
The license type to apply for this database. LicenseIncluded if you need a license, or BasePrice if you have a license and are eligible for the Azure Hybrid Benefit.
| Value |
Description |
|
LicenseIncluded
|
LicenseIncluded
|
|
BasePrice
|
BasePrice
|
DatabaseReadScale
Enumeration
The state of read-only routing. If enabled, connections that have application intent set to readonly in their connection string may be routed to a readonly secondary replica in the same region. Not applicable to a Hyperscale database within an elastic pool.
| Value |
Description |
|
Enabled
|
Enabled
|
|
Disabled
|
Disabled
|
DatabaseStatus
Enumeration
The status of the database.
| Value |
Description |
|
Online
|
Online
|
|
Restoring
|
Restoring
|
|
RecoveryPending
|
RecoveryPending
|
|
Recovering
|
Recovering
|
|
Suspect
|
Suspect
|
|
Offline
|
Offline
|
|
Standby
|
Standby
|
|
Shutdown
|
Shutdown
|
|
EmergencyMode
|
EmergencyMode
|
|
AutoClosed
|
AutoClosed
|
|
Copying
|
Copying
|
|
Creating
|
Creating
|
|
Inaccessible
|
Inaccessible
|
|
OfflineSecondary
|
OfflineSecondary
|
|
Pausing
|
Pausing
|
|
Paused
|
Paused
|
|
Resuming
|
Resuming
|
|
Scaling
|
Scaling
|
|
OfflineChangingDwPerformanceTiers
|
OfflineChangingDwPerformanceTiers
|
|
OnlineChangingDwPerformanceTiers
|
OnlineChangingDwPerformanceTiers
|
|
Disabled
|
Disabled
|
|
Stopping
|
Stopping
|
|
Stopped
|
Stopped
|
|
Starting
|
Starting
|
DatabaseUserIdentity
Object
Azure Active Directory identity configuration for a resource.
| Name |
Type |
Description |
|
clientId
|
string
(uuid)
|
The Azure Active Directory client id.
|
|
principalId
|
string
(uuid)
|
The Azure Active Directory principal id.
|
ErrorAdditionalInfo
Object
The resource management error additional info.
| Name |
Type |
Description |
|
info
|
object
|
The additional info.
|
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
The error detail.
| Name |
Type |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
|
code
|
string
|
The error code.
|
|
details
|
ErrorDetail[]
|
The error details.
|
|
message
|
string
|
The error message.
|
|
target
|
string
|
The error target.
|
ErrorResponse
Object
Error response
| Name |
Type |
Description |
|
error
|
ErrorDetail
|
The error object.
|
FreeLimitExhaustionBehavior
Enumeration
Specifies the behavior when monthly free limits are exhausted for the free database.
AutoPause: The database will be auto paused upon exhaustion of free limits for remainder of the month.
BillForUsage: The database will continue to be online upon exhaustion of free limits and any overage will be billed.
| Value |
Description |
|
AutoPause
|
AutoPause
|
|
BillOverUsage
|
BillOverUsage
|
SampleName
Enumeration
The name of the sample schema to apply when creating this database.
| Value |
Description |
|
AdventureWorksLT
|
AdventureWorksLT
|
|
WideWorldImportersStd
|
WideWorldImportersStd
|
|
WideWorldImportersFull
|
WideWorldImportersFull
|
SecondaryType
Enumeration
The secondary type of the database if it is a secondary. Valid values are Geo, Named and Standby.
| Value |
Description |
|
Geo
|
Geo
|
|
Named
|
Named
|
|
Standby
|
Standby
|
Sku
Object
The resource model definition representing SKU
| Name |
Type |
Description |
|
capacity
|
integer
(int32)
|
If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the resource this may be omitted.
|
|
family
|
string
|
If the service has different generations of hardware, for the same SKU, then that can be captured here.
|
|
name
|
string
|
The name of the SKU. E.g. P3. It is typically a letter+number code
|
|
size
|
string
|
The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code.
|
|
tier
|
SkuTier
|
This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
|
SkuTier
Enumeration
This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required on a PUT.
| Value |
Description |
|
Free
|
|
|
Basic
|
|
|
Standard
|
|
|
Premium
|
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|