Retrive Variable in a variable group using another variable - azure-devops

I have variable group variable as given below
opp453.Name = "Raj"
pqr325.Name = "Shyam"
I know can I retrieve the variable group as below
$(opp453.Name) or $(pqr325.Name)
If I have another variable
$ptrref=opp453 or
$ptrref=pqr325
Then how can I refer to this variable inside the first variable
$($ptrref.Name)
to retrieve the original value

I think this is impossible to achieve at present because Nested variables are not supported yet in build pipeline/variable group.You can check this similar thread for some more details.
We could also use the same workaround, using InlinePowershell task to determine the value of ptrref, and set the value of opp453.Name/ pqr325.Name according to the value of ptrref.

Related

How to select object attribute in ADF using variable

I'm trying to parametrize a pipeline in Azure Data Factory in order to enable a certain functionality to mulptiple environments. The idea is that the current environment is always available through a global parameter. I'd like to use this parameter to look up an array of environments to process data to. Example:
targetEnvs = [{ "dev": ["dev"], "test": ["dev", "test"], "acc": [], "prod": ["acc", "prod"] }]
Then one should be able to select the targetEnv array with something like targetEnvs[environment] or targetEnvs.environment. Subsequently a ForEach is used to execute some logic on these target environments.
I tried setting this up with targetEnvs as a pipeline parameter (with default value mapping each env directly to targetEnv, as follows: {"dev": ["dev"], "test": ["test"]}) Then I have a Set variable step to take value from the targetEnvs parameter, as follows:.
I'm now looking for a way to use the current environment (stored in a global parameter) instead of hardcoding "dev" in the Set Variable expression, but I'm not sure how to do this.
.
Using this expression won't even start the pipeline.
.
Question: how do I select this attribute of the object? Any other suggestions on how to do tackle this problem are welcome as well!
(Python analogy would be to have a dictionary target_envs and taking a value from it by using the key "current_env": target_envs[current_env].)
When I tried to access the object same as you, the same error occurred. I have taken the parameter targetEnv (given array) and global parameter environment with value as dev.
You can use the following dynamic content to access the key value.
#pipeline().parameters.targetEnv[0][pipeline().globalParameters.environment]

Is there a way in sagemath's BooleanPolynomialRing Change the value in the boolean function through the variable in the list

when we can not determine which variable will be determine by a constant,i use a list use a list to store variables ,but the BooleanPolynomialRing do not support change the BooleanPolynomial by variables in list, It seems that it can only be changed by using the variable name; but when we encounter this situation ,is there another way to solve this problem
from sage.crypto.boolean_function import BooleanFunction
R=BooleanPolynomialRing(4,"a,b,c,d")
R.inject_variables()
S=R.gens()
print(S)
f=a*b+b*c
print(f(a=1))
print(f(S[0]=1))
enter image description here

ADF Pipeline Use variable inside another Set Variable

I have two activities inside a for each
Set variable 1 - Value is a string. I want to add this string to the content of Set Variable 2
#item().MessageType (eg :- EVENT, TYPE , STATUS etc. These are the output of a dataflow activity)
Set variable 2 :
#activity('df_dataflow_activity').output.runStatus.output.CacheWaterMarkValue.value[0].EVENT
Here, I want to dynamically change the last part to EVENT,STATUS etc.
#activity('df_dataflow_activity').output.runStatus.output.CacheWaterMarkValue.value[0].{get value of Variable 1)
I tried but getting unable to parse error.
`#activity('df_dataflow_activity').output.runStatus.output.CacheWaterMarkValue.value[0].EVENT`
gives me result of 99999 . The last part EVENT/TYPE/STATUS I want it to be dynamic
Set Variable is used to store the value into a variable. You can use that variable in later activities.
You can include the variable which is used in set variable1 in set variable2.
Set variable1:
Set Variable2:
#concat('sample_',variables('var1'))

Azure-data-Factory Copy data If a certain file exists

I have many files in a blob container. However I wanted to run a Stored procedure only IF a certain file (e.g. SRManifest.csv) exists on the blob Container. I used Get metadata and IF Condition on Data Factory. Can you please help me with the dynamic script for this. I tried this #bool(startswith(
activity('Get Metadata1').output.childitems.ItemName,
'SRManifest.csv')). It doesnt work.
Then I thought, what if i used #greaterOREquals(activity('Get Metadata1').output.LastModified,adddays(utcnow(),-2))But this checks the last modified within 2 days of the Bloob not the file exist. Thank you.
Please see below my diagram
I have understood your requirement differently I think.
I wanted to run a Stored procedure only IF a certain file (e.g. SRManifest.csv) exists on the blob Container
1 Change your metadata activity to look for existence of sentinel file (SRManifest.csv)
2 Follow with an IF activity, use this condition:
3 Put your sp in the True part of the IF activity
If you also needed the file list passed to the sp then you'll need the GetMetadata with childitems option inside the IF-True activity
Based on your diagram, since you are looping over all the blob names already, you can add a Boolean variable to the pipeline and set its default value to false:
Inside the ForEach activity, you only want to attempt to set the variable if the value is still false, and if the blob name is found, set it to true. Since Set Variable cannot be self-referential, do this inside the False branch of an If activity:
This will only attempt to process if the value is false (so the file name has not been found yet), and will do nothing if the value is true. Now set the variable based on your file name:
[NOTE: This value can be hard coded, parameterized, or based on a variable]
When you execute the pipeline, you'll see the Set Variable stops attempting once the value is set to true:
In the main pipeline, after the ForEach activity has completed, you can use the variable to set the condition of your final If activity. If the blob is never found, it will still be false, so put the Stored Procedure activity inside the True branch.

Variable expression contains another variable

I am trying to put some variable inside Variable Expression of another variable.
For example:
$V{sum} = $F{quantity} * ${price}, where sum is simple variable without any calculation
$V{total} = $F{disb} * $V{price}, where total has 'Sum' calculation type.
As a result I receive the wrong amount.
But If I use:
$V{total} = $F{disb} * $F{quantity} * ${price}
the amount is valid.
Is there any reason that variable inside variable expression gives wrong value? Thank you
If you are outputting the $V{total} of your first example in a textfield, then you will need to make sure the Evaluation Time is set correctly per your report. Most likely you will want to set the field evaluation time to "Report".
The evaluation time determines when dynamically calculated variables are actually processed during the report's generation life-cycle.