public override void ExecuteCmdlet()
 {
     if (!string.IsNullOrEmpty(Name))
     {
         // Get for single account
         WriteObject(new PSDataLakeAnalyticsAccount(DataLakeAnalyticsClient.GetAccount(ResourceGroupName, Name)));
     }
     else
     {
         WriteWarning(Resources.IncorrectOutputTypeWarning);
         // List all accounts in given resource group if avaliable otherwise all accounts in the subscription
         WriteObject(DataLakeAnalyticsClient.ListAccounts(ResourceGroupName, null, null, null)
                     .Select(element => new PSDataLakeAnalyticsAccountBasic(element))
                     .ToList(), true);
     }
 }
        public override void ExecuteCmdlet()
        {
            try
            {
                if (DataLakeAnalyticsClient.GetAccount(ResourceGroupName, Name) != null)
                {
                    throw new CloudException(string.Format(Resources.DataLakeAnalyticsAccountExists, Name));
                }
            }
            catch (CloudException ex)
            {
                if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) && ex.Body.Code == "ResourceNotFound" ||
                    ex.Message.Contains("ResourceNotFound"))
                {
                    // account 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 defaultStorage = new AddDataLakeStoreWithAccountParameters
            {
                Name = DefaultDataLakeStore
            };

            WriteObject(
                new PSDataLakeAnalyticsAccount(
                    DataLakeAnalyticsClient.CreateOrUpdateAccount(
                        ResourceGroupName,
                        Name,
                        Location,
                        defaultStorage,
                        customTags: Tag,
                        maxAnalyticsUnits: MaxAnalyticsUnits,
                        maxJobCount: MaxJobCount,
                        queryStoreRetention: QueryStoreRetention,
                        tier: Tier)));
        }
Пример #3
0
        public override void ExecuteCmdlet()
        {
            if (Tags != null && Tags.Length > 0)
            {
                WriteWarningWithTimestamp(Properties.Resources.TagsWarning);
            }

            try
            {
                if (DataLakeAnalyticsClient.GetAccount(ResourceGroupName, Name) != null)
                {
                    throw new CloudException(string.Format(Resources.DataLakeAnalyticsAccountExists, Name));
                }
            }
            catch (CloudException ex)
            {
                if (ex.Body != null && !string.IsNullOrEmpty(ex.Body.Code) && ex.Body.Code == "ResourceNotFound" ||
                    ex.Message.Contains("ResourceNotFound"))
                {
                    // account 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 defaultStorage = new DataLakeStoreAccountInfo
            {
                Name = DefaultDataLakeStore
            };

            WriteObject(DataLakeAnalyticsClient.CreateOrUpdateAccount(ResourceGroupName, Name, Location, defaultStorage,
                                                                      customTags: Tags));
        }
Пример #4
0
        public override void ExecuteCmdlet()
        {
            if (string.IsNullOrEmpty(ResourceGroupName))
            {
                ResourceGroupName = DataLakeAnalyticsClient.GetResourceGroupByAccountName(Name);
            }

            var account = DataLakeAnalyticsClient.GetAccount(ResourceGroupName, Name);

            if (!FirewallState.HasValue)
            {
                FirewallState = account.FirewallState;
            }

            if (AllowAzureIpState.HasValue && FirewallState.Value == Management.DataLake.Analytics.Models.FirewallState.Disabled)
            {
                WriteWarning(string.Format(Properties.Resources.FirewallDisabledWarning, Name));
            }

            WriteObject(
                new PSDataLakeAnalyticsAccount(
                    DataLakeAnalyticsClient.CreateOrUpdateAccount(
                        ResourceGroupName,
                        Name,
                        null,
                        null,
                        null,
                        null,
                        Tags,
                        MaxAnalyticsUnits,
                        MaxJobCount,
                        QueryStoreRetention,
                        Tier,
                        FirewallState,
                        AllowAzureIpState)));
        }