我需要根据某种逻辑从一个故障转移组更新(基本上是移动数据库)到另一个故障转移组。
有人可以帮助我如何从故障转移组中查找主要和辅助 SQL Server 名称吗?有人可以确认当我们更新故障转移时,
Update
方法中的第二个参数是主服务器名称吗?
我们是否也必须更新辅助服务器,或者它会通过复制自动发生?
await client.FailoverGroups
.UpdateAsync("resourcegroupname", "servername", "newfailovername",
new FailoverGroupUpdate() { Databases = databases});
using System;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Rest.Azure.Authentication;
namespace AzureSQLFailoverGroupInfo
{
class Program
{
static void Main(string[] args)
{
string tenantId = "72f988bf-86f1-41af-";
string clientId = "fd6fbe88-d144-4c5c";
string clientSecret = "3yj8Q~h_COxLnMrJ8";
string subscriptionId = "b83c1ed3-c5b6-44fb-b5ba-2b83a0";
string resourceGroupName = "sampath";
string serverName = "sampath23";
string failoverGroupName = "sampath123";
var serviceClientCredentials = ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, clientSecret).Result;
SqlManagementClient sqlClient = new SqlManagementClient(serviceClientCredentials)
{
SubscriptionId = subscriptionId
};
FailoverGroup failoverGroup = sqlClient.FailoverGroups.Get(resourceGroupName, serverName, failoverGroupName);
string secondaryServer = failoverGroup.PartnerServers[0].Id.Split('/')[8];
Console.WriteLine($"Secondary Server: {secondaryServer}");
string primaryServer = failoverGroup.Name;
Console.WriteLine($"Primary Server: {primaryServer}");
}
}
}