Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use multiple --filters for datafactory pipeline-run query-by-factory #6959

Open
hwwilliams opened this issue Nov 7, 2023 · 5 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Data Factory question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@hwwilliams
Copy link

hwwilliams commented Nov 7, 2023

Describe the bug

Documentation mentions that --filters can be used multiple times but does not describe how.

Related command

az datafactory pipeline-run query-by-factory

Errors

None of these commands work.

az datafactory pipeline-run query-by-factory `
    --factory-name $DataFactoryName `
    --resource-group $ResourceGroupName `
    --filters operand="Status" operator="Equals" values="InProgress" `
    --filters operand="Status" operator="Equals" values="Queued" `
    --last-updated-after ((Get-Date).AddDays(-1) | Get-Date -Format "o" -AsUTC) `
    --last-updated-before (Get-Date -Format "o" -AsUTC)

az datafactory pipeline-run query-by-factory `
    --factory-name $DataFactoryName `
    --resource-group $ResourceGroupName `
    --filters operand="Status" operator="Equals" values="InProgress" operand="Status" operator="Equals" values="Queued" `
    --last-updated-after ((Get-Date).AddDays(-1) | Get-Date -Format "o" -AsUTC) `
    --last-updated-before (Get-Date -Format "o" -AsUTC)

az datafactory pipeline-run query-by-factory `
    --factory-name $DataFactoryName `
    --resource-group $ResourceGroupName `
    --filters operand="Status" operator="Equals" values="InProgress" values="Queued" `
    --last-updated-after ((Get-Date).AddDays(-1) | Get-Date -Format "o" -AsUTC) `
    --last-updated-before (Get-Date -Format "o" -AsUTC)

az datafactory pipeline-run query-by-factory `
    --factory-name $DataFactoryName `
    --resource-group $ResourceGroupName `
    --filters operand="Status" operator="Equals" values="InProgress,Queued" `
    --last-updated-after ((Get-Date).AddDays(-1) | Get-Date -Format "o" -AsUTC) `
    --last-updated-before (Get-Date -Format "o" -AsUTC)

az datafactory pipeline-run query-by-factory `
    --factory-name $DataFactoryName `
    --resource-group $ResourceGroupName `
    --filters operand="Status" operator="Equals" values="InProgress Queued" `
    --last-updated-after ((Get-Date).AddDays(-1) | Get-Date -Format "o" -AsUTC) `
    --last-updated-before (Get-Date -Format "o" -AsUTC)

Issue script & Debug output

N/A

Expected behavior

I expect the features described in the documentation to be available and readable.

Environment Summary

azure-cli 2.53.0 *

core 2.53.0 *
telemetry 1.1.0

Extensions:
datafactory 0.9.0

Dependencies:
msal 1.24.0b2
azure-mgmt-resource 23.1.0b2

Python (Windows) 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:05:00) [MSC v.1929 32 bit (Intel)]

Additional context

No response

@hwwilliams hwwilliams added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Nov 7, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Nov 7, 2023
@yonzhan
Copy link
Collaborator

yonzhan commented Nov 7, 2023

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan added Data Factory Service Attention This issue is responsible by Azure service team. and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Nov 7, 2023
@hwwilliams
Copy link
Author

Any update on this?

@hwwilliams
Copy link
Author

I have also tried using the operator Contains as I saw in other parts of the Azure CLI that use the --filters option that this operator works but it failed to work here as I get an error.

image

I saw on this line that the operator In may be allowed which does not result in an error but then I don't know how to write the values="" argument to accept multiple values.

@EntityAdam
Copy link

EntityAdam commented Nov 30, 2023

I'm no python expert, but it appears as there isn't a way for argparse to allow multiple values in this manner (CSV example):

--filters operand="Status" operator="Equals" values="InProgress,Queued"

Since there's no way to pass in multiple values here, this does not allow anyone to use the 'In' operator.

It seems other parameters in the extension are allowing json objects as values which could resolve this issue.

ex;

PowerShell

--filters "@filter1.json" # az cli @<file> syntax

filter1.json

{
  "values": [
    "IngestPipeline",
    "TransformPipeline"
  ],
  "operand": "PipelineName",
  "operator": "In"
}

@EntityAdam
Copy link

If you're looking for a work-around, dropping down to the AzureRM REST API is always an option:

AzureRM REST with PowerShell example

# requires: Az modules
#  -- Install-Module -Name Az -Repository PSGallery -Force
# requires: Log in
#  -- Connect-AzAccount

$subscriptionId = "{id}"
$resourceGroupName = "{rgp-name}"
$factoryName = "{df-name}"
$lastUpdatedAfter = ((Get-Date).AddDays(-1) | Get-Date -Format "o" -AsUTC)
$lastUpdatedBefore = (Get-Date -Format "o" -AsUTC)
$path = "/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.DataFactory/factories/${factoryName}/queryPipelineRuns?api-version=2018-06-01"

$filters = @(
    @{
      operand = "Status"
      operator = "equals"
      values = @("Failed")
    }
    @{
      operand = "PipelineName"
      operator = "In"
      values = @("MyIngestPipeline", "MyTransformPipeline")
    }
)

$body = @{
  lastUpdatedAfter = $lastUpdatedAfter
  lastUpdatedBefore = $lastUpdatedBefore
  filters = $filters
} | ConvertTo-Json -Depth 3


$response = Invoke-AzRestMethod -Path ${path} -Method POST -Payload $body
$response.content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Data Factory question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

4 participants