protected override void RunCmdlet()
        {
            if (!ShouldProcess(this.Name, @"Updating Azure ML commitment plan."))
            {
                return;
            }

            if (!this.Force.IsPresent && !ShouldContinue(Resources.UpdateServiceWarning.FormatInvariant(this.Name), string.Empty))
            {
                return;
            }

            int skuCapacity = this.SkuCapacity == 0 ? 1 : this.SkuCapacity;
            var sku = new ResourceSku(skuCapacity, this.SkuName, this.SkuTier);

            var tags = this.Tags.Cast<DictionaryEntry>()
                .ToDictionary(kvp => (string) kvp.Key, kvp => (string) kvp.Value);

            CommitmentPlanPatchPayload patchPayload = new CommitmentPlanPatchPayload
            {
                Sku = sku,
                Tags = tags
            };

            this.CommitmentPlansClient.PatchAzureMlCommitmentPlan(this.ResourceGroupName, this.Name, patchPayload);
        }
Esempio n. 2
0
 internal static ServerSku FromResourceSku(ResourceSku resourceSku)
 {
     return new ServerSku()
     {
         Name = resourceSku.Name,
         Tier = resourceSku.Tier
     };
 }
        public CommitmentPlan CreateOrUpdateAzureMlCommitmentPlan(
            string resourceGroupName,
            string location,
            string commitmentPlanName,
            ResourceSku commitmentPlanSku)
        {
            CommitmentPlan commitmentPlan = new CommitmentPlan
            {
                Location = location,
                Sku = commitmentPlanSku
            };

            return this.apiClient.CommitmentPlans.CreateOrUpdate(
                commitmentPlan,
                resourceGroupName,
                commitmentPlanName);
        }
        protected override void RunCmdlet()
        {
            this.ConfirmAction(
                this.Force.IsPresent,
                Resources.NewServiceWarning.FormatInvariant(this.Name), 
                "Creating the new commitment plan", 
                this.Name, 
                () =>
                {
                    int skuCapacity = this.SkuCapacity == 0 ? 1 : this.SkuCapacity;
                    ResourceSku sku = new ResourceSku(skuCapacity, this.SkuName, this.SkuTier);

                    CommitmentPlan newCommitmentPlan = this.CommitmentPlansClient.CreateOrUpdateAzureMlCommitmentPlan(
                                                    this.ResourceGroupName,
                                                    this.Location,
                                                    this.Name,
                                                    sku);

                    this.WriteObject(newCommitmentPlan);
                });
        }
        public static SignalRResource CreateSignalR(SignalRManagementClient client, string resourceGroupName, string location, bool isStandard = false, int capacity = 1)
        {
            ResourceSku sku;

            if (isStandard)
            {
                sku = new ResourceSku
                {
                    Name     = "Standard_S1",
                    Tier     = "Standard",
                    Size     = "S1",
                    Capacity = capacity,
                };
            }
            else
            {
                sku = new ResourceSku
                {
                    Name = "Free_F1",
                    Tier = "Free",
                    Size = "F1",
                };
            }

            return(client.SignalR.CreateOrUpdate(
                       resourceGroupName,
                       TestUtilities.GenerateName("signalr-test"),
                       new SignalRResource
            {
                Location = location,
                Sku = sku,
                Tags = DefaultTags,
                Features = new List <SignalRFeature>
                {
                    new SignalRFeature {
                        Flag = FeatureFlags.ServiceMode,
                        Value = "Default",
                    }
                },
                Kind = ServiceKind.SignalR,
                Upstream = new ServerlessUpstreamSettings
                {
                    Templates = new List <UpstreamTemplate>
                    {
                        new UpstreamTemplate
                        {
                            UrlTemplate = "http://foo.com"
                        }
                    }
                },
                NetworkACLs = new SignalRNetworkACLs
                {
                    DefaultAction = ACLAction.Deny,
                    PublicNetwork = new NetworkACL
                    {
                        Allow = new List <string> {
                            SignalRRequestType.ClientConnection
                        },
                    },
                    PrivateEndpoints = new List <PrivateEndpointACL>
                    {
                        new PrivateEndpointACL
                        {
                            Name = "mySignalRService.1fa229cd-bf3f-47f0-8c49-afb36723997e",
                            Allow = new List <string> {
                                SignalRRequestType.ServerConnection
                            },
                        },
                    },
                },
            }));
        }
        internal static ManagedGrafanaData DeserializeManagedGrafanaData(JsonElement element)
        {
            Optional <ResourceSku> sku = default;
            Optional <ManagedGrafanaProperties> properties = default;
            Optional <ManagedIdentity>          identity   = default;
            IDictionary <string, string>        tags       = default;
            AzureLocation      location   = default;
            ResourceIdentifier id         = default;
            string             name       = default;
            ResourceType       type       = default;
            SystemData         systemData = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("sku"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    sku = ResourceSku.DeserializeResourceSku(property.Value);
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    properties = ManagedGrafanaProperties.DeserializeManagedGrafanaProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = ManagedIdentity.DeserializeManagedIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
            }
            return(new ManagedGrafanaData(id, name, type, systemData, tags, location, sku.Value, properties.Value, identity.Value));
        }
