/// <summary> /// Upserts a server /// </summary> /// <param name="model">The server to upsert</param> /// <returns>The updated server model</returns> public AzureSqlServerModel UpsertServer(AzureSqlServerModel model) { var resp = Communicator.CreateOrUpdate(model.ResourceGroupName, model.ServerName, Util.GenerateTracingId(), new ServerCreateOrUpdateParameters() { Location = model.Location, Tags = model.Tags, Properties = new ServerCreateOrUpdateProperties() { AdministratorLogin = model.SqlAdministratorLogin, AdministratorLoginPassword = Decrypt(model.SqlAdministratorPassword), Version = model.ServerVersion, } }); return CreateServerModelFromResponse(model.ResourceGroupName, resp); }
/// <summary> /// Convert a Management.Sql.Models.Server to AzureSqlDatabaseServerModel /// </summary> /// <param name="resourceGroupName">The resource group the server is in</param> /// <param name="resp">The management client server response to convert</param> /// <returns>The converted server model</returns> private static AzureSqlServerModel CreateServerModelFromResponse(string resourceGroupName, Management.Sql.Models.Server resp) { AzureSqlServerModel server = new AzureSqlServerModel(); server.ResourceGroupName = resourceGroupName; server.ServerName = resp.Name; server.ServerVersion = resp.Properties.Version; server.SqlAdministratorLogin = resp.Properties.AdministratorLogin; server.Location = resp.Location; return server; }