How to get Resource Group name from within Logic App - azure-logic-apps

In an Azure Logic App, how can I get the name of the Resource Group containing the current logic app?
I want to include some tracking details in the JSON output that I am sending to another system.
I can get the run Identifier ( using #{workflow()['run']['name']} ),
and the current logic app name ( using #{workflow()['name']} )
However, I cant work out how to get the name of the resource group to which the logic app is deployed.
As a last resort, I will use the resource group name used by the deployment template, but that will be wrong if the logic app is moved later.
I could also use tags, but again that could get out of step if the logic app is moved.
Thanks

A simple formula may be:
split(workflow().id, "/")[4]

If you're deploying the Logic Apps using ARM templates (e.g. edit in Visual Studio, check into Azure DevOps git repo and deploy using release pipeline), you can create an ARM parameter:
"resGroup_ARM": {
"type": "string",
"defaultValue": "[resourceGroup().name]",
"metadata": {
"description": "Resouce group name"
}
}
Then, you can create a workflow parameter:
"resGroup_LA": {
"type": "string",
"defaultValue": "ResGroup LA default"
}
... and give it a value in the parameters initialisation section:
"resGroup_LA": {
"value": "[parameters('resGroup_ARM')]"
}
You can get all the other properties of resourceGroup() in a similar manner, see: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource?tabs=json#resourcegroup

First we can create a "Initialize variable" action to get all of the data in workflow, shown as below screenshot:
Then we can find the data in workflow is:
{
"id": "/subscriptions/*****/resourceGroups/huryTest/providers/Microsoft.Logic/workflows/hurylogicblob",
"name": "hurylogicblob",
"type": "Microsoft.Logic/workflows",
"location": "eastus",
"tags": {},
"run": {
"id": "/subscriptions/*****/resourceGroups/huryTest/providers/Microsoft.Logic/workflows/hurylogicblob/runs/*****",
"name": "*****",
"type": "Microsoft.Logic/workflows/runs"
}
}
It contains the resource group name, so we just need to get the property "id" and substring it to get resource group name. The length of "resourceGroups/" is 15, so in the expression below I use add(,15) and sub(,15).
You can use the expression as below:
substring(workflow()['id'],add(indexOf(workflow()['id'],'resourceGroups/'),15),sub(sub(indexOf(workflow()['id'],'/providers'),indexOf(workflow()['id'],'resourceGroups/')),15))
At last, I got the resource group name of the logic app:

Related

Azure Cognitive Search query specific data source

I have a Azure Cognitive Search set up with two DataSources, two Indexers indexing those DataSources and one Index.
I'd like to be able to able to query/filter by DataSource. Is that possible?
This is certainly possible. You'd just need to find a way to get a field in the index that contains the name of the data source. The best way to do this depends on the data source you're using--for example, if you're using a SQL data source, you might just be able to edit the query to return the value whereas that wouldn't work for blob storage.
Another option that would work for all data sources would be to include a skillset with a conditional skill which you can use to set a default value for a field.
Off of #Derek Legenzoff serve this is how I did it...
Add all your datasources
Create skillsets for each one data source with the following skill
{
"#odata.type": "#Microsoft.Skills.Util.ConditionalSkill",
"name": "#1",
"description": "",
"context": "/document",
"inputs": [
{
"name": "condition",
"source": "= true"
},
{
"name": "whenTrue",
"source": "= 'Production'" //name of your environment
},
{
"name": "whenFalse",
"source": "= ''"
}
],
"outputs": [
{
"name": "output",
"targetName": "Env"
}
]
}
Create single index for your data model and add a Env field, and it's filterable and queriable
Create indexers for each one of your data sources that point to the index from step 3 and datasource from step 1
IMPORTANT: make sure you indexers have the following code in the defnition.
"outputFieldMappings": [
{
"sourceFieldName": "/document/Env",
"targetFieldName": "Env"
}
],
This will connect the product of the skill to the index

Best Firestore data model for file tree data

I'm currently building an app that needs to store data with a similar structure as a file tree. It looks something like this:
{
"type": "folder",
"name": "folder A",
"private": false,
"updatedAt": 1231243,
"items": [
{
"type": "folder",
"name": "subfolder A",
"private": false,
"updatedAt": 1231243,
"items": [
{
"type": "file",
"name": "file1"
}
]
},
{
"type": "file",
"name": "file2"
}
]
}
What I'm aware so far, there are 3 ways of implementing this.
Just dump all the data in 1 doc
Create a subcollection for each items array
Create a flat folder structure and save the parent folder id for lookup
I'm looking for a way to get all of this data with as minimum query as possible, the ideal use case would be only having the root folder id and getting all the subfolder & items. But I'm not sure if that's possible.
Also, I'm planning to subscribe to the data in the future, so the file tree will be updated in real-time.
Please give me a suggestion on what should the data model looks like
Update 1
To give more clarification about the query that I will need:
I will only need to get the topmost folder (folder A) in this example and the items under it
I won't need to get the nested items directly
example: getting Subfolder A / File 2 without accessing Folder A
If all you need is to get the entire structure by some unique ID, just put it all in one document, and get() it using the known ID. You have a 1MB limit per document.
It can get more complicated if you need to access items within lists (which is not really possible to do without reading the entire document), so this would actually be a bad idea for that case.
You would also want to reconsider this if you intend to update the elements of this document frequently, as there is a limit of 1 write per second (sustained). You would want to split it up otherwise.

What is the meaning here list in array calling

Below I have environment file and recipe can you explain I am not getting what is the list here.
{
"json_class": "Chef::Environment",
"description": "prod environment",
"default_attributes": {
},
"chef_type": "environment",
"override_attributes": {
"user": {
"mapr": {
"id": "application",
"group": "application",
},
"local" : {
"id": "chef",
"group": "chef"
},
"ldap" : {
"id": "ldap",
"sudo": true,
},
}
"name": "prod"
}
Below is the recipe what is the list here i did not get
node['user_create'].each do |list, user|
group user['group'] do
group_name user['group']
gid user['gid']
action [:create]
ignore_failure true
end
user user do
username user['id']
uid user['uid']
group user['gid']
home user['home']
manage_home true
end
if list !='ldap'
How list is passing here in if condition
You are not actually passing in any attributes via the environment, which you can see because the values of default_attributes and override_attributes are both just empty hashes { }. The data you've included there is just ignored by Chef as noise. In the future I recommend you use the Ruby DSL for environment files as it has more error checking for things like this (though not perfect error checking).
As an aside, you've been asking a lot of questions on here and seem to be struggling with Chef. Please consider joining the Chef community Slack team and asking there instead as it's a full chat system and thus the community could offer real-time help rather than here random blurbs.

custom property in LRS & Tincan API

is it possible to add custom property to "Actor" via Tincan API to save it
in LRS.
Detail:
i am using Learning Locker as LRS system & Tincan API of Drupal & as its known there are 3 object inside the statement record that is saved in LRS which are [Actor - Verb - Object]
now the Actor has 2 properties which are [name - mbox]
and i tried to modify the Tincan module to add custom property which is [country] but the LRS API "Learning Locker" refused it.
so is there a custom way to additional properties so that i can filter with later like [age - gender - country] or its standard API strict on the defined attributes
{
"version": "1.0.0",
"actor": {
"objectType": "Agent",
"name": "Creative User",
"mbox": "mailto:register#example.com"
},
"verb": {
"id": "http://adlnet.gov/expapi/verbs/action_custom_verb",
"display": {
"en-US": "action_custom_verb"
}
},
"object": {
"objectType": "Activity",
"id": "http://localhost",
"definition": {
"name": {
"en-US": "master"
}
}
},
"authority": {
"objectType": "Agent",
"name": "drupaladmin",
"mbox": "mailto:hello#learninglocker.net"
},
"stored": "2017-02-06T16:58:23.625600+00:00",
"timestamp": "2017-02-06T16:58:23.625600+00:00",
"id": "9c1d552b-c825-4403-9c89-a9381b8d5320"
}
The standard API is strict with respect to the addition of properties. And the Agent/Group objects (which are what actor can contain) do not include the ability to expand their scope.
Additional data points can be added in special properties called extensions that are available in a couple of places in the statement's objects. In this case you could use extensions in the context property's value to include your additional information about the actor. You could do this as single discrete pieces of information where each has its own extensions key, or you could use a single key that uses an object as its value and include individual pieces of information in properties of that object. For more information about extensions see: http://tincanapi.com/deep-dive-extensions/
Note that extensions keys are not filterable via the /statements stream resource, so any querying based off of their key or value will have to be done through other means than the specification's API.

Selenium IDE cannot find ID

I recorded a test with Selenium IDE but when I try to run the test I get an error [error] Element id=jsonform-0-elt-businessActor not found
I also noticed this particular field's id is slightly different.. The rest of the fields have this format id=jsonform-0-elt-0.nameOfJsonAttribute
Could there be any reason why the bussinessActor ID is not working and captured differently?
JsonSchema used to render the form:
{
"type":"object",
"id": "001",
"title": "testSchema",
"properties":{
"businessActor": {
"type":"string",
"title": "Name",
"description": "example of a description."
}
}
}
Note: Am using jsonForm to render the form based on json shema. Form id's are generated dynamically by jsonFom. And am also using Angular.js (angular is not playing a role in this aprticular issue, I think)
As #MarkRowlands suggested, it sounds like your page is dynamic.
Try this out as your target...
css=[id^='jsonform'][id$='businessActor']
^= means 'starts with' in css. $= means 'ends with' in css.
Change that selector to match whatever you would like to select.

Resources