public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, Resources.CreateNewAnalysisServicesServer))
            {
                try
                {
                    if (AnalysisServicesClient.GetServer(ResourceGroupName, Name) != null)
                    {
                        throw new CloudException(string.Format(Resources.AnalysisServerExists, Name));
                    }
                }
                catch (CloudException ex)
                {
                    if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) && ex.Body.Code == "ResourceNotFound" ||
                        ex.Message.Contains("ResourceNotFound"))
                    {
                        // server does not exists so go ahead and create one
                    }
                    else if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) &&
                             ex.Body.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound"))
                    {
                        // resource group not found, let create throw error don't throw from here
                    }
                    else
                    {
                        // all other exceptions should be thrown
                        throw;
                    }
                }

                var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator);
                WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(createdServer));
            }
        }
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrEmpty(Name))
            {
                WriteExceptionError(new PSArgumentNullException("Name", "Name of server not specified"));
            }

            if (ShouldProcess(Name, Resources.UpdatingAnalysisServicesServer))
            {
                AnalysisServicesServer currentServer = null;
                if (!AnalysisServicesClient.TestServer(ResourceGroupName, Name, out currentServer))
                {
                    throw new InvalidOperationException(string.Format(Properties.Resources.ServerDoesNotExist, Name));
                }

                var location = currentServer.Location;
                if (Tag == null && currentServer.Tags != null)
                {
                    Tag = TagsConversionHelper.CreateTagHashtable(currentServer.Tags);
                }

                AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer);

                if (PassThru.IsPresent)
                {
                    WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(updatedServer));
                }
            }
        }
 public override void ExecuteCmdlet()
 {
     if (!string.IsNullOrEmpty(Name))
     {
         // Get for single server
         var server = AnalysisServicesClient.GetServer(ResourceGroupName, Name);
         WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(server));
     }
     else
     {
         // List all servers in given resource group if avaliable otherwise all servers in the subscription
         var list = AnalysisServicesClient.ListServers(ResourceGroupName);
         WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServerCollection(list), true);
     }
 }
Example #4
0
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, Resources.CreateNewAnalysisServicesServer))
            {
                try
                {
                    if (AnalysisServicesClient.GetServer(ResourceGroupName, Name) != null)
                    {
                        throw new CloudException(string.Format(Resources.AnalysisServerExists, Name));
                    }
                }
                catch (CloudException ex)
                {
                    if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) && ex.Body.Code == "ResourceNotFound" ||
                        ex.Message.Contains("ResourceNotFound"))
                    {
                        // server does not exists so go ahead and create one
                    }
                    else if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) &&
                             ex.Body.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound"))
                    {
                        // resource group not found, let create throw error don't throw from here
                    }
                    else
                    {
                        // all other exceptions should be thrown
                        throw;
                    }
                }

                var availableSkus = AnalysisServicesClient.ListSkusForNew();
                if (!availableSkus.Value.Any(v => v.Name == Sku))
                {
                    throw new InvalidOperationException(string.Format(Resources.InvalidSku, Sku, String.Join(",", availableSkus.Value.Select(v => v.Name))));
                }

                var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri);
                WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(createdServer));
            }
        }
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrEmpty(Name))
            {
                WriteExceptionError(new PSArgumentNullException("Name", "Name of server not specified"));
            }

            if (ShouldProcess(Name, Resources.UpdatingAnalysisServicesServer))
            {
                AnalysisServicesServer currentServer = null;
                if (!AnalysisServicesClient.TestServer(ResourceGroupName, Name, out currentServer))
                {
                    throw new InvalidOperationException(string.Format(Properties.Resources.ServerDoesNotExist, Name));
                }

                var availableSkus = AnalysisServicesClient.ListSkusForExisting(ResourceGroupName, Name);
                if (Sku != null && !availableSkus.Value.Any(v => v.Sku.Name == Sku))
                {
                    throw new InvalidOperationException(string.Format(Resources.InvalidSku, Sku, String.Join(",", availableSkus.Value.Select(v => v.Sku.Name))));
                }

                var location = currentServer.Location;
                if (Tag == null && currentServer.Tags != null)
                {
                    Tag = TagsConversionHelper.CreateTagHashtable(currentServer.Tags);
                }

                if (DisableBackup.IsPresent)
                {
                    BackupBlobContainerUri = "-";
                }

                AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri);

                if (PassThru.IsPresent)
                {
                    WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(updatedServer));
                }
            }
        }
Example #6
0
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrEmpty(Name))
            {
                WriteExceptionError(new PSArgumentNullException("Name", "Name of server not specified"));
            }

            if (ShouldProcess(Name, Resources.ResumingAnalysisServicesServer))
            {
                AnalysisServicesServer server = null;
                if (!AnalysisServicesClient.TestServer(ResourceGroupName, Name, out server))
                {
                    throw new InvalidOperationException(string.Format(Properties.Resources.ServerDoesNotExist, Name));
                }

                AnalysisServicesClient.ResumeServer(ResourceGroupName, Name);

                if (PassThru.IsPresent)
                {
                    WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(server));
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            AnalysisServicesServer server = null;

            WriteObject(AnalysisServicesClient.TestServer(ResourceGroupName, Name, out server));
        }
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrEmpty(Name))
            {
                WriteExceptionError(new PSArgumentNullException("Name", "Name of server not specified"));
            }

            if (ShouldProcess(Name, Resources.UpdatingAnalysisServicesServer))
            {
                AnalysisServicesServer currentServer = null;
                if (!AnalysisServicesClient.TestServer(ResourceGroupName, Name, out currentServer))
                {
                    throw new InvalidOperationException(string.Format(Properties.Resources.ServerDoesNotExist, Name));
                }

                var availableSkus = AnalysisServicesClient.ListSkusForExisting(ResourceGroupName, Name);
                if (Sku != null && !availableSkus.Value.Any(v => v.Sku.Name == Sku))
                {
                    throw new InvalidOperationException(string.Format(Resources.InvalidSku, Sku, String.Join(",", availableSkus.Value.Select(v => v.Sku.Name))));
                }

                var location = currentServer.Location;
                if (Tag == null && currentServer.Tags != null)
                {
                    Tag = TagsConversionHelper.CreateTagHashtable(currentServer.Tags);
                }

                if (DisableBackup.IsPresent)
                {
                    BackupBlobContainerUri = "-";
                }

                IPv4FirewallSettings setting = null;
                if (FirewallConfig != null)
                {
                    setting = new IPv4FirewallSettings(new List <IPv4FirewallRule>(), "False");

                    setting.EnablePowerBIService = FirewallConfig.EnablePowerBIService.ToString();

                    if (FirewallConfig.FirewallRules != null)
                    {
                        foreach (var rule in FirewallConfig.FirewallRules)
                        {
                            setting.FirewallRules.Add(new IPv4FirewallRule()
                            {
                                FirewallRuleName = rule.FirewallRuleName,
                                RangeStart       = rule.RangeStart,
                                RangeEnd         = rule.RangeEnd
                            });
                        }
                    }
                }


                if (!MyInvocation.BoundParameters.ContainsKey("ReadonlyReplicaCount"))
                {
                    ReadonlyReplicaCount = -1;
                }

                AnalysisServicesServer updatedServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, location, Sku, Tag, Administrator, currentServer, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting);

                if (PassThru.IsPresent)
                {
                    WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(updatedServer));
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, Resources.CreateNewAnalysisServicesServer))
            {
                try
                {
                    if (AnalysisServicesClient.GetServer(ResourceGroupName, Name) != null)
                    {
                        throw new CloudException(string.Format(Resources.AnalysisServerExists, Name));
                    }
                }
                catch (CloudException ex)
                {
                    if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) && ex.Body.Code == "ResourceNotFound" ||
                        ex.Message.Contains("ResourceNotFound"))
                    {
                        // server does not exists so go ahead and create one
                    }
                    else if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) &&
                             ex.Body.Code == "ResourceGroupNotFound" || ex.Message.Contains("ResourceGroupNotFound"))
                    {
                        // resource group not found, let create throw error don't throw from here
                    }
                    else
                    {
                        // all other exceptions should be thrown
                        throw;
                    }
                }

                var availableSkus = AnalysisServicesClient.ListSkusForNew();
                if (!availableSkus.Value.Any(v => v.Name == Sku))
                {
                    throw new InvalidOperationException(string.Format(Resources.InvalidSku, Sku, String.Join(",", availableSkus.Value.Select(v => v.Name))));
                }

                IPv4FirewallSettings setting = null;
                if (FirewallConfig != null)
                {
                    setting = new IPv4FirewallSettings(new List <IPv4FirewallRule>(), "False");

                    setting.EnablePowerBIService = FirewallConfig.EnablePowerBIService.ToString();

                    if (FirewallConfig.FirewallRules != null)
                    {
                        foreach (var rule in FirewallConfig.FirewallRules)
                        {
                            setting.FirewallRules.Add(new IPv4FirewallRule()
                            {
                                FirewallRuleName = rule.FirewallRuleName,
                                RangeStart       = rule.RangeStart,
                                RangeEnd         = rule.RangeEnd
                            });
                        }
                    }
                }

                if (!MyInvocation.BoundParameters.ContainsKey("ReadonlyReplicaCount"))
                {
                    ReadonlyReplicaCount = 0;
                }

                var createdServer = AnalysisServicesClient.CreateOrUpdateServer(ResourceGroupName, Name, Location, Sku, Tag, Administrator, null, BackupBlobContainerUri, ReadonlyReplicaCount, DefaultConnectionMode, setting, GatewayResourceId);
                WriteObject(AzureAnalysisServicesServer.FromAnalysisServicesServer(createdServer));
            }
        }