Update Tags to multiple Logic Apps using REST API

Published Sep 29 2021 11:26 PM 1,018 Views
Microsoft

Tags are a crucial part of organizing your Azure resources into a taxonomy No matter how or why you use tags, it's important that you can quickly add, change, and remove those tags on your Azure resources. We can apply tags to Azure resources, resource groups, and subscriptions to logically organize them. Each tag consists of a name and a value pair.

 

In this blog let’s see how to add tags to multiple Logic Apps using REST API,

 

REST API to update tags at scope:                 

Below REST API creates or updates the tags on a resource group

https://management.azure.com/subscriptions/{subscriptionid}/resourcegroups/{resourcegroup}/providers...

Below REST API creates or updates the tags on a subscription

https://management.azure.com/subscriptions/{subscriptionid}/providers/Microsoft.Resources/tags/defau...

 

Joyce_Dorothy_4-1632947589692.png

 

Get the list of workflows using the below Graph API where we need to apply the tags.

https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2018-09-01-prev...

 

Joyce_Dorothy_5-1632947589697.png

 

Update the retrieved workflow names to an array variable.

Note: Initialize an Integer variable (int_Index) with value ‘0’ and also initialize an Array variable(Array_workflow) with null value. Count represents the number of LogicApps workflow available in the provided subscription.

The field count can be retrieved from the raw output of ‘Get Workflows’ action. Use ‘Parse JSON’ action to retrieve only the count property.

 

Joyce_Dorothy_6-1632947589700.png

 

Within for-each loop, use the below REST API to apply tags at the workflows

https://management.azure.com/subscriptions/17374829-58e6-426f-ae3b-007191bf70b5/resourcegroups/Logic...

Note: Initialize an Integer variable (int_workflow) with value ‘0’ before using it inside the For-each loop.

 

Joyce_Dorothy_7-1632947589705.png

 

 

DisclaimerManaged Integration Service Environment connectors currently don't support tags

https://docs.microsoft.com/en-us/azure/logic-apps/add-artifacts-integration-service-environment-ise

