Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
589 views
in Technique[技术] by (71.8m points)

azure devops - Unable to parse template language expression 'encodeURIComponent([parameters('table_storage_name')])'

Hey I am doing a CI/CD deployment for a logic app, I have a table storage where I store some data, I have two table storage for test and prod environment. I created a parameter called *table_storage_name" in ARM template :

"parameters": {
// ....
"connections_azuretables_1_externalid": {
   "defaultValue": "/subscriptions/e5..../resourceGroups/myrg.../providers/Microsoft.Web/connections/azuretables-1",
      "type": "String"
        },
"table_storage_name": {
          "defaultValue": "testdevops",
          "type": "String"
        }
}

The error comes from when I reference the parameter here in template.json file:

// ...
"Insert_Entity": {
  "runAfter": {
      "Initialize_variable": [
          "Succeeded"
      ]
  },
  "type": "ApiConnection",
  "inputs": {
      "body": {
          "PartitionKey": "@body('Parse_JSON')?['name']",
          "RowKey": "@body('Parse_JSON')?['last']"
      },
      "host": {
          "connection": {
              "name": "@parameters('$connections')['azuretables_1']['connectionId']"
          }
      },
      "method": "post",
      // problem occur after this line
      "path": "/Tables/@{encodeURIComponent('[parameters('table_storage_name')]')}/entities"
  }
}

but get this error:

InvalidTemplate: The template validation failed: 'The template action 'Insert_Entity' at line '1' and column '582' is not valid: "Unable to parse template language expression 'encodeURIComponent([parameters('table_storage_name')])': expected token 'Identifier' and actual 'LeftSquareBracket'.".'.

I tried escaping the quote with a backslash like: encodeURIComponent('[parameters('table_storage_name')]') or encodeURIComponent('[parameters(''table_storage_name'')]') but all of them raise an error. How can I reference a paramter inside encodeURIComponent in an ARM template ?

question from:https://stackoverflow.com/questions/65887464/unable-to-parse-template-language-expression-encodeuricomponentparametersta

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As discussed in the comments. credits: @marone

 "path": "/Tables/@{encodeURIComponent(parameters('table_storage_name'))}/entities"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...