public static void AssertOriginUpdate(CdnOriginResource updatedOrigin, CdnOriginPatch updateOptions) { Assert.AreEqual(updatedOrigin.Data.HttpPort, updateOptions.HttpPort); Assert.AreEqual(updatedOrigin.Data.HttpsPort, updateOptions.HttpsPort); Assert.AreEqual(updatedOrigin.Data.Priority, updateOptions.Priority); Assert.AreEqual(updatedOrigin.Data.Weight, updateOptions.Weight); }
public async Task Update() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-"); string cdnProfileName = Recording.GenerateAssetName("profile-"); ProfileResource cdnProfile = await CreateCdnProfile(rg, cdnProfileName, CdnSkuName.StandardMicrosoft); string cdnEndpointName = Recording.GenerateAssetName("endpoint-"); CdnEndpointResource cdnEndpoint = await CreateCdnEndpointWithOriginGroup(cdnProfile, cdnEndpointName); string cdnOriginName = Recording.GenerateAssetName("origin-"); CdnOriginResource cdnOrigin = await CreateCdnOrigin(cdnEndpoint, cdnOriginName); CdnOriginPatch updateOptions = new CdnOriginPatch() { HttpPort = 81, HttpsPort = 442, Priority = 1, Weight = 150 }; var lro = await cdnOrigin.UpdateAsync(WaitUntil.Completed, updateOptions); CdnOriginResource updatedCdnOrigin = lro.Value; ResourceDataHelper.AssertOriginUpdate(updatedCdnOrigin, updateOptions); }
public virtual ArmOperation<CdnOriginResource> Update(WaitUntil waitUntil, CdnOriginPatch patch, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); using var scope = _cdnOriginClientDiagnostics.CreateScope("CdnOriginResource.Update"); scope.Start(); try { var response = _cdnOriginRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch, cancellationToken); var operation = new CdnArmOperation<CdnOriginResource>(new CdnOriginOperationSource(Client), _cdnOriginClientDiagnostics, Pipeline, _cdnOriginRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) operation.WaitForCompletion(cancellationToken); return operation; } catch (Exception e) { scope.Failed(e); throw; } }