Esempio n. 7
0
 ///GENMHASH:8D9D2C9D2BDF48FE8D9C24EBA1CF6ACD:BC4B1282CA708DC220050F834F17A184
 internal ComputeSkuImpl(ResourceSku inner)
 {
     this.inner = inner;
 }
Esempio n. 8
0
        public void ScaleUpTest()
        {
            string executingAssemblyPath = typeof(PowerBIDedicated.Tests.ScenarioTests.CapacityOperationsTests).GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");

            using (var context = MockContext.Start(this.GetType()))
            {
                var client = this.GetDedicatedServicesClient(context);

                DedicatedCapacity testCapacity = PowerBIDedicatedTestUtilities.GetDefaultDedicatedResource();

                SkuEnumerationForNewResourceResult skusListForNew = client.Capacities.ListSkus();
                testCapacity.Sku = skusListForNew.Value.Where(val => val.Name == "A1").First();
                if (testCapacity.Sku == null)
                {
                    skusListForNew.Value.First();
                }

                DedicatedCapacity resultCreate = null;
                try
                {
                    // Create a test capacity
                    resultCreate =
                        client.Capacities.Create(
                            PowerBIDedicatedTestUtilities.DefaultResourceGroup,
                            PowerBIDedicatedTestUtilities.DefaultCapacityName,
                            testCapacity);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                Assert.Equal("Succeeded", resultCreate.ProvisioningState);
                Assert.Equal("Succeeded", resultCreate.State);

                // get the capacity and ensure that all the values are properly set.
                var resultGet = client.Capacities.GetDetails(PowerBIDedicatedTestUtilities.DefaultResourceGroup, PowerBIDedicatedTestUtilities.DefaultCapacityName);

                // validate the capacity creation process
                Assert.Equal(PowerBIDedicatedTestUtilities.DefaultLocation, resultGet.Location);
                Assert.Equal(PowerBIDedicatedTestUtilities.DefaultCapacityName, resultGet.Name);
                Assert.Equal(testCapacity.Sku.Name, resultGet.Sku.Name);
                Assert.Equal(2, resultGet.Tags.Count);
                Assert.True(resultGet.Tags.ContainsKey("key1"));
                Assert.Equal(2, resultGet.Administration.Members.Count);

                // Confirm that the capacity creation did succeed
                Assert.True(resultGet.ProvisioningState == "Succeeded");
                Assert.True(resultGet.State == "Succeeded");

                // Scale up the capacity and verify
                SkuEnumerationForExistingResourceResult skusListForExisting = client.Capacities.ListSkusForCapacity(PowerBIDedicatedTestUtilities.DefaultResourceGroup, PowerBIDedicatedTestUtilities.DefaultCapacityName);
                ResourceSku newSku = skusListForExisting.Value.Where(detail => detail.Sku.Name != testCapacity.Sku.Name && detail.Sku.Name.StartsWith("A")).First().Sku;

                DedicatedCapacityUpdateParameters updateParameters = new DedicatedCapacityUpdateParameters()
                {
                    Sku = newSku
                };

                var resultUpdate = client.Capacities.Update(
                    PowerBIDedicatedTestUtilities.DefaultResourceGroup,
                    PowerBIDedicatedTestUtilities.DefaultCapacityName,
                    updateParameters);

                Assert.Equal("Succeeded", resultUpdate.ProvisioningState);
                Assert.Equal("Succeeded", resultUpdate.State);

                // Suspend the capacity
                client.Capacities.Suspend(PowerBIDedicatedTestUtilities.DefaultResourceGroup, PowerBIDedicatedTestUtilities.DefaultCapacityName);

                // get the capacity and ensure that all the values are properly set.
                resultGet = client.Capacities.GetDetails(PowerBIDedicatedTestUtilities.DefaultResourceGroup, PowerBIDedicatedTestUtilities.DefaultCapacityName);

                Assert.Equal("Paused", resultGet.ProvisioningState);
                Assert.Equal("Paused", resultGet.State);

                updateParameters = new DedicatedCapacityUpdateParameters()
                {
                    Sku = testCapacity.Sku
                };

                resultUpdate = client.Capacities.Update(
                    PowerBIDedicatedTestUtilities.DefaultResourceGroup,
                    PowerBIDedicatedTestUtilities.DefaultCapacityName,
                    updateParameters);

                Assert.Equal("Paused", resultUpdate.ProvisioningState);
                Assert.Equal("Paused", resultUpdate.State);

                // get the capacity and ensure that all the values are properly set.
                resultGet = client.Capacities.GetDetails(PowerBIDedicatedTestUtilities.DefaultResourceGroup, PowerBIDedicatedTestUtilities.DefaultCapacityName);

                // validate the capacity creation process
                Assert.Equal(PowerBIDedicatedTestUtilities.DefaultLocation, resultGet.Location);
                Assert.Equal(PowerBIDedicatedTestUtilities.DefaultCapacityName, resultGet.Name);
                Assert.Equal(testCapacity.Sku.Name, resultGet.Sku.Name);
                Assert.Equal(2, resultGet.Tags.Count);
                Assert.True(resultGet.Tags.ContainsKey("key1"));
                Assert.Equal(2, resultGet.Administration.Members.Count);

                // delete the capacity with its old name, which should also succeed.
                client.Capacities.Delete(PowerBIDedicatedTestUtilities.DefaultResourceGroup, PowerBIDedicatedTestUtilities.DefaultCapacityName);
            }
        }
Esempio n. 9
0
        public AppyPlayAzureConfigurationBuilder WithSignalRService(string serviceName, Region serviceRegion, ResourceSku sku = null)
        {
            var rgName      = _infraParameters.ResourceGroupParameters.ResourceGroupName;
            var skuResource = sku ?? new ResourceSku
            {
                Name = "Free_F1",
                Tier = "Free",
                Size = "F1",
            };

            var parameters = new AppySignalRParameters
            {
                ServiceName       = serviceName,
                ResourceGroupName = rgName,
                ResourceSku       = skuResource,
                Description       = serviceName,
                ServiceRegion     = serviceRegion
            };

            _infraParameters.SignalRParameters = parameters;

            return(this);
        }
 ///GENMHASH:4318BDBAE10D86DA6726695F6F266DD0:B4E67A1F603F32204572EE549690656C
 protected override IComputeSku WrapModel(ResourceSku inner)
 {
     return new ComputeSkuImpl(inner);
 }
Esempio n. 11
0
 internal ManagedGrafanaData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, ResourceSku sku, ManagedGrafanaProperties properties, ManagedIdentity identity) : base(id, name, resourceType, systemData, tags, location)
 {
     Sku        = sku;
     Properties = properties;
     Identity   = identity;
 }
