ibda
ibda

Reputation: 508

Create Azure Connection API with Connection Runtime Url

I have a logic App (a standard logic app) that make a call to cosmos DB. I need to store the "Connection Runtime Url" under the configuration of the logic App.

When I create the connection from the logic app designer, the connection have this property. However, when I deploy the same connection using an ARM template, the connection don't have this property.

Anyone knows how can get this property or generate it? And if possible, how to call it later in an ARM template

Thanks

Upvotes: 8

Views: 5783

Answers (2)

Thomas
Thomas

Reputation: 29736

Only API connection of kind: 'V2' can return a connectionRuntimeUrl.

You can create a cosmos db connector with the below script (bicep):

param location string = resourceGroup().location
param cosmosDbAccountName string = 'thomastestcosmos'
param connectorName string = '${cosmosDbAccountName}-connector'

// get a reference to the cosmos db account
resource cosmosDbAccount 'Microsoft.DocumentDB/databaseAccounts@2021-06-15' existing = {
  name: cosmosDbAccountName
}

// create the related connection api
resource cosmosDbConnector 'Microsoft.Web/connections@2018-07-01-preview' = {
  name: connectorName
  location: location
  kind: 'V2'
  properties: {
    displayName: connectorName
    parameterValues: {
      databaseAccount: cosmosDbAccount.name
      accessKey: cosmosDbAccount.listKeys().primaryMasterKey
    }
    api: {
      id: subscriptionResourceId('Microsoft.Web/locations/managedApis', location, 'documentdb') 
    }
  }
}

output connectionRuntimeUrl string = cosmosDbConnector.properties.connectionRuntimeUrl

The url will be an output of the generated ARM You can then set this url as an appsetting in the workflow app:

COSMOS_CONNECTION_RUNTIMEURL: <connectionRuntimeUrl>

Then in the connections.json file, you can reference this app setting:

{
  "managedApiConnections": {
    "documentdb": {
      ...
      "connectionRuntimeUrl": "@appsetting('COSMOS_CONNECTION_RUNTIMEURL')"
    }
  }
}

Using appsettings and parameters should make thing easier to deploy

Upvotes: 7

ibda
ibda

Reputation: 508

According to this discussion, a simple API connection (V1) may not have "connectionRuntimeUrl". So, to be able to see it I need to add

"kind": "V2",

in my connection Template, also as @Thomas wrote in his answer

Upvotes: 1

Related Questions