Пример #1
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(BlobParameterSetName, StringComparison.InvariantCultureIgnoreCase))
            {
                var toAdd = new StorageAccountInfo
                {
                    Name       = Blob,
                    Properties = new StorageAccountProperties
                    {
                        AccessKey = AccessKey
                    }
                };

                DataLakeAnalyticsClient.AddStorageAccount(ResourceGroupName, Account, toAdd);
            }
            else
            {
                var toAdd = new DataLakeStoreAccountInfo
                {
                    Name       = DataLakeStore,
                    Properties = new DataLakeStoreAccountInfoProperties()
                };

                DataLakeAnalyticsClient.AddDataLakeStoreAccount(ResourceGroupName, Account, toAdd);

                if (Default)
                {
                    DataLakeAnalyticsClient.SetDefaultDataLakeStoreAccount(ResourceGroupName, Account, toAdd);
                }
            }
        }
        public void SetDefaultDataLakeStoreAccount(string resourceGroupName, string accountName,
                                                   DataLakeStoreAccountInfo storageToSet)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            var account = GetAccount(resourceGroupName, accountName);

            account.Properties.DefaultDataLakeStoreAccount = storageToSet.Name;

            if (
                !account.Properties.DataLakeStoreAccounts.Any(
                    acct => acct.Name.Equals(storageToSet.Name, StringComparison.InvariantCultureIgnoreCase)))
            {
                _accountClient.Account.AddDataLakeStoreAccount(resourceGroupName, accountName,
                                                               storageToSet.Name, null);
            }

            // null out values that cannot be updated
            account.Properties.DataLakeStoreAccounts = null;
            account.Properties.StorageAccounts       = null;

            _accountClient.Account.Update(resourceGroupName, accountName, account);
        }
Пример #3
0
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(BlobParameterSetName, StringComparison.InvariantCultureIgnoreCase))
            {
                var toAdd = new StorageAccountInfo
                {
                    Name       = Blob,
                    Properties = new StorageAccountProperties
                    {
                        AccessKey = AccessKey
                    }
                };

                DataLakeAnalyticsClient.SetStorageAccount(ResourceGroupName, Account, toAdd);
            }
            else if (Default)
            {
                var toAdd = new DataLakeStoreAccountInfo
                {
                    Name = DataLakeStore
                };

                DataLakeAnalyticsClient.SetDefaultDataLakeStoreAccount(ResourceGroupName, Account, toAdd);
            }
            else
            {
                WriteWarning(Resources.InvalidDataLakeStoreAccountModificationAttempt);
            }
        }
 public PSDataLakeStoreAccountInfo(DataLakeStoreAccountInfo baseAccount) :
     base(
         baseAccount.Name,
         baseAccount.Id,
         baseAccount.Type,
         baseAccount.Suffix)
 {
 }
Пример #5
0
 public PSDataLakeStoreAccountInfo(DataLakeStoreAccountInfo baseAccount) :
     base(
         baseAccount.Name,
         baseAccount.Id,
         baseAccount.Type,
         baseAccount.Suffix)
 {
     Properties = new PSDataLakeStoreAccountInfoProperties(baseAccount.Suffix);
 }
        public void AddDataLakeStoreAccount(string resourceGroupName, string accountName,
                                            DataLakeStoreAccountInfo storageToAdd)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            _accountClient.DataLakeStoreAccounts.Add(resourceGroupName, accountName,
                                                     storageToAdd.Name);
        }
        public override void ExecuteCmdlet()
        {
            DataLakeStoreAccountInfo defaultAccount = null;
            if (!string.IsNullOrEmpty(DefaultDataLakeStore))
            {
                defaultAccount = new DataLakeStoreAccountInfo
                {
                    Name = DefaultDataLakeStore
                };
            }

            WriteObject(DataLakeAnalyticsClient.CreateOrUpdateAccount(ResourceGroupName, Name, null, defaultAccount,
                    null, null, Tags));
        }
