简体   繁体   中英

Set environment variables in runtime logic app

I have a logic app that is triggered by events from 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. Environment can be either Fabrikam or Contoso.

Now I have tried to set both url's in template parameters. The variable is set to Contoso or Fabrikam right after the event, but the workflow definition parameter is not able to use variables('ApiBaseUrl')

Is there a way to set url environment this way?

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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