/// <summary>
        /// Converts the response from the service to a powershell database object
        /// </summary>
        /// <param name="resourceGroupName">The resource group the server is in</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="pool">The service response</param>
        /// <returns>The converted model</returns>
        private AzureSqlElasticPoolModel CreateElasticPoolModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.ElasticPool pool)
        {
            AzureSqlElasticPoolModel model = new AzureSqlElasticPoolModel
            {
                ResourceId        = pool.Id,
                ResourceGroupName = resourceGroup,
                ServerName        = serverName,
                ElasticPoolName   = pool.Name,
                CreationDate      = pool.CreationDate ?? DateTime.MinValue,
                State             = pool.State,
                StorageMB         = pool.StorageMB,
                MaxSizeBytes      = pool.MaxSizeBytes,
                Tags =
                    TagsConversionHelper.CreateTagDictionary(TagsConversionHelper.CreateTagHashtable(pool.Tags), false),
                Location            = pool.Location,
                Edition             = pool.Edition,
                ZoneRedundant       = pool.ZoneRedundant,
                Capacity            = pool.Sku.Capacity,
                SkuName             = pool.Sku.Name,
                DatabaseCapacityMin = pool.PerDatabaseSettings.MinCapacity,
                DatabaseCapacityMax = pool.PerDatabaseSettings.MaxCapacity,
                Dtu            = pool.Dtu,
                DatabaseDtuMin = pool.DatabaseDtuMin,
                DatabaseDtuMax = pool.DatabaseDtuMax,
                Family         = pool.Sku.Family,
                LicenseType    = pool.LicenseType
            };

            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts the response from the service to a powershell database object
        /// </summary>
        /// <param name="resourceGroupName">The resource group the server is in</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="pool">The service response</param>
        /// <returns>The converted model</returns>
        private AzureSqlElasticPoolModel CreateElasticPoolModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.ElasticPool pool)
        {
            AzureSqlElasticPoolModel model = new AzureSqlElasticPoolModel();

            model.ResourceId        = pool.Id;
            model.ResourceGroupName = resourceGroup;
            model.ServerName        = serverName;
            model.ElasticPoolName   = pool.Name;
            model.CreationDate      = pool.Properties.CreationDate ?? DateTime.MinValue;
            model.DatabaseDtuMax    = (int)pool.Properties.DatabaseDtuMax;
            model.DatabaseDtuMin    = (int)pool.Properties.DatabaseDtuMin;
            model.Dtu       = (int)pool.Properties.Dtu;
            model.State     = pool.Properties.State;
            model.StorageMB = pool.Properties.StorageMB;
            model.Tags      = pool.Tags as Dictionary <string, string>;
            model.Location  = pool.Location;

            DatabaseEdition edition = DatabaseEdition.None;

            Enum.TryParse <DatabaseEdition>(pool.Properties.Edition, out edition);
            model.Edition = edition;

            return(model);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an Elastic Pool
        /// </summary>
        public Management.Sql.Models.ElasticPool Create(string resourceGroupName, string serverName, string elasticPoolName, Management.Sql.Models.ElasticPool parameters)
        {
            // Occasionally after PUT elastic pool, if we poll for operation results immediately then
            // the polling may fail with 404. This is mitigated in the client by adding a brief wait.
            var client = GetCurrentSqlClient();
            AzureOperationResponse <Management.Sql.Models.ElasticPool> createOrUpdateResponse =
                client.ElasticPools.BeginCreateOrUpdateWithHttpMessagesAsync(
                    resourceGroupName, serverName, elasticPoolName, parameters).Result;

            // Sleep 5 seconds
            TestMockSupport.Delay(5000);

            return(client.GetPutOrPatchOperationResultAsync(
                       createOrUpdateResponse, null, CancellationToken.None).Result.Body);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Converts the response from the service to a powershell database object
        /// </summary>
        /// <param name="resourceGroupName">The resource group the server is in</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="pool">The service response</param>
        /// <returns>The converted model</returns>
        private AzureSqlElasticPoolModel CreateElasticPoolModelFromResponse(string resourceGroup, string serverName, Management.Sql.Models.ElasticPool pool)
        {
            DatabaseEdition edition = DatabaseEdition.None;

            Enum.TryParse <DatabaseEdition>(pool.Edition, out edition);

            AzureSqlElasticPoolModel model = new AzureSqlElasticPoolModel
            {
                ResourceId        = pool.Id,
                ResourceGroupName = resourceGroup,
                ServerName        = serverName,
                ElasticPoolName   = pool.Name,
                CreationDate      = pool.CreationDate ?? DateTime.MinValue,
                DatabaseDtuMax    = pool.DatabaseDtuMax.Value,
                DatabaseDtuMin    = pool.DatabaseDtuMin.Value,
                Dtu       = pool.Dtu,
                State     = pool.State,
                StorageMB = pool.StorageMB,
                Tags      =
                    TagsConversionHelper.CreateTagDictionary(TagsConversionHelper.CreateTagHashtable(pool.Tags), false),
                Location = pool.Location,
                Edition  = edition
            };

            return(model);
        }
 /// <summary>
 /// Creates or updates an Elastic Pool
 /// </summary>
 public Management.Sql.Models.ElasticPool CreateOrUpdate(string resourceGroupName, string serverName, string elasticPoolName, string clientRequestId, Management.Sql.Models.ElasticPool parameters)
 {
     return(GetCurrentSqlClient(clientRequestId).ElasticPools.CreateOrUpdate(resourceGroupName, serverName, elasticPoolName, parameters));
 }