我正在创建一个部署Web应用程序(Mvc Api)和逻辑应用程序的ARM模板。
我尝试在逻辑应用程序中定义HTTP操作,以便使用int[] move;
public static int makeMove(Board board, int currentPlayerColor, int maxingPlayerColor){
int score = 0;
int[] moveIndex={};
if (Rules.gameOver(board)[0]==1){
if(Rules.gameOver(board)[1] == maxingPlayerColor){
System.out.println("1");
return score = 1;
} else if(Rules.gameOver(board)[1] == Math.abs(maxingPlayerColor-1)) {
System.out.println("-1");
return score = -1;
} else{
System.out.println("0");
return score = 0;
}
} else {
int[][] availableMoves = board.availableMoves(board, currentPlayerColor);
int[] allScores = {};
System.out.println("loop length: "+ availableMoves.length);
for(int x = 0; x<availableMoves.length; x++){
Board temp = board;
if(currentPlayerColor == maxingPlayerColor){
Board.doMove(availableMoves[x], temp, 7);
} else {
Board.doMove(availableMoves[x], temp, 0);
}
System.out.println(""+x);
allScores = add(makeMove(temp,Math.abs(maxingPlayerColor-1), maxingPlayerColor), allScores);
System.out.println("allscore len "+ allScores.length);
}
if(currentPlayerColor == maxingPlayerColor){
for(int x = 0; x<allScores.length; x++){
if(score < allScores[x]){
allScores = add(score, allScores);
}
}
for(int x = 0; x<allScores.length; x++){
if(score == allScores[x]){
moveIndex = add(x,moveIndex);
}
}
System.out.println("max "+moveIndex.length);
move = availableMoves[rand.nextInt(moveIndex.length)];
} else {
for(int x = 0; x<allScores.length; x++){
if(score > allScores[x]){
score = allScores[x];
}
}
for(int x = 0; x<allScores.length; x++){
if(score == allScores[x]){
moveIndex = add(x,moveIndex);
}
}
System.out.println("min "+moveIndex.length);
move = availableMoves[rand.nextInt(moveIndex.length)];
}
}
return 0;
}
和splitOn
动态连接Api的基本Uri以及当前项的属性。基本Uri本身从ARM模板中的一组参数连接到变量@triggerBody()
。
这里是动作定义的相关剪辑:
variables('hockeyAppAPISettings').Uri
"actionName": {
"conditions": [ ],
"inputs": {
"authentication": {
"audience": "[variables('apiSettings').Authentication.Audience]",
"clientId": "[variables('apiSettings').Authentication.ClientId]",
"secret": "[variables('apiSettings').Authentication.Secret]",
"tenant": "[variables('apiSettings').Authentication.Tenant]",
"type": "ActiveDirectoryOAuth"
},
"method": "patch",
"uri": "[concat(variables('apiSettings').Uri, '/@{triggerBody()['Id']}/ScanningInProgress')]"
//"uri": "[concat(variables('apiSettings').Uri, '//@{triggerBody()[/'Id/']}//ScanningInProgress')]"
//"uri": "[concat(variables('apiSettings').Uri, '//@@{triggerBody()[/'Id/']}//ScanningInProgress')]"
},
"type": "Http"
},
部分正是我所挣扎的。我已经在不同的模式中散布了各种转义字符("uri"
和\
)。
我要么部署错误,要么部署错误,例如:
无法解析模板语言表达式 &#39;的concat(变量(&#39; apiSettings&#39;。)乌里 &#39; // @ {triggerBody()[/&#39; Id /&#39;]} // ScanningInProgress&#39;)&#39;:预期令牌 &#39; RightParenthesis&#39;和实际的标识符&#39;。请参阅 http://aka.ms/arm-template-expressions了解使用详情..&#39;。
或者,如果我使部署工作,然后在部署后查看门户中的代码,则字符串连接似乎无法正常工作。变量不会转换为其值。
我已经验证过,如果我使用以下方式直接编辑Uri(通过门户网站HTML编辑器):@
,Logic App将为来自HTTP触发器的每个项目进行补丁调用。
我做错了什么?
答案 0 :(得分:9)
你需要逃避内部单引号,即尝试
"uri": "[concat(variables('apiSettings').Uri, '/@{triggerBody()[''Id'']}/ScanningInProgress')]"
或者,您可以使用点符号来引用属性,即
"uri": "[concat(variables('apiSettings').Uri, '/@{triggerBody().Id}/ScanningInProgress')]"