%3CLINGO-SUB%20id%3D%22lingo-sub-2796941%22%20slang%3D%22en-US%22%3EUpdate%20Tags%20to%20multiple%20Logic%20Apps%20using%20REST%20API%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2796941%22%20slang%3D%22en-US%22%3E%3CP%3E%3CFONT%20size%3D%222%22%3ETags%20are%20a%20crucial%20part%20of%20organizing%20your%20Azure%20resources%20into%20a%20taxonomy%20No%20matter%20how%20or%20why%20you%20use%20tags%2C%20it's%20important%20that%20you%20can%20quickly%20add%2C%20change%2C%20and%20remove%20those%20tags%20on%20your%20Azure%20resources.%26nbsp%3B%3C%2FFONT%3E%3CFONT%20size%3D%222%22%3EWe%20can%20apply%20tags%20to%20Azure%20resources%2C%20resource%20groups%2C%20and%20subscriptions%20to%20logically%20organize%20them.%20Each%20tag%20consists%20of%20a%20name%20and%20a%20value%20pair.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EIn%20this%20blog%20let%E2%80%99s%20see%20how%20to%20add%20tags%20to%20multiple%20Logic%20Apps%20using%20REST%20API%2C%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSTRONG%3EREST%20API%20to%20update%20tags%20at%20scope%3A%3C%2FSTRONG%3E%3C%2FFONT%3E%3CFONT%20size%3D%222%22%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EBelow%20REST%20API%20creates%20or%20updates%20the%20tags%20on%20a%20resource%20group%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CA%20title%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%7Bsubscriptionid%7D%2Fresourcegroups%2F%7Bresourcegroup%7D%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%22%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%257bsubscriptionid%257d%2Fresourcegroups%2F%257bresourcegroup%257d%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%7Bsubscriptionid%7D%2Fresourcegroups%2F%7Bresourcegroup%7D%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EBelow%20REST%20API%20creates%20or%20updates%20the%20tags%20on%20a%20subscription%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CA%20title%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%7Bsubscriptionid%7D%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%22%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%257bsubscriptionid%257d%2Fresourcegroups%2F%257bresourcegroup%257d%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F%7Bsubscriptionid%7D%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Joyce_Dorothy_4-1632947589692.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F313772i6DB5F421D817BCBA%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Joyce_Dorothy_4-1632947589692.png%22%20alt%3D%22Joyce_Dorothy_4-1632947589692.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CFONT%20size%3D%222%22%3EGet%20the%20list%20of%20workflows%20using%20the%20below%20Graph%20API%20where%20we%20need%20to%20apply%20the%20tags.%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CA%20title%3D%22https%3A%2F%2Fmanagement.azure.com%2Fproviders%2FMicrosoft.ResourceGraph%2Fresources%3Fapi-version%3D2018-09-01-preview%22%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Fproviders%2FMicrosoft.ResourceGraph%2Fresources%3Fapi-version%3D2018-09-01-preview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Fproviders%2FMicrosoft.ResourceGraph%2Fresources%3Fapi-version%3D2018-09-01-preview%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Joyce_Dorothy_5-1632947589697.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F313773i8C67BFA1E1794086%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Joyce_Dorothy_5-1632947589697.png%22%20alt%3D%22Joyce_Dorothy_5-1632947589697.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CFONT%20size%3D%222%22%3EUpdate%20the%20retrieved%20workflow%20names%20to%20an%20array%20variable.%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%3A%20Initialize%20an%20Integer%20variable%20(int_Index)%20with%20value%20%E2%80%980%E2%80%99%20and%20also%20initialize%20an%20Array%20variable(Array_workflow)%20with%20null%20value.%20Count%20represents%20the%20number%20of%20LogicApps%20workflow%20available%20in%20the%20provided%20subscription.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3EThe%20field%20count%20can%20be%20retrieved%20from%20the%20raw%20output%20of%20%E2%80%98Get%20Workflows%E2%80%99%20action.%20Use%20%E2%80%98Parse%20JSON%E2%80%99%20action%20to%20retrieve%20only%20the%20count%20property.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Joyce_Dorothy_6-1632947589700.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F313771iD12FC17D4EBF2194%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Joyce_Dorothy_6-1632947589700.png%22%20alt%3D%22Joyce_Dorothy_6-1632947589700.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CFONT%20size%3D%222%22%3EWithin%20for-each%20loop%2C%20use%20the%20below%20REST%20API%20to%20apply%20tags%20at%20the%20workflows%3C%2FFONT%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3E%3CA%20title%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F17374829-58e6-426f-ae3b-007191bf70b5%2Fresourcegroups%2FLogicAppConsumption%2Fproviders%2FMicrosoft.Logic%2Fworkflows%2F%40%7Bvariables('Array_workflow')%5Bvariables('int_workflow')%5D%7D%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%22%20href%3D%22https%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F17374829-58e6-426f-ae3b-007191bf70b5%2Fresourcegroups%2FLogicAppConsumption%2Fproviders%2FMicrosoft.Logic%2Fworkflows%2F%40%257bvariables('Array_workflow')%255bvariables('int_workflow')%255d%257d%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmanagement.azure.com%2Fsubscriptions%2F17374829-58e6-426f-ae3b-007191bf70b5%2Fresourcegroups%2FLogicAppConsumption%2Fproviders%2FMicrosoft.Logic%2Fworkflows%2F%40%7Bvariables('Array_workflow')%5Bvariables('int_workflow')%5D%7D%2Fproviders%2FMicrosoft.Resources%2Ftags%2Fdefault%3Fapi-version%3D2021-04-01%3C%2FA%3E%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSPAN%3E%3CSTRONG%3ENote%3C%2FSTRONG%3E%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%20Initialize%20an%20Integer%20variable%20(int_workflow)%20with%20value%20%E2%80%980%E2%80%99%20before%20using%20it%20inside%20the%20For-each%20loop.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Joyce_Dorothy_7-1632947589705.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F313775iB1B6D0F1D75C7B44%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Joyce_Dorothy_7-1632947589705.png%22%20alt%3D%22Joyce_Dorothy_7-1632947589705.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CSTRONG%3EDisclaimer%3C%2FSTRONG%3E%3A%26nbsp%3B%3CSPAN%3EManaged%20Integration%20Service%20Environment%20connectors%20currently%20don't%20support%26nbsp%3Btags%3C%2FSPAN%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20size%3D%222%22%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Flogic-apps%2Fadd-artifacts-integration-service-environment-ise%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Flogic-apps%2Fadd-artifacts-integration-service-environment-ise%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2796941%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELogic%20Apps%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Sep 29 2021 10:16 PM
Updated by: