Beispiel #1
0
        public async Task Update()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string          afdProfileName     = Recording.GenerateAssetName("AFDProfile-");
            ProfileResource afdProfileResource = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor);

            string afdOriginGroupName = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroupResource afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfileResource, afdOriginGroupName);

            string            afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOriginResource afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            AfdOriginPatch updateOptions = new AfdOriginPatch
            {
                Priority = 1,
                Weight   = 150
            };
            var lro = await afdOriginInstance.UpdateAsync(WaitUntil.Completed, updateOptions);

            AfdOriginResource updatedAfdOriginInstance = lro.Value;

            ResourceDataHelper.AssertAfdOriginUpdate(updatedAfdOriginInstance, updateOptions);
        }
        public virtual ArmOperation <AfdOriginResource> Update(WaitUntil waitUntil, AfdOriginPatch patch, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(patch, nameof(patch));

            using var scope = _afdOriginClientDiagnostics.CreateScope("AfdOriginResource.Update");
            scope.Start();
            try
            {
                var response  = _afdOriginRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch, cancellationToken);
                var operation = new CdnArmOperation <AfdOriginResource>(new AfdOriginOperationSource(Client), _afdOriginClientDiagnostics, Pipeline, _afdOriginRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 public static void AssertAfdOriginUpdate(AfdOriginResource updatedAfdOrigin, AfdOriginPatch updateOptions)
 {
     Assert.AreEqual(updatedAfdOrigin.Data.Priority, updateOptions.Priority);
     Assert.AreEqual(updatedAfdOrigin.Data.Weight, updateOptions.Weight);
 }