public override void ExecuteCmdlet() { if (this.ParameterSetName.Equals(GetByResourceIdParameterSet)) { this.ResourceGroupName = ResourceIdHandler.GetResourceGroupName(ResourceId); this.Name = ResourceIdHandler.GetResourceName(ResourceId); } if (this.ParameterSetName.Equals(GetByInputObjectParameterSet)) { this.ResourceGroupName = InputObject.ResourceGroup; this.Name = InputObject.JobResource.Name; } // Initiate to delete job if (ShouldProcess(this.Name, string.Format(Resource.DeletingDataboxJob + this.Name + Resource.InResourceGroup + this.ResourceGroupName))) { JobsOperationsExtensions.Delete( DataBoxManagementClient.Jobs, ResourceGroupName, Name); if (PassThru) { WriteObject(true); } } }
/// <summary> /// This method deletes the specified job. /// </summary> private static void DeleteJob() { string resourceGroupName = "<resource-group-name>"; string jobName = "<job-name>"; // Initializes a new instance of the DataBoxManagementClient class. DataBoxManagementClient dataBoxManagementClient = InitializeDataBoxClient(); // Gets information about the specified job. JobResource jobResource = JobsOperationsExtensions.Get( dataBoxManagementClient.Jobs, resourceGroupName, jobName); if (jobResource.Status == StageName.Cancelled || jobResource.Status == StageName.Completed || jobResource.Status == StageName.CompletedWithErrors) { // Initiate delete job JobsOperationsExtensions.Delete(dataBoxManagementClient.Jobs, resourceGroupName, jobName); } }