Azure Logic App tips and tricks


  1. Introduction
  2. Generate guid id
  3. Enable foreach parallelism
  4. ADO pagination
  5. Spaces in ADO names
  6. Alternative queries
  7. Resume
  8. Links


Here are several tips and advices for using the Azure Logic App. Some workflows are not obvious. Hope it will help you save your time.

Generate guid id

To insert a new document in a cosmos collection you have to use an id. However, if you use guid() function inside the document template it will work only in case of non-id PK (partition key). But for most cases, PK should be an id. Hence you should use the same guid in both the document and partition key, it is obvious. If call guid() twice, two different guids will be returned.

Using guid() twice. Improper way

To solve this problem, we have to generate a guid before the insertion. To do it, use Compose logic block.

Compose block for generating a guid usage.

After that, we can use pre defined value inside the insertion block.

The proper way to generate a guid for Partition Key

P.S. do not forget to set quotes around partition key value, or you will face with a weird error 🙂

Enable foreach parallelism

If you work with a set of documents you usually use Foreach block. Assume a case you need to make a query inside the loop.

Make additional query inside a loop

In case of many ADO items Foreach block will literally DDOS ADO server. It will cause error 429 (too many requests). To reduce amount of requests we can adjust the level of the parallelism for a loop.

Foreach block default concurrency settings.
Foreach block non-parallel consequentially settings.

This setup works much longer, of course but ADO server will swallow all of them.

In addition, if you ADO server has an aggressive firewall setup you can add a delay block inside a loop to reduce a frequency of sending requests.

Loop with inner Delay block.

ADO pagination

In case of your ADO query returns more than 1k items you have to configure ADO query block to handle this situation. To do it open settings and set page size.

ADO query block settings

A problem here can be there if you set maximum threshold (1k). In this case block returns an error. So use small page size like here: 100.

Spaces in ADO names

If you ADO organisation or project has spaces in name then you have to escape spaces with %20. Just like that:

ADO project name space escaping

Alternative queries

Escape is good but it could be a nightmare when you handle big query (SQL or Kusto). In this case I recommend to use a conditional block and not try to escape all the lines of a query and inline it.

Conditional query run


Azure logic apps platform might be useful if you need fast development or you ask one junior do to stuff. Of course it has some not obvious things and even pitfalls. Some of them I’d faced with I presented here. If I find new I also write it down and post in my twitter (you can follow one:).

Read other Azure related articles by tag Azure

Leave a Reply