Multiple values within multiplier in azure pipeline task - azure

Here is my case :
enter image description here
I'm trying to deploy parallely two applications within one stage inside of azure release pipeline with help of multi-configuration parallelization. To do that I need 2 sets of values to fill required parameters let's say (x1,y1,z1) and (x2,y2,z2) . When I create 3 multipliers for that (x,y,z) it goes with each combination of them (x1,y1,z2) for example - is there a way to nest values inside of multipliers ?
Let's say declare one multiplier variable - "application" with values presenting this way :
{
app1:{x1,y1,z1},
app2:{x2,y2,z2}
}

Related

Trying to Add more than 2 variables in Logic App Cosmos DB

Requirement in Logic App : Need to add 4 variables into a single variable.
I am using the expression Add(Variable1, variable2, variable3, variable4)
But it throws the below error.
Is there any other way to add 4 variables(int).
Compound them, i.e. use this concept ...
add(add(add(variables('Number 1'), variables('Number 2')), variables('Number 3')), variables('Number 4'))
This test flow ...
... gives me this result when I add them using that compound approach ...
However, if the amount of numbers you're adding is dynamic, you may need to loop.
Since Add()'s synatx is Add(summand1,summand2), you can do something like below
Add(variables('Variable1'),Add(variables('Variable2'),Add(variables('Variable3'),variables('Variable4'))))
Here is my logic app
RESULT:

Update a parameter value in Brightway

It seems to be a simple question but I have a hard time to find an answer to it. I already have a project with several parameters (project and database parameters). I would like to obtain the LCA results for several scenarios with my parameters having different values each time. I was thinking of the following simple procedure:
change the parameters' value,
update the exchanges in my project,
calculate the LCA results.
I know that the answer should be in the documentation somewhere, but I have a hard time to understand how I should apply it to my ProjectParameters, DatabaseParameters and ActivityParameters.
Thanks in advance!
EDIT: Thanks to #Nabla, I was able to come up with this:
For ProjectParameter
for pjparam in ProjectParameter.select():
if pjparam.name=='my_param_name':
break
pjparam.amount = 3
pjparam.save()
bw.parameters.recalculate()
For DatabaseParameter
for dbparam in DatabaseParameter.select():
if dbparam.name=='my_param_name':
break
dbparam.amount = 3
dbparam.save()
bw.parameters.recalculate()
For ActivityParameter
for param in ActivityParameter.select():
if param.name=='my_param_name':
break
param.amount = 3
param.save()
param.recalculate_exchanges(param.group)
You could import DatabaseParameter and ActivityParameter iterate until you find the parameter you want to change, update the value, save it and recalculate the exchanges. I think you need to do it in tiers. First you update the project parameters (if any) then the database parameters that may depend on project parameters and then the activity parameters that depend on them.
A simplified case without project parameters:
from bw2data.parameters import ActivityParameter,DatabaseParameter
# find the database parameter to be updated
for dbparam in DatabaseParameter.select():
if (dbparam.database == uncertain_db.name) and (dbparam.name=='foo'):
break
dbparam.amount = 3
dbparam.save()
#there is also this method if foruma depend on something else
#dbparam.recalculate(uncertain_db.name)
# here updating the exchanges of a particular activity (act)
for param in ActivityParameter.select():
if param.group == ":".join(act.key):
param.recalculate_exchanges(param.group)
you may want to update all the activities in the project instead of a single one like in the example. you just need to change the condition when looping through the activity parameters.

How to Use a Key Vault Secret in a Task Group Without Creating a Task Group Parameter

I have a task group in Azure DevOps that does the following tasks (among other tasks):
1 - Read secrets from a Key Vault
2 - Set/Update an application's setting to a secret from the key vault
[
{
"name": "Foo",
"value": "$(FooKeyVaultKey)",
"slotSetting": false
}
]
The only parameter I want in the task group given the above tasks is the name of the key vault where it takes the secrets from. The probem is, since the second task uses a variable (which is set by task 1), the task group creates a new parameter called "FooKeyVaultKey".
I tried accessing the variables in different ways, but only using parentheses works.
$(FooKeyVaultKey) - works, but creates parameter
${{FooKeyVaultKey}} - doesn't work
${FooKeyVaultKey} - doesn't work
$[FooKeyVaultKey] - doesn't work
Simple trick is to use a blank expression (microsoft calls it a macro syntax) nested in the variable expression:
$($()foo)
This way a parameter isn't created for the task group.
EDIT:
I noticed some inconsistent behavior where at times the app configuration would be set to literally $($()foo).
This is not possible what you are trying achieve. This is written in the documentation
All the '$(vars)' from the underlying tasks, excluding the predefined variables, will surface as the mandatory parameters for the newly created task group.
For example, let's say you have a task input $(foobar), which you don't intend to parameterize. However, when you create a task group, the task input is converted into task group parameter 'foobar'. Now, you can provide the default value for the task group parameter 'foobar' as $(foobar). This ensures that at runtime, the expanded task gets the same input it's intended to.

How to append array data to array variable in logic app?

I'm calling API using HTTP connector getting result array data. and used until loop. so every time i will get some records into result array.
Now I want to append all records so that i will those all.
Like 1st time i got 2 records like below and 2nd time 1 then I want to append so that it will be 3 total.
1st iteration result -
"results":[
{"id":"2","name":"t1"},{"id":"3","name":"t4"}
]
2nd iteration result -
"results":[
{"id":"66","name":"i7"}]
I want to append all data so that final result will be like -
[{"id":"2","name":"t1"},{"id":"3","name":"t4"}, {"id":"66","name":"i7"}]
instead of foreach I tried using append array variable but it throws below error -
its a type of array need to be string to append.
I can able to achieve it using foreach but it does not make sense just to add values use foreach instead if we found any way to directly add array it will be great.
You can use JS inline code to implement your requirement. I did some test on my side, post to arrays(result1 and result2) to logic app and compose them using JS :
Result :
Please note if you want to use this feature , you should create an integration account and associated with your logic app in "Workflow settings" blade .
The above solution works only if you have integration account.
Other simple option - use union function inside compose action to append two array collections:
union(variables('ResponseArray'),body('Response'))
https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#union

How to assign individual attributes to Any Logic Agents

I would like to solve the following issue:
agent based model with a population of 500 agents
each agent gets assigned with an ID number using a variable called v_agentID using the order v_agentID++; after being created
The agent should then be further processed based on a condition monitoring the individual waiting time
How can I assign individual attributes like waiting times (as a result of the calculation waitingTime=waitingTimeEnd-waitingTimeStart)to each individual agent?
Thanks a lot for your help.
Bastian
Many ways:
1) create a cyclical event on the individual agent that calculates waitingTime with the formula you provided
2) create a dynamic variable for each agent and make it equal to waitingTimeEnd-waitingTimeStart
3) create the variable whenever you want and change it in all the agents:
for(Agent a : agents){
a.waitingTime=a.waitingTimeEnd-a.waitingTimeStart;
}
4) Find the agent with the id you want and assign the variable to it
Agent theAgent=findFirst(agents,a->a.id=theIdYouWant);
theAgent.waitingTime=theAgent.waitingTimeEnd-theAgent-waitingTimeStart;
5) If you know the index of the agent just do
agents.get(index).waitingTime=agents.get(index).waitingTimeEnd-agents.get(index).waitingTimeStart

Resources