Пример #8
0
        public override void ExecuteCmdlet()
        {
            DataLakeStoreAccountInfo defaultAccount = null;

            if (!string.IsNullOrEmpty(DefaultDataLakeStore))
            {
                defaultAccount = new DataLakeStoreAccountInfo
                {
                    Name = DefaultDataLakeStore
                };
            }

            WriteObject(DataLakeAnalyticsClient.CreateOrUpdateAccount(ResourceGroupName, Name, null, defaultAccount,
                                                                      null, null, Tags));
        }
        public void AddDataLakeStoreAccount(string resourceGroupName, string accountName,
                                            DataLakeStoreAccountInfo storageToAdd)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            var storageParams = new AddDataLakeStoreParameters
            {
                Properties = storageToAdd.Properties
            };

            _accountClient.Account.AddDataLakeStoreAccount(resourceGroupName, accountName,
                                                           storageToAdd.Name, storageParams);
        }
        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 DataLakeStoreAccountInfo
            {
                Name = DefaultDataLakeStore
            };

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

            DataLakeStoreAccountInfo defaultAccount = null;
            if (!string.IsNullOrEmpty(DefaultDataLakeStore))
            {
                defaultAccount = new DataLakeStoreAccountInfo
                {
                    Name = DefaultDataLakeStore
                };
            }

            WriteObject(DataLakeAnalyticsClient.CreateOrUpdateAccount(ResourceGroupName, Name, null, defaultAccount,
                    null, null, Tags));
        }
Пример #12
0
        public override void ExecuteCmdlet()
        {
            if (Tags != null && Tags.Length > 0)
            {
                WriteWarningWithTimestamp(Properties.Resources.TagsWarning);
            }

            DataLakeStoreAccountInfo defaultAccount = null;

            if (!string.IsNullOrEmpty(DefaultDataLakeStore))
            {
                defaultAccount = new DataLakeStoreAccountInfo
                {
                    Name = DefaultDataLakeStore
                };
            }

            WriteObject(DataLakeAnalyticsClient.CreateOrUpdateAccount(ResourceGroupName, Name, null, defaultAccount,
                                                                      null, null, Tags));
        }
