简体   繁体   English

在运行时逻辑应用程序中设置环境变量

[英]Set environment variables in runtime logic app

I have a logic app that is triggered by events from Azure Eventhub.我有一个由 Azure Eventhub 事件触发的逻辑应用程序。 Two environments are sending events to the same hub.两个环境将事件发送到同一个集线器。 I want to set environment specific URL based on the message from event hub.我想根据来自事件中心的消息设置特定于环境的 URL。 Environment can be either Fabrikam or Contoso.环境可以是 Fabrikam 或 Contoso。

Now I have tried to set both url's in template parameters.现在我尝试在模板参数中设置两个 url。 The variable is set to Contoso or Fabrikam right after the event, but the workflow definition parameter is not able to use variables('ApiBaseUrl')该变量在事件发生后立即设置为 Contoso 或 Fabrikam,但工作流定义参数无法使用变量('ApiBaseUrl')

Is there a way to set url environment this way?有没有办法以这种方式设置 url 环境?

Parameters file:参数文件:

"Contoso": {
      "value": {
        "ApiBaseUrl": "https://contoso.azurewebsites.net/"
      }
"Fabrikam": {
      "value": {
        "ApiBaseUrl": "https://fabrikam.azurewebsites.net/"
      }

Logic app file:逻辑应用文件:

"environment": {
            "value": {
              "ApiBaseUrl": "[parameters('variables('ApiBaseUrl')).ApiBaseUrl]"
            }
          }

If I understand you correctly, you want to use the value of the variable as the key of the parameter to get the parameter value.如果我理解正确,你想使用变量的值作为参数的键来获取参数值。 Now the code of your parameter should be like:现在你的参数代码应该是这样的:

"parameters": {
    "Contoso": {
      "value": {
        "ApiBaseUrl": "https://contoso.azurewebsites.net/"
    }
}

Please modify the parameters code above to:请将上面的参数代码修改为:

"parameters": {
    "Contoso": {
        "defaultValue": "https://contoso.azurewebsites.net/",
        "type": "String"
    }
}

Then you can just use parameters(variables('ApiBaseUrl')) to get the result you want.然后你可以使用parameters(variables('ApiBaseUrl'))来获得你想要的结果。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM