0

Background

  • I have an application which get list of runbooks jobs using REST API
  • I would like to apply $filter on properties parameters(see JSON in the end). Parameters is of type IDictionary<string,string>

Issue

  • $filter works fine for most of the properties but fails for IDictionary<string,string>
  • This is what I am trying https://management.azure.com/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/XXX/jobs?$filter=properties/parameters/any(keyValue: keyValue/owner eq 'Adam@test.com')&api-version=2015-10-31
  • Request fails with error { "code": "BadRequest", "message": "Could not find a property named 'owner' on type 'System.Collections.Generic.KeyValuePair_2OfString_String'." }

Question

  • Is it possible to filter what I am trying?
  • If yes, then what I am doing wrong?

JSON response on which I want to apply filter

"value": [
        {
            "id": "/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/XXX/jobs/XXX",
            "properties": {
                "jobId": "XXX",
                "runbook": {
                    "name": "HelloWorldRunbook"
                },
                "schedule": null,
                "provisioningState": "Succeeded",
                "status": "Completed",
                "creationTime": "2018-06-17T05:44:12.197+00:00",
                "startTime": "2018-06-17T05:44:21.227+00:00",
                "lastModifiedTime": "2018-06-17T05:44:43.43+00:00",
                "endTime": "2018-06-17T05:44:43.43+00:00",
                "jobScheduleId": "7fc134ac-d8bd-464e-b041-6e6b50f83f0c",
                "runOn": null,
                "parameters": {
                  "Owner": "Adam@test.com",
                  "mailBox": "test_mailbox@test.com"
             }
            }
 ............removed for brevity
shobhit vaish
  • 951
  • 8
  • 22
  • I try to test the [List Job By Automation Account Rest API](https://learn.microsoft.com/en-us/rest/api/automation/job/listbyautomationaccount), but there is no `parameters` returned in the response body. I test with powershell command in the runbook with script that required parameters. Would mind sharing your runbook script demo code that could get the parameters in the response? – Tom Sun - MSFT Jun 18 '18 at 07:33
  • @TomSun Thanks for your response! I assumed that there is `parameters` property somewhere in backend because they are returned when you try this [API](https://learn.microsoft.com/en-us/rest/api/automation/job/get). Sorry if my assumption does not make sense? – shobhit vaish Jun 18 '18 at 17:26

1 Answers1

0

When I try to run List Job By Automation Account Rest API, there is no properties parameters returned in the response body.

If yes, then what I am doing wrong?

  ...
  "parameters": {
                  "Owner": "Adam@test.com",
                  "mailBox": "test_mailbox@test.com"
             }
   ...

But according to you mentioned responsed json format, the parameters properties is an object not a dictionary, so you could use $filter=properties/parameters/Owner eq 'Adam@test.com' to do that if you make sure that parameters is existed.

 Get https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs?api-version=2015-10-31&$filter=properties/parameters/Owner eq 'Adam@test.com'
Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47