Пример #13
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));
        }
        public void AddDataLakeStoreAccount(string resourceGroupName, string accountName,
            DataLakeStoreAccountInfo storageToAdd)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            var storageParams = new AddDataLakeStoreParameters
            {
                Properties = storageToAdd.Properties
            };

            _accountClient.Account.AddDataLakeStoreAccount(resourceGroupName, accountName,
                storageToAdd.Name, storageParams);
        }
        public DataLakeAnalyticsAccount CreateOrUpdateAccount(string resourceGroupName, string accountName,
                                                              string location,
                                                              DataLakeStoreAccountInfo defaultDataLakeStoreAccount             = null,
                                                              IList <DataLakeStoreAccountInfo> additionalDataLakeStoreAccounts = null,
                                                              IList <StorageAccountInfo> additionalStorageAccounts             = null,
                                                              Hashtable customTags = null)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            var tags = TagsConversionHelper.CreateTagDictionary(customTags, true);

            var parameters = new DataLakeAnalyticsAccount
            {
                Name     = accountName,
                Location = location,
                Tags     = tags ?? new Dictionary <string, string>()
            };


            parameters.Properties = new DataLakeAnalyticsAccountProperties();

            if (defaultDataLakeStoreAccount != null)
            {
                parameters.Properties.DefaultDataLakeStoreAccount =
                    defaultDataLakeStoreAccount.Name;
            }

            if (additionalStorageAccounts != null && additionalStorageAccounts.Count > 0)
            {
                parameters.Properties.StorageAccounts = additionalStorageAccounts;
            }

            if (additionalDataLakeStoreAccounts != null && additionalDataLakeStoreAccounts.Count > 0)
            {
                if (defaultDataLakeStoreAccount != null)
                {
                    additionalDataLakeStoreAccounts.Add(defaultDataLakeStoreAccount);
                }

                parameters.Properties.DataLakeStoreAccounts = additionalDataLakeStoreAccounts;
            }
            else if (defaultDataLakeStoreAccount != null)
            {
                parameters.Properties.DataLakeStoreAccounts = new List <DataLakeStoreAccountInfo>
                {
                    defaultDataLakeStoreAccount
                };
            }

            var accountExists = false;

            try
            {
                if (GetAccount(resourceGroupName, accountName) != null)
                {
                    accountExists = true;
                }
            }
            catch
            {
                // intentionally empty since if there is any exception attempting to
                // get the account we know it doesn't exist and we will attempt to create it fresh.
            }

            return(accountExists
                ? _accountClient.Account.Update(resourceGroupName, accountName, parameters)
                : _accountClient.Account.Create(resourceGroupName, accountName, parameters));
        }
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(BlobParameterSetName, StringComparison.InvariantCultureIgnoreCase))
            {
                var toAdd = new StorageAccountInfo
                {
                    Name = Blob,
                    Properties = new StorageAccountProperties
                    {
                        AccessKey = AccessKey
                    }
                };

                DataLakeAnalyticsClient.AddStorageAccount(ResourceGroupName, Account, toAdd);
            }
            else
            {
                var toAdd = new DataLakeStoreAccountInfo
                {
                    Name = DataLakeStore,
                    Properties = new DataLakeStoreAccountInfoProperties()
                };

                DataLakeAnalyticsClient.AddDataLakeStoreAccount(ResourceGroupName, Account, toAdd);

                if (Default)
                {
                    DataLakeAnalyticsClient.SetDefaultDataLakeStoreAccount(ResourceGroupName, Account, toAdd);
                }
            }
        }
        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 DataLakeStoreAccountInfo
            {
                Name = DefaultDataLakeStore
            };

            WriteObject(DataLakeAnalyticsClient.CreateOrUpdateAccount(ResourceGroupName, Name, Location, defaultStorage,
                customTags: Tags));
        }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdlDataSource"/> class.
 /// </summary>
 /// <param name="dataSourceInfo">The data source information.</param>
 /// <param name="isDefault">if set to <c>true</c> [is default].</param>
 public AdlDataSource(DataLakeStoreAccountInfo dataSourceInfo, bool isDefault = false)
 {
     Name      = dataSourceInfo.Name;
     Type      = DataLakeAnalyticsEnums.DataSourceType.DataLakeStore;
     IsDefault = isDefault;
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AdlDataSource"/> class.
 /// </summary>
 /// <param name="dataSourceInfo">The data source information.</param>
 /// <param name="isDefault">if set to <c>true</c> [is default].</param>
 public AdlDataSource(DataLakeStoreAccountInfo dataSourceInfo, bool isDefault = false)
 {
     Name = dataSourceInfo.Name;
     Type = DataLakeAnalyticsEnums.DataSourceType.DataLakeStore;
     IsDefault = isDefault;
 }
        public void SetDefaultDataLakeStoreAccount(string resourceGroupName, string accountName,
            DataLakeStoreAccountInfo storageToSet)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            var account = GetAccount(resourceGroupName, accountName);
            account.Properties.DefaultDataLakeStoreAccount = storageToSet.Name;

            if (
                !account.Properties.DataLakeStoreAccounts.Any(
                    acct => acct.Name.Equals(storageToSet.Name, StringComparison.InvariantCultureIgnoreCase)))
            {
                _accountClient.Account.AddDataLakeStoreAccount(resourceGroupName, accountName,
                    storageToSet.Name, null);
            }

            // null out values that cannot be updated
            account.Properties.DataLakeStoreAccounts = null;
            account.Properties.StorageAccounts = null;

            _accountClient.Account.Update(resourceGroupName, accountName, account);
        }
        public DataLakeAnalyticsAccount CreateOrUpdateAccount(string resourceGroupName, string accountName,
                                                              string location,
                                                              DataLakeStoreAccountInfo defaultDataLakeStoreAccount             = null,
                                                              IList <DataLakeStoreAccountInfo> additionalDataLakeStoreAccounts = null,
                                                              IList <StorageAccountInfo> additionalStorageAccounts             = null,
                                                              Hashtable customTags       = null,
                                                              int?maxDegreeOfParallelism = 0,
                                                              int?maxJobCount            = 0,
                                                              int?queryStoreRetention    = 0,
                                                              TierType?tier = null)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            var tags = TagsConversionHelper.CreateTagDictionary(customTags, true);

            var parameters = new DataLakeAnalyticsAccount
            {
                Location = location,
                Tags     = tags ?? new Dictionary <string, string>()
            };

            if (defaultDataLakeStoreAccount != null)
            {
                parameters.DefaultDataLakeStoreAccount =
                    defaultDataLakeStoreAccount.Name;
            }

            if (additionalStorageAccounts != null && additionalStorageAccounts.Count > 0)
            {
                parameters.StorageAccounts = additionalStorageAccounts;
            }

            if (additionalDataLakeStoreAccounts != null && additionalDataLakeStoreAccounts.Count > 0)
            {
                if (defaultDataLakeStoreAccount != null)
                {
                    additionalDataLakeStoreAccounts.Add(defaultDataLakeStoreAccount);
                }

                parameters.DataLakeStoreAccounts = additionalDataLakeStoreAccounts;
            }
            else if (defaultDataLakeStoreAccount != null)
            {
                parameters.DataLakeStoreAccounts = new List <DataLakeStoreAccountInfo>
                {
                    defaultDataLakeStoreAccount
                };
            }

            if (maxDegreeOfParallelism.HasValue && maxDegreeOfParallelism > 0)
            {
                parameters.MaxDegreeOfParallelism = maxDegreeOfParallelism;
            }

            if (maxJobCount.HasValue && maxJobCount > 0)
            {
                parameters.MaxJobCount = maxJobCount;
            }

            if (queryStoreRetention.HasValue && queryStoreRetention > 0)
            {
                parameters.QueryStoreRetention = queryStoreRetention;
            }

            if (tier.HasValue)
            {
                parameters.NewTier = tier;
            }

            var accountExists = false;

            try
            {
                if (GetAccount(resourceGroupName, accountName) != null)
                {
                    accountExists = true;
                }
            }
            catch
            {
                // intentionally empty since if there is any exception attempting to
                // get the account we know it doesn't exist and we will attempt to create it fresh.
            }

            return(accountExists
                ? _accountClient.Account.Update(resourceGroupName, accountName, new DataLakeAnalyticsAccountUpdateParameters
            {
                MaxDegreeOfParallelism = parameters.MaxDegreeOfParallelism,
                MaxJobCount = parameters.MaxJobCount,
                QueryStoreRetention = parameters.QueryStoreRetention,
                Tags = parameters.Tags,
                NewTier = parameters.NewTier
            })
                : _accountClient.Account.Create(resourceGroupName, accountName, parameters));
        }
        public DataLakeAnalyticsAccount CreateOrUpdateAccount(string resourceGroupName, string accountName,
            string location,
            DataLakeStoreAccountInfo defaultDataLakeStoreAccount = null,
            IList<DataLakeStoreAccountInfo> additionalDataLakeStoreAccounts = null,
            IList<StorageAccountInfo> additionalStorageAccounts = null,
            Hashtable customTags = null)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            var tags = TagsConversionHelper.CreateTagDictionary(customTags, true);

            var parameters = new DataLakeAnalyticsAccount
            {
                Name = accountName,
                Location = location,
                Tags = tags ?? new Dictionary<string, string>()
            };


            parameters.Properties = new DataLakeAnalyticsAccountProperties();

            if (defaultDataLakeStoreAccount != null)
            {
                parameters.Properties.DefaultDataLakeStoreAccount =
                    defaultDataLakeStoreAccount.Name;
            }

            if (additionalStorageAccounts != null && additionalStorageAccounts.Count > 0)
            {
                parameters.Properties.StorageAccounts = additionalStorageAccounts;
            }

            if (additionalDataLakeStoreAccounts != null && additionalDataLakeStoreAccounts.Count > 0)
            {
                if (defaultDataLakeStoreAccount != null)
                {
                    additionalDataLakeStoreAccounts.Add(defaultDataLakeStoreAccount);
                }

                parameters.Properties.DataLakeStoreAccounts = additionalDataLakeStoreAccounts;
            }
            else if (defaultDataLakeStoreAccount != null)
            {
                parameters.Properties.DataLakeStoreAccounts = new List<DataLakeStoreAccountInfo>
                {
                    defaultDataLakeStoreAccount
                };
            }

            var accountExists = false;
            try
            {
                if (GetAccount(resourceGroupName, accountName) != null)
                {
                    accountExists = true;
                }
            }
            catch
            {
                // intentionally empty since if there is any exception attempting to 
                // get the account we know it doesn't exist and we will attempt to create it fresh.
            }

            return accountExists
                ? _accountClient.Account.Update(resourceGroupName, accountName, parameters)
                : _accountClient.Account.Create(resourceGroupName, accountName, parameters);
        }
        public override void ExecuteCmdlet()
        {
            if (ParameterSetName.Equals(BlobParameterSetName, StringComparison.InvariantCultureIgnoreCase))
            {
                var toAdd = new StorageAccountInfo
                {
                    Name = Blob,
                    Properties = new StorageAccountProperties
                    {
                        AccessKey = AccessKey
                    }
                };

                DataLakeAnalyticsClient.SetStorageAccount(ResourceGroupName, Account, toAdd);
            }
            else if (Default)
            {
                var toAdd = new DataLakeStoreAccountInfo
                {
                    Name = DataLakeStore
                };

                DataLakeAnalyticsClient.SetDefaultDataLakeStoreAccount(ResourceGroupName, Account, toAdd);
            }
            else
            {
                WriteWarning(Resources.InvalidDataLakeStoreAccountModificationAttempt);
            }
        }