Exemplo n.º 1
0
        public async Task RemoveStorageAccountFromVNet(string resourceGroupForStorageAccount, string storageAccountName, string resourceGroupForVnet, string vNetName, CancellationToken cancellation)
        {
            try
            {
                var storageAccount = await GetResourceAsync(resourceGroupForStorageAccount, storageAccountName, cancellationToken : cancellation);

                var network = await _azure.Networks.GetByResourceGroupAsync(resourceGroupForVnet, vNetName, cancellation);

                if (network == null)
                {
                    throw NotFoundException.CreateForAzureResource(vNetName, resourceGroupForVnet);
                }

                var sandboxSubnet = AzureVNetUtil.GetSandboxSubnetOrThrow(network);

                var networkRuleSet = GetNetworkRuleSetForUpdate(storageAccount, true);

                if (GetRuleForSubnet(networkRuleSet, sandboxSubnet.Inner.Id, Microsoft.Azure.Management.Storage.Fluent.Models.Action.Allow, out VirtualNetworkRule existingRule))
                {
                    networkRuleSet = RemoveVNetFromRuleSet(networkRuleSet, sandboxSubnet.Inner.Id);

                    var updateParameters = new StorageAccountUpdateParameters()
                    {
                        NetworkRuleSet = networkRuleSet
                    };

                    await _azure.StorageAccounts.Inner.UpdateAsync(resourceGroupForStorageAccount, storageAccountName, updateParameters, cancellation);
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Could not add Storage Account {storageAccountName} to VNet {vNetName}", ex);
            }
        }
 /// <summary>
 /// Creates StorageNetworkRulesHelper.
 /// </summary>
 /// <param name="updateParameters">the model representing payload for storage account update</param>
 /// <param name="inner">the current state of storage account</param>
 internal StorageNetworkRulesHelper(StorageAccountUpdateParameters updateParameters, StorageAccountInner inner)
 {
     this.isInCreateMode   = false;
     this.createParameters = null;
     this.updateParameters = updateParameters;
     this.inner            = inner;
 }
 /// <summary>
 /// Creates StorageNetworkRulesHelper.
 /// </summary>
 /// <param name="createParameters">the model representing payload for storage account create.</param>
 internal StorageNetworkRulesHelper(StorageAccountCreateParameters createParameters)
 {
     this.isInCreateMode   = true;
     this.createParameters = createParameters;
     this.updateParameters = null;
     this.inner            = null;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates StorageEncryptionHelper.
 /// </summary>
 /// <param name="createParameters">the model representing payload for storage account create</param>
 internal StorageEncryptionHelper(StorageAccountCreateParameters createParameters)
 {
     this.isInCreateMode   = true;
     this.createParameters = createParameters;
     this.updateParameters = null;
     this.inner            = null;
 }
 ///GENMHASH:6BCE517E09457FF033728269C8936E64:D26CBA1CFC05445E2A90F41690FC5CB3
 public override IUpdate Update()
 {
     this.createParameters   = null;
     this.updateParameters   = new StorageAccountUpdateParameters();
     this.networkRulesHelper = new StorageNetworkRulesHelper(this.updateParameters, this.Inner);
     this.encryptionHelper   = new StorageEncryptionHelper(this.updateParameters, this.Inner);
     return(this);
 }
Exemplo n.º 6
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (ShouldProcess(this.Name, "Set Storage Account"))
            {
                if (this.force || this.AccessTier == null || ShouldContinue("Changing the access tier may result in additional charges. See (http://go.microsoft.com/fwlink/?LinkId=786482) to learn more.", ""))
                {
                    StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters();
                    if (this.SkuName != null)
                    {
                        updateParameters.Sku = new Sku(ParseSkuName(this.SkuName));
                    }

                    if (this.Tag != null)
                    {
                        Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);
                        updateParameters.Tags = tagDictionary ?? new Dictionary <string, string>();
                    }

                    if (this.CustomDomainName != null)
                    {
                        updateParameters.CustomDomain = new CustomDomain()
                        {
                            Name         = CustomDomainName,
                            UseSubDomain = UseSubDomain
                        };
                    }
                    else if (UseSubDomain != null)
                    {
                        throw new System.ArgumentException(string.Format("UseSubDomain must be set together with CustomDomainName."));
                    }

                    if (this.EnableEncryptionService != null || this.DisableEncryptionService != null)
                    {
                        updateParameters.Encryption = ParseEncryption(EnableEncryptionService, DisableEncryptionService);
                    }

                    if (this.AccessTier != null)
                    {
                        updateParameters.AccessTier = ParseAccessTier(AccessTier);
                    }
                    if (enableHttpsTrafficOnly != null)
                    {
                        updateParameters.EnableHttpsTrafficOnly = enableHttpsTrafficOnly;
                    }

                    var updatedAccountResponse = this.StorageClient.StorageAccounts.Update(
                        this.ResourceGroupName,
                        this.Name,
                        updateParameters);

                    var storageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);

                    WriteStorageAccount(storageAccount);
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (ShouldProcess(this.Name, "Update Storage Account NetworkRule"))
            {
                if (IPRule == null && VirtualNetworkRule == null && bypass == null && defaultAction == null)
                {
                    throw new System.ArgumentNullException("IPRules, VirtualNetworkRules, Bypass, DefaultAction", "Request must specify an account NetworkRule property to update.");
                }

                var storageAccount = this.StorageClient.StorageAccounts.GetProperties(
                    this.ResourceGroupName,
                    this.Name);
                NetworkRuleSet storageACL = storageAccount.NetworkRuleSet;

                if (storageACL == null)
                {
                    storageACL = new NetworkRuleSet();
                }

                PSNetworkRuleSet psNetworkRule = PSNetworkRuleSet.ParsePSNetworkRule(storageACL);

                if (isIpRuleSet)
                {
                    psNetworkRule.IpRules = IPRule;
                }

                if (isNetworkRuleSet)
                {
                    psNetworkRule.VirtualNetworkRules = VirtualNetworkRule;
                }

                if (bypass != null)
                {
                    psNetworkRule.Bypass = bypass;
                }

                if (defaultAction != null)
                {
                    psNetworkRule.DefaultAction = defaultAction.Value;
                }

                StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters();
                updateParameters.NetworkRuleSet = PSNetworkRuleSet.ParseStorageNetworkRule(psNetworkRule);

                var updatedAccountResponse = this.StorageClient.StorageAccounts.Update(
                    this.ResourceGroupName,
                    this.Name,
                    updateParameters);

                storageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);

                WriteObject(PSNetworkRuleSet.ParsePSNetworkRule(storageAccount.NetworkRuleSet));
            }
        }
        public async Task BlobContainerSoftDelete()
        {
            //update storage account to v2
            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters()
            {
                Kind = Kind.StorageV2
            };
            await _storageAccount.UpdateAsync(updateParameters);

            _blobService = await _blobService.GetAsync();

            BlobServiceData properties = _blobService.Data;

            //enable container softdelete
            properties.ContainerDeleteRetentionPolicy         = new DeleteRetentionPolicy();
            properties.ContainerDeleteRetentionPolicy.Enabled = true;
            properties.ContainerDeleteRetentionPolicy.Days    = 30;
            _blobService = (await _blobService.CreateOrUpdateAsync(properties)).Value;

            //create two blob containers and delete 1
            string        containerName1 = Recording.GenerateAssetName("testblob1");
            string        containerName2 = Recording.GenerateAssetName("testblob2");
            BlobContainer container1     = (await _blobContainerCollection.CreateOrUpdateAsync(containerName1, new BlobContainerData())).Value;
            BlobContainer container2     = (await _blobContainerCollection.CreateOrUpdateAsync(containerName2, new BlobContainerData())).Value;
            await container2.DeleteAsync();

            //list delete included
            List <BlobContainer> blobContainers = await _blobContainerCollection.GetAllAsync(include : ListContainersInclude.Deleted).ToEnumerableAsync();

            Assert.AreEqual(2, blobContainers.Count);
            foreach (BlobContainer con in blobContainers)
            {
                if (con.Data.Name == containerName1)
                {
                    Assert.IsFalse(con.Data.Deleted);
                }
                else
                {
                    Assert.IsTrue(con.Data.Deleted);
                    Assert.NotNull(con.Data.RemainingRetentionDays);
                }
            }
            //list without delete included
            blobContainers = await _blobContainerCollection.GetAllAsync().ToEnumerableAsync();

            Assert.AreEqual(1, blobContainers.Count);

            //disable container softdelete
            properties = _blobService.Data;
            properties.ContainerDeleteRetentionPolicy = new DeleteRetentionPolicy();
            properties.DeleteRetentionPolicy.Enabled  = false;
            _blobService = (await _blobService.CreateOrUpdateAsync(properties)).Value;
            properties   = _blobService.Data;
            Assert.IsFalse(properties.ContainerDeleteRetentionPolicy.Enabled);
        }
        public async Task ExtendImmutabilityPolicy()
        {
            //update storage account to v2
            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters()
            {
                Kind = Kind.StorageV2
            };

            _storageAccount = await _storageAccount.UpdateAsync(updateParameters);

            _blobService = await _blobService.GetAsync();

            // create a blob container
            string            containerName = Recording.GenerateAssetName("testblob");
            BlobContainerData data          = new BlobContainerData();
            BlobContainer     container     = (await _blobContainerCollection.CreateOrUpdateAsync(containerName, new BlobContainerData())).Value;

            //create immutability policy
            ImmutabilityPolicyData immutabilityPolicyModel = new ImmutabilityPolicyData()
            {
                ImmutabilityPeriodSinceCreationInDays = 3
            };
            ImmutabilityPolicy immutabilityPolicy = (await container.GetImmutabilityPolicy().CreateOrUpdateAsync(ifMatch: "", parameters: immutabilityPolicyModel)).Value;

            //validate
            Assert.NotNull(immutabilityPolicy.Data.Id);
            Assert.NotNull(immutabilityPolicy.Data.Type);
            Assert.NotNull(immutabilityPolicy.Data.Name);
            Assert.AreEqual(3, immutabilityPolicy.Data.ImmutabilityPeriodSinceCreationInDays);
            Assert.AreEqual(ImmutabilityPolicyState.Unlocked, immutabilityPolicy.Data.State);

            //lock immutability policy
            immutabilityPolicy = await container.GetImmutabilityPolicy().LockImmutabilityPolicyAsync(ifMatch: immutabilityPolicy.Data.Etag);

            Assert.NotNull(immutabilityPolicy.Data.Id);
            Assert.NotNull(immutabilityPolicy.Data.Type);
            Assert.NotNull(immutabilityPolicy.Data.Name);
            Assert.AreEqual(3, immutabilityPolicy.Data.ImmutabilityPeriodSinceCreationInDays);
            Assert.AreEqual(ImmutabilityPolicyState.Locked, immutabilityPolicy.Data.State);

            //extend immutability policy
            immutabilityPolicyModel = new ImmutabilityPolicyData()
            {
                ImmutabilityPeriodSinceCreationInDays = 100
            };
            immutabilityPolicy = await container.GetImmutabilityPolicy().ExtendImmutabilityPolicyAsync(ifMatch: immutabilityPolicy.Data.Etag, parameters: immutabilityPolicyModel);

            Assert.NotNull(immutabilityPolicy.Data.Id);
            Assert.NotNull(immutabilityPolicy.Data.Type);
            Assert.NotNull(immutabilityPolicy.Data.Name);
            Assert.AreEqual(100, immutabilityPolicy.Data.ImmutabilityPeriodSinceCreationInDays);
            Assert.AreEqual(ImmutabilityPolicyState.Locked, immutabilityPolicy.Data.State);
            await container.DeleteAsync();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Updates the storage account
        /// </summary>
        /// <param name="rgname">Resource Group Name</param>
        /// <param name="acctName">Account Name</param>
        /// <param name="storageMgmtClient"></param>
        private static void UpdateStorageAccount(string rgname, string acctName, StorageManagementClient storageMgmtClient)
        {
            Console.WriteLine("Updating storage account...");
            // Update storage account type
            var parameters = new StorageAccountUpdateParameters
            {
                AccountType = AccountType.StandardLRS
            };
            var response = storageMgmtClient.StorageAccounts.Update(rgname, acctName, parameters);

            Console.WriteLine("Account type on storage account updated to " + response.StorageAccount.AccountType);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Updates the storage account
        /// </summary>
        /// <param name="rgname">Resource Group Name</param>
        /// <param name="acctName">Account Name</param>
        /// <param name="storageMgmtClient"></param>
        private static void UpdateStorageAccountSku(string rgname, string acctName, SkuName skuName, StorageManagementClient storageMgmtClient)
        {
            Console.WriteLine("Updating storage account...");
            // Update storage account sku
            var parameters = new StorageAccountUpdateParameters
            {
                Sku = new Sku(skuName)
            };
            var storageAccount = storageMgmtClient.StorageAccounts.Update(rgname, acctName, parameters);

            Console.WriteLine("Sku on storage account updated to " + storageAccount.Sku.Name);
        }
        internal void UpdateStorageAccount(string Description, string Label, string AccountType)
        {
            var parms = new StorageAccountUpdateParameters();

            parms.Description = Description;
            parms.Label       = Label;
            parms.AccountType = AccountType;

            _storageManagementClient.StorageAccounts.Update(
                _parameters.StorageAccountName,
                parms);
        }
        public async Task CreateDeleteListFileShareSnapshot()
        {
            //update storage account to v2
            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters()
            {
                Kind = Kind.StorageV2
            };
            await _storageAccount.UpdateAsync(updateParameters);

            // Enable share soft delete in service properties
            _fileService = await _fileService.GetAsync();

            FileServiceData properties = new FileServiceData()
            {
                ShareDeleteRetentionPolicy = new DeleteRetentionPolicy()
                {
                    Enabled = true,
                    Days    = 5
                }
            };

            _fileService = (await _fileService.CreateOrUpdateAsync(true, properties)).Value;

            //create 2 file share and delete 1
            string    fileShareName1 = Recording.GenerateAssetName("testfileshare1");
            string    fileShareName2 = Recording.GenerateAssetName("testfileshare2");
            FileShare share1         = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName1, new FileShareData())).Value;
            FileShare share2         = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName2, new FileShareData())).Value;
            await share2.DeleteAsync(true);

            //create 2 share snapshots
            FileShare shareSnapshot1 = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName1, new FileShareData(), expand: "snapshots")).Value;
            FileShare shareSnapshot2 = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName1, new FileShareData(), expand: "snapshots")).Value;

            //get single share snapshot
            FileShare shareSnapshot = await _fileShareCollection.GetAsync(fileShareName1, "stats", shareSnapshot1.Data.SnapshotTime.Value.UtcDateTime.ToString("o"));

            Assert.AreEqual(shareSnapshot.Data.SnapshotTime, shareSnapshot1.Data.SnapshotTime);

            //list share with snapshot
            List <FileShare> fileShares = await _fileShareCollection.GetAllAsync(expand : "snapshots").ToEnumerableAsync();

            Assert.AreEqual(3, fileShares.Count);

            //delete share snapshot
            await shareSnapshot.DeleteAsync(true);

            // List share with deleted
            fileShares = await _fileShareCollection.GetAllAsync(expand : "deleted").ToEnumerableAsync();

            Assert.AreEqual(2, fileShares.Count);
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            WriteWarning("Will add confirmation of executing the cmdlet and Force parameter in a future release. ");
            WriteWarning("The usage of Tags parameter in this cmdlet will be modified in a future release. This will impact creating, updating and appending tags for Azure resources. For more details about the change, please visit https://github.com/Azure/azure-powershell/issues/726#issuecomment-213545494");

            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters();

            if (this.SkuName != null)
            {
                updateParameters.Sku = new Sku(ParseSkuName(this.SkuName));
            }

            if (this.Tag != null)
            {
                Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);
                updateParameters.Tags = tagDictionary ?? new Dictionary <string, string>();
            }

            if (this.CustomDomainName != null)
            {
                updateParameters.CustomDomain = new CustomDomain()
                {
                    Name         = CustomDomainName,
                    UseSubDomain = UseSubDomain
                };
            }
            else if (UseSubDomain != null)
            {
                throw new System.ArgumentException(string.Format("UseSubDomain must be set together with CustomDomainName."));
            }

            if (this.EnableEncryptionService != null || this.DisableEncryptionService != null)
            {
                updateParameters.Encryption = ParseEncryption(EnableEncryptionService, DisableEncryptionService);
            }

            if (this.AccessTier != null)
            {
                updateParameters.AccessTier = ParseAccessTier(AccessTier);
            }

            var updatedAccountResponse = this.StorageClient.StorageAccounts.Update(
                this.ResourceGroupName,
                this.Name,
                updateParameters);

            var storageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);

            WriteStorageAccount(storageAccount);
        }
