public override async Task <DeleteVolumeResponse> DeleteVolume( DeleteVolumeRequest request, ServerCallContext context) { DeleteVolumeResponse response = new DeleteVolumeResponse(); var id = request.VolumeId; using (logger.BeginKeyValueScope("volume_id", id)) using (var _s = logger.StepInformation("{0}", nameof(DeleteVolume))) { try { var ctx = new Helpers.Azure.DataProviderContext <ManagedDiskConfig>(); await contextConfig.Provide(ctx); var actx = new AzureAuthConfigProviderContext { Secrets = request.ControllerDeleteSecrets }; var provisionService = provisionServiceFactory.Create(provider.Provide(actx), ctx.Result.SubscriptionId); await provisionService.DeleteAsync(AzureResourceInnerHelper.CreateForDisk( ctx.Result.SubscriptionId, ctx.Result.ResourceGroupName, id)); } catch (Exception ex) { logger.LogError(ex, "Exception in DeleteVolume"); throw new RpcException(new Status(StatusCode.Internal, ex.Message)); } _s.Commit(); } return(response); }
public override async Task <ControllerUnpublishVolumeResponse> ControllerUnpublishVolume(ControllerUnpublishVolumeRequest request, ServerCallContext context) { var response = new ControllerUnpublishVolumeResponse(); var id = request.VolumeId; using (logger.BeginKeyValueScope("volume_id", id)) using (var _s = logger.StepInformation("{0}", nameof(ControllerUnpublishVolume))) { try { var ctx = new Helpers.Azure.DataProviderContext <ManagedDiskConfig>(); await contextConfig.Provide(ctx); var actx = new AzureAuthConfigProviderContext { Secrets = request.ControllerUnpublishSecrets }; var setupService = setupServiceFactory.Create(provider.Provide(actx), ctx.Result.SubscriptionId); var vmRid = ResourceId.FromString(request.NodeId); var diskId = ResourceId.FromString(id); await setupService.RemoveAsync(vmRid, diskId); } catch (Exception ex) { logger.LogError(ex, "Exception in ControllerUnpublishVolume"); throw new RpcException(new Status(StatusCode.Internal, ex.Message)); } _s.Commit(); } return(response); }