创建新数据库或更新现有数据库。
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}?api-version=2025-01-01
URI 参数
| 名称 |
在 |
必需 |
类型 |
说明 |
|
databaseName
|
path |
True
|
string
|
数据库的名称。
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
资源组的名称。 此名称不区分大小写。
|
|
serverName
|
path |
True
|
string
|
服务器的名称。
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
目标订阅的 ID。 该值必须是 UUID。
|
|
api-version
|
query |
True
|
string
minLength: 1
|
用于此操作的 API 版本。
|
请求正文
| 名称 |
必需 |
类型 |
说明 |
|
location
|
True
|
string
|
资源所在的地理位置
|
|
identity
|
|
DatabaseIdentity
|
数据库的 Azure Active Directory 标识。
|
|
properties.autoPauseDelay
|
|
integer
(int32)
|
数据库自动暂停的时间(以分钟为单位)。 -1 值表示禁用自动暂停
|
|
properties.availabilityZone
|
|
AvailabilityZoneType
|
指定数据库固定到的可用性区域。
|
|
properties.catalogCollation
|
|
CatalogCollationType
|
元数据目录的排序规则。
|
|
properties.collation
|
|
string
|
数据库的排序规则。
|
|
properties.createMode
|
|
CreateMode
|
指定数据库创建模式。
默认值:常规数据库创建。
复制:将数据库创建为现有数据库的副本。 sourceDatabaseId 必须指定为源数据库的资源 ID。
辅助数据库:将数据库创建为现有数据库的次要副本。 sourceDatabaseId 必须指定为现有主数据库的资源 ID。
PointInTimeRestore:通过还原现有数据库的时间点备份来创建数据库。 sourceDatabaseId 必须指定为现有数据库的资源 ID,并且必须指定 restorePointInTime。
恢复:通过还原异地复制的备份来创建数据库。 sourceDatabaseId 必须指定为可恢复的数据库资源 ID 才能还原。
还原:通过还原已删除数据库的备份来创建数据库。 必须指定 sourceDatabaseId。 如果 sourceDatabaseId 是数据库的原始资源 ID,则必须指定 sourceDatabaseDeletionDate。 否则,sourceDatabaseId 必须是可还原删除的数据库资源 ID,并且将忽略 sourceDatabaseDeletionDate。 还可以指定 restorePointInTime,以便从以前的时间点还原。
RestoreLongTermRetentionBackup:通过从长期保留保管库还原来创建数据库。 recoveryServicesRecoveryPointResourceId 必须指定为恢复点资源 ID。
DataWarehouse 版本不支持 Copy、Secondary 和 RestoreLongTermRetentionBackup。
|
|
properties.elasticPoolId
|
|
string
(arm-id)
|
包含此数据库的弹性池的资源标识符。
|
|
properties.encryptionProtector
|
|
string
|
如果数据库配置了每个数据库客户管理的密钥,则数据库的 Azure 密钥保管库 URI。
|
|
properties.encryptionProtectorAutoRotation
|
|
boolean
|
用于启用或禁用数据库加密保护程序 AKV 密钥自动轮换的标志。
|
|
properties.federatedClientId
|
|
string
(uuid)
|
用于每个数据库 CMK 方案的跨租户的客户端 ID
|
|
properties.freeLimitExhaustionBehavior
|
|
FreeLimitExhaustionBehavior
|
指定免费数据库使用每月免费限制时的行为。
AutoPause:当剩余月份的可用限制用尽时,数据库将自动暂停。
BillForUsage:在耗尽免费限制后,数据库将继续联机,并且将收取任何超额费用。
|
|
properties.highAvailabilityReplicaCount
|
|
integer
(int32)
|
与用于提供高可用性的业务关键版、高级版或超大规模版数据库关联的次要副本数。 不适用于弹性池中的“超大规模”数据库。
|
|
properties.isLedgerOn
|
|
boolean
|
此数据库是否为账本数据库,这意味着数据库中的所有表都是账本表。 注意:创建数据库后,无法更改此属性的值。
|
|
properties.keys
|
|
<string,
DatabaseKey>
|
要使用的用户分配标识的资源 ID
|
|
properties.licenseType
|
|
DatabaseLicenseType
|
要申请此数据库的许可证类型。 如果需要许可证,LicenseIncluded,或者 BasePrice 拥有许可证并且有资格获得 Azure 混合权益。
|
|
properties.longTermRetentionBackupResourceId
|
|
string
(arm-id)
|
与此数据库的创建操作关联的长期保留备份的资源标识符。
|
|
properties.maintenanceConfigurationId
|
|
string
|
分配给数据库的维护配置 ID。 此配置定义维护更新的发生时间。
|
|
properties.manualCutover
|
|
boolean
|
在“更新数据库”操作到“超大规模”层期间,是否需要执行客户控制的手动直接转换。
仅当将数据库从业务关键/常规用途/高级/标准层缩放到“超大规模”层时,此属性才适用。
指定 manualCutover 时,缩放操作将等待用户输入触发“超大规模”数据库的直接转换。
若要触发直接转换,请在缩放操作处于等待状态时提供“performCutover”参数。
|
|
properties.maxSizeBytes
|
|
integer
(int64)
|
以字节表示的数据库的最大大小。
|
|
properties.minCapacity
|
|
number
(double)
|
数据库始终分配的最小容量(如果未暂停)
|
|
properties.performCutover
|
|
boolean
|
在缩放操作正在进行期间触发客户控制的手动直接转换。
此属性参数仅适用于随“manualCutover”参数一起启动的缩放操作。
仅当正在将数据库从业务关键/常规用途/高级/标准层缩放到“超大规模”层时,此属性才适用。
指定 performCutover 时,缩放操作将触发直接转换并执行超大规模数据库的角色更改。
|
|
properties.preferredEnclaveType
|
|
AlwaysEncryptedEnclaveType
|
在数据库(即默认或 VBS enclave)上请求的 enclave 类型。
|
|
properties.readScale
|
|
DatabaseReadScale
|
只读路由的状态。 如果启用,将应用程序意向设置为只读的连接在其连接字符串中可能会路由到同一区域中的只读次要副本。 不适用于弹性池中的“超大规模”数据库。
|
|
properties.recoverableDatabaseId
|
|
string
(arm-id)
|
与此数据库的创建作关联的可恢复数据库的资源标识符。
|
|
properties.recoveryServicesRecoveryPointId
|
|
string
(arm-id)
|
与此数据库的创建操作关联的恢复点的资源标识符。
|
|
properties.requestedBackupStorageRedundancy
|
|
BackupStorageRedundancy
|
用于存储此数据库的备份的存储帐户类型。
|
|
properties.restorableDroppedDatabaseId
|
|
string
(arm-id)
|
与此数据库的创建操作关联的可还原已删除数据库的资源标识符。
|
|
properties.restorePointInTime
|
|
string
(date-time)
|
指定将还原以创建新数据库的源数据库的时间点(ISO8601格式)。
|
|
properties.sampleName
|
|
SampleName
|
创建此数据库时要应用的示例架构的名称。
|
|
properties.secondaryType
|
|
SecondaryType
|
数据库的辅助类型(如果是辅助数据库)。 有效值为 Geo、Named 和 Standby。
|
|
properties.sourceDatabaseDeletionDate
|
|
string
(date-time)
|
指定删除数据库的时间。
|
|
properties.sourceDatabaseId
|
|
string
(arm-id)
|
与此数据库的创建作关联的源数据库的资源标识符。
|
|
properties.sourceResourceId
|
|
string
(arm-id)
|
与此数据库的创建操作关联的源的资源标识符。
仅 DataWarehouse 版本支持此属性,并允许跨订阅还原。
指定 sourceResourceId 时,sourceDatabaseId、recoverableDatabaseId、restoreableDroppedDatabaseId 和 sourceDatabaseDeletionDate 不得指定,CreateMode 必须是 PointInTimeRestore、Restore 或 Recover。
createMode 为 PointInTimeRestore 时,sourceResourceId 必须是现有数据库或现有 sql 池的资源 ID,并且必须指定 restorePointInTime。
当 createMode 为 Restore 时,sourceResourceId 必须是可还原的已删除数据库或可还原的已删除 sql 池的资源 ID。
CreateMode 为 Recover 时,sourceResourceId 必须是可恢复数据库或可恢复 SQL 池的资源 ID。
当源订阅属于与目标订阅不同的租户时,“x-ms-authorization-auxiliary”标头必须包含源租户的身份验证令牌。 有关“x-ms-authorization-auxiliary”标头的更多详细信息,请参阅 https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.useFreeLimit
|
|
boolean
|
数据库是否使用免费的每月限制。 在订阅中的一个数据库上允许。
|
|
properties.zoneRedundant
|
|
boolean
|
此数据库是否为区域冗余,这意味着此数据库的副本将分布在多个可用性区域。
|
|
sku
|
|
Sku
|
数据库 SKU。
SKU 列表可能因区域和支持产品/服务而异。 若要确定 Azure 区域中订阅可用的 SKU(包括 SKU 名称、层/版本、系列和容量),请使用 Capabilities_ListByLocation REST API 或以下命令之一:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
tags
|
|
object
|
资源标记。
|
响应
| 名称 |
类型 |
说明 |
|
200 OK
|
Database
|
资源“数据库”更新作成功
|
|
201 Created
|
Database
|
资源“数据库”创建作成功
标头
Azure-AsyncOperation: string
|
|
202 Accepted
|
|
已接受资源作。
标头
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
ErrorResponse
|
未预期的错误响应。
|
安全性
azure_auth
Azure Active Directory OAuth2 流程。
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 |
说明 |
|
user_impersonation
|
冒充您的用户账户
|
示例
Creates a data warehouse database as a cross-subscription restore from a backup of a dropped database.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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.
示例请求
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
}
}
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://mms.heiai.top/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
示例响应
{
"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
示例请求
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"
}
}
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://mms.heiai.top/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
示例响应
{
"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
示例请求
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
}
}
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://mms.heiai.top/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
示例响应
{
"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
定义
AlwaysEncryptedEnclaveType
枚举
在数据库(即默认或 VBS enclave)上请求的 enclave 类型。
AvailabilityZoneType
枚举
指定数据库固定到的可用性区域。
| 值 |
说明 |
|
NoPreference
|
无偏好
|
|
1
|
1
|
|
2
|
2
|
|
3
|
3
|
BackupStorageRedundancy
枚举
用于存储此数据库的备份的存储帐户类型。
| 值 |
说明 |
|
Geo
|
地理位置
|
|
Local
|
Local
|
|
Zone
|
区域
|
|
GeoZone
|
GeoZone
|
CatalogCollationType
枚举
元数据目录的排序规则。
| 值 |
说明 |
|
DATABASE_DEFAULT
|
DATABASE_DEFAULT
|
|
SQL_Latin1_General_CP1_CI_AS
|
SQL_Latin1_General_CP1_CI_AS
|
createdByType
枚举
创建该资源的身份类型。
| 值 |
说明 |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
CreateMode
枚举
指定数据库创建模式。
默认值:常规数据库创建。
复制:将数据库创建为现有数据库的副本。 sourceDatabaseId 必须指定为源数据库的资源 ID。
辅助数据库:将数据库创建为现有数据库的次要副本。 sourceDatabaseId 必须指定为现有主数据库的资源 ID。
PointInTimeRestore:通过还原现有数据库的时间点备份来创建数据库。 sourceDatabaseId 必须指定为现有数据库的资源 ID,并且必须指定 restorePointInTime。
恢复:通过还原异地复制的备份来创建数据库。 sourceDatabaseId 必须指定为可恢复的数据库资源 ID 才能还原。
还原:通过还原已删除数据库的备份来创建数据库。 必须指定 sourceDatabaseId。 如果 sourceDatabaseId 是数据库的原始资源 ID,则必须指定 sourceDatabaseDeletionDate。 否则,sourceDatabaseId 必须是可还原删除的数据库资源 ID,并且将忽略 sourceDatabaseDeletionDate。 还可以指定 restorePointInTime,以便从以前的时间点还原。
RestoreLongTermRetentionBackup:通过从长期保留保管库还原来创建数据库。 recoveryServicesRecoveryPointResourceId 必须指定为恢复点资源 ID。
DataWarehouse 版本不支持 Copy、Secondary 和 RestoreLongTermRetentionBackup。
| 值 |
说明 |
|
Default
|
默认
|
|
Copy
|
复制
|
|
Secondary
|
次级
|
|
PointInTimeRestore
|
PointInTimeRestore
|
|
Restore
|
Restore
|
|
Recovery
|
恢复
|
|
RestoreExternalBackup
|
恢复外部备份
|
|
RestoreExternalBackupSecondary
|
恢复外部备份次级
|
|
RestoreLongTermRetentionBackup
|
恢复长期保留备份
|
|
OnlineSecondary
|
在线中学
|
Database
对象
数据库资源。
| 名称 |
类型 |
说明 |
|
id
|
string
(arm-id)
|
该资源的完全限定资源 ID。 例如“/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}”
|
|
identity
|
DatabaseIdentity
|
数据库的 Azure Active Directory 标识。
|
|
kind
|
string
|
数据库类型。 这是用于 Azure 门户体验的元数据。
|
|
location
|
string
|
资源所在的地理位置
|
|
managedBy
|
string
|
管理数据库的资源。
|
|
name
|
string
|
资源的名称
|
|
properties.autoPauseDelay
|
integer
(int32)
|
数据库自动暂停的时间(以分钟为单位)。 -1 值表示禁用自动暂停
|
|
properties.availabilityZone
|
AvailabilityZoneType
|
指定数据库固定到的可用性区域。
|
|
properties.catalogCollation
|
CatalogCollationType
|
元数据目录的排序规则。
|
|
properties.collation
|
string
|
数据库的排序规则。
|
|
properties.createMode
|
CreateMode
|
指定数据库创建模式。
默认值:常规数据库创建。
复制:将数据库创建为现有数据库的副本。 sourceDatabaseId 必须指定为源数据库的资源 ID。
辅助数据库:将数据库创建为现有数据库的次要副本。 sourceDatabaseId 必须指定为现有主数据库的资源 ID。
PointInTimeRestore:通过还原现有数据库的时间点备份来创建数据库。 sourceDatabaseId 必须指定为现有数据库的资源 ID,并且必须指定 restorePointInTime。
恢复:通过还原异地复制的备份来创建数据库。 sourceDatabaseId 必须指定为可恢复的数据库资源 ID 才能还原。
还原:通过还原已删除数据库的备份来创建数据库。 必须指定 sourceDatabaseId。 如果 sourceDatabaseId 是数据库的原始资源 ID,则必须指定 sourceDatabaseDeletionDate。 否则,sourceDatabaseId 必须是可还原删除的数据库资源 ID,并且将忽略 sourceDatabaseDeletionDate。 还可以指定 restorePointInTime,以便从以前的时间点还原。
RestoreLongTermRetentionBackup:通过从长期保留保管库还原来创建数据库。 recoveryServicesRecoveryPointResourceId 必须指定为恢复点资源 ID。
DataWarehouse 版本不支持 Copy、Secondary 和 RestoreLongTermRetentionBackup。
|
|
properties.creationDate
|
string
(date-time)
|
数据库的创建日期(ISO8601格式)。
|
|
properties.currentBackupStorageRedundancy
|
BackupStorageRedundancy
|
用于存储此数据库的备份的存储帐户类型。
|
|
properties.currentServiceObjectiveName
|
string
|
数据库的当前服务级别目标名称。
|
|
properties.currentSku
|
Sku
|
SKU 的名称和层。
|
|
properties.databaseId
|
string
(uuid)
|
数据库的 ID。
|
|
properties.defaultSecondaryLocation
|
string
|
此数据库的默认次要区域。
|
|
properties.earliestRestoreDate
|
string
(date-time)
|
这会记录此数据库的最早开始日期和时间(ISO8601格式)。
|
|
properties.elasticPoolId
|
string
(arm-id)
|
包含此数据库的弹性池的资源标识符。
|
|
properties.encryptionProtector
|
string
|
如果数据库配置了每个数据库客户管理的密钥,则数据库的 Azure 密钥保管库 URI。
|
|
properties.encryptionProtectorAutoRotation
|
boolean
|
用于启用或禁用数据库加密保护程序 AKV 密钥自动轮换的标志。
|
|
properties.failoverGroupId
|
string
|
此数据库所属的故障转移组资源标识符。
|
|
properties.federatedClientId
|
string
(uuid)
|
用于每个数据库 CMK 方案的跨租户的客户端 ID
|
|
properties.freeLimitExhaustionBehavior
|
FreeLimitExhaustionBehavior
|
指定免费数据库使用每月免费限制时的行为。
AutoPause:当剩余月份的可用限制用尽时,数据库将自动暂停。
BillForUsage:在耗尽免费限制后,数据库将继续联机,并且将收取任何超额费用。
|
|
properties.highAvailabilityReplicaCount
|
integer
(int32)
|
与用于提供高可用性的业务关键版、高级版或超大规模版数据库关联的次要副本数。 不适用于弹性池中的“超大规模”数据库。
|
|
properties.isInfraEncryptionEnabled
|
boolean
|
为此数据库启用了基础结构加密。
|
|
properties.isLedgerOn
|
boolean
|
此数据库是否为账本数据库,这意味着数据库中的所有表都是账本表。 注意:创建数据库后,无法更改此属性的值。
|
|
properties.keys
|
<string,
DatabaseKey>
|
要使用的用户分配标识的资源 ID
|
|
properties.licenseType
|
DatabaseLicenseType
|
要申请此数据库的许可证类型。 如果需要许可证,LicenseIncluded,或者 BasePrice 拥有许可证并且有资格获得 Azure 混合权益。
|
|
properties.longTermRetentionBackupResourceId
|
string
(arm-id)
|
与此数据库的创建操作关联的长期保留备份的资源标识符。
|
|
properties.maintenanceConfigurationId
|
string
|
分配给数据库的维护配置 ID。 此配置定义维护更新的发生时间。
|
|
properties.manualCutover
|
boolean
|
在“更新数据库”操作到“超大规模”层期间,是否需要执行客户控制的手动直接转换。
仅当将数据库从业务关键/常规用途/高级/标准层缩放到“超大规模”层时,此属性才适用。
指定 manualCutover 时,缩放操作将等待用户输入触发“超大规模”数据库的直接转换。
若要触发直接转换,请在缩放操作处于等待状态时提供“performCutover”参数。
|
|
properties.maxLogSizeBytes
|
integer
(int64)
|
此数据库的最大日志大小。
|
|
properties.maxSizeBytes
|
integer
(int64)
|
以字节表示的数据库的最大大小。
|
|
properties.minCapacity
|
number
(double)
|
数据库始终分配的最小容量(如果未暂停)
|
|
properties.pausedDate
|
string
(date-time)
|
由用户配置或操作(ISO8601格式)暂停数据库的日期。 如果数据库准备就绪,则为 Null。
|
|
properties.performCutover
|
boolean
|
在缩放操作正在进行期间触发客户控制的手动直接转换。
此属性参数仅适用于随“manualCutover”参数一起启动的缩放操作。
仅当正在将数据库从业务关键/常规用途/高级/标准层缩放到“超大规模”层时,此属性才适用。
指定 performCutover 时,缩放操作将触发直接转换并执行超大规模数据库的角色更改。
|
|
properties.preferredEnclaveType
|
AlwaysEncryptedEnclaveType
|
在数据库(即默认或 VBS enclave)上请求的 enclave 类型。
|
|
properties.readScale
|
DatabaseReadScale
|
只读路由的状态。 如果启用,将应用程序意向设置为只读的连接在其连接字符串中可能会路由到同一区域中的只读次要副本。 不适用于弹性池中的“超大规模”数据库。
|
|
properties.recoverableDatabaseId
|
string
(arm-id)
|
与此数据库的创建作关联的可恢复数据库的资源标识符。
|
|
properties.recoveryServicesRecoveryPointId
|
string
(arm-id)
|
与此数据库的创建操作关联的恢复点的资源标识符。
|
|
properties.requestedBackupStorageRedundancy
|
BackupStorageRedundancy
|
用于存储此数据库的备份的存储帐户类型。
|
|
properties.requestedServiceObjectiveName
|
string
|
请求的数据库服务级别目标名称。
|
|
properties.restorableDroppedDatabaseId
|
string
(arm-id)
|
与此数据库的创建操作关联的可还原已删除数据库的资源标识符。
|
|
properties.restorePointInTime
|
string
(date-time)
|
指定将还原以创建新数据库的源数据库的时间点(ISO8601格式)。
|
|
properties.resumedDate
|
string
(date-time)
|
用户操作或数据库登录恢复数据库的日期(ISO8601格式)。 如果暂停数据库,则为 Null。
|
|
properties.sampleName
|
SampleName
|
创建此数据库时要应用的示例架构的名称。
|
|
properties.secondaryType
|
SecondaryType
|
数据库的辅助类型(如果是辅助数据库)。 有效值为 Geo、Named 和 Standby。
|
|
properties.sourceDatabaseDeletionDate
|
string
(date-time)
|
指定删除数据库的时间。
|
|
properties.sourceDatabaseId
|
string
(arm-id)
|
与此数据库的创建作关联的源数据库的资源标识符。
|
|
properties.sourceResourceId
|
string
(arm-id)
|
与此数据库的创建操作关联的源的资源标识符。
仅 DataWarehouse 版本支持此属性,并允许跨订阅还原。
指定 sourceResourceId 时,sourceDatabaseId、recoverableDatabaseId、restoreableDroppedDatabaseId 和 sourceDatabaseDeletionDate 不得指定,CreateMode 必须是 PointInTimeRestore、Restore 或 Recover。
createMode 为 PointInTimeRestore 时,sourceResourceId 必须是现有数据库或现有 sql 池的资源 ID,并且必须指定 restorePointInTime。
当 createMode 为 Restore 时,sourceResourceId 必须是可还原的已删除数据库或可还原的已删除 sql 池的资源 ID。
CreateMode 为 Recover 时,sourceResourceId 必须是可恢复数据库或可恢复 SQL 池的资源 ID。
当源订阅属于与目标订阅不同的租户时,“x-ms-authorization-auxiliary”标头必须包含源租户的身份验证令牌。 有关“x-ms-authorization-auxiliary”标头的更多详细信息,请参阅 https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/authenticate-multi-tenant
|
|
properties.status
|
DatabaseStatus
|
数据库的状态。
|
|
properties.useFreeLimit
|
boolean
|
数据库是否使用免费的每月限制。 在订阅中的一个数据库上允许。
|
|
properties.zoneRedundant
|
boolean
|
此数据库是否为区域冗余,这意味着此数据库的副本将分布在多个可用性区域。
|
|
sku
|
Sku
|
数据库 SKU。
SKU 列表可能因区域和支持产品/服务而异。 若要确定 Azure 区域中订阅可用的 SKU(包括 SKU 名称、层/版本、系列和容量),请使用 Capabilities_ListByLocation REST API 或以下命令之一:
az sql db list-editions -l <location> -o table
Get-AzSqlServerServiceObjective -Location <location>
|
|
systemData
|
systemData
|
包含 createdBy 和 modifiedBy 信息的 Azure 资源管理器元数据。
|
|
tags
|
object
|
资源标记。
|
|
type
|
string
|
资源类型。 例如“Microsoft.Compute/virtualMachines”或“Microsoft.Storage/storageAccounts”
|
DatabaseIdentity
对象
资源的 Azure Active Directory 标识配置。
DatabaseIdentityType
枚举
标识类型
| 值 |
说明 |
|
None
|
None
|
|
UserAssigned
|
UserAssigned
|
DatabaseKey
对象
用于静态加密的数据库级密钥。
| 名称 |
类型 |
说明 |
|
creationDate
|
string
(date-time)
|
数据库密钥创建日期。
|
|
keyVersion
|
string
|
数据库密钥的版本。
|
|
subregion
|
string
|
服务器密钥的子区域。
|
|
thumbprint
|
string
|
数据库密钥的指纹。
|
|
type
|
DatabaseKeyType
|
数据库密钥类型。 仅支持的值是“AzureKeyVault”。
|
DatabaseKeyType
枚举
数据库密钥类型。 仅支持的值是“AzureKeyVault”。
| 值 |
说明 |
|
AzureKeyVault
|
AzureKeyVault
|
DatabaseLicenseType
枚举
要申请此数据库的许可证类型。 如果需要许可证,LicenseIncluded,或者 BasePrice 拥有许可证并且有资格获得 Azure 混合权益。
| 值 |
说明 |
|
LicenseIncluded
|
包含许可
|
|
BasePrice
|
BasePrice
|
DatabaseReadScale
枚举
只读路由的状态。 如果启用,将应用程序意向设置为只读的连接在其连接字符串中可能会路由到同一区域中的只读次要副本。 不适用于弹性池中的“超大规模”数据库。
| 值 |
说明 |
|
Enabled
|
已启用
|
|
Disabled
|
Disabled
|
DatabaseStatus
枚举
数据库的状态。
| 值 |
说明 |
|
Online
|
在线
|
|
Restoring
|
恢复
|
|
RecoveryPending
|
恢复待处理
|
|
Recovering
|
恢复
|
|
Suspect
|
怀疑
|
|
Offline
|
离线
|
|
Standby
|
备用
|
|
Shutdown
|
关机
|
|
EmergencyMode
|
紧急模式
|
|
AutoClosed
|
自动关闭
|
|
Copying
|
复制
|
|
Creating
|
创建
|
|
Inaccessible
|
无法
|
|
OfflineSecondary
|
离线次要
|
|
Pausing
|
暂停
|
|
Paused
|
已暂停
|
|
Resuming
|
继续
|
|
Scaling
|
Scaling
|
|
OfflineChangingDwPerformanceTiers
|
离线变更DW性能等级
|
|
OnlineChangingDwPerformanceTiers
|
在线变动DW性能层级
|
|
Disabled
|
Disabled
|
|
Stopping
|
停止中
|
|
Stopped
|
已停止
|
|
Starting
|
正在启动
|
DatabaseUserIdentity
对象
资源的 Azure Active Directory 标识配置。
| 名称 |
类型 |
说明 |
|
clientId
|
string
(uuid)
|
Azure Active Directory 客户端 ID。
|
|
principalId
|
string
(uuid)
|
Azure Active Directory 主体 ID。
|
ErrorAdditionalInfo
对象
资源管理错误附加信息。
| 名称 |
类型 |
说明 |
|
info
|
object
|
附加信息。
|
|
type
|
string
|
附加信息类型。
|
ErrorDetail
对象
错误详细信息。
ErrorResponse
对象
错误响应
FreeLimitExhaustionBehavior
枚举
指定免费数据库使用每月免费限制时的行为。
AutoPause:当剩余月份的可用限制用尽时,数据库将自动暂停。
BillForUsage:在耗尽免费限制后,数据库将继续联机,并且将收取任何超额费用。
| 值 |
说明 |
|
AutoPause
|
自动暂停
|
|
BillOverUsage
|
账单过度使用
|
SampleName
枚举
创建此数据库时要应用的示例架构的名称。
| 值 |
说明 |
|
AdventureWorksLT
|
冒险工作LT
|
|
WideWorldImportersStd
|
WideWorldImportersStd
|
|
WideWorldImportersFull
|
WideWorldImportersFull
|
SecondaryType
枚举
数据库的辅助类型(如果是辅助数据库)。 有效值为 Geo、Named 和 Standby。
| 值 |
说明 |
|
Geo
|
地理位置
|
|
Named
|
名为
|
|
Standby
|
备用
|
Sku
对象
表示 SKU 的资源模型定义
| 名称 |
类型 |
说明 |
|
capacity
|
integer
(int32)
|
如果 SKU 支持横向扩展/缩减,则应包含容量整数。 如果资源无法横向扩展/缩小,则可能会省略此范围。
|
|
family
|
string
|
如果服务具有不同代的硬件(对于同一 SKU,则可以在此处捕获)。
|
|
name
|
string
|
SKU 的名称。 例如 P3。 它通常是字母+数字代码
|
|
size
|
string
|
SKU 大小。 当名称字段是层和其他一些值的组合时,这将是独立的代码。
|
|
tier
|
SkuTier
|
如果服务具有多个层,但在 PUT 上不需要,则需要资源提供程序实现此字段。
|
SkuTier
枚举
如果服务具有多个层,但在 PUT 上不需要,则需要资源提供程序实现此字段。
| 值 |
说明 |
|
Free
|
|
|
Basic
|
|
|
Standard
|
|
|
Premium
|
|
systemData
对象
与创建和上次修改资源相关的元数据。
| 名称 |
类型 |
说明 |
|
createdAt
|
string
(date-time)
|
资源创建时间戳(UTC)。
|
|
createdBy
|
string
|
创建该资源的身份。
|
|
createdByType
|
createdByType
|
创建该资源的身份类型。
|
|
lastModifiedAt
|
string
(date-time)
|
上次修改的资源时间戳(UTC)
|
|
lastModifiedBy
|
string
|
上次修改资源的标识。
|
|
lastModifiedByType
|
createdByType
|
上次修改资源的标识的类型。
|