public async void UpdateImage(Guid imageId, ImageUpdate update) { var uriString = _apiConfig.ImagesApiUrl + "/api/images/" + imageId; var response = await _apiClient.PutAsync(uriString, update); response.EnsureSuccessStatusCode(); }
public virtual ArmOperation <Image> Update(bool waitForCompletion, ImageUpdate parameters, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _imageClientDiagnostics.CreateScope("Image.Update"); scope.Start(); try { var response = _imageRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken); var operation = new ComputeArmOperation <Image>(new ImageOperationSource(Client), _imageClientDiagnostics, Pipeline, _imageRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public ImageResponse Delete(ImageUpdate request) { var response = new ImageResponse(); using (_dbSession) { try { // Remove all links from containers IEnumerable <Container> containers = _dbSession.Query <Container>(); foreach (Container container in containers) { RemoveImageFromContainer(container, request.ImageUrl); } // Delete the image itself _imageSession.Delete(request.ImageUrl); _dbSession.SaveChanges(); response.ImageUrl = request.ImageUrl; } catch (Exception ex) { Debug.WriteLine("Delete(ImageUpdate): {0}", ex.Message); throw; } } return(response); }
public virtual ImageUpdateOperation Update(ImageUpdate parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("Image.Update"); scope.Start(); try { var response = _imagesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken); var operation = new ImageUpdateOperation(this, _clientDiagnostics, Pipeline, _imagesRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public ImageResponse Delete(ImageUpdate request) { var response = new ImageResponse(); using (_dbSession) { try { // Remove all links from containers IEnumerable<Container> containers = _dbSession.Query<Container>(); foreach (Container container in containers) { RemoveImageFromContainer(container, request.ImageUrl); } // Delete the image itself _imageSession.Delete(request.ImageUrl); _dbSession.SaveChanges(); response.ImageUrl = request.ImageUrl; } catch (Exception ex) { Debug.WriteLine("Delete(ImageUpdate): {0}", ex.Message); throw; } } return response; }
public Response Update(string resourceGroupName, string imageName, ImageUpdate parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (imageName == null) { throw new ArgumentNullException(nameof(imageName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var message = CreateUpdateRequest(resourceGroupName, imageName, parameters); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } }
public void Awake() { m_button = GetComponent <Button>(); m_button.onClick.AddListener(delegate { m_actionOnClick(m_spellID); }); m_image = GetComponent <Image>(); m_imageCoolDown = GetComponentInChildren <ImageUpdate>(); }
protected void ExecuteImageUpdateMethod(object[] invokeMethodInputParameters) { string resourceGroupName = (string)ParseParameter(invokeMethodInputParameters[0]); string imageName = (string)ParseParameter(invokeMethodInputParameters[1]); ImageUpdate parameters = (ImageUpdate)ParseParameter(invokeMethodInputParameters[2]); var result = ImagesClient.Update(resourceGroupName, imageName, parameters); WriteObject(result); }
protected PSArgument[] CreateImageUpdateParameters() { string resourceGroupName = string.Empty; string imageName = string.Empty; ImageUpdate parameters = new ImageUpdate(); return(ConvertFromObjectsToArguments( new string[] { "ResourceGroupName", "ImageName", "Parameters" }, new object[] { resourceGroupName, imageName, parameters })); }
public async Task <IActionResult> Put(Guid id, [FromBody] ImageUpdate imageUpdate) { var image = await _images.Where(i => i.Id == id).FirstOrDefaultAsync(); if (image != null) { image.Title = imageUpdate.Title; _images.Update(image); await _context.SaveChangesAsync(); } return(Ok()); }
public IActionResult Put(Guid imageId, [FromBody] ImageUpdate imageUpdate) { try { _imagesService.UpdateImage(imageId, imageUpdate); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }
public object Update(ImageUpdate request) { using (_dbSession) { try { // Sanity checks if (!request.ToContainerId.HasValue) { return(new HttpError(HttpStatusCode.BadRequest, "Destination(To) container ID must be specified")); } string destId = string.Format("containers/{0}", request.ToContainerId.Value); Container destDbContainer = _dbSession.Load <Container>(destId); if (destDbContainer == null) { return(new HttpError(HttpStatusCode.NotFound, "Destination(To) container not found")); } Container sourceDbContainer = null; if (request.FromContainerId.HasValue) { string sourceId = string.Format("containers/{0}", request.FromContainerId); sourceDbContainer = _dbSession.Load <Container>(sourceId); if (sourceDbContainer == null) { return(new HttpError(HttpStatusCode.NotFound, "Source container not found")); } } // Update destination container AddImageToContainer(destDbContainer, request.ImageUrl); // Update source container if (sourceDbContainer != null) { RemoveImageFromContainer(sourceDbContainer, request.ImageUrl); } _dbSession.SaveChanges(); } catch (Exception ex) { Debug.WriteLine("Update(ImageUpdate): {0}", ex.Message); throw; } } return(new HttpResult(HttpStatusCode.OK)); }
protected void ButtonSave_Click(object sender, EventArgs e) { if (ImageUpdate.HasFile) { string imagePath = "~/images/" + ImageUpdate.FileName; ImageUpdate.SaveAs(Server.MapPath(imagePath).ToString()); SqlCommand cmd = new SqlCommand("UPDATE restaurantAdminAccount SET restaurantAdminName = '" + UserProfileName.Text + "', restaurantAdminDP ='" + imagePath + "', restaurantAdminEmail = '" + AdminProfileEmail.Text + "' WHERE restaurantAdminID = " + Session["restaurantAdminID"], con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); BindData(); } Response.Redirect("UserAccount.aspx"); }
public void TestUploadAndDeleteImage() { string filename = "IMG_0001.JPG"; ImageResponse response = _uploadClient.Upload(filename); Assert.IsNotNull(response); Assert.IsFalse(string.IsNullOrEmpty(response.ImageUrl)); Assert.IsTrue(File.Exists(response.ImageUrl)); var update = new ImageUpdate { ImageUrl = response.ImageUrl }; var delResponse = _client.Delete<ImageResponse>(update); Assert.IsNotNull(delResponse); Assert.IsFalse(File.Exists(response.ImageUrl)); }
public void TestUploadAndDeleteImage() { string filename = "IMG_0001.JPG"; ImageResponse response = _uploadClient.Upload(filename); Assert.IsNotNull(response); Assert.IsFalse(string.IsNullOrEmpty(response.ImageUrl)); Assert.IsTrue(File.Exists(response.ImageUrl)); var update = new ImageUpdate { ImageUrl = response.ImageUrl }; var delResponse = _client.Delete <ImageResponse>(update); Assert.IsNotNull(delResponse); Assert.IsFalse(File.Exists(response.ImageUrl)); }
protected void ValidateImageUpdate(ImageUpdate request) { try { if (request.Id < 1) { throw new RestaurantException { ErrorCode = new ErrorCode { ErrorMessage = "wrong source id", ErrorNumber = ErrorNumber.EmptyRequiredField } } } ; } catch (RestaurantException ex) { throw ex; } }
internal HttpMessage CreateUpdateRequest(string resourceGroupName, string imageName, ImageUpdate parameters) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Patch; var uri = new RawRequestUriBuilder(); uri.Reset(endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Compute/images/", false); uri.AppendPath(imageName, true); uri.AppendQuery("api-version", "2019-12-01", true); request.Uri = uri; request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(parameters); request.Content = content; return(message); }
/// <summary> /// Updates an image. /// </summary> /// <remarks> /// Updates an image resource. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// The request body. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='labPlanName'> /// The name of the lab plan that uniquely identifies it within containing /// resource group. Used in resource URIs and in UI. /// </param> /// <param name='imageName'> /// The image name. /// </param> public static Image Update(this IImagesOperations operations, ImageUpdate body, string resourceGroupName, string labPlanName, string imageName) { return(operations.UpdateAsync(body, resourceGroupName, labPlanName, imageName).GetAwaiter().GetResult()); }
/// <summary> /// Updates an image. /// </summary> /// <remarks> /// Updates an image resource. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// The request body. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. The name is case insensitive. /// </param> /// <param name='labPlanName'> /// The name of the lab plan that uniquely identifies it within containing /// resource group. Used in resource URIs and in UI. /// </param> /// <param name='imageName'> /// The image name. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Image> UpdateAsync(this IImagesOperations operations, ImageUpdate body, string resourceGroupName, string labPlanName, string imageName, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateWithHttpMessagesAsync(body, resourceGroupName, labPlanName, imageName, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Update an image. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='imageName'> /// The name of the image. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Image operation. /// </param> public static Image Update(this IImagesOperations operations, string resourceGroupName, string imageName, ImageUpdate parameters) { return(operations.UpdateAsync(resourceGroupName, imageName, parameters).GetAwaiter().GetResult()); }
/// <summary> /// Update an image. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='imageName'> /// The name of the image. /// </param> /// <param name='parameters'> /// Parameters supplied to the Update Image operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Image> BeginUpdateAsync(this IImagesOperations operations, string resourceGroupName, string imageName, ImageUpdate parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginUpdateWithHttpMessagesAsync(resourceGroupName, imageName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
public async Task <Response> UpdateAsync(string subscriptionId, string resourceGroupName, string imageName, ImageUpdate parameters, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (imageName == null) { throw new ArgumentNullException(nameof(imageName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var message = CreateUpdateRequest(subscriptionId, resourceGroupName, imageName, parameters); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
private void CreateImageTestHelper(string originalTestLocation, string diskEncryptionSetId) { VirtualMachine inputVM = null; // Create resource group var rgName = ComputeManagementTestUtilities.GenerateName(TestPrefix); var imageName = ComputeManagementTestUtilities.GenerateName("imageTest"); // Create a VM, so we can use its OS disk for creating the image string storageAccountName = ComputeManagementTestUtilities.GenerateName(TestPrefix); string asName = ComputeManagementTestUtilities.GenerateName("as"); ImageReference imageRef = GetPlatformVMImage(useWindowsImage: true); try { // Create Storage Account var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName); // Add data disk to the VM. Action <VirtualMachine> addDataDiskToVM = vm => { string containerName = HttpMockServer.GetAssetName("TestImageOperations", TestPrefix); var vhdContainer = "https://" + storageAccountName + ".blob.core.windows.net/" + containerName; var vhduri = vhdContainer + string.Format("/{0}.vhd", HttpMockServer.GetAssetName("TestImageOperations", TestPrefix)); vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardA4; vm.StorageProfile.DataDisks = new List <DataDisk>(); foreach (int index in new int[] { 1, 2 }) { var diskName = "dataDisk" + index; var ddUri = vhdContainer + string.Format("/{0}{1}.vhd", diskName, HttpMockServer.GetAssetName("TestImageOperations", TestPrefix)); var dd = new DataDisk { Caching = CachingTypes.None, Image = null, DiskSizeGB = 10, CreateOption = DiskCreateOptionTypes.Empty, Lun = 1 + index, Name = diskName, Vhd = new VirtualHardDisk { Uri = ddUri } }; vm.StorageProfile.DataDisks.Add(dd); } var testStatus = new InstanceViewStatus { Code = "test", Message = "test" }; var testStatusList = new List <InstanceViewStatus> { testStatus }; }; // Create the VM, whose OS disk will be used in creating the image var createdVM = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM, addDataDiskToVM); int expectedDiskLunWithDiskEncryptionSet = createdVM.StorageProfile.DataDisks[0].Lun; // Create the Image var imageInput = new Image() { Location = m_location, Tags = new Dictionary <string, string>() { { "RG", "rg" }, { "testTag", "1" }, }, StorageProfile = new ImageStorageProfile() { OsDisk = new ImageOSDisk() { BlobUri = createdVM.StorageProfile.OsDisk.Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null : new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, OsState = OperatingSystemStateTypes.Generalized, OsType = OperatingSystemTypes.Windows, }, DataDisks = new List <ImageDataDisk>() { new ImageDataDisk() { BlobUri = createdVM.StorageProfile.DataDisks[0].Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null: new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, Lun = expectedDiskLunWithDiskEncryptionSet, } } }, HyperVGeneration = HyperVGeneration.V1 }; var image = m_CrpClient.Images.CreateOrUpdate(rgName, imageName, imageInput); var getImage = m_CrpClient.Images.Get(rgName, imageName); ValidateImage(imageInput, getImage); if (diskEncryptionSetId != null) { Assert.True(getImage.StorageProfile.OsDisk.DiskEncryptionSet != null, "OsDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.OsDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "getImage.StorageProfile.OsDisk.DiskEncryptionSet is not matching with expected DiskEncryptionSet resource"); Assert.Equal(1, getImage.StorageProfile.DataDisks.Count); Assert.True(getImage.StorageProfile.DataDisks[0].DiskEncryptionSet != null, ".DataDisks.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.DataDisks[0].DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ImageUpdate updateParams = new ImageUpdate() { Tags = getImage.Tags }; string tagKey = "UpdateTag"; updateParams.Tags.Add(tagKey, "TagValue"); m_CrpClient.Images.Update(rgName, imageName, updateParams); getImage = m_CrpClient.Images.Get(rgName, imageName); Assert.True(getImage.Tags.ContainsKey(tagKey)); var listResponse = m_CrpClient.Images.ListByResourceGroup(rgName); Assert.Single(listResponse); m_CrpClient.Images.Delete(rgName, image.Name); } finally { Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", originalTestLocation); if (inputVM != null) { m_CrpClient.VirtualMachines.Delete(rgName, inputVM.Name); } m_ResourcesClient.ResourceGroups.Delete(rgName); } }
public object Update(ImageUpdate request) { using (_dbSession) { try { // Sanity checks if (!request.ToContainerId.HasValue) { return new HttpError(HttpStatusCode.BadRequest, "Destination(To) container ID must be specified"); } string destId = string.Format("containers/{0}", request.ToContainerId.Value); Container destDbContainer = _dbSession.Load<Container>(destId); if (destDbContainer == null) { return new HttpError(HttpStatusCode.NotFound, "Destination(To) container not found"); } Container sourceDbContainer = null; if (request.FromContainerId.HasValue) { string sourceId = string.Format("containers/{0}", request.FromContainerId); sourceDbContainer = _dbSession.Load<Container>(sourceId); if (sourceDbContainer == null) { return new HttpError(HttpStatusCode.NotFound, "Source container not found"); } } // Update destination container AddImageToContainer(destDbContainer, request.ImageUrl); // Update source container if (sourceDbContainer != null) { RemoveImageFromContainer(sourceDbContainer, request.ImageUrl); } _dbSession.SaveChanges(); } catch (Exception ex) { Debug.WriteLine("Update(ImageUpdate): {0}", ex.Message); throw; } } return new HttpResult(HttpStatusCode.OK); }
private async Task CreateImageTestHelper(string originalTestLocation, string diskEncryptionSetId) { // Create resource group var rgName = Recording.GenerateAssetName(TestPrefix); var imageName = Recording.GenerateAssetName("imageTest"); // Create a VM, so we can use its OS disk for creating the image string storageAccountName = Recording.GenerateAssetName(TestPrefix); string asName = Recording.GenerateAssetName("as"); ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true); // Create Storage Account var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName); // Add data disk to the VM. Action <VirtualMachine> addDataDiskToVM = vm => { string containerName = Recording.GenerateAssetName("testimageoperations", TestPrefix); var vhdContainer = "https://" + storageAccountName + ".blob.core.windows.net/" + containerName; var vhduri = vhdContainer + string.Format("/{0}.vhd", Recording.GenerateAssetName("testimageoperations", TestPrefix)); vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardA4; foreach (int index in new int[] { 1, 2 }) { var diskName = "dataDisk" + index; var ddUri = vhdContainer + string.Format("/{0}{1}.vhd", diskName, Recording.GenerateAssetName("testimageoperations", TestPrefix)); var dd = new DataDisk(1 + index, DiskCreateOptionTypes.Empty) { Caching = CachingTypes.None, Image = null, DiskSizeGB = 10, Name = diskName, Vhd = new VirtualHardDisk { Uri = ddUri } }; vm.StorageProfile.DataDisks.Add(dd); } var testStatus = new InstanceViewStatus { Code = "test", Message = "test" }; var testStatusList = new List <InstanceViewStatus> { testStatus }; }; // Create the VM, whose OS disk will be used in creating the image var returnTwoVM = await CreateVM(rgName, asName, storageAccountOutput, imageRef, addDataDiskToVM); var createdVM = returnTwoVM.Item1; int expectedDiskLunWithDiskEncryptionSet = createdVM.StorageProfile.DataDisks[0].Lun; // Create the Image var imageInput = new Image(m_location) { Tags = { { "RG", "rg" }, { "testTag", "1" }, }, StorageProfile = new ImageStorageProfile() { OsDisk = new ImageOSDisk(OperatingSystemTypes.Windows, OperatingSystemStateTypes.Generalized) { BlobUri = createdVM.StorageProfile.OsDisk.Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null : new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, }, DataDisks = { new ImageDataDisk(expectedDiskLunWithDiskEncryptionSet) { BlobUri = createdVM.StorageProfile.DataDisks[0].Vhd.Uri, DiskEncryptionSet = diskEncryptionSetId == null ? null: new DiskEncryptionSetParameters() { Id = diskEncryptionSetId }, } } }, HyperVGeneration = HyperVGenerationTypes.V1 }; var image = await WaitForCompletionAsync(await ImagesOperations.StartCreateOrUpdateAsync(rgName, imageName, imageInput)); var getImage = (await ImagesOperations.GetAsync(rgName, imageName)).Value; ValidateImage(imageInput, getImage); if (diskEncryptionSetId != null) { Assert.True(getImage.StorageProfile.OsDisk.DiskEncryptionSet != null, "OsDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.OsDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "getImage.StorageProfile.OsDisk.DiskEncryptionSet is not matching with expected DiskEncryptionSet resource"); Assert.AreEqual(1, getImage.StorageProfile.DataDisks.Count); Assert.True(getImage.StorageProfile.DataDisks[0].DiskEncryptionSet != null, ".DataDisks.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getImage.StorageProfile.DataDisks[0].DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ImageUpdate updateParams = new ImageUpdate(); updateParams.Tags.InitializeFrom(getImage.Tags); string tagKey = "UpdateTag"; updateParams.Tags.Add(tagKey, "TagValue"); await WaitForCompletionAsync(await ImagesOperations.StartUpdateAsync(rgName, imageName, updateParams)); getImage = (await ImagesOperations.GetAsync(rgName, imageName)).Value; Assert.True(getImage.Tags.ContainsKey(tagKey)); var listResponse = await(ImagesOperations.ListByResourceGroupAsync(rgName)).ToEnumerableAsync(); Assert.IsTrue(listResponse.Count() == 1); await WaitForCompletionAsync(await ImagesOperations.StartDeleteAsync(rgName, image.Value.Name)); }
public virtual ImagesUpdateOperation StartUpdate(string resourceGroupName, string imageName, ImageUpdate parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (imageName == null) { throw new ArgumentNullException(nameof(imageName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("ImagesOperations.StartUpdate"); scope.Start(); try { var originalResponse = RestClient.Update(resourceGroupName, imageName, parameters, cancellationToken); return(new ImagesUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateUpdateRequest(resourceGroupName, imageName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <ImageUpdateOperation> UpdateAsync(bool waitForCompletion, ImageUpdate parameters, CancellationToken cancellationToken = default) { if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _imageClientDiagnostics.CreateScope("Image.Update"); scope.Start(); try { var response = await _imageRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters, cancellationToken).ConfigureAwait(false); var operation = new ImageUpdateOperation(ArmClient, _imageClientDiagnostics, Pipeline, _imageRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }