예제 #1
0
 private static void VerifyEndpointUpdated(AFDEndpointUpdateParameters endpointUpdateProperties, AFDEndpoint endpoint)
 {
     Assert.NotNull(endpoint);
     Assert.Equal(endpointUpdateProperties.EnabledState, endpoint.EnabledState);
     Assert.Equal(endpointUpdateProperties.OriginResponseTimeoutSeconds, endpoint.OriginResponseTimeoutSeconds);
     Assert.Equal(endpointUpdateProperties.Tags, endpoint.Tags);
 }
        private void UpdateAfdEndpoint()
        {
            try
            {
                AFDEndpointUpdateParameters afdEndpointParameters = new AFDEndpointUpdateParameters();

                Dictionary <string, string> afdEndpointTags = TagsConversionHelper.CreateTagDictionary(this.Tag, true);

                afdEndpointParameters.Tags = afdEndpointTags;

                PSAfdEndpoint psAfdEndpoint = this.CdnManagementClient.AFDEndpoints.Update(this.ResourceGroupName, this.ProfileName, this.EndpointName, afdEndpointParameters).ToPSAfdEndpoint();

                WriteObject(psAfdEndpoint);
            }
            catch (AfdErrorResponseException errorResponseException)
            {
                throw new PSArgumentException(errorResponseException.Response.Content);
            }
        }
 /// <summary>
 /// Updates an existing AzureFrontDoor endpoint with the specified endpoint
 /// name under the specified subscription, resource group and profile. Only
 /// tags can be updated after creating an endpoint. To update origins, use the
 /// Update Origin operation. To update origin groups, use the Update Origin
 /// group operation. To update domains, use the Update Custom Domain operation.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of the Resource group within the Azure subscription.
 /// </param>
 /// <param name='profileName'>
 /// Name of the CDN profile which is unique within the resource group.
 /// </param>
 /// <param name='endpointName'>
 /// Name of the endpoint under the profile which is unique globally.
 /// </param>
 /// <param name='endpointUpdateProperties'>
 /// Endpoint update properties
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AFDEndpoint> BeginUpdateAsync(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Updates an existing AzureFrontDoor endpoint with the specified endpoint
 /// name under the specified subscription, resource group and profile. Only
 /// tags can be updated after creating an endpoint. To update origins, use the
 /// Update Origin operation. To update origin groups, use the Update Origin
 /// group operation. To update domains, use the Update Custom Domain operation.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of the Resource group within the Azure subscription.
 /// </param>
 /// <param name='profileName'>
 /// Name of the CDN profile which is unique within the resource group.
 /// </param>
 /// <param name='endpointName'>
 /// Name of the endpoint under the profile which is unique globally.
 /// </param>
 /// <param name='endpointUpdateProperties'>
 /// Endpoint update properties
 /// </param>
 public static AFDEndpoint BeginUpdate(this IAFDEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, AFDEndpointUpdateParameters endpointUpdateProperties)
 {
     return(operations.BeginUpdateAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties).GetAwaiter().GetResult());
 }
예제 #5
0
        public void AFDEndpointUpdateTest()
        {
            var handler1 = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };
            var handler2 = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType()))
            {
                // Create clients
                var cdnMgmtClient   = CdnTestUtilities.GetCdnManagementClient(context, handler1);
                var resourcesClient = CdnTestUtilities.GetResourceManagementClient(context, handler2);

                // Create resource group
                var resourceGroupName = CdnTestUtilities.CreateResourceGroup(resourcesClient);

                try
                {
                    // Create a standard Azure frontdoor profile
                    string  profileName      = TestUtilities.GenerateName("profile");
                    Profile createParameters = new Profile
                    {
                        Location = "WestUs",
                        Sku      = new Sku {
                            Name = SkuName.StandardAzureFrontDoor
                        },
                        Tags = new Dictionary <string, string>
                        {
                            { "key1", "value1" },
                            { "key2", "value2" }
                        }
                    };
                    var profile = cdnMgmtClient.Profiles.Create(resourceGroupName, profileName, createParameters);

                    // Create a standard Azure frontdoor endpoint
                    string endpointName             = TestUtilities.GenerateName("endpointName");
                    var    endpointCreateParameters = new AFDEndpoint("WestUs")
                    {
                        EnabledState = "Enabled",
                        OriginResponseTimeoutSeconds = 60,
                        Tags = new Dictionary <string, string>
                        {
                            { "key1", "value1" },
                            { "key2", "value2" }
                        }
                    };
                    var endpoint = cdnMgmtClient.AFDEndpoints.Create(resourceGroupName, profileName, endpointName, endpointCreateParameters);
                    VerifyEndpointCreated(endpointName, endpointCreateParameters, endpoint);

                    AFDEndpointUpdateParameters endpointUpdateProperties = new AFDEndpointUpdateParameters
                    {
                        Tags = new Dictionary <string, string>
                        {
                            { "key1", "value1updated" },
                            { "key2", "value2updated" }
                        },
                        OriginResponseTimeoutSeconds = 80,
                        EnabledState = EnabledState.Disabled,
                    };
                    var updatedEndpoint = cdnMgmtClient.AFDEndpoints.Update(resourceGroupName, profileName, endpointName, endpointUpdateProperties);
                    VerifyEndpointUpdated(endpointUpdateProperties, updatedEndpoint);
                }
                finally
                {
                    // Delete resource group
                    _ = CdnTestUtilities.DeleteResourceGroupAsync(resourcesClient, resourceGroupName);
                }
            }
        }