CI/CD pipeline for Logic app (consumption) with parameterized connections #933
Answered
by
GABRIELNGBTUC
Nevinia210
asked this question in
Help Needed
-
Beta Was this translation helpful? Give feedback.
Answered by
GABRIELNGBTUC
Jan 4, 2024
Replies: 1 comment 1 reply
-
I do not think it is possible for consumption logic apps. For them, we generate them inside bicep like this: @description('Key value pair of parameters for the logic app')
type LogicAppParameterInput = {
@description('Name of the parameter')
name: string
@description('Value of the parameter')
value: string
}
@description('Object defining the connection before transformation')
type LogicAppConnectionInput = {
@description('Name of the connection to be used in the workflow')
key: string
@description('Resource ID of the connection')
con_id: string
@description('Connection name inside the properties')
con_name: string
@description('API ID of the connection')
api_id: string
@description('Authentication properties.')
authentication: ConnectionAuthentication?
}
@description('Object defining the authentication type')
type ConnectionAuthentication = {
type: string
}
@description('Authentication properties')
type ConnectionProperties = {
authentication: ConnectionAuthentication
}
@description('Schema of a logic app connection')
type LogicAppConnectionValue = {
connectionId: string
connectionName: string
id: string
connectionProperties: ConnectionProperties?
}
@description('Dictionary of logic app connections')
type LogicAppConnectionValueDictionary = {
*: LogicAppConnectionValue
}
@description('Root objecy for the logic app connections')
type LogicAppConnection = {
value: LogicAppConnectionValueDictionary
}
@description('Key value pair of parameters for the logic app')
type LogicAppParameterKeyValue = {
value: string
}
@description('Parameter object inside a workflow root JSON schema')
type LogicAppParameterDictionary = {
'$connections': LogicAppConnection?
*: LogicAppParameterKeyValue
}
@description('''List of objects representing the parameters to add to the workflow.''')
param parameter_values_array LogicAppParameterInput[] = []
@description('List of connections joigned into an array')
param connections_array LogicAppConnectionInput[] = []
@description('Function creating an Azure logic app workflow connection object')
func createConnectionObject(connection LogicAppConnectionInput) object => {
'${connection.key}': contains(connection, 'authentication') ? {
connectionId: connection.con_id
connectionName: connection.con_name
id: connection.api_id
connectionProperties: {
authentication: connection.?authentication
}
} : {
connectionId: connection.con_id
connectionName: connection.con_name
id: connection.api_id
}
}
@description('Array of workflow connection objects')
var connections = [for connection in connections_array: !empty(connection) ? createConnectionObject(connection) : {}]
@description('Array of workflow parameter objects')
var parameters = [for parameter in parameter_values_array: {
'${parameter.name}': {
value: string(parameter.value)
}
}]
@description('Formated workflow parameters into an object list')
// Create an object and add elements of the array as properties
var built_parameters = reduce(parameters, {}, (cur, next) => union(cur,next))
@description('Formated workflow connections into an object list')
var built_connection = {
'$connections': {
value: reduce(connections, {}, (cur, next) => union(cur,next))
}
}
@description('''Object containing the correctly formatted workflow parameters.''')
output parameters LogicAppParameterDictionary = union(built_connection, built_parameters) The [
{
name: 'paramname'
value: 'paramvalue'
}
...
] The @description('Location pof the connection')
param location string = resourceGroup().location
@minLength(1)
@maxLength(43)
@description('Name of the logic app the connection is created for')
param logic_app_name string
@description('Tags to apply on the resource')
param tags object = resourceGroup().tags
@description('Name of the connection')
var connection_name = '${logic_app_name}-arm'
@description('Properties of the managed identity')
var managed_identity_properties = {
parameterValueType: 'Alternative' // Set the connector to managed identity
}
resource armConnection 'Microsoft.Web/connections@2016-06-01' = {
name: connection_name
tags: tags
#disable-next-line BCP187
kind: 'V1'
location: location
properties: union(managed_identity_properties, {
displayName: connection_name
api: {
name: 'arm'
#disable-next-line use-resource-id-functions
id: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Web/locations/${location}/managedApis/arm'
type: 'Microsoft.Web/locations/managedApis' // static value
}
})
}
@description('Object defining the authentication type')
type ConnectionAuthentication = {
type: string
}
@description('Object defining the connection before transformation')
type LogicAppConnectionInput = {
key: string
con_id: string
con_name: string
api_id: string
authentication: ConnectionAuthentication?
}
@description('''
Object containing the required properties for the workflow parameters
''')
output connection_properties LogicAppConnectionInput = {
key: 'arm'
con_name: armConnection.name
con_id: armConnection.id
api_id: armConnection.properties.api.id
authentication: {
type: 'ManagedServiceIdentity'
}
}
@description('Id of the connection')
output connection_id_outputs string = armConnection.id
@description('Name of the connection')
output connection_name_outputs string = armConnection.name The idea is that we pass all parameters and connections in the initial module and it transforms them in a format that is accepted by the parameter |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Nevinia210
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I do not think it is possible for consumption logic apps.
For them, we generate them inside bicep like this: