Repository navigation
Expand file tree
/
Copy pathRemove-FabricApacheAirflowJob.ps1
More file actions
64 lines (54 loc) · 2.59 KB
/
Copy pathRemove-FabricApacheAirflowJob.ps1
File metadata and controls
64 lines (54 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<#
.SYNOPSIS
Removes an Apache Airflow Job from a specified Microsoft Fabric workspace.
.DESCRIPTION
This function deletes an Apache Airflow Job from a Microsoft Fabric workspace by performing a DELETE request
to the Fabric API. It requires the workspace and job identifiers, validates authentication, and handles errors.
.PARAMETER WorkspaceId
The unique identifier of the workspace containing the Apache Airflow Job to be removed.
.PARAMETER ApacheAirflowJobId
The unique identifier of the Apache Airflow Job to remove.
.EXAMPLE
Remove-FabricApacheAirflowJob -WorkspaceId "workspace-12345" -ApacheAirflowJobId "airflowjob-67890"
Removes the Apache Airflow Job with ID "airflowjob-67890" from the workspace with ID "workspace-12345".
.NOTES
- Requires the `$FabricConfig` global variable, which must include `BaseUrl` and `FabricHeaders`.
- Validates authentication by calling `Test-TokenExpired` before making the API request.
- Author: Tiago Balabuch
#>
function Remove-FabricApacheAirflowJob {
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
param (
[Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[string]$WorkspaceId,
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateNotNullOrEmpty()]
[Alias('id')]
[string]$ApacheAirflowJobId
)
process {
try {
# Validate authentication
Invoke-FabricAuthCheck -ThrowOnFailure
# Construct the API endpoint URI
$apiEndpointURI = New-FabricAPIUri -Resource 'workspaces' -WorkspaceId $WorkspaceId -Subresource 'ApacheAirflowJobs' -ItemId $ApacheAirflowJobId
if ($PSCmdlet.ShouldProcess("Apache Airflow Job '$ApacheAirflowJobId' in workspace '$WorkspaceId'", "Delete")) {
# Make the API request
$apiParams = @{
Headers = $script:FabricAuthContext.FabricHeaders
BaseURI = $apiEndpointURI
Method = 'Delete'
}
$response = Invoke-FabricAPIRequest @apiParams
Write-FabricLog -Message "Apache Airflow Job '$ApacheAirflowJobId' deleted successfully from workspace '$WorkspaceId'." -Level Host
$response
}
}
catch {
# Log and handle errors
$errorDetails = $_.Exception.Message
Write-FabricLog -Message "Failed to delete Apache Airflow Job '$ApacheAirflowJobId' from workspace '$WorkspaceId'. Error: $errorDetails" -Level Error
}
}
}