Exemplo n.º 1
0
        public async Task UpdateAvailabilitySet()
        {
            #region Snippet:Managing_Availability_Set_UpdateAnAvailabilitySet
            // First, initialize the ArmClient and get the default subscription
            ArmClient armClient = new ArmClient(new DefaultAzureCredential());
            // Now we get a ResourceGroup collection for that subscription
            Subscription subscription = await armClient.GetDefaultSubscriptionAsync();

            ResourceGroupCollection rgCollection = subscription.GetResourceGroups();

            // With the collection, we can create a new resource group with an specific name
            string        rgName        = "myRgName";
            ResourceGroup resourceGroup = await rgCollection.GetAsync(rgName);

            AvailabilitySetCollection availabilitySetCollection = resourceGroup.GetAvailabilitySets();
            string          availabilitySetName = "myAvailabilitySet";
            AvailabilitySet availabilitySet     = await availabilitySetCollection.GetAsync(availabilitySetName);

            // availabilitySet is an AvailabilitySet instance created above
            AvailabilitySetUpdate update = new AvailabilitySetUpdate()
            {
                PlatformFaultDomainCount = 3
            };
            AvailabilitySet updatedAvailabilitySet = await availabilitySet.UpdateAsync(update);

            #endregion Snippet:Managing_Availability_Set_UpdateAnAvailabilitySet
        }
        /// <summary>
        /// Adds a tag to an availability set.
        /// If the tag already exists it will be modified.
        /// </summary>
        /// <param name="key"> The key for the tag. </param>
        /// <param name="value"> The value for the tag. </param>
        /// <remarks>
        /// <see href="https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-longrunning"> Details on long running operation object. </see>
        /// </remarks>
        /// <returns> An <see cref="ArmOperation{AvailabilitySet}"/> that allows polling for completion of the operation. </returns>
        public ArmOperation <AvailabilitySet> StartAddTag(string key, string value)
        {
            var patchable = new AvailabilitySetUpdate();

            patchable.Tags[key] = value;
            return(Update(patchable));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Adds a tag to an availability set.
 /// If the tag already exists it will be modified.
 /// </summary>
 /// <param name="key"> The key for the tag. </param>
 /// <param name="value"> The value for the tag. </param>
 /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param>
 /// <remarks>
 /// <see href="https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-longrunning"> Details on long running operation object. </see>
 /// </remarks>
 /// <returns> A <see cref="Task"/> that on completion returns an <see cref="ArmOperation{AvailabilitySet}"/> that allows polling for completion of the operation. </returns>
 public Task<ArmOperation<AvailabilitySet>> StartAddTagAsync(string key, string value, CancellationToken cancellationToken = default)
 {
     var resource = GetResource();
     var patchable = new AvailabilitySetUpdate() { Tags = resource.Data.Tags };
     patchable.Tags[key] = value;
     return StartUpdateAsync(patchable);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a tag to an availability set.
 /// If the tag already exists it will be modified.
 /// </summary>
 /// <param name="key"> The key for the tag. </param>
 /// <param name="value"> The value for the tag. </param>
 /// <remarks>
 /// <see href="https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-longrunning"> Details on long running operation object. </see>
 /// </remarks>
 /// <returns> An <see cref="ArmOperation{AvailabilitySet}"/> that allows polling for completion of the operation. </returns>
 public ArmOperation<AvailabilitySet> StartAddTag(string key, string value)
 {
     var resource = GetResource();
     var patchable = new AvailabilitySetUpdate() { Tags = resource.Data.Tags };
     patchable.Tags[key] = value;
     return StartUpdate(patchable);
 }
Exemplo n.º 5
0
 /// <inheritdoc/>
 public async Task<ArmOperation<AvailabilitySet>> StartSetTagsAsync(IDictionary<string, string> tags, CancellationToken cancellationToken = default)
 {
     var resource = GetResource();
     var patchable = new AvailabilitySetUpdate() { Tags = resource.Data.Tags };
     ReplaceTags(tags, patchable.Tags);
     return await StartUpdateAsync(patchable);
 }
Exemplo n.º 6
0
 /// <inheritdoc/>
 public ArmOperation<AvailabilitySet> StartSetTags(IDictionary<string, string> tags)
 {
     var resource = GetResource();
     var patchable = new AvailabilitySetUpdate() { Tags = resource.Data.Tags };
     ReplaceTags(tags, patchable.Tags);
     return StartUpdate(patchable);
 }
Exemplo n.º 7
0
 /// <inheritdoc/>
 public ArmResponse<AvailabilitySet> RemoveTag(string key)
 {
     var resource = GetResource();
     var patchable = new AvailabilitySetUpdate() { Tags = resource.Data.Tags };
     DeleteTag(key, patchable.Tags);
     return Update(patchable);
 }
Exemplo n.º 8
0
 /// <inheritdoc/>
 public ArmOperation<AvailabilitySet> StartRemoveTag(string key)
 {
     var resource = GetResource();
     var patchable = new AvailabilitySetUpdate() { Tags = resource.Data.Tags };
     DeleteTag(key, patchable.Tags);
     return StartUpdate(patchable);
 }
Exemplo n.º 9
0
 /// <inheritdoc/>
 public async Task<ArmOperation<AvailabilitySet>> StartRemoveTagAsync(string key, CancellationToken cancellationToken = default)
 {
     var resource = GetResource();
     var patchable = new AvailabilitySetUpdate() { Tags = resource.Data.Tags };
     DeleteTag(key, patchable.Tags);
     return await StartUpdateAsync(patchable);
 }
        /// <summary>
        /// Adds a tag to an availability set.
        /// If the tag already exists it will be modified.
        /// </summary>
        /// <param name="key"> The key for the tag. </param>
        /// <param name="value"> The value for the tag. </param>
        /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param>
        /// <remarks>
        /// <see href="https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-longrunning"> Details on long running operation object. </see>
        /// </remarks>
        /// <returns> A <see cref="Task"/> that on completion returns an <see cref="ArmOperation{AvailabilitySet}"/> that allows polling for completion of the operation. </returns>
        public Task <ArmOperation <AvailabilitySet> > StartAddTagAsync(string key, string value, CancellationToken cancellationToken = default)
        {
            var patchable = new AvailabilitySetUpdate();

            patchable.Tags[key] = value;
            return(UpdateAsync(patchable));
        }
        protected void ExecuteAvailabilitySetUpdateMethod(object[] invokeMethodInputParameters)
        {
            string resourceGroupName         = (string)ParseParameter(invokeMethodInputParameters[0]);
            string availabilitySetName       = (string)ParseParameter(invokeMethodInputParameters[1]);
            AvailabilitySetUpdate parameters = (AvailabilitySetUpdate)ParseParameter(invokeMethodInputParameters[2]);

            var result = AvailabilitySetsClient.Update(resourceGroupName, availabilitySetName, parameters);

            WriteObject(result);
        }
        protected PSArgument[] CreateAvailabilitySetUpdateParameters()
        {
            string resourceGroupName         = string.Empty;
            string availabilitySetName       = string.Empty;
            AvailabilitySetUpdate parameters = new AvailabilitySetUpdate();

            return(ConvertFromObjectsToArguments(
                       new string[] { "ResourceGroupName", "AvailabilitySetName", "Parameters" },
                       new object[] { resourceGroupName, availabilitySetName, parameters }));
        }
Exemplo n.º 13
0
 public async Task <ArmOperation <AvailabilitySet> > UpdateAsync(AvailabilitySetUpdate patchable, CancellationToken cancellationToken = default)
 {
     return(new PhArmOperation <AvailabilitySet, Azure.ResourceManager.Compute.Models.AvailabilitySet>(
                await Operations.UpdateAsync(Id.ResourceGroup, Id.Name, patchable, cancellationToken),
                a =>
     {
         Resource = new AvailabilitySetData(a);
         return new AvailabilitySet(ClientOptions, Resource as AvailabilitySetData);
     }));
 }
Exemplo n.º 14
0
 public ArmOperation <AvailabilitySet> Update(AvailabilitySetUpdate patchable)
 {
     return(new PhArmOperation <AvailabilitySet, Azure.ResourceManager.Compute.Models.AvailabilitySet>(
                Operations.Update(Id.ResourceGroup, Id.Name, patchable),
                a =>
     {
         Resource = new AvailabilitySetData(a);
         return new AvailabilitySet(ClientOptions, Resource as AvailabilitySetData);
     }));
 }
        /// <summary>
        /// Adds a tag to an availability set.
        /// If the tag already exists it will be modified.
        /// </summary>
        /// <param name="key"> The key for the tag. </param>
        /// <param name="value"> The value for the tag. </param>
        /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param>
        /// <returns> A <see cref="Task"/> that on completion returns an <see cref="ArmResponse{AvailabilitySet}"/> that allows polling for completion of the operation. </returns>
        public async Task <ArmResponse <AvailabilitySet> > AddTagAsync(string key, string value, CancellationToken cancellationToken = default)
        {
            var resource  = GetResource();
            var patchable = new AvailabilitySetUpdate()
            {
                Tags = resource.Data.Tags
            };

            patchable.Tags[key] = value;
            return(await UpdateAsync(patchable));
        }
        /// <summary>
        /// Adds a tag to an availability set.
        /// If the tag already exists it will be modified.
        /// </summary>
        /// <param name="key"> The key for the tag. </param>
        /// <param name="value"> The value for the tag. </param>
        /// <returns> An <see cref="ArmResponse{AvailabilitySet}"/> that allows polling for completion of the operation. </returns>
        public ArmResponse <AvailabilitySet> AddTag(string key, string value)
        {
            var resource  = GetResource();
            var patchable = new AvailabilitySetUpdate()
            {
                Tags = resource.Data.Tags
            };

            patchable.Tags[key] = value;
            return(Update(patchable));
        }
        public async Task Update()
        {
            var setName = Recording.GenerateAssetName("testAS-");
            var set     = await CreateAvailabilitySetAsync(setName);

            var updatedPlatformFaultDomainCount = 3;
            var update = new AvailabilitySetUpdate()
            {
                PlatformFaultDomainCount = updatedPlatformFaultDomainCount
            };
            AvailabilitySet updatedSet = await set.UpdateAsync(update);

            Assert.AreEqual(updatedPlatformFaultDomainCount, updatedSet.Data.PlatformFaultDomainCount);
        }
Exemplo n.º 18
0
        public virtual Response <AvailabilitySet> Update(AvailabilitySetUpdate parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

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

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

                return(Response.FromValue(new AvailabilitySet(ArmClient, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        private void VerifyDefaultValuesSucceed()
        {
            var inputAvailabilitySetName = ComputeManagementTestUtilities.GenerateName("asdefaultvalues");
            var inputAvailabilitySet     = new AvailabilitySet
            {
                Location = location,
                Tags     = new Dictionary <string, string>()
                {
                    { "RG", "rg" },
                    { "testTag", "1" },
                },
            };

            var createOrUpdateResponse = computeClient.AvailabilitySets.CreateOrUpdate(
                resourceGroup1Name,
                inputAvailabilitySetName,
                inputAvailabilitySet);

            // List AvailabilitySets
            string expectedAvailabilitySetId = Helpers.GetAvailabilitySetRef(subId, resourceGroup1Name, inputAvailabilitySetName);
            var    listResponse = computeClient.AvailabilitySets.List(resourceGroup1Name);

            ValidateAvailabilitySet(inputAvailabilitySet, listResponse.FirstOrDefault(x => x.Name == inputAvailabilitySetName),
                                    inputAvailabilitySetName, expectedAvailabilitySetId, defaultFD, defaultUD);

            AvailabilitySetUpdate updateParams = new AvailabilitySetUpdate()
            {
                Tags = inputAvailabilitySet.Tags
            };

            string updateKey = "UpdateTag";

            updateParams.Tags.Add(updateKey, "updateValue");
            createOrUpdateResponse = computeClient.AvailabilitySets.Update(resourceGroup1Name, inputAvailabilitySetName, updateParams);

            Assert.True(createOrUpdateResponse.Tags.ContainsKey(updateKey));

            // This call will also delete the Availability Set
            ValidateResults(createOrUpdateResponse, inputAvailabilitySet, resourceGroup1Name, inputAvailabilitySetName, defaultFD, defaultUD);
        }
        private async Task VerifyDefaultValuesSucceed()
        {
            var inputAvailabilitySetName = Recording.GenerateAssetName("asdefaultvalues");
            var inputAvailabilitySet     = new AvailabilitySet(TestEnvironment.Location)
            {
                Tags = new Dictionary <string, string>()
                {
                    { "RG", "rg" },
                    { "testTag", "1" },
                },
            };

            var createOrUpdateResponse = await AvailabilitySetsOperations.CreateOrUpdateAsync(
                resourceGroup1Name,
                inputAvailabilitySetName,
                inputAvailabilitySet);

            // List AvailabilitySets
            string expectedAvailabilitySetId = Helpers.GetAvailabilitySetRef(subId, resourceGroup1Name, inputAvailabilitySetName);
            var    listResponse     = AvailabilitySetsOperations.ListAsync(resourceGroup1Name);
            var    listResponseList = await listResponse.ToEnumerableAsync();

            ValidateAvailabilitySet(inputAvailabilitySet, listResponseList.FirstOrDefault(x => x.Name == inputAvailabilitySetName),
                                    inputAvailabilitySetName, expectedAvailabilitySetId, defaultFD, defaultUD);

            AvailabilitySetUpdate updateParams = new AvailabilitySetUpdate()
            {
                Tags = inputAvailabilitySet.Tags
            };

            string updateKey = "UpdateTag";

            updateParams.Tags.Add(updateKey, "updateValue");
            createOrUpdateResponse = await AvailabilitySetsOperations.UpdateAsync(resourceGroup1Name, inputAvailabilitySetName, updateParams);

            Assert.True(createOrUpdateResponse.Value.Tags.ContainsKey(updateKey));

            // This call will also delete the Availability Set
            await ValidateResults(createOrUpdateResponse, inputAvailabilitySet, resourceGroup1Name, inputAvailabilitySetName, defaultFD, defaultUD);
        }
Exemplo n.º 22
0
 public virtual async Task <Response <AvailabilitySet> > UpdateAsync(string resourceGroupName, string availabilitySetName, AvailabilitySetUpdate parameters, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsOperations.Update");
     scope.Start();
     try
     {
         return(await RestClient.UpdateAsync(resourceGroupName, availabilitySetName, parameters, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
 /// <summary>
 /// Update an availability set.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='availabilitySetName'>
 /// The name of the availability set.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Update Availability Set operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AvailabilitySetInner> UpdateAsync(this IAvailabilitySetsOperations operations, string resourceGroupName, string availabilitySetName, AvailabilitySetUpdate parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, availabilitySetName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Exemplo n.º 24
0
 /// <summary>
 /// Update an availability set.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='availabilitySetName'>
 /// The name of the availability set.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Update Availability Set operation.
 /// </param>
 public static AvailabilitySet Update(this IAvailabilitySetsOperations operations, string resourceGroupName, string availabilitySetName, AvailabilitySetUpdate parameters)
 {
     return(operations.UpdateAsync(resourceGroupName, availabilitySetName, parameters).GetAwaiter().GetResult());
 }
Exemplo n.º 25
0
 public virtual Response <AvailabilitySet> Update(string resourceGroupName, string availabilitySetName, AvailabilitySetUpdate parameters, CancellationToken cancellationToken = default)
 {
     using var scope = _clientDiagnostics.CreateScope("AvailabilitySetsClient.Update");
     scope.Start();
     try
     {
         return(RestClient.Update(resourceGroupName, availabilitySetName, parameters, cancellationToken));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Exemplo n.º 26
0
 /// <summary>
 /// The operation to update an availability set.
 /// </summary>
 /// <param name="patchable">  The parameters to update. </param>
 /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param>
 /// <returns> A <see cref="Task"/> that on completion returns the operation of the updated resource. </returns>
 public async Task<ArmOperation<AvailabilitySet>> StartUpdateAsync(AvailabilitySetUpdate patchable, CancellationToken cancellationToken = default)
 {
     return new PhArmOperation<AvailabilitySet, Azure.ResourceManager.Compute.Models.AvailabilitySet>(
         await Operations.UpdateAsync(Id.ResourceGroup, Id.Name, patchable, cancellationToken),
         a => new AvailabilitySet(this, new AvailabilitySetData(a)));
 }
Exemplo n.º 27
0
 /// <summary>
 /// The operation to update an availability set. 
 /// </summary>
 /// <param name="patchable"> The parameters to update. </param>
 /// <returns> The operation of the updated resource. </returns>
 public ArmOperation<AvailabilitySet> StartUpdate(AvailabilitySetUpdate patchable)
 {
     return new PhArmOperation<AvailabilitySet, Azure.ResourceManager.Compute.Models.AvailabilitySet>(
         Operations.Update(Id.ResourceGroup, Id.Name, patchable),
         a => new AvailabilitySet(this, new AvailabilitySetData(a)));
 }