Exemplo n.º 15
0
        public void SetStorageAccountProcess()
        {
            var upstorageinput = new StorageAccountUpdateParameters
            {
                GeoReplicationEnabled = GeoReplicationEnabled,
                Description           = this.Description,
                Label = this.Label
            };

            ExecuteClientActionNewSM(
                upstorageinput,
                CommandRuntime.ToString(),
                () => this.StorageClient.StorageAccounts.Update(this.StorageAccountName, upstorageinput));
        }
        public void SetStorageAccountProcess()
        {
            var upstorageinput = new StorageAccountUpdateParameters
            {
                GeoReplicationEnabled = GeoReplicationEnabled,
                Description = this.Description,
                Label = this.Label
            };

            ExecuteClientActionNewSM(
                upstorageinput,
                CommandRuntime.ToString(),
                () => this.StorageClient.StorageAccounts.Update(this.StorageAccountName, upstorageinput));
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters();

            if (this.SkuName != null)
            {
                updateParameters.Sku = new Sku(ParseSkuName(this.SkuName));
            }

            if (this.Tags != null)
            {
                Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(Tags, validate: true);
                updateParameters.Tags = tagDictionary ?? new Dictionary <string, string>();
            }

            if (this.CustomDomainName != null)
            {
                updateParameters.CustomDomain = new CustomDomain()
                {
                    Name         = CustomDomainName,
                    UseSubDomain = UseSubDomain
                };
            }
            else if (UseSubDomain != null)
            {
                throw new System.ArgumentException(string.Format("UseSubDomain must be set together with CustomDomainName."));
            }

            if (this.EnableEncryptionService != null || this.DisableEncryptionService != null)
            {
                updateParameters.Encryption = ParseEncryption(EnableEncryptionService, DisableEncryptionService);
            }

            if (this.AccessTier != null)
            {
                updateParameters.AccessTier = ParseAccessTier(AccessTier);
            }

            var updatedAccountResponse = this.StorageClient.StorageAccounts.Update(
                this.ResourceGroupName,
                this.Name,
                updateParameters);

            var storageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);

            WriteStorageAccount(storageAccount);
        }
        public async Task BlobContainersVLW()
        {
            //update storage account to v2
            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters()
            {
                Kind = Kind.StorageV2
            };

            _storageAccount = await _storageAccount.UpdateAsync(updateParameters);

            _blobService = await _blobService.GetAsync();

            //enable blob versioning
            BlobServiceData properties = _blobService.Data;

            properties.IsVersioningEnabled = true;
            _blobService = (await _blobService.CreateOrUpdateAsync(properties)).Value;
            Assert.IsTrue(properties.IsVersioningEnabled);

            //create container with VLW
            string            containerName1 = Recording.GenerateAssetName("testblob1");
            BlobContainerData parameters1    = new BlobContainerData()
            {
                ImmutableStorageWithVersioning = new ImmutableStorageWithVersioning()
                {
                    Enabled = true
                }
            };
            BlobContainer container1 = (await _blobContainerCollection.CreateOrUpdateAsync(containerName1, parameters1)).Value;

            Assert.IsTrue(container1.Data.ImmutableStorageWithVersioning.Enabled);
            Assert.IsNull(container1.Data.ImmutableStorageWithVersioning.MigrationState);

            //update container to enabled  Immutability Policy
            string            containerName2 = Recording.GenerateAssetName("testblob2");
            BlobContainerData parameters2    = new BlobContainerData();
            BlobContainer     container2     = (await _blobContainerCollection.CreateOrUpdateAsync(containerName2, parameters2)).Value;
            await container2.GetImmutabilityPolicy().CreateOrUpdateAsync(parameters: new ImmutabilityPolicyData()
            {
                ImmutabilityPeriodSinceCreationInDays = 1
            });

            await container2.ObjectLevelWormAsync();

            container2 = await container2.GetAsync();

            Assert.IsTrue(container2.Data.ImmutableStorageWithVersioning.Enabled);
            Assert.AreEqual("Completed", container2.Data.ImmutableStorageWithVersioning.MigrationState);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Updates the storage account
        /// </summary>
        /// <param name="resourceGroupName">Resource Group Name</param>
        /// <param name="aacountName">Account Name</param>
        public void UpdateStorageAccountSku(string resourceGroupName, string aacountName, SkuName skuName)
        {
            Console.WriteLine("Updating storage account...");

            // Update storage account sku

            var parameters = new StorageAccountUpdateParameters
            {
                Sku = new Sku(skuName)
            };

            var storageAccount = _storageMgmtClient.StorageAccounts.Update(resourceGroupName, aacountName, parameters);

            Console.WriteLine("Sku on storage account updated to " + storageAccount.Sku.Name);
        }
        public async Task PITR()
        {
            //update storage account to v2
            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters()
            {
                Kind = Kind.StorageV2
            };

            _storageAccount = await _storageAccount.UpdateAsync(updateParameters);

            _blobService = await _blobService.GetAsync();

            BlobServiceData properties = _blobService.Data;

            properties.DeleteRetentionPolicy         = new DeleteRetentionPolicy();
            properties.DeleteRetentionPolicy.Enabled = true;
            properties.DeleteRetentionPolicy.Days    = 30;
            properties.ChangeFeed          = new ChangeFeed();
            properties.ChangeFeed.Enabled  = true;
            properties.IsVersioningEnabled = true;
            properties.RestorePolicy       = new RestorePolicyProperties(true)
            {
                Days = 5
            };

            _blobService = (await _blobService.CreateOrUpdateAsync(properties)).Value;

            if (Mode != RecordedTestMode.Playback)
            {
                await Task.Delay(10000);
            }

            //create restore ranges
            List <Models.BlobRestoreRange> ranges = new List <Models.BlobRestoreRange>();

            ranges.Add(new Models.BlobRestoreRange("", "container1/blob1"));
            ranges.Add(new Models.BlobRestoreRange("container1/blob2", "container2/blob3"));
            ranges.Add(new Models.BlobRestoreRange("container3/blob3", ""));

            //start restore
            Models.BlobRestoreParameters             parameters       = new Models.BlobRestoreParameters(Recording.Now.AddSeconds(-1).ToUniversalTime(), ranges);
            StorageAccountRestoreBlobRangesOperation restoreOperation = _storageAccount.RestoreBlobRanges(parameters);

            //wait for restore completion
            Models.BlobRestoreStatus restoreStatus = await restoreOperation.WaitForCompletionAsync();

            Assert.IsTrue(restoreStatus.Status == BlobRestoreProgressStatus.Complete || restoreStatus.Status == BlobRestoreProgressStatus.InProgress);
        }
Exemplo n.º 21
0
        public async Task <List <FirewallRule> > SetFirewallRules(string resourceGroupName, string resourceName, List <FirewallRule> rules, CancellationToken cancellationToken = default)
        {
            var account = await GetResourceAsync(resourceGroupName, resourceName, cancellationToken : cancellationToken);

            var ruleSet = GetNetworkRuleSetForUpdate(account, false);

            ruleSet.IpRules = rules?.Select(alw => new IPRule(alw.Address, (Action)alw.Action)).ToList();
            var updateParameters = new StorageAccountUpdateParameters()
            {
                NetworkRuleSet = ruleSet
            };

            var updateResult = await _azure.StorageAccounts.Inner.UpdateAsync(resourceGroupName, resourceName, updateParameters, cancellationToken);

            return(rules);
        }
        public async Task UpdateFirewall(CancellationToken cancellationToken)
        {
            var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(_securityConfig.TenantId, _securityConfig.ClientId, _securityConfig.ClientSecret);

            var currentIp = await _ipAddressLookup.GetCurrentIdAsync(cancellationToken);

            var storClient = new StorageManagementClient(serviceCreds)
            {
                SubscriptionId = _securityConfig.SubscriptionId
            };

            var sProp = storClient.StorageAccounts.GetProperties(_firewallConfig.ResourceGroupName, _firewallConfig.AccountName);
            var rules = sProp.NetworkRuleSet;
            var currentIpAddresses = string.Join(',', rules.IpRules.Select(r => r.IPAddressOrRange));

            _logger.LogInformation("Current allowed IP addresses: {currentIpAddesses}", currentIpAddresses);

            if (!rules.IpRules.Any(r => r.IPAddressOrRange.Equals(currentIp)))
            {
                _logger.LogInformation("Updating with current IP address: {currentIp}", currentIp);

                var updateParam = new StorageAccountUpdateParameters
                {
                    NetworkRuleSet = new NetworkRuleSet
                    {
                        DefaultAction       = DefaultAction.Deny,
                        ResourceAccessRules = new List <ResourceAccessRule>(),
                        VirtualNetworkRules = new List <VirtualNetworkRule>(),
                        IpRules             = new List <IPRule> {
                            new IPRule(currentIp, Action.Allow)
                        },
                        Bypass = "******"
                    }
                };

                var rulesResponse = await storClient.StorageAccounts.UpdateAsync(
                    _firewallConfig.ResourceGroupName,
                    _firewallConfig.AccountName,
                    updateParam,
                    cancellationToken);
            }
            else
            {
                _logger.LogInformation("No need to update firewall rules, current IP address already present.");
            }
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            Dictionary <string, string>    tagDictionary    = null;
            StorageAccountUpdateParameters updateParameters = null;

            if (ParameterSetName == UpdateAccountTypeParamSet)
            {
                updateParameters = new StorageAccountUpdateParameters
                {
                    AccountType = ParseAccountType(this.Type)
                };
            }
            else if (ParameterSetName == UpdateCustomDomainParamSet)
            {
                updateParameters = new StorageAccountUpdateParameters
                {
                    CustomDomain = new CustomDomain
                    {
                        Name         = CustomDomainName,
                        UseSubDomain = UseSubDomain
                    }
                };
            }
            else
            {
                tagDictionary = TagsConversionHelper.CreateTagDictionary(Tags, validate: true);

                updateParameters = new StorageAccountUpdateParameters
                {
                    Tags = tagDictionary
                };
            }

            var updatedAccountResponse = this.StorageClient.StorageAccounts.Update(
                this.ResourceGroupName,
                this.Name,
                updateParameters);

            var accountProperties = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);

            WriteStorageAccount(accountProperties.StorageAccount);
        }
        public void SetStorageAccountProcess()
        {
            if (string.Equals(this.ParameterSetName, GeoReplicationEnabledParamSet))
            {
                WriteWarning(Resources.DeprecationOfTheGeoReplicationEnabledParamInTheSetCmdlet);
            }

            var upstorageinput = new StorageAccountUpdateParameters
            {
                AccountType = GeoReplicationEnabled.HasValue && GeoReplicationEnabled.Value ? StorageAccountTypes.StandardGRS : this.Type,
                Description = this.Description,
                Label       = this.Label
            };

            ExecuteClientActionNewSM(
                upstorageinput,
                CommandRuntime.ToString(),
                () => this.StorageClient.StorageAccounts.Update(this.StorageAccountName, upstorageinput));
        }
Exemplo n.º 25
0
        public virtual Response <StorageAccount> Update(StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("StorageAccount.Update");
            scope.Start();
            try
            {
                var response = _restClient.Update(Id.ResourceGroupName, Id.Name, parameters, cancellationToken);
                return(Response.FromValue(new StorageAccount(this, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 26
0
        public async virtual Task <Response <StorageAccount> > UpdateAsync(StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _storageAccountClientDiagnostics.CreateScope("StorageAccount.Update");
            scope.Start();
            try
            {
                var response = await _storageAccountRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken).ConfigureAwait(false);

                return(Response.FromValue(new StorageAccount(ArmClient, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 27
0
        public void StorageAccountUpdateMultipleTest()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                var resourcesClient   = StorageManagementTestUtilities.GetResourceManagementClient(context, handler);
                var storageMgmtClient = StorageManagementTestUtilities.GetStorageManagementClient(context, handler);

                // Create resource group
                var rgname = StorageManagementTestUtilities.CreateResourceGroup(resourcesClient);

                // Create storage account
                string accountName = StorageManagementTestUtilities.CreateStorageAccount(storageMgmtClient, rgname);

                // Update storage account type
                var parameters = new StorageAccountUpdateParameters
                {
                    Sku = new Sku {
                        Name = SkuName.StandardLRS
                    },
                    Tags = new Dictionary <string, string>
                    {
                        { "key3", "value3" },
                        { "key4", "value4" },
                        { "key5", "value6" }
                    }
                };
                var account = storageMgmtClient.StorageAccounts.Update(rgname, accountName, parameters);
                Assert.Equal(account.Sku.Name, SkuName.StandardLRS);
                Assert.Equal(account.Tags.Count, parameters.Tags.Count);

                // Validate
                account = storageMgmtClient.StorageAccounts.GetProperties(rgname, accountName);
                Assert.Equal(account.Sku.Name, SkuName.StandardLRS);
                Assert.Equal(account.Tags.Count, parameters.Tags.Count);
            }
        }
        public async Task FileShareAccessPolicy()
        {
            //update storage account to v2
            StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters()
            {
                Kind = Kind.StorageV2
            };
            await _storageAccount.UpdateAsync(updateParameters);

            //create share
            string    fileShareName = Recording.GenerateAssetName("testfileshare");
            FileShare share         = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName, new FileShareData())).Value;

            // Prepare signedIdentifiers to set
            List <SignedIdentifier> sigs    = new List <SignedIdentifier>();
            DateTimeOffset          datenow = Recording.Now;
            DateTimeOffset          start1  = datenow.ToUniversalTime();
            DateTimeOffset          end1    = datenow.AddHours(2).ToUniversalTime();
            DateTimeOffset          start2  = datenow.AddMinutes(1).ToUniversalTime();
            DateTimeOffset          end2    = datenow.AddMinutes(40).ToUniversalTime();
            var updateParameters2           = new FileShareData();
            SignedIdentifier sig1           = new SignedIdentifier("testSig1",
                                                                   new AccessPolicy(startTime: start1,
                                                                                    expiryTime: end1,
                                                                                    permission: "rw"));
            SignedIdentifier sig2 = new SignedIdentifier("testSig2",
                                                         new AccessPolicy(startTime: start2,
                                                                          expiryTime: end2,
                                                                          permission: "rwdl"));

            updateParameters2.SignedIdentifiers.Add(sig1);
            updateParameters2.SignedIdentifiers.Add(sig2);

            // Update share
            share = await share.UpdateAsync(updateParameters2);

            Assert.AreEqual(2, share.Data.SignedIdentifiers.Count);
            Assert.AreEqual("testSig1", share.Data.SignedIdentifiers[0].Id);
            Assert.AreEqual("rw", share.Data.SignedIdentifiers[0].AccessPolicy.Permission);
        }
 public virtual Response <StorageAccount> Update(string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("StorageAccountsClient.Update");
     scope.Start();
     try
     {
         return(RestClient.Update(resourceGroupName, accountName, parameters, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            if (ShouldProcess(this.Name, "Set Storage Account"))
            {
                if (this.force || this.AccessTier == null || ShouldContinue("Changing the access tier may result in additional charges. See (http://go.microsoft.com/fwlink/?LinkId=786482) to learn more.", ""))
                {
                    StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters();
                    if (this.SkuName != null)
                    {
                        updateParameters.Sku = new Sku(this.SkuName);
                    }

                    if (this.Tag != null)
                    {
                        Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);
                        updateParameters.Tags = tagDictionary ?? new Dictionary <string, string>();
                    }

                    if (this.CustomDomainName != null)
                    {
                        updateParameters.CustomDomain = new CustomDomain()
                        {
                            Name             = CustomDomainName,
                            UseSubDomainName = UseSubDomain
                        };
                    }
                    else if (UseSubDomain != null)
                    {
                        throw new System.ArgumentException(string.Format("UseSubDomain must be set together with CustomDomainName."));
                    }

                    if (this.AccessTier != null)
                    {
                        updateParameters.AccessTier = ParseAccessTier(AccessTier);
                    }
                    if (enableHttpsTrafficOnly != null)
                    {
                        updateParameters.EnableHttpsTrafficOnly = enableHttpsTrafficOnly;
                    }

                    if (AssignIdentity.IsPresent || this.UserAssignedIdentityId != null || this.IdentityType != null)
                    {
                        updateParameters.Identity = new Identity()
                        {
                            Type = StorageModels.IdentityType.SystemAssigned
                        };
                        if (this.IdentityType != null)
                        {
                            updateParameters.Identity.Type = GetIdentityTypeString(this.IdentityType);
                        }
                        if (this.UserAssignedIdentityId != null)
                        {
                            if (updateParameters.Identity.Type != StorageModels.IdentityType.UserAssigned && updateParameters.Identity.Type != StorageModels.IdentityType.SystemAssignedUserAssigned)
                            {
                                throw new ArgumentException("UserAssignIdentityId should only be specified when AssignIdentityType is UserAssigned or SystemAssignedUserAssigned.", "UserAssignIdentityId");
                            }
                            updateParameters.Identity.UserAssignedIdentities = new Dictionary <string, UserAssignedIdentity>();
                            updateParameters.Identity.UserAssignedIdentities.Add(this.UserAssignedIdentityId, new UserAssignedIdentity());

                            var accountProperties = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
                            if (accountProperties.Identity != null && accountProperties.Identity.UserAssignedIdentities != null && accountProperties.Identity.UserAssignedIdentities.Count > 0)
                            {
                                foreach (var uid in accountProperties.Identity.UserAssignedIdentities)
                                {
                                    if (!uid.Key.Equals(this.UserAssignedIdentityId, StringComparison.OrdinalIgnoreCase))
                                    {
                                        updateParameters.Identity.UserAssignedIdentities.Add(uid.Key, null);
                                    }
                                }
                            }
                        }
                    }

                    if (StorageEncryption || ParameterSetName == KeyvaultEncryptionParameterSet || this.KeyVaultUserAssignedIdentityId != null)
                    {
                        if (ParameterSetName == KeyvaultEncryptionParameterSet)
                        {
                            keyvaultEncryption = true;
                        }
                        updateParameters.Encryption = ParseEncryption(StorageEncryption, keyvaultEncryption, KeyName, KeyVersion, KeyVaultUri);
                        if (this.KeyVaultUserAssignedIdentityId != null)
                        {
                            updateParameters.Encryption.EncryptionIdentity = new EncryptionIdentity();
                            updateParameters.Encryption.EncryptionIdentity.EncryptionUserAssignedIdentity = this.KeyVaultUserAssignedIdentityId;
                        }
                    }

                    if (NetworkRuleSet != null)
                    {
                        updateParameters.NetworkRuleSet = PSNetworkRuleSet.ParseStorageNetworkRule(NetworkRuleSet);
                    }

                    if (UpgradeToStorageV2.IsPresent)
                    {
                        updateParameters.Kind = Kind.StorageV2;
                    }
                    if (enableAzureActiveDirectoryDomainServicesForFile != null)
                    {
                        if (enableAzureActiveDirectoryDomainServicesForFile.Value) // enable AADDS
                        {
                            //if user want to enable AADDS, must first disable AD
                            var originStorageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
                            if (originStorageAccount.AzureFilesIdentityBasedAuthentication != null &&
                                originStorageAccount.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions == DirectoryServiceOptions.AD)
                            {
                                throw new System.ArgumentException("The Storage account already enabled ActiveDirectoryDomainServicesForFile, please disable it by run this cmdlets with \"-EnableActiveDirectoryDomainServicesForFile $false\" before enable AzureActiveDirectoryDomainServicesForFile.");
                            }
                            updateParameters.AzureFilesIdentityBasedAuthentication = new AzureFilesIdentityBasedAuthentication();
                            updateParameters.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions = DirectoryServiceOptions.AADDS;
                        }
                        else //Disable AADDS
                        {
                            // Only disable AADDS; else keep unchanged
                            var originStorageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
                            if (originStorageAccount.AzureFilesIdentityBasedAuthentication == null ||
                                originStorageAccount.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions == DirectoryServiceOptions.AADDS)
                            {
                                updateParameters.AzureFilesIdentityBasedAuthentication = new AzureFilesIdentityBasedAuthentication();
                                updateParameters.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions = DirectoryServiceOptions.None;
                            }
                            else
                            {
                                updateParameters.AzureFilesIdentityBasedAuthentication = originStorageAccount.AzureFilesIdentityBasedAuthentication;
                            }
                        }
                    }
                    if (enableActiveDirectoryDomainServicesForFile != null)
                    {
                        if (enableActiveDirectoryDomainServicesForFile.Value) // Enable AD
                        {
                            if (string.IsNullOrEmpty(this.ActiveDirectoryDomainName) ||
                                string.IsNullOrEmpty(this.ActiveDirectoryNetBiosDomainName) ||
                                string.IsNullOrEmpty(this.ActiveDirectoryForestName) ||
                                string.IsNullOrEmpty(this.ActiveDirectoryDomainGuid) ||
                                string.IsNullOrEmpty(this.ActiveDirectoryDomainSid) ||
                                string.IsNullOrEmpty(this.ActiveDirectoryAzureStorageSid)
                                )
                            {
                                throw new System.ArgumentNullException("ActiveDirectoryDomainName, ActiveDirectoryNetBiosDomainName, ActiveDirectoryForestName, ActiveDirectoryDomainGuid, ActiveDirectoryDomainSid, ActiveDirectoryAzureStorageSid",
                                                                       "To enable ActiveDirectoryDomainServicesForFile, user must specify all of: ActiveDirectoryDomainName, ActiveDirectoryNetBiosDomainName, ActiveDirectoryForestName, ActiveDirectoryDomainGuid, ActiveDirectoryDomainSid, ActiveDirectoryAzureStorageSid.");
                            }

                            //if user want to enable AD, must first disable AADDS
                            var originStorageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
                            if (originStorageAccount.AzureFilesIdentityBasedAuthentication != null &&
                                originStorageAccount.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions == DirectoryServiceOptions.AADDS)
                            {
                                throw new System.ArgumentException("The Storage account already enabled AzureActiveDirectoryDomainServicesForFile, please disable it by run this cmdlets with \"-EnableAzureActiveDirectoryDomainServicesForFile $false\" before enable ActiveDirectoryDomainServicesForFile.");
                            }

                            updateParameters.AzureFilesIdentityBasedAuthentication = new AzureFilesIdentityBasedAuthentication();
                            updateParameters.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions   = DirectoryServiceOptions.AD;
                            updateParameters.AzureFilesIdentityBasedAuthentication.ActiveDirectoryProperties = new ActiveDirectoryProperties()
                            {
                                DomainName        = this.ActiveDirectoryDomainName,
                                NetBiosDomainName = this.ActiveDirectoryNetBiosDomainName,
                                ForestName        = this.ActiveDirectoryForestName,
                                DomainGuid        = this.ActiveDirectoryDomainGuid,
                                DomainSid         = this.ActiveDirectoryDomainSid,
                                AzureStorageSid   = this.ActiveDirectoryAzureStorageSid
                            };
                        }
                        else // Disable AD
                        {
                            if (!string.IsNullOrEmpty(this.ActiveDirectoryDomainName) ||
                                !string.IsNullOrEmpty(this.ActiveDirectoryNetBiosDomainName) ||
                                !string.IsNullOrEmpty(this.ActiveDirectoryForestName) ||
                                !string.IsNullOrEmpty(this.ActiveDirectoryDomainGuid) ||
                                !string.IsNullOrEmpty(this.ActiveDirectoryDomainSid) ||
                                !string.IsNullOrEmpty(this.ActiveDirectoryAzureStorageSid)
                                )
                            {
                                throw new System.ArgumentException("To Disable ActiveDirectoryDomainServicesForFile, user can't specify any of: ActiveDirectoryDomainName, ActiveDirectoryNetBiosDomainName, ActiveDirectoryForestName, ActiveDirectoryDomainGuid, ActiveDirectoryDomainSid, ActiveDirectoryAzureStorageSid.");
                            }

                            // Only disable AD; else keep unchanged
                            var originStorageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);
                            if (originStorageAccount.AzureFilesIdentityBasedAuthentication == null ||
                                originStorageAccount.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions == DirectoryServiceOptions.AD)
                            {
                                updateParameters.AzureFilesIdentityBasedAuthentication = new AzureFilesIdentityBasedAuthentication();
                                updateParameters.AzureFilesIdentityBasedAuthentication.DirectoryServiceOptions = DirectoryServiceOptions.None;
                            }
                            else
                            {
                                updateParameters.AzureFilesIdentityBasedAuthentication = originStorageAccount.AzureFilesIdentityBasedAuthentication;
                            }
                        }
                    }
                    if (this.DefaultSharePermission != null)
                    {
                        if (updateParameters.AzureFilesIdentityBasedAuthentication == null)
                        {
                            updateParameters.AzureFilesIdentityBasedAuthentication = new AzureFilesIdentityBasedAuthentication();
                        }
                        updateParameters.AzureFilesIdentityBasedAuthentication.DefaultSharePermission = this.DefaultSharePermission;
                    }
                    if (this.EnableLargeFileShare.IsPresent)
                    {
                        updateParameters.LargeFileSharesState = LargeFileSharesState.Enabled;
                    }
                    if (this.minimumTlsVersion != null)
                    {
                        updateParameters.MinimumTlsVersion = this.minimumTlsVersion;
                    }
                    if (this.allowBlobPublicAccess != null)
                    {
                        updateParameters.AllowBlobPublicAccess = this.allowBlobPublicAccess;
                    }
                    if (this.RoutingChoice != null || this.publishMicrosoftEndpoint != null || this.publishInternetEndpoint != null)
                    {
                        updateParameters.RoutingPreference = new RoutingPreference(this.RoutingChoice, this.publishMicrosoftEndpoint, this.publishInternetEndpoint);
                    }
                    if (allowSharedKeyAccess != null)
                    {
                        updateParameters.AllowSharedKeyAccess = allowSharedKeyAccess;
                    }
                    if (SasExpirationPeriod != null && SasExpirationPeriod != TimeSpan.Zero)
                    {
                        updateParameters.SasPolicy = new SasPolicy(SasExpirationPeriod.ToString(@"d\.hh\:mm\:ss"));
                    }
                    if (keyExpirationPeriodInDay != null)
                    {
                        updateParameters.KeyPolicy = new KeyPolicy(keyExpirationPeriodInDay.Value);
                    }
                    if (allowCrossTenantReplication != null)
                    {
                        updateParameters.AllowCrossTenantReplication = allowCrossTenantReplication;
                    }

                    var updatedAccountResponse = this.StorageClient.StorageAccounts.Update(
                        this.ResourceGroupName,
                        this.Name,
                        updateParameters);

                    var storageAccount = this.StorageClient.StorageAccounts.GetProperties(this.ResourceGroupName, this.Name);

                    WriteStorageAccount(storageAccount);
                }
            }
        }
 /// <summary>
 /// The update operation can be used to update the SKU, encryption, access
 /// tier, or tags for a storage account. It can also be used to map the account
 /// to a custom domain. Only one custom domain is supported per storage
 /// account; the replacement/change of custom domain is not supported. In order
 /// to replace an old custom domain, the old value must be cleared/unregistered
 /// before a new value can be set. The update of multiple properties is
 /// supported. This call does not change the storage keys for the account. If
 /// you want to change the storage account keys, use the regenerate keys
 /// operation. The location and name of the storage account cannot be changed
 /// after creation.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group within the user's subscription. The name is
 /// case insensitive.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and use
 /// numbers and lower-case letters only.
 /// </param>
 /// <param name='parameters'>
 /// The parameters to provide for the updated account.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <StorageAccountInner> UpdateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Updates the account type or tags for a storage account. It can also be
 /// used to add a custom domain (note that custom domains cannot be added via
 /// the Create operation). Only one custom domain is supported per storage
 /// account. In order to replace a custom domain, the old value must be
 /// cleared before a new value may be set. To clear a custom domain, simply
 /// update the custom domain with empty string. Then call update again with
 /// the new cutsom domain name. The update API can only be used to update one
 /// of tags, accountType, or customDomain per call. To update multiple of
 /// these properties, call the API multiple times with one change per call.
 /// This call does not change the storage keys for the account. If you want
 /// to change storage account keys, use the RegenerateKey operation. The
 /// location and name of the storage account cannot be changed after creation.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group within the user's subscription.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and
 /// use numbers and lower-case letters only.
 /// </param>
 /// <param name='parameters'>
 /// The parameters to update on the account. Note that only one property can
 /// be changed at a time using this API.
 /// </param>
 public static StorageAccount Update(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters)
 {
     return Task.Factory.StartNew(s => ((IStorageAccountsOperations)s).UpdateAsync(resourceGroupName, accountName, parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Updates the account type or tags for a storage account. It can also be
 /// used to add a custom domain (note that custom domains cannot be added via
 /// the Create operation). Only one custom domain is supported per storage
 /// account. In order to replace a custom domain, the old value must be
 /// cleared before a new value may be set. To clear a custom domain, simply
 /// update the custom domain with empty string. Then call update again with
 /// the new cutsom domain name. The update API can only be used to update one
 /// of tags, accountType, or customDomain per call. To update multiple of
 /// these properties, call the API multiple times with one change per call.
 /// This call does not change the storage keys for the account. If you want
 /// to change storage account keys, use the RegenerateKey operation. The
 /// location and name of the storage account cannot be changed after creation.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group within the user's subscription.
 /// </param>
 /// <param name='accountName'>
 /// The name of the storage account within the specified resource group.
 /// Storage account names must be between 3 and 24 characters in length and
 /// use numbers and lower-case letters only.
 /// </param>
 /// <param name='parameters'>
 /// The parameters to update on the account. Note that only one property can
 /// be changed at a time using this API.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<StorageAccount> UpdateAsync(this IStorageAccountsOperations operations, string resourceGroupName, string accountName, StorageAccountUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, accountName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return _result.Body;
     }
 }