Logic apps: Create Blob depending on outcome - azure-logic-apps

I was wondering if there was a way to create a single blob connector in a logic app workflow that creates the blob containing different content DEPENDING on if Logic app connectors fail.
That is (picture to show idea):

This is currently only possible via code view.
1: Modify Create blob's run-after property to
"runAfter": {
"3": [
"Failed"
]
}
2: Modify Create blob's run-after property to
"runAfter": {
"3": [
"Skipped"
]
}
Or,
"runAfter": {
"2": [
"Failed"
]
}
3, similar to #2.

Related

Encapsulate a JSON Array inside an object with JOLT?

I work on a project where the output of one of our APIs is a JSON array. I'd like to encapsulate this array inside an object.
I try to use a JOLT transformation (this is the first time I use this tool) to achieve this. I've already searched through a lot of example, but I still can't figure out what my JOLT specification has to be to perform the transformation. I can't find what I am looking for.
For example, if my input is like this:
[
{
"id": 1,
"name": "foo"
},
{
"id": 2,
"name": "bar"
}
]
I'd like the output to be:
{
"list":
[
{
"id": 1,
"name": "foo"
},
{
"id": 2,
"name": "bar"
}
]
}
In short, I just want to put my array inside a field of another object.
You can use a shift transformation spec such as
[
{
"operation": "shift",
"spec": {
"*": "list[]"
}
}
]
where "*" wildcard represents indices of the current wrapper array of objects
the demo on the site http://jolt-demo.appspot.com/ is

Is there a procedure for migrating azure logic app from one account to another account

Have two Azure accounts with different subscription, I wants to migrate azure logic app from old account to new account. Please help with the steps for migration
Navigate to your logic app, In overview pane beside subscription you can find move from where you can migrate to another account from present.
Now you can select the destination subscription and Resource group from the Subscription list and Resource group list and then select OK.
REFERENCES:
Move logic apps across subscriptions, resource groups, or regions
For Cloning
WAY - 1
One workaround that you can try is to clone the logic app into the same subscription and resource and then move to another subscription.
WAY - 2 Deploy the ARM template of your logic app to another Subscription.
Step-1
Navigate to the Export template and click deploy
Step-2
Change the subscription Id of your connectors then select the subscription and resource group to which you want to deploy.
You made a comment that you want to clone your LogicApp to another subscription/account, if the first answer isn't what you want then you can (in your words) clone the app by copying the code view and pasting it into a new LogicApp in the other subscription/account.
For example, this is a JSON definition for an extremely basic LogicApp I just created ...
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Text String",
"type": "string",
"value": "This is a test"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Month",
"interval": 12
},
"recurrence": {
"frequency": "Month",
"interval": 12
},
"type": "Recurrence"
}
}
},
"parameters": {}
}
It looks like this ...
You can literally take that JSON definition and paste it into any existing LogicApp and it will produce the same flow.

In Azure Logic App how to iterate over a dictionary

I am having a Azure logic app where I want to iterate over a dictionary as shown below.
"test": {"text1":"qabdstw1234",
"text2":"vhry46578"
},
Here, in my Logic app I am able to iterate over a list of dictionary but here I want to iterate over a dictionary.
Does anybody knows how to do it?
I have used parse JSON inorder to fetch test1 data from the JSON which you have provided and then used compose connector to get the same. Here is my Logic app :-
Here is the generated schema while using the sample JSON Payload which you have provided I'm using:-
{
"type": "object",
"properties": {
"title": {
"type": "string"
},
"text1": {
"type": "array",
"items": {
"type": "string"
}
},
"id": {
"type": "string"
},
"status": {
"type": "string"
}
}
}
Add a new action, search for Control and select the For each:
To process an array in your logic app, you can create a "Foreach" loop. This loop repeats one or more actions on each item in the array.
Source: Create loops that repeat workflow actions or process arrays in Azure Logic Apps

Microsoft Azure Search

I have a use case in which:
I want to store images in Microsoft Blob storage,
Search images by giving text input like 'water' then all images which contain water in any way should appear in the search result.
I followed below link:
https://github.com/Azure/LearnAI-Cognitive-Search/blob/master/05-Lab-2-Image-Skills.md
But here I get to know that there are only 2 predefined skills which are ImageAnalysisSkill and OcrSkill which do not give full images as the search result.
Please help...
Programatically, you can use the Image Analysis Cognitive Skill to automatically extract tags from the images.
See https://learn.microsoft.com/en-us/azure/search/cognitive-search-skill-image-analysis for more information on this skill.
Your skill would look something like this:
{ "#odata.type": "#Microsoft.Skills.Vision.ImageAnalysisSkill",
"context": "/document/normalized_images/*",
"visualFeatures": [
"Tags",
"Description"
],
"defaultLanguageCode": "en",
"inputs": [
{
"name": "image",
"source": "/document/normalized_images/*"
}
],
"outputs": [
{
"name": "tags",
"targetName": "myTags"
},
{
"name": "description",
"targetName": "myDescription"
}
]
}
Then in the index, make sure to create a field of type Collection(Edm.String) to contain the list of tags. Let's call that the imageTags field. Make sure that field is searchable.
In the output field mappings (a property of the indexer) you will need to map the list of tags to the newly created imageTags field as follows:
"outputFieldMappings": [
{
"sourceFieldName": "/document/normalized_images/*/myDescription/tags/*",
"targetFieldName": "imageTags"
}
This will ensure that each of the tags found on the images are insterted in the imageTags array.
Please also read this document that explains how to extract normalized_imagesif you are not familiar with that already: https://learn.microsoft.com/en-us/azure/search/cognitive-search-concept-image-scenarios

Restheart query for an nested array subdocument

I m working with mongodb and restheart.
In my nosql db i have a unique document with this structure:
{
"_id": "docID",
"users": [
{
"userID": "12",
"elements": [
{
"elementID": "1492446877599",
"events": [
{
"event1": "one"
},
{
"event2": "two",
}
]
}
},
{
"userID": "11",
"elements": [
{
"elementID": "14924",
"events": [
{
"event1": "one"
},
{
"event2": "two",
}
]
}
}
]
}
how can i build an url-query in order to get the user with id 11?
Using mongo shell it should be something like this one:
db.getCollection('collection').find({},{'users':{'$elemMatch':{'userID':'12'}}}).pretty()
I cannot find anything similar on restheart.
Could someone help me?
Using this
http://myHost:port/documents/docID?filter={%27users%27:{%27$elemMatch%27:{%27userID%27:%2712%27}}}
restheart returns me all the documents: userID 11 and 12.
Your request is against a document resource, i.e. the URL is http://myHost:port/documents/docID
The filter query parameter applies for collection requests, i.e. URLs such as http://myHost:port/documents
In any case you need to projection (the keys query parameter) to limit the returned properties.
You should achieve it with the following request (I haven't tried it) using the $elementMatch projection operator:
http://myHost:port/documents?keys={"users":{"$elemMatch":{"userID":"12"}}}

Resources