Logo

dev-resources.site

for different kinds of informations.

How to edit a JSON object inside an Azure Logic App

Published at
2/10/2023
Categories
azure
cloud
json
logicapps
Author
fboucheros
Categories
4 categories in total
azure
open
cloud
open
json
open
logicapps
open
Author
10 person written this
fboucheros
open
How to edit a JSON object inside an Azure Logic App

I use Azure Logic Apps in many of my solutions, I find them so conviennant to integrate different systemes. Recently one of them was failling and by lookink at the error message: The property value exceeds the maximum allowed size, I knew what was wrong. I was tying to save a JSON object into a Storage table but one property was too long. For this particular case I didn't need the value contain in the property so the plan was to delete it. At first, I thought it wasn't possible to edit a variable of type object in a Logic Apps, but it is!

In this post I will show how to use Compose action and setProperty to perform data operations in Azure Logic Apps.

The Context

First think to know is that the Compose action does not update the the current object but creates a new one. In this demo the JSON object use is quite short to simplyfy the demo.

{   
"firstname":"Frank",    
"lastname":"Boucher",   
"alias":"fboucheros",   
"bio":"With many years of experience in the IT industry, François (Frank) Boucher is a trusted Microsoft Azure professional whose expertise and bilingual service are relied upon in large Canadian markets (Ottawa and Montreal) as well as internationally. Among his many accolades, Francois has been awarded four times Microsoft Azure MVP status, named a Microsoft Azure Advisor, and Microsoft Azure P-Seller. Frank created the “Cloud 5 minutes” show. Where every second week, a new episode that answers a different technical question, is published both in French and English (cloud5mins.com). "
}
Enter fullscreen mode Exit fullscreen mode

The Details

The Logic App recieve a JSON object from the request body. This is transfom as an Person object. To empty the bio property the action Compose will be used.

Overview of the Compose action in the LogicApp

Inside the Compose action, use the context menu to find setProperty in the Expression section. The expression setProperty takes three parameters: the object, the property name, and the edited value. In this demo the goal was to empty the property therefore and empty string will be assign like this:

setProperty(variables('Person'),'bio','').

The edited object is accessible from the output of the Compose action and this what will be return in the Response action.

Logic App closeup

The Result

By adding a single action it's possible to edit JSON object in a Logic App without requiring to use inline code or external tools. A demo wouldn't be complite without a end-to-end run so here the result of a HTTP POST to the Logic App passing the Person JSON and the returned result.

Result of HTTP call

Video version

If you prefer, I also have a video version of this post.

Useful links

~ Frank

logicapps Article's
30 articles in total
Favicon
TOP 5 Brain-Boosting Logic Games for Your Phone
Favicon
Security-First Architecture in Azure Logic Apps: Patterns, Practices, and Compliance
Favicon
Serverless Integration: Automate Your Workflow with Logic App
Favicon
Usando PAM no Linux
Favicon
Understanding the Differences between Overriding and Overloading in C#
Favicon
Add Parameters for Workflow Input in Azure Logic Apps
Favicon
AmP Credit Loan Cust0mer Care®Helpline Number-8102301568-@7061107023All problem Solhcf.
Favicon
Dynamically Parse JSON as Object or Array
Favicon
Updates to the Azure Onboarding App
Favicon
Automated Onboarding Azure Project
Favicon
Azure Logic Apps: Orchestrating Workflows with Zero Code Complexity" 🌐🔧[5/8]
Favicon
Azure Automated Onboarding Project
Favicon
Real-World Use Cases and Examples of Azure Logic Apps in Action
Favicon
Automate document processing with Form Recognizer and Logic Apps (Part 2)
Favicon
Automate document processing with Form Recognizer and Logic Apps (Part 1)
Favicon
Configuring Azure Logic App Failure Alerts To Stay Ahead
Favicon
Disabling Highly Privileged Azure AD Users with Azure Logic Apps and Microsoft Graph API
Favicon
Power Automate vs Azure Logic Apps
Favicon
How to edit a JSON object inside an Azure Logic App
Favicon
How to solve a DSA problem
Favicon
Using Logic Apps in Power Automate
Favicon
Quickly provision Logic App environment to start developing the flow
Favicon
Why you probably shouldn't use Logic Apps for enterprise integrations
Favicon
f-of-xstate: run some logic on your logic
Favicon
No-code Automation for Azure Boards Using Azure Logic Apps, Power Automate, and Power Virtual Agents
Favicon
Deploy Azure Logic Apps as code
Favicon
For loop with liquid template in Azure LogicApp
Favicon
Liquid template in Logic App
Favicon
Get Logic App Workflow using REST API (Postman)
Favicon
Parameterising Logic App (Standard) connections.json with bicep - Part 3

Featured ones: