Trying to create a function that will take a key as a parameter and return its respective value. This value will be used in the cluster() function. This is being done, so that in the future if the cluster path changes, it can be easily updated at just 1 place, instead of 50 different places. However, I am getting errors with the below code, please refer to the screenshot:
let DictionaryFunction = (tableName:string)
{
let Dictionary = datatable(Name:string, Value:string)
[
"Key1", "Value1", //key1 would be the identifier, Value1 would be the path to actual cluster
"Key2", "Value2",
"Key3", "Value3",
"Key4", "Value4"
];
tostring(toscalar(table('Dictionary') |where Name == tableName |project tostring(Value)))
};
cluster(DictionaryFunction('Key1')).database('MyDatabase').MyTable
What you're trying to achieve isn't currently supported. That's mentioned in the documentation: "The value can't be the result of subquery evaluation."
An alternative is to programmatically generate the query text, then invoke it using the API.