Esempio n. 12
0
        public void CreateAndListCommitmentPlans()
        {
            this.RunAMLCommitmentPlanTestScenario((commitmentPlanName, resourceGroupName, resourcesClient, amlPlansClient) =>
            {
                string plan1Name = TestUtilities.GenerateName(CommitmentPlanTests.TestPlanNamePrefix);
                string plan2Name = TestUtilities.GenerateName(CommitmentPlanTests.TestPlanNamePrefix);
                string plan3Name = TestUtilities.GenerateName(CommitmentPlanTests.TestPlanNamePrefix);

                string resourceGroup1Name = TestUtilities.GenerateName(CommitmentPlanTests.TestResourceGroupNamePrefix);
                string resourceGroup2Name = TestUtilities.GenerateName(CommitmentPlanTests.TestResourceGroupNamePrefix);

                try
                {
                    ResourceSku sku = new ResourceSku(1, CommitmentPlanTests.TestSkuName, CommitmentPlanTests.TestSkuTier);
                    CommitmentPlan inputCommitmentPlan = new CommitmentPlan(CommitmentPlanTests.DefaultLocation, sku: sku);

                    // Create two commitment plans in the first resource group
                    resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroup1Name, new ResourceGroup {
                        Location = CommitmentPlanTests.DefaultLocation
                    });

                    CommitmentPlan outputCommitmentPlan1 = amlPlansClient.CommitmentPlans.CreateOrUpdateWithHttpMessagesAsync(inputCommitmentPlan, resourceGroup1Name, plan1Name).Result.Body;
                    CommitmentPlanTests.ValidateCommitmentPlanResource(amlPlansClient.SubscriptionId, resourceGroup1Name, plan1Name, outputCommitmentPlan1);

                    CommitmentPlan outputCommitmentPlan2 = amlPlansClient.CommitmentPlans.CreateOrUpdateWithHttpMessagesAsync(inputCommitmentPlan, resourceGroup1Name, plan2Name).Result.Body;
                    CommitmentPlanTests.ValidateCommitmentPlanResource(amlPlansClient.SubscriptionId, resourceGroup1Name, plan2Name, outputCommitmentPlan2);

                    // Create one commitment plan in the second resource group
                    resourcesClient.ResourceGroups.CreateOrUpdate(resourceGroup2Name, new ResourceGroup {
                        Location = CommitmentPlanTests.DefaultLocation
                    });

                    CommitmentPlan outputCommitmentPlan3 = amlPlansClient.CommitmentPlans.CreateOrUpdateWithHttpMessagesAsync(inputCommitmentPlan, resourceGroup2Name, plan3Name).Result.Body;
                    CommitmentPlanTests.ValidateCommitmentPlanResource(amlPlansClient.SubscriptionId, resourceGroup2Name, plan3Name, outputCommitmentPlan3);

                    // Get plans from first resource group and validate
                    var plansInGroup1 = amlPlansClient.CommitmentPlans.ListInResourceGroup(resourceGroup1Name);

                    Assert.NotNull(plansInGroup1);
                    Assert.Equal(2, plansInGroup1.Count());

                    string expectedResourceId1 = string.Format(CultureInfo.InvariantCulture, CommitmentPlanTests.ResourceIdFormat, amlPlansClient.SubscriptionId, resourceGroup1Name, plan1Name);
                    Assert.Contains(plansInGroup1, plan => string.Equals(plan.Id, expectedResourceId1, StringComparison.OrdinalIgnoreCase));

                    string expectedResourceId2 = string.Format(CultureInfo.InvariantCulture, CommitmentPlanTests.ResourceIdFormat, amlPlansClient.SubscriptionId, resourceGroup1Name, plan2Name);
                    Assert.Contains(plansInGroup1, plan => string.Equals(plan.Id, expectedResourceId2, StringComparison.OrdinalIgnoreCase));

                    // Get plans from second resource group and validate
                    var plansInGroup2 = amlPlansClient.CommitmentPlans.ListInResourceGroup(resourceGroup2Name);

                    Assert.NotNull(plansInGroup2);
                    Assert.Single(plansInGroup2);

                    string expectedResourceId3 = string.Format(CultureInfo.InvariantCulture, CommitmentPlanTests.ResourceIdFormat, amlPlansClient.SubscriptionId, resourceGroup2Name, plan3Name);
                    Assert.Contains(plansInGroup2, plan => string.Equals(plan.Id, expectedResourceId3, StringComparison.OrdinalIgnoreCase));
                }
                finally
                {
                    // Delete plans and resource groups
                    BaseScenarioTests.DisposeOfTestResource(() => amlPlansClient.CommitmentPlans.RemoveWithHttpMessagesAsync(resourceGroup1Name, plan1Name));
                    BaseScenarioTests.DisposeOfTestResource(() => amlPlansClient.CommitmentPlans.RemoveWithHttpMessagesAsync(resourceGroup1Name, plan2Name));
                    BaseScenarioTests.DisposeOfTestResource(() => resourcesClient.ResourceGroups.Delete(resourceGroup1Name));

                    BaseScenarioTests.DisposeOfTestResource(() => amlPlansClient.CommitmentPlans.RemoveWithHttpMessagesAsync(resourceGroup2Name, plan3Name));
                    BaseScenarioTests.DisposeOfTestResource(() => resourcesClient.ResourceGroups.Delete(resourceGroup2Name));
                }
            });
        }
Esempio n. 13
0
        public void FirewallTest()
        {
            string executingAssemblyPath = typeof(AnalysisServices.Tests.ScenarioTests.ServerOperationsTests).GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");
            var s1SKU = "S1";
            var sampleIPV4FirewallSetting = new IPv4FirewallSettings()
            {
                EnablePowerBIService = "True",
                FirewallRules        = new List <IPv4FirewallRule>()
                {
                    new IPv4FirewallRule()
                    {
                        FirewallRuleName = "rule1",
                        RangeStart       = "0.0.0.0",
                        RangeEnd         = "255.255.255.255"
                    },
                    new IPv4FirewallRule()
                    {
                        FirewallRuleName = "rule2",
                        RangeStart       = "7.7.7.7",
                        RangeEnd         = "8.8.8.8"
                    },
                }
            };

            using (var context = MockContext.Start(this.GetType()))
            {
                var client = this.GetAnalysisServicesClient(context);

                AnalysisServicesServer             analysisServicesServer = AnalysisServicesTestUtilities.GetDefaultAnalysisServicesResource();
                SkuEnumerationForNewResourceResult skusListForNew         = client.Servers.ListSkusForNew();
                analysisServicesServer.Sku = skusListForNew.Value.Where((s) => s.Name == s1SKU).First();
                analysisServicesServer.IpV4FirewallSettings = sampleIPV4FirewallSetting;

                AnalysisServicesServer resultCreate = null;
                try
                {
                    Console.Out.Write(analysisServicesServer.Sku.Capacity);
                    // Create a test server
                    resultCreate =
                        client.Servers.Create(
                            AnalysisServicesTestUtilities.DefaultResourceGroup,
                            AnalysisServicesTestUtilities.DefaultServerName,
                            analysisServicesServer);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                Assert.Equal("Succeeded", resultCreate.ProvisioningState);
                Assert.Equal("Succeeded", resultCreate.State);

                // get the server and ensure that all the values are properly set.
                var resultGet = client.Servers.GetDetails(AnalysisServicesTestUtilities.DefaultResourceGroup, AnalysisServicesTestUtilities.DefaultServerName);

                // validate the server creation process
                Assert.Equal(AnalysisServicesTestUtilities.DefaultLocation, resultGet.Location);
                Assert.Equal(AnalysisServicesTestUtilities.DefaultServerName, resultGet.Name);
                Assert.NotEmpty(resultGet.ServerFullName);
                Assert.Equal(analysisServicesServer.Sku.Name, resultGet.Sku.Name);
                Assert.Equal(2, resultGet.Tags.Count);
                Assert.True(resultGet.Tags.ContainsKey("key1"));
                Assert.Equal(2, resultGet.AsAdministrators.Members.Count);
                Assert.Equal("Microsoft.AnalysisServices/servers", resultGet.Type);
                Assert.Equal(sampleIPV4FirewallSetting.EnablePowerBIService, resultGet.IpV4FirewallSettings.EnablePowerBIService);
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.Count(), resultGet.IpV4FirewallSettings.FirewallRules.Count());
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.First().FirewallRuleName, resultGet.IpV4FirewallSettings.FirewallRules.First().FirewallRuleName);
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.First().RangeStart, resultGet.IpV4FirewallSettings.FirewallRules.First().RangeStart);
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.First().RangeEnd, resultGet.IpV4FirewallSettings.FirewallRules.First().RangeEnd);

                // Confirm that the server creation did succeed
                Assert.True(resultGet.ProvisioningState == "Succeeded");
                Assert.True(resultGet.State == "Succeeded");

                // Update firewall and verify
                ResourceSku newSku = resultGet.Sku;
                sampleIPV4FirewallSetting.EnablePowerBIService = "False";
                sampleIPV4FirewallSetting.FirewallRules        = new List <IPv4FirewallRule>()
                {
                    new IPv4FirewallRule()
                    {
                        FirewallRuleName = "rule3",
                        RangeStart       = "6.6.6.6",
                        RangeEnd         = "255.255.255.255"
                    }
                };

                AnalysisServicesServerUpdateParameters updateParameters = new AnalysisServicesServerUpdateParameters()
                {
                    IpV4FirewallSettings = sampleIPV4FirewallSetting
                };

                var resultUpdate = client.Servers.Update(
                    AnalysisServicesTestUtilities.DefaultResourceGroup,
                    AnalysisServicesTestUtilities.DefaultServerName,
                    updateParameters);

                Assert.Equal("Succeeded", resultUpdate.ProvisioningState);
                Assert.Equal("Succeeded", resultUpdate.State);

                // get the server and ensure that all the values are properly set.
                resultGet = client.Servers.GetDetails(AnalysisServicesTestUtilities.DefaultResourceGroup, AnalysisServicesTestUtilities.DefaultServerName);

                // validate the server creation process
                Assert.Equal(AnalysisServicesTestUtilities.DefaultLocation, resultGet.Location);
                Assert.Equal(AnalysisServicesTestUtilities.DefaultServerName, resultGet.Name);
                Assert.NotEmpty(resultGet.ServerFullName);
                Assert.Equal(newSku.Name, resultGet.Sku.Name);
                Assert.Equal(newSku.Tier, resultGet.Sku.Tier);
                Assert.Equal(2, resultGet.Tags.Count);
                Assert.True(resultGet.Tags.ContainsKey("key1"));
                Assert.Equal(2, resultGet.AsAdministrators.Members.Count);
                Assert.Equal("Microsoft.AnalysisServices/servers", resultGet.Type);
                Assert.Equal(1, resultGet.Sku.Capacity);
                Assert.Equal(sampleIPV4FirewallSetting.EnablePowerBIService, resultGet.IpV4FirewallSettings.EnablePowerBIService);
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.Count(), resultGet.IpV4FirewallSettings.FirewallRules.Count());
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.First().FirewallRuleName, resultGet.IpV4FirewallSettings.FirewallRules.First().FirewallRuleName);
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.First().RangeStart, resultGet.IpV4FirewallSettings.FirewallRules.First().RangeStart);
                Assert.Equal(sampleIPV4FirewallSetting.FirewallRules.First().RangeEnd, resultGet.IpV4FirewallSettings.FirewallRules.First().RangeEnd);

                // delete the server with its old name, which should also succeed.
                client.Servers.Delete(AnalysisServicesTestUtilities.DefaultResourceGroup, AnalysisServicesTestUtilities.DefaultServerName);
            }
        }
