如何在 C# 中设置 Azure SQL 服务器的名称?

How do you set the name of a Azure SQL Server in C#?

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

在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 尚未赶上。

API预览版支持这个:

 var result = client.Servers.CreateOrUpdateAsync(
      _resourceGroupName, "my-Server", new ServerCreateOrUpdateParameters...

https://azure.microsoft.com/en-gb/documentation/articles/sql-database-client-library/