Exemple #1
0
        /// <summary>
        /// Create the model from user input
        /// </summary>
        /// <param name="model">Model retrieved from service</param>
        /// <returns>The model that was passed in</returns>
        protected override IEnumerable <AzureSqlServerDisasterRecoveryConfigurationModel> ApplyUserInputToModel(
            IEnumerable <AzureSqlServerDisasterRecoveryConfigurationModel> model)
        {
            List <AzureSqlServerDisasterRecoveryConfigurationModel> newEntity =
                new List <AzureSqlServerDisasterRecoveryConfigurationModel>();

            AzureSqlServerDisasterRecoveryConfigurationModel entry = model.First();

            if (entry != null)
            {
                newEntity.Add(new AzureSqlServerDisasterRecoveryConfigurationModel()
                {
                    ResourceGroupName = entry.ResourceGroupName,
                    ServerName        = entry.ServerName,
                    ServerDisasterRecoveryConfigurationName = entry.ServerDisasterRecoveryConfigurationName,
                    Location          = entry.Location,
                    AutoFailover      = entry.AutoFailover,
                    FailoverPolicy    = entry.FailoverPolicy,
                    PartnerServerName = entry.PartnerServerName,
                    Role = entry.Role
                });
            }
            return(newEntity);
        }
        /// <summary>
        /// Creates an Azure Sql Server Disaster Recovery Configuration.
        /// </summary>
        /// <param name="resourceGroup">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Server</param>
        /// <param name="partnerServerId">The id (path) of the partner Azure Sql Server</param>
        /// <param name="model">A model containing parameters for the Server Disaster Recovery Configuration</param>
        /// <returns>The created Azure Sql Server Disaster Recovery Configuration</returns>
        internal AzureSqlServerDisasterRecoveryConfigurationModel CreateServerDisasterRecoveryConfiguration(string resourceGroup, string serverName, string partnerServerId, AzureSqlServerDisasterRecoveryConfigurationModel model)
        {
            var resp = Communicator.Create(resourceGroup, serverName, model.ServerDisasterRecoveryConfigurationName, Util.GenerateTracingId(), new ServerDisasterRecoveryConfigurationCreateOrUpdateParameters()
            {
                Location   = model.Location,
                Properties = new ServerDisasterRecoveryConfigurationCreateOrUpdateProperties()
                {
                    PartnerServerId = partnerServerId
                }
            });

            return(CreateServerDisasterRecoveryConfigurationModelFromResponse(resourceGroup, serverName, resp));
        }
 /// <summary>
 /// Starts failover for an Azure Sql Server Disaster Recovery Configuration.
 /// </summary>
 /// <param name="resourceGroup">The name of the resource group</param>
 /// <param name="serverName">The name of the Azure Sql Server</param>
 /// <param name="model">The input parameters for the create/update operation</param>
 /// <param name="allowDataLoss">Whether or not potential data loss is allowed during the failover</param>
 internal void FailoverServerDisasterRecoveryConfiguration(string resourceGroup, string serverName, AzureSqlServerDisasterRecoveryConfigurationModel model, bool allowDataLoss)
 {
     Communicator.Failover(resourceGroup, serverName, model.ServerDisasterRecoveryConfigurationName, allowDataLoss, Util.GenerateTracingId());
 }