Esempio n. 14
0
        public void ScaleOutTest()
        {
            string executingAssemblyPath = typeof(AnalysisServices.Tests.ScenarioTests.ServerOperationsTests).GetTypeInfo().Assembly.Location;

            HttpMockServer.RecordsDirectory = Path.Combine(Path.GetDirectoryName(executingAssemblyPath), "SessionRecords");
            var defaultScaleOutCap = 2;
            var s1SKU = "S1";

            using (var context = MockContext.Start(this.GetType()))
            {
                var client = this.GetAnalysisServicesClient(context);

                AnalysisServicesServer             analysisServicesServer = AnalysisServicesTestUtilities.GetDefaultAnalysisServicesResource();
                SkuEnumerationForNewResourceResult skusListForNew         = client.Servers.ListSkusForNew();
                analysisServicesServer.Sku          = skusListForNew.Value.Where((s) => s.Name == s1SKU).First();
                analysisServicesServer.Sku.Capacity = defaultScaleOutCap;

                AnalysisServicesServer resultCreate = null;
                try
                {
                    // Create a test server
                    resultCreate =
                        client.Servers.Create(
                            AnalysisServicesTestUtilities.DefaultResourceGroup,
                            AnalysisServicesTestUtilities.DefaultServerName,
                            analysisServicesServer);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }

                Assert.Equal("Succeeded", resultCreate.ProvisioningState);
                Assert.Equal("Succeeded", resultCreate.State);

                // get the server and ensure that all the values are properly set.
                var resultGet = client.Servers.GetDetails(AnalysisServicesTestUtilities.DefaultResourceGroup, AnalysisServicesTestUtilities.DefaultServerName);

                // validate the server creation process
                Assert.Equal(AnalysisServicesTestUtilities.DefaultLocation, resultGet.Location);
                Assert.Equal(AnalysisServicesTestUtilities.DefaultServerName, resultGet.Name);
                Assert.NotEmpty(resultGet.ServerFullName);
                Assert.Equal(analysisServicesServer.Sku.Name, resultGet.Sku.Name);
                Assert.Equal(2, resultGet.Tags.Count);
                Assert.True(resultGet.Tags.ContainsKey("key1"));
                Assert.Equal(2, resultGet.AsAdministrators.Members.Count);
                Assert.Equal("Microsoft.AnalysisServices/servers", resultGet.Type);
                Assert.Equal(2, resultGet.Sku.Capacity);

                // Confirm that the server creation did succeed
                Assert.True(resultGet.ProvisioningState == "Succeeded");
                Assert.True(resultGet.State == "Succeeded");

                // Scale in the server and verify
                ResourceSku newSku = resultGet.Sku;
                newSku.Capacity = 1;

                AnalysisServicesServerUpdateParameters updateParameters = new AnalysisServicesServerUpdateParameters()
                {
                    Sku = newSku
                };

                var resultUpdate = client.Servers.Update(
                    AnalysisServicesTestUtilities.DefaultResourceGroup,
                    AnalysisServicesTestUtilities.DefaultServerName,
                    updateParameters);

                Assert.Equal("Succeeded", resultUpdate.ProvisioningState);
                Assert.Equal("Succeeded", resultUpdate.State);
                Assert.Equal(1, resultUpdate.Sku.Capacity);

                // get the server and ensure that all the values are properly set.
                resultGet = client.Servers.GetDetails(AnalysisServicesTestUtilities.DefaultResourceGroup, AnalysisServicesTestUtilities.DefaultServerName);

                // validate the server creation process
                Assert.Equal(AnalysisServicesTestUtilities.DefaultLocation, resultGet.Location);
                Assert.Equal(AnalysisServicesTestUtilities.DefaultServerName, resultGet.Name);
                Assert.NotEmpty(resultGet.ServerFullName);
                Assert.Equal(newSku.Name, resultGet.Sku.Name);
                Assert.Equal(newSku.Tier, resultGet.Sku.Tier);
                Assert.Equal(2, resultGet.Tags.Count);
                Assert.True(resultGet.Tags.ContainsKey("key1"));
                Assert.Equal(2, resultGet.AsAdministrators.Members.Count);
                Assert.Equal("Microsoft.AnalysisServices/servers", resultGet.Type);
                Assert.Equal(1, resultGet.Sku.Capacity);

                // delete the server with its old name, which should also succeed.
                client.Servers.Delete(AnalysisServicesTestUtilities.DefaultResourceGroup, AnalysisServicesTestUtilities.DefaultServerName);
            }
        }