public virtual CdnEndpointCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string endpointName, CdnEndpointData endpointInput, CancellationToken cancellationToken = default) { if (endpointName == null) { throw new ArgumentNullException(nameof(endpointName)); } if (endpointInput == null) { throw new ArgumentNullException(nameof(endpointInput)); } using var scope = _clientDiagnostics.CreateScope("CdnEndpointCollection.CreateOrUpdate"); scope.Start(); try { var response = _cdnEndpointsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput, cancellationToken); var operation = new CdnEndpointCreateOrUpdateOperation(this, _clientDiagnostics, Pipeline, _cdnEndpointsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <CdnEndpointCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string endpointName, CdnEndpointData endpointInput, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName)); if (endpointInput == null) { throw new ArgumentNullException(nameof(endpointInput)); } using var scope = _cdnEndpointClientDiagnostics.CreateScope("CdnEndpointCollection.CreateOrUpdate"); scope.Start(); try { var response = await _cdnEndpointRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput, cancellationToken).ConfigureAwait(false); var operation = new CdnEndpointCreateOrUpdateOperation(ArmClient, _cdnEndpointClientDiagnostics, Pipeline, _cdnEndpointRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task CreateOriginGroups() { #region Snippet:Managing_OriginGroups_CreateAnOriginGroup // Create a new cdn profile string profileName = "myProfile"; var input1 = new ProfileData(AzureLocation.WestUS, new Models.Sku { Name = SkuName.StandardMicrosoft }); ProfileCreateOrUpdateOperation lro1 = await resourceGroup.GetProfiles().CreateOrUpdateAsync(true, profileName, input1); Profile profile = lro1.Value; // Get the cdn endpoint collection from the specific profile and create an endpoint string endpointName = "myEndpoint"; var input2 = new CdnEndpointData(AzureLocation.WestUS) { IsHttpAllowed = true, IsHttpsAllowed = true, OptimizationType = OptimizationType.GeneralWebDelivery }; DeepCreatedOrigin deepCreatedOrigin = new DeepCreatedOrigin("myOrigin") { HostName = "testsa4dotnetsdk.blob.core.windows.net", Priority = 3, Weight = 100 }; input2.Origins.Add(deepCreatedOrigin); CdnEndpointCreateOrUpdateOperation lro2 = await profile.GetCdnEndpoints().CreateOrUpdateAsync(true, endpointName, input2); CdnEndpoint endpoint = lro2.Value; // Get the cdn origin group collection from the specific endpoint and create an origin group string originGroupName = "myOriginGroup"; var input3 = new CdnOriginGroupData(); input3.Origins.Add(new WritableSubResource { Id = new ResourceIdentifier($"{endpoint.Id}/origins/myOrigin") }); CdnOriginGroupCreateOrUpdateOperation lro3 = await endpoint.GetCdnOriginGroups().CreateOrUpdateAsync(true, originGroupName, input3); CdnOriginGroup originGroup = lro3.Value; #endregion Snippet:Managing_OriginGroups_CreateAnOriginGroup }