/// <summary>
        /// Restore a given Sql Azure Database
        /// </summary>
        /// <param name="resourceGroup">The name of the resource group</param>
        /// <param name="restorePointInTime">A point to time to restore to (for PITR and dropped DB restore)</param>
        /// <param name="resourceId">The resource ID of the DB to restore (live, geo backup, deleted database, long term retention backup, etc.)</param>
        /// <param name="model">An object modeling the database to create via restore</param>
        /// <returns>Restored database object</returns>
        internal AzureSqlDatabaseModel RestoreDatabase(string resourceGroup, DateTime restorePointInTime, string resourceId, AzureSqlDatabaseModel model)
        {
            if (model.CreateMode.Equals("RestoreLongTermRetentionBackup", StringComparison.OrdinalIgnoreCase) && CultureInfo.CurrentCulture.CompareInfo.IndexOf(resourceId, "/providers/Microsoft.Sql", CompareOptions.IgnoreCase) >= 0)
            {
                // LongTermRetentionV2 Restore
                //
                Management.Sql.Models.Database database = Communicator.RestoreDatabase(resourceGroup, model.ServerName, model.DatabaseName, resourceId, model);

                return(new AzureSqlDatabaseModel(resourceGroup, model.ServerName, database));
            }
            else
            {
                DatabaseCreateOrUpdateParameters parameters = new DatabaseCreateOrUpdateParameters()
                {
                    Location   = model.Location,
                    Properties = new DatabaseCreateOrUpdateProperties()
                    {
                        Edition = model.Edition == DatabaseEdition.None ? null : model.Edition.ToString(),
                        RequestedServiceObjectiveId             = model.RequestedServiceObjectiveId,
                        ElasticPoolName                         = model.ElasticPoolName,
                        RequestedServiceObjectiveName           = model.RequestedServiceObjectiveName,
                        SourceDatabaseId                        = resourceId,
                        RecoveryServicesRecoveryPointResourceId = resourceId,
                        RestorePointInTime                      = restorePointInTime,
                        CreateMode = model.CreateMode
                    }
                };
                var resp = Communicator.LegacyRestoreDatabase(resourceGroup, model.ServerName, model.DatabaseName, parameters);
                return(AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroup, model.ServerName, resp));
            }
        }
        /// <summary>
        /// Gets a list of Azure Sql Databases in an ElasticPool.
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="poolName">The name of the elastic pool the database are in</param>
        /// <returns>A list of database objects</returns>
        internal ICollection <AzureSqlDatabaseModel> ListElasticPoolDatabases(string resourceGroupName, string serverName, string poolName)
        {
            var resp = Communicator.ListDatabases(resourceGroupName, serverName, poolName);

            return(resp.Select((db) =>
            {
                return AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroupName, serverName, db);
            }).ToList());
        }
示例#3
0
        /// <summary>
        /// Gets a list of Azure Sql Databases in a secondary server.
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <returns>A list of database objects</returns>
        internal ICollection <AzureSqlDatabaseModel> ListDatabasesOnServer(string resourceGroupName, string serverName)
        {
            var resp = Communicator.ListDatabasesOnServer(resourceGroupName, serverName, Util.GenerateTracingId());

            return(resp.Select((db) =>
            {
                return AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroupName, serverName, db);
            }).ToList());
        }
        /// <summary>
        /// Restore a given Sql Azure Database
        /// </summary>
        /// <param name="resourceGroup">The name of the resource group</param>
        /// <param name="restorePointInTime">A point to time to restore to (for PITR and dropped DB restore)</param>
        /// <param name="resourceId">The resource ID of the DB to restore (live, geo backup, or deleted database)</param>
        /// <param name="model">An object modeling the database to create via restore</param>
        /// <param name="parameters">Parameters describing the database restore request</param>
        /// <returns>Restored database object</returns>
        internal AzureSqlDatabaseModel RestoreDatabase(string resourceGroup, DateTime restorePointInTime, string resourceId, AzureSqlDatabaseModel model)
        {
            DatabaseCreateOrUpdateParameters parameters = new DatabaseCreateOrUpdateParameters()
            {
                Location   = model.Location,
                Properties = new DatabaseCreateOrUpdateProperties()
                {
                    Edition = model.Edition == DatabaseEdition.None ? null : model.Edition.ToString(),
                    RequestedServiceObjectiveId   = model.RequestedServiceObjectiveId,
                    ElasticPoolName               = model.ElasticPoolName,
                    RequestedServiceObjectiveName = model.RequestedServiceObjectiveName,
                    SourceDatabaseId              = resourceId,
                    RestorePointInTime            = restorePointInTime,
                    CreateMode = model.CreateMode
                }
            };
            var resp = Communicator.RestoreDatabase(resourceGroup, model.ServerName, model.DatabaseName, Util.GenerateTracingId(), parameters);

            return(AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroup, model.ServerName, resp));
        }
示例#5
0
        /// <summary>
        /// Gets an Azure SQL Database by name
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure SQL Server</param>
        /// <param name="databaseName">The name of the Azure SQL Database</param>
        /// <returns>The Azure SQL Database object</returns>
        internal AzureSqlDatabaseModel GetDatabase(string resourceGroupName, string serverName, string databaseName)
        {
            var resp = DatabaseCommunicator.Get(resourceGroupName, serverName, databaseName);

            return(AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroupName, serverName, resp));
        }
示例#6
0
        /// <summary>
        /// Resumes a Azure Sql Data Warehouse database.
        /// </summary>
        /// <param name="resourceGroup">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure SQL Server</param>
        /// <param name="databaseName">The name of the Azure SQL Data Warehouse database</param>
        /// <returns>The resumed Azure SQL Data Warehouse database object</returns>
        internal AzureSqlDatabaseModel ResumeDatabase(string resourceGroup, string serverName, string databaseName)
        {
            var resp = Communicator.Resume(resourceGroup, serverName, databaseName, Util.GenerateTracingId());

            return(AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroup, serverName, resp));
        }
        /// <summary>
        /// Gets a database in an elastic pool
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="poolName">The name of the Azure Sql Database ElasticPool</param>
        /// <param name="databaseName">The name of the database</param>
        /// <returns></returns>
        public AzureSqlDatabaseModel GetElasticPoolDatabase(string resourceGroupName, string serverName, string poolName, string databaseName)
        {
            var resp = Communicator.GetDatabase(resourceGroupName, serverName, databaseName);

            return(AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroupName, serverName, resp));
        }
示例#8
0
        /// <summary>
        /// Gets a database in an recommended elastic pool
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="poolName">The name of the Azure Sql RecommendedElasticPool</param>
        /// <param name="databaseName">The name of the database</param>
        /// <returns></returns>
        public AzureSqlDatabaseModel GetElasticPoolRecommendationDatabase(string resourceGroupName, string serverName, string poolName, string databaseName)
        {
            var resp = RecommendationCommunicator.GetDatabase(resourceGroupName, serverName, poolName, databaseName, Util.GenerateTracingId());

            return(AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroupName, serverName, resp));
        }
示例#9
0
        /// <summary>
        /// Gets a list of Azure Sql Databases in an RecommendedElasticPool.
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="poolName">The name of the recommended elastic pool the database are in</param>
        /// <returns>A list of database objects</returns>
        internal ICollection <AzureSqlDatabaseModel> ListElasticPoolRecommendationDatabases(string resourceGroupName, string serverName, string poolName)
        {
            var resp = RecommendationCommunicator.ListDatabases(resourceGroupName, serverName, poolName, Util.GenerateTracingId());

            return(resp.Select((db) => AzureSqlDatabaseAdapter.CreateDatabaseModelFromResponse(resourceGroupName, serverName, db)).ToList());
        }