/// <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 <AzureSqlSyncAgentModel> ApplyUserInputToModel(IEnumerable <AzureSqlSyncAgentModel> model) { List <Model.AzureSqlSyncAgentModel> newEntity = new List <AzureSqlSyncAgentModel>(); AzureSqlSyncAgentModel newModel = new AzureSqlSyncAgentModel() { ResourceGroupName = this.ResourceGroupName, ServerName = this.ServerName, SyncAgentName = this.Name }; if (ParameterSetName == SyncDatabaseResourceIDSet) { newModel.SyncDatabaseId = this.SyncDatabaseResourceID; } else { if (!MyInvocation.BoundParameters.ContainsKey("SyncDatabaseResourceGroupName")) { this.SyncDatabaseResourceGroupName = this.ResourceGroupName; } if (!MyInvocation.BoundParameters.ContainsKey("SyncDatabaseServerName")) { this.SyncDatabaseServerName = this.ServerName; } // "/subscriptions/{id}/" will be added in AzureSqlDataSyncCommunicator this.syncDatabaseId = string.Format("resourceGroups/{0}/providers/Microsoft.Sql/servers/{1}/databases/{2}", this.SyncDatabaseResourceGroupName, this.SyncDatabaseServerName, this.SyncDatabaseName); } newEntity.Add(newModel); return(newEntity); }
/// <summary> /// Create a sync agent /// </summary> /// <param name="model">AzureSqlSyncAgentModel object</param> /// <returns>Created AzureSqlSyncAgentModel object</returns> internal AzureSqlSyncAgentModel CreateSyncAgent(AzureSqlSyncAgentModel model, string syncDatabaseId) { var resp = Communicator.CreateSyncAgent(model.ResourceGroupName, model.ServerName, model.SyncAgentName, syncDatabaseId, new SyncAgentCreateOrUpdateParameters() { Properties = new SyncAgentCreateOrUpdateProperties() { SyncDatabaseId = model.SyncDatabaseId } }); // Workaround for Rest API return response value incorrect issue. Remove this line after backend fix is deployed resp = Communicator.GetSyncAgent(model.ResourceGroupName, model.ServerName, model.SyncAgentName); return(CreateSyncAgentModelFromResponse(model.ResourceGroupName, model.ServerName, resp)); }