コード例 #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);
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #4
0
 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);
 }
コード例 #6
0
        public void AddDataLakeStoreAccount(string resourceGroupName, string accountName,
                                            DataLakeStoreAccountInfo storageToAdd)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByAccountName(accountName);
            }

            _accountClient.DataLakeStoreAccounts.Add(resourceGroupName, accountName,
                                                     storageToAdd.Name);
        }
コード例 #7
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));
        }
コード例 #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));
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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));
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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));
        }
コード例 #16
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);
                }
            }
        }
コード例 #17
0
        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;
 }
コード例 #20
0
        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);
        }
コード例 #21
0
        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));
        }
コード例 #22
0
        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);
        }
コード例 #23
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);
            }
        }