Skip to main content
 首页 » 编程设计

c#之如何在 C# 中设置 Azure SQL Server 的名称

2024年02月05日11虾米哥

在 Azure 门户中,您可以设置 SQL Server 的名称(而非数据库)。

在C#中如何设置名称?

(使用 Microsoft.WindowsAzure.Management.Sql.5.2.0)

var result = client.Servers.CreateAsync(new ServerCreateParameters 
{ 
   AdministratorUserName = config.ServerUserName, 
   AdministratorPassword = config.ServerPassword, 
   Location = config.Location, 
   Version = config.Version 
}, CancellationToken.None).Result; 
 
var serverName = result.ServerName; 

请您参考如下方法:

这仍然无法通过 API 实现。它最初是设计的 - 来自 https://azure.microsoft.com/en-us/documentation/articles/sql-database-dotnet-how-to-use/ :

Notice that you did not specify a server name. SQL Database auto-generates the server name to ensure there are no duplicate DNS entries. The server name is a ten-character alphanumeric string. You cannot change the name of your SQL Database server.

新门户已更新为现在支持此功能,但 C# API 尚未跟上。