private ServerDisasterRecoveryConfigurationCreateOrUpdateResponse CreateDrc(SqlManagementClient sqlClient, string resGroupName, Server server1, Server server2, string failoverAliasName) { ServerDisasterRecoveryConfigurationCreateOrUpdateParameters p = new ServerDisasterRecoveryConfigurationCreateOrUpdateParameters(); p.Properties = new ServerDisasterRecoveryConfigurationCreateOrUpdateProperties { AutoFailover = "Off", FailoverPolicy = "Off", PartnerServerId = string.Format(CultureInfo.InvariantCulture, "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Sql/servers/{2}", sqlClient.Credentials.SubscriptionId, resGroupName, server2.Name) }; p.Location = server1.Location; return(sqlClient.ServerDisasterRecoveryConfigurations.CreateOrUpdate(resGroupName, server1.Name, failoverAliasName, p)); }
/// <summary> /// Begins creating a new or updating an existing Azure SQL Server /// disaster recovery configuration. To determine the status of the /// operation call /// GetServerDisasterRecoveryConfigurationOperationStatus. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Sql.LegacySdk.IServerDisasterRecoveryConfigurationOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the Resource Group to which the Azure SQL /// Server belongs. /// </param> /// <param name='serverName'> /// Required. The name of the Azure SQL Server. /// </param> /// <param name='serverDisasterRecoveryConfigurationName'> /// Required. The name of the Azure SQL Server disaster recovery /// configuration to be operated on (Updated or created). /// </param> /// <param name='parameters'> /// Required. The required parameters for creating or updating a Server /// disaster recovery configuration. /// </param> /// <returns> /// Response for long running Azure Sql server disaster recovery /// configuration operation. /// </returns> public static ServerDisasterRecoveryConfigurationCreateOrUpdateResponse BeginCreateOrUpdate(this IServerDisasterRecoveryConfigurationOperations operations, string resourceGroupName, string serverName, string serverDisasterRecoveryConfigurationName, ServerDisasterRecoveryConfigurationCreateOrUpdateParameters parameters) { return(Task.Factory.StartNew((object s) => { return ((IServerDisasterRecoveryConfigurationOperations)s).BeginCreateOrUpdateAsync(resourceGroupName, serverName, serverDisasterRecoveryConfigurationName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Creates a Disaster Recovery Configuration /// </summary> public Management.Sql.LegacySdk.Models.ServerDisasterRecoveryConfiguration Create(string resourceGroupName, string serverName, string serverDisasterRecoveryConfigurationName, ServerDisasterRecoveryConfigurationCreateOrUpdateParameters parameters) { return(GetCurrentSqlClient().ServerDisasterRecoveryConfigurations.CreateOrUpdate(resourceGroupName, serverName, serverDisasterRecoveryConfigurationName, parameters).ServerDisasterRecoveryConfiguration); }
/// <summary> /// Creates a new or updates an existing Azure SQL Server disaster /// recovery configuration. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.Sql.LegacySdk.IServerDisasterRecoveryConfigurationOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the Resource Group to which the Azure SQL /// Database Server belongs. /// </param> /// <param name='serverName'> /// Required. The name of the Azure SQL Server. /// </param> /// <param name='serverDisasterRecoveryConfigurationName'> /// Required. The name of the Azure SQL Server disaster recovery /// configuration to be operated on (Updated or created). /// </param> /// <param name='parameters'> /// Required. The required parameters for creating or updating a Server /// disaster recovery configuration. /// </param> /// <returns> /// Response for long running Azure Sql server disaster recovery /// configuration operation. /// </returns> public static Task <ServerDisasterRecoveryConfigurationCreateOrUpdateResponse> CreateOrUpdateAsync(this IServerDisasterRecoveryConfigurationOperations operations, string resourceGroupName, string serverName, string serverDisasterRecoveryConfigurationName, ServerDisasterRecoveryConfigurationCreateOrUpdateParameters parameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, serverName, serverDisasterRecoveryConfigurationName, parameters, CancellationToken.None)); }