コード例 #1
0
        public override void ExecuteCmdlet()
        {
            try
            {
                if (DataLakeStoreClient.GetAccount(ResourceGroupName, Name) != null)
                {
                    throw new CloudException(string.Format(Resources.DataLakeStoreAccountExists, 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;
                }
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, Location, Tags));
        }
コード例 #2
0
        public override void ExecuteCmdlet()
        {
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            // validation of encryption parameters
            if (Encryption != null)
            {
                var identity = new EncryptionIdentity
                {
                    Type = EncryptionIdentityType.SystemAssigned,
                };
                var config = new EncryptionConfig
                {
                    Type = Encryption.Value,
                };

                if (Encryption.Value == EncryptionConfigType.UserManaged)
                {
                    if (string.IsNullOrEmpty(KeyVaultId) ||
                        string.IsNullOrEmpty(KeyName) ||
                        string.IsNullOrEmpty(KeyVersion))
                    {
                        throw new PSArgumentException(Resources.MissingKeyVaultParams);
                    }

                    config.KeyVaultMetaInfo = new KeyVaultMetaInfo
                    {
                        KeyVaultResourceId   = KeyVaultId,
                        EncryptionKeyName    = KeyName,
                        EncryptionKeyVersion = KeyVersion
                    };
                }
                else
                {
                    if (!string.IsNullOrEmpty(KeyVaultId) ||
                        !string.IsNullOrEmpty(KeyName) ||
                        !string.IsNullOrEmpty(KeyVersion))
                    {
                        WriteWarning(Resources.IgnoredKeyVaultParams);
                    }
                }

                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags, identity, config));
            }
            else
            {
                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
            }
        }
コード例 #3
0
        public override void ExecuteCmdlet()
        {
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
        }
コード例 #4
0
        protected override void ProcessRecord()
        {
            // TODO: Define what can be updated for DataLakeStore accounts
            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null || Tags.Length == 0)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
        }
コード例 #5
0
        public override void ExecuteCmdlet()
        {
            if (Tags != null && Tags.Length > 0)
            {
                WriteWarningWithTimestamp(Properties.Resources.TagsWarning);
            }

            var currentAccount = DataLakeStoreClient.GetAccount(ResourceGroupName, Name);
            var location       = currentAccount.Location;

            if (string.IsNullOrEmpty(DefaultGroup))
            {
                DefaultGroup = currentAccount.Properties.DefaultGroup;
            }

            if (Tags == null || Tags.Length == 0)
            {
                Tags = TagsConversionHelper.CreateTagHashtable(currentAccount.Tags);
            }

            WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, location, Tags));
        }
コード例 #6
0
        public override void ExecuteCmdlet()
        {
            try
            {
                if (DataLakeStoreClient.GetAccount(ResourceGroupName, Name) != null)
                {
                    throw new CloudException(string.Format(Resources.DataLakeStoreAccountExists, 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;
                }
            }

            // validation of encryption parameters
            if (Encryption != null)
            {
                var identity = new EncryptionIdentity
                {
                    Type = EncryptionIdentityType.SystemAssigned,
                };
                var config = new EncryptionConfig
                {
                    Type = Encryption.Value,
                };

                if (Encryption.Value == EncryptionConfigType.UserManaged)
                {
                    if (string.IsNullOrEmpty(KeyVaultId) ||
                        string.IsNullOrEmpty(KeyName) ||
                        string.IsNullOrEmpty(KeyVersion))
                    {
                        throw new PSArgumentException(Resources.MissingKeyVaultParams);
                    }

                    config.KeyVaultMetaInfo = new KeyVaultMetaInfo
                    {
                        KeyVaultResourceId   = KeyVaultId,
                        EncryptionKeyName    = KeyName,
                        EncryptionKeyVersion = KeyVersion
                    };
                }
                else
                {
                    if (!string.IsNullOrEmpty(KeyVaultId) ||
                        !string.IsNullOrEmpty(KeyName) ||
                        !string.IsNullOrEmpty(KeyVersion))
                    {
                        WriteWarning(Resources.IgnoredKeyVaultParams);
                    }
                }

                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, Location, Tags, identity, config));
            }
            else
            {
                WriteObject(DataLakeStoreClient.CreateOrUpdateAccount(ResourceGroupName, Name, DefaultGroup, Location, Tags));
            }
        }