简体   繁体   English

使用Azure SDK创建Azure SQL数据库

[英]create azure sql database with Azure SDK

I can use the following code to create Azure SQL database with Azure SDK 我可以使用以下代码通过Azure SDK创建Azure SQL数据库

var sqlServer = azure.SqlServers.Define(sqlServerName)
                            .WithRegion(Region.USEast)
                            .WithNewResourceGroup(rgName)
                            .WithAdministratorLogin(AdministratorLogin)
                            .WithAdministratorPassword(AdministratorPassword)
                            .WithNewFirewallRule(FirewallRuleIPAddress)
                            .WithNewFirewallRule(FirewallRuleStartIPAddress, FirewallRuleEndIPAddress)
                            .Create();
    var database = sqlServer.Databases
                            .Define(DatabaseName)
                            .Create(); 

But, I want to create databases with Serverless tier "General Purpose: Serverless, Gen5, 1 vCore", but I couldn't find any method that offers that possibility. 但是,我想使用无服务器层“通用:无服务器,Gen5、1 vCore”创建数据库,但是我找不到任何提供这种可能性的方法。 Who can help me? 谁能帮我?

According to my test, we can use the following c# code to create "General Purpose: Serverless, Gen5, 1 vCore" database 根据我的测试,我们可以使用以下c#代码创建“通用:无服务器,Gen5、1个vCore”数据库

var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(client,key,tenant,AzureEnvironment.AzureGlobalCloud);
var azure = Azure.Configure().Authenticate(credentials).WithSubscription(SubscriptionId);
var sqlserver=azure.SqlServers.GetById("/subscriptions/<your subscrption id>/resourceGroups/<your resource group name>/providers/Microsoft.Sql/servers/<your server name>");
var database = sqlserver.Databases.Define("test").WithEdition("GeneralPurpose").WithServiceObjective("GP_S_Gen5_1").Create();
Console.WriteLine(database.ServiceLevelObjective);
Console.WriteLine(database.Edition);
Console.WriteLine(database.Name);
Console.ReadLine();

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure搜索SDK创建数据源 - Azure Search SDK Create DataSource 如何在Azure中创建数据库? - How to create a database in Azure? 如何以编程方式在Basic Edition中创建sql数据库? 在Windows Azure中 - How to create a sql database in Basic edition programmatically? in Windows Azure 无法使用SMO在SQL Azure数据库中创建表 - Failure to CREATE TABLE in SQL Azure database using SMO 如何以编程方式创建Azure网站和SQL数据库? - How do I create an Azure Website and SQL Database programmatically? 如何创建Azure Web服务并使用现有的SQL数据库 - How to create an azure web service and use existing sql database Azure CosmosDB SQL API createDatabaseAsync不创建数据库 - Azure CosmosDB SQL API createDatabaseAsync does not create database 使用 Azure Sql 从 C# 应用程序副本创建数据库 - create a database from a copy C# application using Azure Sql 如何在弹性池中以编程方式创建Azure SQL数据库? - How to programmatically create an Azure SQL Database in an Elastic Pool? Azure ARM - Create SQL Database from Azure GUI - privateEndpointNestedTemplateId and privateEndpointDnsRecordUniqueId seem like similar GUIDs - Azure ARM - Create SQL Database from Azure GUI - privateEndpointNestedTemplateId and privateEndpointDnsRecordUniqueId seem like similar GUIDs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM