private void SetEndpoint() { var resourceGroupName = CdnEndpoint.ResourceGroupName; var profileName = CdnEndpoint.ProfileName; try { EndpointUpdateParameters updatedEndpoint = new EndpointUpdateParameters(); updatedEndpoint.Tags = CdnEndpoint.Tags.ToDictionaryTags(); updatedEndpoint.OriginPath = CdnEndpoint.OriginPath; updatedEndpoint.ContentTypesToCompress = CdnEndpoint.ContentTypesToCompress.ToList(); updatedEndpoint.OriginHostHeader = CdnEndpoint.OriginHostHeader; updatedEndpoint.IsCompressionEnabled = CdnEndpoint.IsCompressionEnabled; updatedEndpoint.IsHttpAllowed = CdnEndpoint.IsHttpAllowed; updatedEndpoint.IsHttpsAllowed = CdnEndpoint.IsHttpsAllowed; updatedEndpoint.QueryStringCachingBehavior = (QueryStringCachingBehavior)Enum.Parse(typeof(QueryStringCachingBehavior), CdnEndpoint.QueryStringCachingBehavior.ToString()); updatedEndpoint.OptimizationType = CdnEndpoint.OptimizationType; updatedEndpoint.ProbePath = CdnEndpoint.ProbePath; updatedEndpoint.GeoFilters = CdnEndpoint.GeoFilters.Select(g => g.ToSdkGeoFilter()).ToList(); updatedEndpoint.DeliveryPolicy = CdnEndpoint.DeliveryPolicy?.ToSdkDeliveryPolicy(); updatedEndpoint.DefaultOriginGroup = CdnEndpoint.DefaultOriginGroup; var endpoint = CdnManagementClient.Endpoints.Update(resourceGroupName, profileName, CdnEndpoint.Name, updatedEndpoint); WriteVerbose(Resources.Success); WriteObject(endpoint.ToPsEndpoint()); } catch (ErrorResponseException e) { throw new PSArgumentException(string.Format("Error response received.Error Message: '{0}'", e.Response.Content)); } }
public bool EnableDisableTrafficManagerEndpoint(TrafficManagerEndpoint endpoint, bool shouldEnableEndpointStatus) { endpoint.EndpointStatus = shouldEnableEndpointStatus ? Constants.StatusEnabled : Constants.StatusDisabled; Endpoint sdkEndpoint = endpoint.ToSDKEndpoint(); sdkEndpoint.Properties.EndpointLocation = null; sdkEndpoint.Properties.EndpointMonitorStatus = null; sdkEndpoint.Properties.Priority = null; sdkEndpoint.Properties.Weight = null; sdkEndpoint.Properties.Target = null; sdkEndpoint.Properties.TargetResourceId = null; var parameters = new EndpointUpdateParameters { Endpoint = sdkEndpoint }; AzureOperationResponse response = this.TrafficManagerManagementClient.Endpoints.Update( endpoint.ResourceGroupName, endpoint.ProfileName, endpoint.Type, endpoint.Name, parameters); return(response.StatusCode.Equals(HttpStatusCode.Created)); }
///GENMHASH:F08598A17ADD014E223DFD77272641FF:F733ABC4C4375BDE663CF05B96352BF2 public async override Task <Microsoft.Azure.Management.Cdn.Fluent.ICdnEndpoint> UpdateAsync(CancellationToken cancellationToken = default(CancellationToken)) { EndpointUpdateParameters updateInner = new EndpointUpdateParameters { IsHttpAllowed = Inner.IsHttpAllowed, IsHttpsAllowed = Inner.IsHttpsAllowed, OriginPath = Inner.OriginPath, OriginHostHeader = Inner.OriginHostHeader, IsCompressionEnabled = Inner.IsCompressionEnabled, ContentTypesToCompress = Inner.ContentTypesToCompress, GeoFilters = Inner.GeoFilters, OptimizationType = Inner.OptimizationType, QueryStringCachingBehavior = Inner.QueryStringCachingBehavior, Tags = Inner.Tags }; DeepCreatedOrigin originInner = Inner.Origins.ElementAt(0); OriginUpdateParameters originParameters = new OriginUpdateParameters { HostName = originInner.HostName, HttpPort = originInner.HttpPort, HttpsPort = originInner.HttpsPort }; await Task.WhenAll(deletedCustomDomainList .Select(itemToDelete => Parent.Manager.Inner.CustomDomains.DeleteAsync( Parent.ResourceGroupName, Parent.Name, Name(), itemToDelete.Name, cancellationToken))); deletedCustomDomainList.Clear(); await Parent.Manager.Inner.Origins.UpdateAsync( Parent.ResourceGroupName, Parent.Name, Name(), originInner.Name, originParameters, cancellationToken); var endpointInner = await Parent.Manager.Inner.Endpoints.UpdateAsync( Parent.ResourceGroupName, Parent.Name, Name(), updateInner, cancellationToken); SetInner(endpointInner); return(this); }
public bool EnableDisableTrafficManagerEndpoint(TrafficManagerEndpoint endpoint, bool shouldEnableEndpointStatus) { endpoint.EndpointStatus = shouldEnableEndpointStatus ? Constants.StatusEnabled : Constants.StatusDisabled; Endpoint sdkEndpoint = endpoint.ToSDKEndpoint(); sdkEndpoint.Properties.EndpointLocation = null; sdkEndpoint.Properties.EndpointMonitorStatus = null; sdkEndpoint.Properties.Priority = null; sdkEndpoint.Properties.Weight = null; sdkEndpoint.Properties.Target = null; sdkEndpoint.Properties.TargetResourceId = null; var parameters = new EndpointUpdateParameters { Endpoint = sdkEndpoint }; AzureOperationResponse response = this.TrafficManagerManagementClient.Endpoints.Update( endpoint.ResourceGroupName, endpoint.ProfileName, endpoint.Type, endpoint.Name, parameters); return response.StatusCode.Equals(HttpStatusCode.Created); }
/// <summary> /// Updates an existing CDN endpoint with the specified endpoint name under the /// specified subscription, resource group and profile. Only tags and Origin /// HostHeader can be updated after creating an endpoint. To update origins, /// use the Update Origin operation. To update custom 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 <Endpoint> BeginUpdateAsync(this IEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, EndpointUpdateParameters 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 CDN endpoint with the specified endpoint name under the /// specified subscription, resource group and profile. Only tags and Origin /// HostHeader can be updated after creating an endpoint. To update origins, /// use the Update Origin operation. To update custom 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 Endpoint BeginUpdate(this IEndpointsOperations operations, string resourceGroupName, string profileName, string endpointName, EndpointUpdateParameters endpointUpdateProperties) { return(operations.BeginUpdateAsync(resourceGroupName, profileName, endpointName, endpointUpdateProperties).GetAwaiter().GetResult()); }
/// <summary> /// Create or update a Traffic Manager endpoint. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.TrafficManager.IEndpointOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group containing the Traffic /// Manager endpoint to be created or updated. /// </param> /// <param name='profileName'> /// Required. The name of the Traffic Manager endpoint to be created or /// updated. /// </param> /// <param name='endpointType'> /// Required. The type of the Traffic Manager endpoint to be created or /// updated. /// </param> /// <param name='endpointName'> /// Required. The name of the Traffic Manager endpoint to be created or /// updated. /// </param> /// <param name='parameters'> /// Required. The Traffic Manager endpoint parameters supplied to the /// Update operation. /// </param> /// <returns> /// The response to a Traffic Manager endpoint 'CreateOrUpdate' /// operation. /// </returns> public static Task <EndpointUpdateResponse> UpdateAsync(this IEndpointOperations operations, string resourceGroupName, string profileName, string endpointType, string endpointName, EndpointUpdateParameters parameters) { return(operations.UpdateAsync(resourceGroupName, profileName, endpointType, endpointName, parameters, CancellationToken.None)); }
/// <summary> /// Create or update a Traffic Manager endpoint. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.Azure.Management.TrafficManager.IEndpointOperations. /// </param> /// <param name='resourceGroupName'> /// Required. The name of the resource group containing the Traffic /// Manager endpoint to be created or updated. /// </param> /// <param name='profileName'> /// Required. The name of the Traffic Manager endpoint to be created or /// updated. /// </param> /// <param name='endpointType'> /// Required. The type of the Traffic Manager endpoint to be created or /// updated. /// </param> /// <param name='endpointName'> /// Required. The name of the Traffic Manager endpoint to be created or /// updated. /// </param> /// <param name='parameters'> /// Required. The Traffic Manager endpoint parameters supplied to the /// Update operation. /// </param> /// <returns> /// The response to a Traffic Manager endpoint 'CreateOrUpdate' /// operation. /// </returns> public static EndpointUpdateResponse Update(this IEndpointOperations operations, string resourceGroupName, string profileName, string endpointType, string endpointName, EndpointUpdateParameters parameters) { return(Task.Factory.StartNew((object s) => { return ((IEndpointOperations)s).UpdateAsync(resourceGroupName, profileName, endpointType, endpointName, parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
public void EndpointUpdateTest() { var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType().FullName)) { // Create clients var cdnMgmtClient = CdnTestUtilities.GetCdnManagementClient(context, handler1); var resourcesClient = CdnTestUtilities.GetResourceManagementClient(context, handler2); // Create resource group var resourceGroupName = CdnTestUtilities.CreateResourceGroup(resourcesClient); // Create a standard cdn profile string profileName = TestUtilities.GenerateName("profile"); ProfileCreateParameters createParameters = new ProfileCreateParameters { Location = "WestUs", Sku = new Sku { Name = SkuName.StandardVerizon }, Tags = new Dictionary <string, string> { { "key1", "value1" }, { "key2", "value2" } } }; var profile = cdnMgmtClient.Profiles.Create(profileName, createParameters, resourceGroupName); // Create a cdn endpoint with minimum requirements should succeed string endpointName = TestUtilities.GenerateName("endpoint"); var endpointCreateParameters = new EndpointCreateParameters { Location = "WestUs", IsHttpAllowed = true, IsHttpsAllowed = true, Origins = new List <DeepCreatedOrigin> { new DeepCreatedOrigin { Name = "origin1", HostName = "host1.hello.com" } } }; cdnMgmtClient.Endpoints.Create(endpointName, endpointCreateParameters, profileName, resourceGroupName); // Update endpoint with invalid origin path should fail var endpointUpdateParameters = new EndpointUpdateParameters { IsHttpAllowed = false, OriginPath = "\\&123invalid_path/.", OriginHostHeader = "www.bing.com" }; Assert.ThrowsAny <ErrorResponseException>(() => { cdnMgmtClient.Endpoints.Update(endpointName, endpointUpdateParameters, profileName, resourceGroupName); }); // Update endpoint to enable compression without specifying compression types should fail endpointUpdateParameters = new EndpointUpdateParameters { IsHttpAllowed = false, OriginPath = "/path/valid", OriginHostHeader = "www.bing.com", IsCompressionEnabled = true, QueryStringCachingBehavior = QueryStringCachingBehavior.IgnoreQueryString }; Assert.ThrowsAny <ErrorResponseException>(() => { cdnMgmtClient.Endpoints.Update(endpointName, endpointUpdateParameters, profileName, resourceGroupName); }); // Update endpoint with valid properties should succeed endpointUpdateParameters = new EndpointUpdateParameters { IsHttpAllowed = false, OriginPath = "/path/valid", OriginHostHeader = "www.bing.com", IsCompressionEnabled = true, ContentTypesToCompress = new List <string> { "text/html", "application/octet-stream" }, QueryStringCachingBehavior = QueryStringCachingBehavior.IgnoreQueryString }; var endpoint = cdnMgmtClient.Endpoints.Update(endpointName, endpointUpdateParameters, profileName, resourceGroupName); // Create a cdn endpoint but don't wait for creation to complete endpointName = TestUtilities.GenerateName("endpoint"); endpointCreateParameters = new EndpointCreateParameters { Location = "WestUs", IsHttpAllowed = true, IsHttpsAllowed = true, Origins = new List <DeepCreatedOrigin> { new DeepCreatedOrigin { Name = "origin1", HostName = "host1.hello.com" } } }; cdnMgmtClient.Endpoints.BeginCreateAsync(endpointName, endpointCreateParameters, profileName, resourceGroupName).Wait(5000); // Update endpoint in creating state should fail endpointUpdateParameters = new EndpointUpdateParameters { IsHttpAllowed = false, OriginHostHeader = "www.bing.com" }; Assert.ThrowsAny <ErrorResponseException>(() => { cdnMgmtClient.Endpoints.Update(endpointName, endpointUpdateParameters, profileName, resourceGroupName); }); // Delete resource group CdnTestUtilities.DeleteResourceGroup(resourcesClient, resourceGroupName); } }
/// <summary> /// Updates an existing CDN endpoint with the specified parameters. Only tags /// and OriginHostHeader can be updated after creating an endpoint. To update /// origins, use the Update Origin operation. To update custom domains, use /// the Update Custom Domain operation. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='endpointName'> /// Name of the endpoint within the CDN profile. /// </param> /// <param name='endpointProperties'> /// Endpoint properties /// </param> /// <param name='profileName'> /// Name of the CDN profile within the resource group. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group within the Azure subscription. /// </param> public static Endpoint BeginUpdate(this IEndpointsOperations operations, string endpointName, EndpointUpdateParameters endpointProperties, string profileName, string resourceGroupName) { return(Task.Factory.StartNew(s => ((IEndpointsOperations)s).BeginUpdateAsync(endpointName, endpointProperties, profileName, resourceGroupName), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }