public async Task UpdateOriginGroups() { #region Snippet:Managing_OriginGroups_UpdateAnOriginGroup // First we need to get the cdn origin group collection from the specific endpoint Profile profile = await resourceGroup.GetProfiles().GetAsync("myProfile"); CdnEndpoint endpoint = await profile.GetCdnEndpoints().GetAsync("myEndpoint"); CdnOriginGroupCollection originGroupCollection = endpoint.GetCdnOriginGroups(); // Now we can get the origin group with GetAsync() CdnOriginGroup originGroup = await originGroupCollection.GetAsync("myOriginGroup"); // With UpdateAsync(), we can update the origin group CdnOriginGroupUpdateOptions input = new CdnOriginGroupUpdateOptions() { HealthProbeSettings = new HealthProbeParameters { ProbePath = "/healthz", ProbeRequestType = HealthProbeRequestType.Head, ProbeProtocol = ProbeProtocol.Https, ProbeIntervalInSeconds = 60 } }; ArmOperation <CdnOriginGroup> lro = await originGroup.UpdateAsync(true, input); originGroup = lro.Value; #endregion Snippet:Managing_OriginGroups_UpdateAnOriginGroup }
public async Task Update() { Subscription subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-"); string cdnProfileName = Recording.GenerateAssetName("profile-"); Profile cdnProfile = await CreateCdnProfile(rg, cdnProfileName, SkuName.StandardMicrosoft); string cdnEndpointName = Recording.GenerateAssetName("endpoint-"); CdnEndpoint cdnEndpoint = await CreateCdnEndpoint(cdnProfile, cdnEndpointName); string cdnOriginGroupName = Recording.GenerateAssetName("origingroup-"); CdnOriginGroup cdnOriginGroup = await CreateCdnOriginGroup(cdnEndpoint, cdnOriginGroupName, cdnEndpoint.Data.Origins[0].Name); CdnOriginGroupUpdateOptions updateOptions = new CdnOriginGroupUpdateOptions() { HealthProbeSettings = new HealthProbeParameters { ProbePath = "/healthz", ProbeRequestType = HealthProbeRequestType.Head, ProbeProtocol = ProbeProtocol.Https, ProbeIntervalInSeconds = 60 } }; var lro = await cdnOriginGroup.UpdateAsync(true, updateOptions); CdnOriginGroup updatedCdnOriginGroup = lro.Value; ResourceDataHelper.AssertOriginGroupUpdate(updatedCdnOriginGroup, updateOptions); }
public virtual ArmOperation <CdnOriginGroup> Update(bool waitForCompletion, CdnOriginGroupUpdateOptions options, CancellationToken cancellationToken = default) { Argument.AssertNotNull(options, nameof(options)); using var scope = _cdnOriginGroupClientDiagnostics.CreateScope("CdnOriginGroup.Update"); scope.Start(); try { var response = _cdnOriginGroupRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, options, cancellationToken); var operation = new CdnArmOperation <CdnOriginGroup>(new CdnOriginGroupOperationSource(Client), _cdnOriginGroupClientDiagnostics, Pipeline, _cdnOriginGroupRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, options).Request, response, OperationFinalStateVia.OriginalUri); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public static void AssertOriginGroupUpdate(CdnOriginGroup updatedOriginGroup, CdnOriginGroupUpdateOptions updateOptions) { Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbePath, updateOptions.HealthProbeSettings.ProbePath); Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbeRequestType, updateOptions.HealthProbeSettings.ProbeRequestType); Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbeProtocol, updateOptions.HealthProbeSettings.ProbeProtocol); Assert.AreEqual(updatedOriginGroup.Data.HealthProbeSettings.ProbeIntervalInSeconds, updateOptions.HealthProbeSettings.ProbeIntervalInSeconds); }