Home > Enterprise >  how to run a When a resource event occurs based on file name?
how to run a When a resource event occurs based on file name?

Time:08-29

i have a workflow in logic app that i'd like to run based on file name. it works fine without the condition, but more than i want. so used this condition to restrict the runs of the Workflow

@or(contains(triggerBody()?['Name'],'example.csv'),contains(triggerBody()?['Name'],'Hello.csv'))

Body of the Firstelement:

   {
  "topic": "/subscriptions/5665-56-56-56-56/resourceGroups/nameResources/providers/Microsoft.Storage/storageAccounts/name",
  "subject": "/blobServices/default/containers/output/blobs/hello.csv",
  "eventType": "Microsoft.Storage.BlobCreated",
  "id": "45-45-45-45-456",
  "data": {
    "api": "PutBlob",
    "clientRequestId": "45-45-4fd8-45-45",
    "requestId": "45-45-0028-5346-45",
    "eTag": "45",
    "contentType": "text/csv",
    "contentLength": 5432,
    "blobType": "BlockBlob",
    "blobUrl": "https://name.blob.core.windows.net/output/hello.csv",
    "url": "https://name.blob.core.windows.net/output/hello.csv",
    "sequencer": "66666",
    "identity": "$superuser",
    "storageDiagnostics": {
      "batchId": "66-66-66-66-66"
    }
  },
  "dataVersion": "",
  "metadataVersion": "1",
  "eventTime": "time"
}

The Workflow:

enter image description here

is this condition based on the filename correct?

CodePudding user response:

I'd suggest trying something like this ...

@or(contains(string(triggerBody()),'example.csv'),contains(string(triggerBody()),'Hello.csv'))

Simplifies having to traverse the JSON structure.

I tested that concept and it worked for me.

  • Related