Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

BizTalk Migrator Dependency - Azure Templates

  • 1
  • 2
  • 3

1.0.0 | Updated: 28 Sep 2021

Downloads:

1,376

Downloads of v 1.0.0:

664

Software Author(s):

  • Microsoft

BizTalk Migrator Dependency - Azure Templates 1.0.0

Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Microsoft. The inclusion of Microsoft trademark(s), if any, upon this webpage is solely to identify Microsoft goods or services and not for commercial purposes.

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

Deployment Method: Individual Install, Upgrade, & Uninstall

To install BizTalk Migrator Dependency - Azure Templates, run the following command from the command line or from PowerShell:

>

To upgrade BizTalk Migrator Dependency - Azure Templates, run the following command from the command line or from PowerShell:

>

To uninstall BizTalk Migrator Dependency - Azure Templates, run the following command from the command line or from PowerShell:

>

Deployment Method:

NOTE

This applies to both open source and commercial editions of Chocolatey.

1. Enter Your Internal Repository Url

(this should look similar to https://community.chocolatey.org/api/v2/)


2. Setup Your Environment

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

2. Get the package into your environment

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Copy Your Script

choco upgrade biztalkmigrator-azure -y --source="'INTERNAL REPO URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade biztalkmigrator-azure -y --source="'INTERNAL REPO URL'" 
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Install biztalkmigrator-azure
  win_chocolatey:
    name: biztalkmigrator-azure
    version: '1.0.0'
    source: INTERNAL REPO URL
    state: present

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'biztalkmigrator-azure' do
  action    :install
  source   'INTERNAL REPO URL'
  version  '1.0.0'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller biztalkmigrator-azure
{
    Name     = "biztalkmigrator-azure"
    Version  = "1.0.0"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'biztalkmigrator-azure':
  ensure   => '1.0.0',
  provider => 'chocolatey',
  source   => 'INTERNAL REPO URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


4. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

Package Approved

This package was approved by moderator TheCakeIsNaOH on 28 Sep 2021.

Description

Azure templates to migrate BizTalk applications to Microsoft Azure Integration Services.


tools\LICENSE.txt
    MIT License

    Copyright (c) Microsoft Corporation.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE
tools\templates\application\applicationgroup\applicationgroup.dev.parameters.json.liquid
 
tools\templates\application\applicationgroup\applicationgroup.json.liquid
 
tools\templates\application\applicationgroup\applicationgroup.prod.parameters.json.liquid
 
tools\templates\application\applicationgroup\Deploy-10-ApplicationGroup.ps1.liquid
 
tools\templates\application\applicationgroup\New-ApplicationGroup.ps1.liquid
 
tools\templates\application\applicationgroup\Remove-ApplicationGroup.ps1.liquid
 
tools\templates\application\applicationgroup\TearDown-10-ApplicationGroup.ps1.liquid
 
tools\templates\application\config\configurationentries\configurationentry.appcfg.dev.psparameters.json.liquid
 
tools\templates\application\config\configurationentries\configurationentry.appcfg.prod.psparameters.json.liquid
 
tools\templates\application\config\configurationentries\Deploy-105-ConfigurationEntry-AppConfig.ps1.liquid
 
tools\templates\application\config\configurationentries\New-ConfigurationEntry-AppConfig.ps1
<#
.SYNOPSIS
Creates a configuration entry in application configuration.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key for the configuration item.

.PARAMETER value
The value for the configuration item

.PARAMETER type
The type assigned to the configuration item.

.PARAMETER label
The label for the configuration item.

.PARAMETER tags
The tags to apply to the configuration item.

.EXAMPLE
.\New-ConfigurationEntry-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -value "{ ""samplekey"": ""samplevalue"" }" -type configType -label "sample label"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $value,
    [parameter(Mandatory = $true)]
    [string] $type,
    [parameter(Mandatory = $true)]
    [string] $label,
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

Write-Host "Deploying the configuraton entry key $key"

az appconfig kv set --name $configStoreName --key $key --value $value --content-type $type --label $label --tags $tags --yes 

Write-Host "Deployment complete for the configuration entry key $key"
tools\templates\application\config\configurationentries\Remove-ConfigurationEntry-AppConfig.ps1
<#
.SYNOPSIS
Removes a configuration entry from the application configuration.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key of the item remove from the configuration store.

.PARAMETER label
The label of the item remove from the configuration store.

.EXAMPLE
.\TearDown-100-ConfigurationEntry-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -label "SampleLabel"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $label
)

Write-Host "Removing the configuration entry for key $key"

az appconfig kv delete --name $configStoreName --key $key --label $label --yes

Write-Host "Removed the configuration entry for key $key"
tools\templates\application\config\configurationentries\TearDown-105-ConfigurationEntry-AppConfig.ps1.liquid
 
tools\templates\application\config\routingproperties\route\Deploy-105-RoutingProperties-AppConfig.ps1.liquid
 
tools\templates\application\config\routingproperties\route\New-RoutingProperties-AppConfig.ps1
<#
.SYNOPSIS
Creates routing properties in app config.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key for the configuration item.

.PARAMETER value
The value for the configuration item

.PARAMETER type
The type assigned to the configuration item.

.PARAMETER label
The label for the configuration item.

.PARAMETER tags
The tags to apply to the configuration item.

.EXAMPLE
.\New-RoutingProperties-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -value "{ ""samplekey"": ""samplevalue"" }" -type configType -label "sample label"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $value,
    [parameter(Mandatory = $true)]
    [string] $type,
    [parameter(Mandatory = $true)]
    [string] $label,
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

Write-Host "Deploying routing properties with the key $key"

az appconfig kv set --name $configStoreName --key $key --value $value --content-type $type --label $label --tags $tags --yes 

Write-Host "Deployment complete routing properties with the key $key"
tools\templates\application\config\routingproperties\route\Remove-RoutingProperties-AppConfig.ps1
<#
.SYNOPSIS
Removes routing properties from app config.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key of the item remove from the configuration store.

.PARAMETER label
The label of the item remove from the configuration store.

.EXAMPLE
.\TearDown-100-RoutingProperties-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -label "SampleLabel"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $label
)

Write-Host "Removing routing properties with the key $key"

az appconfig kv delete --name $configStoreName --key $key --label $label --yes

Write-Host "Removed routing properties with the key $key"
tools\templates\application\config\routingproperties\route\routingproperties.appcfg.dev.psparameters.json.liquid
 
tools\templates\application\config\routingproperties\route\routingproperties.appcfg.prod.psparameters.json.liquid
 
tools\templates\application\config\routingproperties\route\TearDown-105-RoutingProperties-AppConfig.ps1.liquid
 
tools\templates\application\config\routingproperties\schema\Deploy-105-RoutingProperties-AppConfig.ps1.liquid
 
tools\templates\application\config\routingproperties\schema\New-RoutingProperties-AppConfig.ps1
<#
.SYNOPSIS
Creates routing properties in app config.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key for the configuration item.

.PARAMETER value
The value for the configuration item

.PARAMETER type
The type assigned to the configuration item.

.PARAMETER label
The label for the configuration item.

.PARAMETER tags
The tags to apply to the configuration item.

.EXAMPLE
.\New-RoutingProperties-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -value "{ ""samplekey"": ""samplevalue"" }" -type configType -label "sample label"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $value,
    [parameter(Mandatory = $true)]
    [string] $type,
    [parameter(Mandatory = $true)]
    [string] $label,
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

Write-Host "Deploying the routing properties for key $key"

az appconfig kv set --name $configStoreName --key $key --value $value --content-type $type --label $label --tags $tags --yes 

Write-Host "Deployment complete for the routing properties for key $key"
tools\templates\application\config\routingproperties\schema\Remove-RoutingProperties-AppConfig.ps1
<#
.SYNOPSIS
Removes routing properties from app config.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key of the item remove from the configuration store.

.PARAMETER label
The label of the item remove from the configuration store.

.EXAMPLE
.\TearDown-100-RoutingProperties-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -label "SampleLabel"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $label
)

Write-Host "Removing the routing properties for key $key"

az appconfig kv delete --name $configStoreName --key $key --label $label --yes

Write-Host "Removed routing properties for the key $key"
tools\templates\application\config\routingproperties\schema\routingproperties.appcfg.dev.psparameters.json.liquid
 
tools\templates\application\config\routingproperties\schema\routingproperties.appcfg.prod.psparameters.json.liquid
 
tools\templates\application\config\routingproperties\schema\TearDown-105-RoutingProperties-AppConfig.ps1.liquid
 
tools\templates\application\config\routingslips\Deploy-105-RoutingSlip-AppConfig.ps1.liquid
 
tools\templates\application\config\routingslips\New-RoutingSlip-AppConfig.ps1
<#
.SYNOPSIS
Creates routing slip configuration in application configuration.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key for the configuration item.

.PARAMETER value
The value for the configuration item

.PARAMETER type
The type assigned to the configuration item.

.PARAMETER label
The label for the configuration item.

.PARAMETER tags
The tags to apply to the configuration item.

.EXAMPLE
.\New-RoutingSlip-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -value "{ ""samplekey"": ""samplevalue"" }" -type configType -label "sample label"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $value,
    [parameter(Mandatory = $true)]
    [string] $type,
    [parameter(Mandatory = $true)]
    [string] $label,
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

Write-Host "Deploying the routing slip configuration key $key"

az appconfig kv set --name $configStoreName --key $key --value $value --content-type $type --label $label --tags $tags --yes 

Write-Host "Deployment complete for the routing slip configuration key $key"
tools\templates\application\config\routingslips\Remove-RoutingSlip-AppConfig.ps1
<#
.SYNOPSIS
Removes routing slip configuration from the application configuration.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER configStoreName
The name of the application configuration store.

.PARAMETER key
The key of the item remove from the configuration store.

.PARAMETER label
The label of the item remove from the configuration store.

.EXAMPLE
.\TearDown-100-RoutingSlip-AppConfig.ps1 -configStoreName "appcfg-aimroutestore-dev" -key "SampleConfigKey" -label "SampleLabel"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $configStoreName,
    [parameter(Mandatory = $true)]
    [string] $key,
    [parameter(Mandatory = $true)]
    [string] $label
)

Write-Host "Removing the routing slip configuration for key $key"

az appconfig kv delete --name $configStoreName --key $key --label $label --yes

Write-Host "Removed routing slip configuration for key $key"
tools\templates\application\config\routingslips\routingslip.appcfg.dev.psparameters.json.liquid
 
tools\templates\application\config\routingslips\routingslip.appcfg.prod.psparameters.json.liquid
 
tools\templates\application\config\routingslips\TearDown-105-RoutingSlip-AppConfig.ps1.liquid
 
tools\templates\application\standard\application.logic.dev.parameters.json.liquid
 
tools\templates\application\standard\application.logic.prod.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\.funcignore
 
tools\templates\application\standard\application.logic.workflows\.vscode\extensions.json
{
  "recommendations": [
    "ms-azuretools.vscode-azurefunctions"
  ]
}
tools\templates\application\standard\application.logic.workflows\.vscode\launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:azureLogicAppsStandard.pickProcess}"
    }
  ]
}
tools\templates\application\standard\application.logic.workflows\.vscode\settings.json
{
  "azureLogicAppsStandard.deploySubpath": ".",
  "azureLogicAppsStandard.projectLanguage": "JavaScript",
  "azureLogicAppsStandard.projectRuntime": "~3",
  "debug.internalConsoleOptions": "neverOpen"
}
tools\templates\application\standard\application.logic.workflows\.vscode\tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "generateDebugSymbols",
      "command": "dotnet",
      "args": [
        "${input:getDebugSymbolDll}"
      ],
      "type": "process",
      "problemMatcher": "$msCompile"
    },
    {
      "type": "func",
      "command": "host start",
      "problemMatcher": "$func-watch",
      "isBackground": true
    }
  ],
  "inputs": [
    {
      "id": "getDebugSymbolDll",
      "type": "command",
      "command": "azureLogicAppsStandard.getDebugSymbolDll"
    }
  ]
}
tools\templates\application\standard\application.logic.workflows\base.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\base.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\base.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\base.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filereceiveadapter\filereceiveadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filereceiveadapter\filereceiveadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filereceiveadapter\filereceiveadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filereceiveadapter\filereceiveadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filereceiveadapter\filereceiveadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filereceiveadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filesendadapter\filesendadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filesendadapter\filesendadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filesendadapter\filesendadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filesendadapter\filesendadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filesendadapter\filesendadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\filesendadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpreceiveadapter\ftpreceiveadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpreceiveadapter\ftpreceiveadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpreceiveadapter\ftpreceiveadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpreceiveadapter\ftpreceiveadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpreceiveadapter\ftpreceiveadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpreceiveadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpsendadapter\ftpsendadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpsendadapter\ftpsendadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpsendadapter\ftpsendadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpsendadapter\ftpsendadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpsendadapter\ftpsendadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\ftpsendadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\host.json
{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": "[1.*, 2.0.0)"
  }
}
tools\templates\application\standard\application.logic.workflows\httpreceiveadapter\httpreceiveadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpreceiveadapter\httpreceiveadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpreceiveadapter\httpreceiveadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpreceiveadapter\httpreceiveadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpreceiveadapter\httpreceiveadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpreceiveadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpsendadapter\httpsendadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpsendadapter\httpsendadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpsendadapter\httpsendadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpsendadapter\httpsendadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpsendadapter\httpsendadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\httpsendadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpreceiveadapter\sftpreceiveadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpreceiveadapter\sftpreceiveadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpreceiveadapter\sftpreceiveadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpreceiveadapter\sftpreceiveadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpreceiveadapter\sftpreceiveadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpreceiveadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpsendadapter\sftpsendadapter.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpsendadapter\sftpsendadapter.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpsendadapter\sftpsendadapter.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpsendadapter\sftpsendadapter.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpsendadapter\sftpsendadapter.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\sftpsendadapter\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\topicsubscriber\topicsubscriber.appsettings.json.liquid
 
tools\templates\application\standard\application.logic.workflows\topicsubscriber\topicsubscriber.appsettings.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\topicsubscriber\topicsubscriber.connections.json.liquid
 
tools\templates\application\standard\application.logic.workflows\topicsubscriber\topicsubscriber.parameters.json.liquid
 
tools\templates\application\standard\application.logic.workflows\topicsubscriber\topicsubscriber.parameters.local.json.liquid
 
tools\templates\application\standard\application.logic.workflows\topicsubscriber\workflow.json.liquid
 
tools\templates\application\standard\application.logic.workflows\workflow-designtime\host.json
{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": "[1.*, 2.0.0)"
  },
  "extensions": {
    "workflow": {
      "settings": {
        "Runtime.WorkflowOperationDiscoveryHostMode": "true"
      }
    }
  }
}
tools\templates\application\standard\application.logic.workflows\workflow-designtime\local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsSecretStorageType": "Files",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}
tools\templates\application\standard\base.application.logic.json.liquid
 
tools\templates\application\standard\Deploy-105-Application-LogicApp.ps1.liquid
 
tools\templates\application\standard\Deploy-110-Application-LogicApp-Configuration.ps1.liquid
 
tools\templates\application\standard\Deploy-115-Application-LogicApp-Workflows.ps1.liquid
 
tools\templates\application\standard\Deploy-120-Application-ClearUrlCache.ps1.liquid
 
tools\templates\application\standard\New-Application-ClearUrlCache.ps1
<#
.SYNOPSIS
Clears the Url Cache for a given Workflow in this Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the Logic App is located.

.PARAMETER resourceName
Name of the Logic App.

.PARAMETER workflowName
Name of the Workflow.

.PARAMETER apimInstanceName
Name of the APIM instance used to clear the cache.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.EXAMPLE
.\New-Application-ClearUrlCache.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -workflowName "workflowname" -apimInstanceName "apim-aimmsgbussvc-dev-xxxxx" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,
	[parameter(Mandatory = $true)]
    [string] $workflowName,
    [parameter(Mandatory = $true)]    
    [string] $apimInstanceName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

$apimBaseUrl = "https://$apimInstanceName.azure-api.net/aimroutingmanager/standardlogicappcallbackurl/$resourceGroupName/$resourceName"
Write-Host "Using base url: $apimBaseUrl"

Write-Host "Clearing cache for Workflow"

Write-Host "$workflowName"
az rest --method get --url "$apimBaseUrl/$workflowName?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "Cache Clearing complete"
tools\templates\application\standard\New-Application-LogicApp-Configuration.ps1
<#
.SYNOPSIS
Creates the Application Logic App Configuration.
This script will merge the individual workflow config files into single files,
prior to the workflows app being uploaded to the Logic App in Azure.
Note that if you want to open this Logic App project in VS Code,
you need to run this script first.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER workflowFolder
Location of the folder containing the Logic App Workflows.

.EXAMPLE
.\New-Application-LogicApp-Configuration.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -workflowFolder "$PSScriptRoot\application.logic.workflows"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,	
	[parameter(Mandatory = $true)]
    [string] $workflowFolder
)

Write-Host "Merging Parameters Files"

# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\parameters.json" -PathType Leaf))
{
	# We're using PowerShell Hashtables to merge the Json files.
	# We're not using Newtonsoft's Json.NET JObject.Merge() option here
	# as we can't guarantee the version of PowerShell being used has access to Json.NET.
	$mergedParameters = [ordered]@{}

	Get-ChildItem "$workflowFolder\*.parameters.json" -Recurse | 
	Foreach-Object {
		$parameterFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
		
		# Remove any duplicate property names - have to do this or the merge will fail
		# as we'll be generating invalid Json
		foreach ($jsonPropertyName in $parameterFile.Keys) {
			if ($mergedParameters.Contains($jsonPropertyName)) {
				$mergedParameters.Remove($jsonPropertyName);
			}
		}
		
		# Union the two hashtables together
		$mergedParameters = $mergedParameters + $parameterFile;
		
		# Delete this file
		Remove-Item -Path $_.FullName
	}

	# Output a new merged parameters file
	ConvertTo-Json $mergedParameters -Depth 10 | Set-Content "$workflowFolder\parameters.json"
}
else
{
	Write-Host "Parameters File has already been merged - no work to do"	
}

Write-Host "Parameters File Merging Complete"

Write-Host "Merging Local Parameters Files"

# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\parameters.local.json" -PathType Leaf))
{
	# We're using PowerShell Hashtables to merge the Json files.
	# We're not using Newtonsoft's Json.NET JObject.Merge() option here
	# as we can't guarantee the version of PowerShell being used has access to Json.NET.
	$mergedLocalParameters = [ordered]@{}

	Get-ChildItem "$workflowFolder\*.parameters.local.json" -Recurse | 
	Foreach-Object {
		$localParameterFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
		
		# Remove any duplicate property names - have to do this or the merge will fail
		# as we'll be generating invalid Json
		foreach ($jsonPropertyName in $localParameterFile.Keys) {
			if ($mergedLocalParameters.Contains($jsonPropertyName)) {
				$mergedLocalParameters.Remove($jsonPropertyName);
			}
		}
		
		# Union the two hashtables together
		$mergedLocalParameters = $mergedLocalParameters + $localParameterFile;
		
		# Delete this file
		Remove-Item -Path $_.FullName
	}

	# Output a new merged local parameters file
	ConvertTo-Json $mergedLocalParameters -Depth 10 | Set-Content "$workflowFolder\parameters.local.json"
}
else
{
	Write-Host "Local Parameters File has already been merged - no work to do"	
}

Write-Host "Local Parameters File Merging Complete"

Write-Host "Merging Connections Files"

# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\connections.json" -PathType Leaf))
{
	# We're using PowerShell Hashtables to merge the Json files.
	# We're not using Newtonsoft's Json.NET JObject.Merge() option here
	# as we can't guarantee the version of PowerShell being used has access to Json.NET.
	$serviceProviderConnections = [ordered]@{}
	$managedApiConnections = [ordered]@{}

	Get-ChildItem "$PSScriptRoot\*.connections.json" -Recurse | 
	Foreach-Object {
		$connectionsFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
		
		if ($connectionsFile.Contains("serviceProviderConnections"))
		{
			$tempServiceProviderConnections = $connectionsFile["serviceProviderConnections"]
			foreach ($serviceProviderConnectionKey in $tempServiceProviderConnections.Keys) {
				if (-Not $serviceProviderConnections.Contains($serviceProviderConnectionKey))
				{
					$serviceProviderConnections[$serviceProviderConnectionKey] = $tempServiceProviderConnections[$serviceProviderConnectionKey]
				}
			}
		}
		
		if ($connectionsFile.Contains("managedApiConnections"))
		{
			$tempManagedApiConnections = $connectionsFile["managedApiConnections"]
			foreach ($managedApiConnectionKey in $tempManagedApiConnections.Keys) {
				if (-Not $managedApiConnections.Contains($managedApiConnectionKey))
				{
					$managedApiConnections[$managedApiConnectionKey] = $tempManagedApiConnections[$managedApiConnectionKey]
				}
			}
		}
		
		# Delete this file
		Remove-Item -Path $_.FullName
	}

	$connections = [ordered]@{}
	$connections["serviceProviderConnections"] = $serviceProviderConnections
	$connections["managedApiConnections"] = $managedApiConnections

	ConvertTo-Json $connections -Depth 10 | Set-Content "$workflowFolder\connections.json"
}
else
{
	Write-Host "Connections File has already been merged - no work to do"	
}

Write-Host "Connections File Merging Complete"

Write-Host "Merging Local AppSettings Files"

# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\local.settings.json" -PathType Leaf))
{
	# We're using PowerShell Hashtables to merge the Json files.
	# We're not using Newtonsoft's Json.NET JObject.Merge() option here
	# as we can't guarantee the version of PowerShell being used has access to Json.NET.
	$mergedLocalAppSettings = [ordered]@{}

	Get-ChildItem "$workflowFolder\*.appsettings.local.json" -Recurse | 
	Foreach-Object {
		$localAppSettingsFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
		
		# Remove any duplicate property names - have to do this or the merge will fail
		# as we'll be generating invalid Json
		foreach ($jsonPropertyName in $localAppSettingsFile.Keys) {
			if ($mergedLocalAppSettings.Contains($jsonPropertyName)) {
				$mergedLocalAppSettings.Remove($jsonPropertyName);
			}
		}
		
		# Union the two hashtables together
		$mergedLocalAppSettings = $mergedLocalAppSettings + $localAppSettingsFile;
		
		# Delete this file
		Remove-Item -Path $_.FullName
	}

	# Create Local App Settings format
	$localAppSettings = [ordered]@{}
	$localAppSettings["IsEncrypted"] = $false
	$localAppSettings["Values"] = $mergedLocalAppSettings

	# Output a new merged local appsettings file
	ConvertTo-Json $localAppSettings -Depth 10 | Set-Content "$workflowFolder\local.settings.json"
}
else
{
	Write-Host "Local App Settings File has already been merged - no work to do"	
}

Write-Host "Local AppSettings File Merging Complete"
tools\templates\application\standard\New-Application-LogicApp-Workflows.ps1
<#
.SYNOPSIS
Creates the Application Logic App Workflows.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER workflowFolder
Location of the folder containing the Logic App Workflows.

.EXAMPLE
.\New-Application-LogicApp-Workflows.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -workflowFolder "$PSScriptRoot\application.logic.workflows"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,	
	[parameter(Mandatory = $true)]
    [string] $workflowFolder
)

Write-Host "Creating a ZIP file from the workflow folder"
# create the zip
$zipFile = "$workflowFolder.zip"
if(Test-path $zipFile) {Remove-item $zipFile}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($workflowFolder, $zipFile)

Write-Host "Zip File creation complete"

Write-Host "Uploading the application logic app zip package $zipFile"

if (!(Test-Path $zipFile)) {
    throw "Zip file $zipFile doesn't exist, unable to upload"
}

az logicapp deployment source config-zip --resource-group $resourceGroupName --name $resourceName --src "$zipFile"

Write-Host "Upload complete"
tools\templates\application\standard\New-Application-LogicApp.ps1
<#
.SYNOPSIS
Creates the Application Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER workflowFolder
Location of the folder containing the Logic App Workflows.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-Application-LogicApp.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -templateFile "$PSScriptRoot\application.logic.json" -templateParameterFile "$PSScriptRoot\application.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -workflowFolder "$PSScriptRoot\application.logic.workflows" -deploymentName "application.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,	
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
	[parameter(Mandatory = $true)]
    [string] $workflowFolder,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Merging AppSetting Files"

# We're using PowerShell Arrays to merge the Json AppSettings files.
# We're not using Newtonsoft's Json.NET JObject.Merge() option here
# as we can't guarantee the version of PowerShell being used has access to Json.NET.
$mergedAppSettings = @()

Get-ChildItem "$workflowFolder\*.appsettings.json" -Recurse | 
Foreach-Object {
    $appSettingsFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
	
	# Union the two arrays together
	$mergedAppSettings += $appSettingsFile;
	
	# Delete this file
	Remove-Item -Path $_.FullName
}

$templatePath = Split-Path -Path $templateFile
$templateFileName = Split-Path -Path $templateFile -Leaf
$baseTemplateFile = "$templatePath\base.$templateFileName"

# Load in the original template, and add in the updated AppSettings
if (Test-Path -Path $baseTemplateFile -PathType Leaf) {
	$applicationTemplate = Get-Content $baseTemplateFile -Raw | ConvertFrom-Json
	
	# Look for the web site resource
	foreach ($resource in $applicationTemplate.resources) {
			if ($resource.type -eq "Microsoft.Web/sites") {
				$resource.properties.siteConfig.appSettings += $mergedAppSettings
			}
	}

	# Write out a new template
	ConvertTo-Json $applicationTemplate -Depth 10 | Set-Content $templateFile
	
	# Delete the base template file
	Remove-Item -Path $baseTemplateFile
}

Write-Host "Finished AppSetting File Merge"

Write-Host "Deploying the Application Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\application\standard\Remove-Application-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Application Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER logicAppName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-Application-LogicApp.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -logicAppName "logic-application-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $logicAppName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $logicAppName --resource-type "Microsoft.Web/sites"

if ($resourceExists) {
    Write-Host "Removing the Logic App $logicAppName"

    az resource delete --resource-group $resourceGroupName --name $logicAppName --resource-type "Microsoft.Web/sites"

    Write-Host "Removed the Logic App $logicAppName"
}
else {
    Write-Host "The Logic App $logicAppName does not exist in resource group $resourceGroupName"
}
tools\templates\application\standard\TearDown-100-Application-LogicApp.ps1.liquid
 
tools\templates\application\workflows\messageresponsehandler\Deploy-80-MessageResponseHandlerServiceBus-ApiConnection.ps1.liquid
 
tools\templates\application\workflows\messageresponsehandler\Deploy-85-MessageResponseHandler-LogicApp.ps1.liquid
 
tools\templates\application\workflows\messageresponsehandler\Deploy-90-MessageResponseHandlerServiceBus-ApiConnPolicy.ps1.liquid
 
tools\templates\application\workflows\messageresponsehandler\messageresponsehandler.logicapp.dev.parameters.json.liquid
 
tools\templates\application\workflows\messageresponsehandler\messageresponsehandler.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "serviceBusTopicSubscribeApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus Response Subscribe operations."
            }
        },
        "scenarioStep": {
            "defaultValue": "messageResponseHandler",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. messageResponseHandler."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "serviceBusTopicSubscribeApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicSubscribeApiConnectionName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. messageResponseHandler."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {},
                            "type": "Request",
                            "operationOptions": "EnableSchemaValidation",
                            "kind": "Http",
                            "inputs": {
                                "schema": {
                                    "properties": {
                                        "correlationId": {
                                            "type": "string"
                                        },
                                        "responseSubscriptionName": {
                                            "type": "string"
                                        },
                                        "responseTimeoutInMinutes": {
                                            "type": "integer"
                                        },
                                        "responseTopicName": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "correlationId",
                                        "responseTopicName",
                                        "responseSubscriptionName",
                                        "responseTimeoutInMinutes"
                                    ],
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseBodyArray_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseBodyArray",
                                        "type": "array"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseCount_variable": {
                            "runAfter": {
                                "Initialize_ResponseBodyArray_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseCount",
                                        "type": "integer",
                                        "value": 0
                                    }
                                ]
                            }
                        },
                        "SendResponse:_Check_Outcome": {
                            "actions": {
                                "SendResponse:_Switch_on_Checkpoint": {
                                    "cases": {
                                        "Success": {
                                            "case": "WaitForResponseSuccess",
                                            "actions": {
                                                "SendResponse:Success:_Complete_each_Response_Message": {
                                                    "actions": {
                                                        "SendResponse:Success:_Complete_Current_Response_message": {
                                                            "inputs": {
                                                                "host": {
                                                                    "connection": {
                                                                        "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                                                                    }
                                                                },
                                                                "method": "delete",
                                                                "path": "/@{encodeURIComponent(triggerBody()?['responseTopicName'])}/subscriptions/@{encodeURIComponent(triggerBody()?['responseSubscriptionName'])}/messages/complete",
                                                                "queries": {
                                                                    "lockToken": "@items('SendResponse:Success:_Complete_each_Response_Message')?['LockToken']",
                                                                    "sessionId": "@items('SendResponse:Success:_Complete_each_Response_Message')?['SessionId']",
                                                                    "subscriptionType": "Main"
                                                                },
                                                                "retryPolicy": {
                                                                    "type": "none"
                                                                }
                                                            },
                                                            "runAfter": {},
                                                            "type": "ApiConnection"
                                                        }
                                                    },
                                                    "foreach": "@variables('ResponseBodyArray')",
                                                    "runAfter": {},
                                                    "type": "Foreach"
                                                },
                                                "SendResponse:Success:_Build_Response": {
                                                    "inputs": {
                                                        "$content-type": "@variables('ResponseBodyArray')?[0]?['ContentType']",
                                                        "$content": "@variables('ResponseBodyArray')?[0]?['ContentData']",
                                                        "$content-encoding": "@variables('ResponseBodyArray')?[0]?['ContentTransferEncoding']"
                                                    },
                                                    "runAfter": {
                                                        "SendResponse:Success:_Complete_each_Response_Message": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose"
                                                },
                                                "SendResponse:Success:_Send_Response": {
                                                    "runAfter": {
                                                        "SendResponse:Success:_Build_Response": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@outputs('SendResponse:Success:_Build_Response')",
                                                        "headers": {
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                },
                                                "SendResponse:Success:_Send_Fault_Response": {
                                                    "runAfter": {
                                                        "SendResponse:Success:_Complete_each_Response_Message": [
                                                            "Failed",
                                                            "Skipped",
                                                            "TimedOut"
                                                        ]
                                                    },
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": {
                                                            "fault": {
                                                                "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                                "faultCategory": "Error",
                                                                "faultCode": "500",
                                                                "faultMessage": "An error occurred trying to complete the response messages received for this session.",
                                                                "faultReason": ""
                                                            }
                                                        },
                                                        "headers": {
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 500
                                                    }
                                                }
                                            }
                                        },
                                        "Failure": {
                                            "case": "WaitForResponseFailure",
                                            "actions": {
                                                "SendResponse:Failure:_Send_Fault_Response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@variables('FaultMessage')",
                                                        "headers": {
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 500
                                                    }
                                                }
                                            }
                                        },
                                        "Timeout": {
                                            "case": "WaitForResponseTimeout",
                                            "actions": {
                                                "SendResponse:Timeout:_Send_Fault_Response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": {
                                                            "fault": {
                                                                "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                                "faultCategory": "Error",
                                                                "faultCode": "504",
                                                                "faultMessage": "Timed out waiting for a response message.",
                                                                "faultReason": ""
                                                            }
                                                        },
                                                        "headers": {
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 504
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "SendResponse:UnknownCheckpoint:_Send_Fault_Response": {
                                                "runAfter": {},
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": {
                                                        "fault": {
                                                            "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                            "faultCategory": "Error",
                                                            "faultCode": "500",
                                                            "faultMessage": "Unexpected Checkpoint value of '@{variables('Checkpoint')}' in LogicApp @{workflow()['name']}. Unable to continue.",
                                                            "faultReason": ""
                                                        }
                                                    },
                                                    "headers": {
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 500
                                                }
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "expression": "@variables('Checkpoint')",
                                    "type": "Switch"
                                }
                            },
                            "runAfter": {
                                "Step:_Wait_for_Response": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Do_we_have_a_Fault": {
                                        "actions": {
                                            "Failure:NoFault:_Send_Fault_Response": {
                                                "runAfter": {},
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": {
                                                        "fault": {
                                                            "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                            "faultCategory": "Error",
                                                            "faultCode": "500",
                                                            "faultMessage": "An error occurred in LogicApp @{workflow()['name']}. Unable to continue. Expected a Checkpoint of WaitForResponseSuccess/WaitForResponseFailure/WaitForResponseTimeout but received a Checkpoint of '@{variables('Checkpoint')}'.",
                                                            "faultReason": ""
                                                        }
                                                    },
                                                    "headers": {
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 500
                                                }
                                            }
                                        },
                                        "else": {
                                            "actions": {
                                                "Failure:HaveFault:_Send_Fault_Response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@variables('FaultMessage')",
                                                        "headers": {
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 500
                                                    }
                                                }
                                            }
                                        },
                                        "runAfter": {},
                                        "expression": {
                                            "and": [
                                                {
                                                    "equals": [
                                                        "@coalesce(variables('FaultMessage'), '')",
                                                        ""
                                                    ]
                                                }
                                            ]
                                        },
                                        "type": "if"
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "WaitForResponseSuccess"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "WaitForResponseFailure"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "WaitForResponseTimeout"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Wait_for_Response": {
                            "actions": {
                                "WaitForResponse:_Loop_until_we_get_Response_or_TimeOut": {
                                    "actions": {
                                        "WaitForResponse:_Get_Response_Message_from_Topic": {
                                            "inputs": {
                                                "host": {
                                                    "connection": {
                                                        "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                                                    }
                                                },
                                                "method": "get",
                                                "path": "/@{encodeURIComponent(encodeURIComponent(triggerBody()?['responseTopicName']))}/subscriptions/@{encodeURIComponent(triggerBody()?['responseSubscriptionName'])}/messages/batch/peek",
                                                "queries": {
                                                    "maxMessageCount": 1,
                                                    "sessionId": "@{triggerBody()?['correlationId']}",
                                                    "subscriptionType": "Main"
                                                },
                                                "retryPolicy": {
                                                    "type": "none"
                                                }
                                            },
                                            "runAfter": {},
                                            "type": "ApiConnection"
                                        },
                                        "WaitForResponse:_Set_StatusCode_variable": {
                                            "runAfter": {
                                                "WaitForResponse:_Get_Response_Message_from_Topic": [
                                                    "Succeeded",
                                                    "Failed",
                                                    "Skipped",
                                                    "TimedOut"
                                                ]
                                            },
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "StatusCode",
                                                "value": "@coalesce(outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['statusCode'], 500)"
                                            }
                                        },
                                        "WaitForResponse:_Check_Status_Code": {
                                            "runAfter": {
                                                "WaitForResponse:_Set_StatusCode_variable": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "cases": {
                                                "Success": {
                                                    "case": 200,
                                                    "actions": {
                                                        "WaitForResponse:Success:_Set_ResponseBodyArray_variable": {
                                                            "inputs": {
                                                                "name": "ResponseBodyArray",
                                                                "value": "@array(body('WaitForResponse:_Get_Response_Message_from_Topic'))"
                                                            },
                                                            "runAfter": {},
                                                            "type": "SetVariable"
                                                        },
                                                        "WaitForResponse:Success:_Set_ResponseCount_variable": {
                                                            "inputs": {
                                                                "name": "ResponseCount",
                                                                "value": "@length(variables('ResponseBodyArray'))"
                                                            },
                                                            "runAfter": {
                                                                "WaitForResponse:Success:_Set_ResponseBodyArray_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable"
                                                        }
                                                    }
                                                }
                                            },
                                            "default": {
                                                "actions": {
                                                    "WaitForResponse:Failure:_Create_Fault_Message": {
                                                        "runAfter": {},
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "fault": {
                                                                "faultActor": "@{workflow()?['name']}.@{actions('WaitForResponse:_Get_Response_Message_from_Topic')?['name']} (@{workflow()?['run']?['name']})",
                                                                "faultCategory": "Error",
                                                                "faultCode": "@{coalesce(outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['statusCode'], outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['body']?['statusCode'], actions('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['code'])}",
                                                                "faultMessage": "@{coalesce(outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['message'], body('WaitForResponse:_Get_Response_Message_from_Topic')?['message'], body('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['message'], actions('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['message'])}",
                                                                "faultReason": "@{actions('WaitForResponse:_Get_Response_Message_from_Topic')?['status']}"
                                                            }
                                                        }
                                                    },
                                                    "WaitForResponse:Failure:_Set_FaultMessage_variable": {
                                                        "runAfter": {
                                                            "WaitForResponse:Failure:_Create_Fault_Message": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@outputs('WaitForResponse:Failure:_Create_Fault_Message')"
                                                        }
                                                    },
                                                    "WaitForResponse:Failure:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "WaitForResponse:Failure:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred executing the @{actions('WaitForResponse:_Get_Response_Message_from_Topic')?['name']} action to get the response message."
                                                        }
                                                    },
                                                    "WaitForResponse:Failure:_Set_Checkpoint_variable": {
                                                        "inputs": {
                                                            "name": "Checkpoint",
                                                            "value": "WaitForResponseFailure"
                                                        },
                                                        "runAfter": {
                                                            "WaitForResponse:Failure:_Set_ErrorMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable"
                                                    }
                                                }
                                            },
                                            "expression": "@variables('StatusCode')",
                                            "type": "Switch"
                                        }
                                    },
                                    "expression": "@or(greater(variables('ResponseCount'), 0), equals(variables('Checkpoint'), 'WaitForResponseFailure'))",
                                    "limit": {
                                        "count": "@mul(coalesce(triggerBody()?['responseTimeoutInMinutes'], 3), 2)",
                                        "timeout": "PT@{coalesce(triggerBody()?['responseTimeoutInMinutes'], 3)}M"
                                    },
                                    "runAfter": {},
                                    "type": "Until"
                                },
                                "WaitForResponse:_Check_Outcome": {
                                    "actions": {
                                        "WaitForResponse:Success:_Set_Checkpoint_variable": {
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "WaitForResponseSuccess"
                                            },
                                            "runAfter": {},
                                            "type": "SetVariable"
                                        }
                                    },
                                    "else": {
                                        "actions": {
                                            "WaitForResponse:TimeOut:_Set_Checkpoint_variable": {
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "WaitForResponseTimeout"
                                                },
                                                "runAfter": {},
                                                "type": "SetVariable"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "WaitForResponse:_Loop_until_we_get_Response_or_TimeOut": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@variables('Checkpoint')",
                                                    ""
                                                ]
                                            },
                                            {
                                                "greater": [
                                                    "@variables('ResponseCount')",
                                                    0
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "if"
                                }
                            },
                            "runAfter": {
                                "Initialize_ResponseCount_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "servicebussubscribe": {
                                "connectionId": "[variables('serviceBusTopicSubscribeApiConnectionResourceId')]",
                                "connectionName": "[parameters('serviceBusTopicSubscribeApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
                            }
                        }
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\application\workflows\messageresponsehandler\messageresponsehandler.logicapp.prod.parameters.json.liquid
 
tools\templates\application\workflows\messageresponsehandler\messageresponsehandlerservicebus.apiconnection.dev.parameters.json.liquid
 
tools\templates\application\workflows\messageresponsehandler\messageresponsehandlerservicebus.apiconnection.json.liquid
 
tools\templates\application\workflows\messageresponsehandler\messageresponsehandlerservicebus.apiconnection.prod.parameters.json.liquid
 
tools\templates\application\workflows\messageresponsehandler\messageresponsehandlerservicebus.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\application\workflows\messageresponsehandler\messageresponsehandlerservicebus.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\application\workflows\messageresponsehandler\messageresponsehandlerservicebus.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\application\workflows\messageresponsehandler\New-MessageResponseHandler-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageResponseHandler-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\messageresponsehandler.logicapp.json" -templateParameterFile ".\messagereponsehandler.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "messagereponsehandler.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the message response handler Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\application\workflows\messageresponsehandler\New-MessageResponseHandlerServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Creates a service bus api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageResponseHandlerServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\messageresponsehandlersb.apiconnection.json" -templateParameterFile ".\messageresponsehandlersb.apiconnection.dev.parameters.json" -deploymentName "messageresponsehandlersb.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a service bus api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\application\workflows\messageresponsehandler\New-MessageResponseHandlerServiceBus-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates a message response handler service bus api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageResponseHandlerServiceBus-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\messageresponsehandlerservicebus.apiconnpolicy.json" -templateParameterFile ".\messageresponsehandlerservicebus.apiconnpolicy.dev.parameters.json" -deploymentName "messageresponsehandlerservicebus.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\application\workflows\messageresponsehandler\Remove-MessageResponseHandler-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-MessageResponseHandler-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-messageresponsehandler-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\application\workflows\messageresponsehandler\Remove-MessageResponseHandlerServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the message response handlers service bus api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-MessageResponseHandlerServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -resourceName "apic-aimsmessageresponsehandlerconnector-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the message response handler service bus api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the message response handler service bus api connection resource: $resourceName"
}
else {
    Write-Host "The message response handlers service bus api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\application\workflows\messageresponsehandler\TearDown-80-MessageResponseHandlerServiceBus-ApiConnection.ps1.liquid
 
tools\templates\application\workflows\messageresponsehandler\TearDown-85-MessageResponseHandler-LogicApp.ps1.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\Deploy-80-MessageSuspendProcessorServiceBus-ApiConnection.ps1.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\Deploy-85-MessageSuspendProcessor-LogicApp.ps1.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\messagesuspendprocessor.logicapp.dev.parameters.json.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\messagesuspendprocessor.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "serviceBusTopicPublishApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus SuspendQueue Publish operations."
            }
        },
        "scenarioStep": {
            "defaultValue": "messageSuspendProcessor",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. messageSuspendProcessor."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "serviceBusTopicPublishApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicPublishApiConnectionName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. messageSuspendProcessor."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "operationOptions": "EnableSchemaValidation",
                            "kind": "Http",
                            "inputs": {
                                "schema": {
                                    "properties": {
                                        "nackMessage": {
                                            "properties": {},
                                            "type": "object"
                                        },
                                        "originalMessage": {
                                            "properties": {},
                                            "type": "object"
                                        },
                                        "suspendQueueTopicName": {
                                            "type": "string"
                                        },
                                        "failedMessageRouting": {
                                            "type": "boolean"
                                        },
                                        "scenario": {
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "nackMessage",
                                        "suspendQueueTopicName",
                                        "failedMessageRouting",
                                        "scenario"
                                    ],
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_NackMessage_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "NackMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_OriginalMessage_variable": {
                            "runAfter": {
                                "Initialize_NackMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "OriginalMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Success:_Build_ACK_message": {
                                    "runAfter": {},
                                    "type": "Compose",
                                    "inputs": {
                                        "body": [
                                            {
                                                "$content": { "result": "Successfully published a NACK@{if(equals(variables('Checkpoint'), 'SuspendOriginalMessage'), ' and Original message', '')} to the SuspendQueue in ServiceBus" },
                                                "$contentType": "application/json",
                                                "$part": 1,
                                                "$partType": "http://schemas.microsoft.com/aim#ack"
                                            }
                                        ],
                                        "header": {
                                            "properties": {
                                                "createDate": "@utcNow()",
                                                "envelopeType": "ack",
                                                "messageId": "@guid()",
                                                "rootPart": 1,
                                                "trackingId": "@variables('NackMessage')?['header']?['properties']?['trackingId']"
                                            },
                                            "routing": {
                                                "messageType": "http://schemas.microsoft.com/aim#ack"
                                            },
                                            "routingSlip": {},
                                            "state": {}
                                        }
                                    }
                                },
                                "Routing:Success:_Send_ACK-Content_response": {
                                    "runAfter": {
                                        "Success:_Build_ACK_message": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "Response",
                                    "kind": "Http",
                                    "inputs": {
                                        "body": "@outputs('Success:_Build_ACK_message')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{variables('NackMessage')?['header']?['properties']?['trackingId']}",
                                            "Aim-Clear-Cache": "@coalesce(trigger()?['headers']?['Aim-Clear-Cache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(trigger()?['headers']?['Aim-Enable-Trace'], 'false')",
                                            "Content-Type": "application/json"
                                        },
                                        "statusCode": 200
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Suspend_Original_Message": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@variables('NackMessage')?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "messageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Tracking-Id": "@{variables('NackMessage')?['header']?['properties']?['trackingId']}",
                                                "Aim-Clear-Cache": "@coalesce(trigger()?['headers']?['Aim-Clear-Cache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(trigger()?['headers']?['Aim-Enable-Trace'], 'false')",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SuspendOriginalMessage"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SkippedSuspendOriginalMessage"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Messages": {
                            "actions": {
                                "GetMessages:_Set_NackMessage_variable": {
                                    "runAfter": {},
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "NackMessage",
                                        "value": "@triggerBody()?['nackMessage']"
                                    }
                                },
                                "GetMessages:_Set_OriginalMessage_variable": {
                                    "runAfter": {
                                        "GetMessages:_Set_NackMessage_variable": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "OriginalMessage",
                                        "value": "@triggerBody()?['originalMessage']"
                                    }
                                },
                                "GetMessages:_Have_Valid_Messages": {
                                    "actions": {
                                        "GetMessages:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "GetMessages"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "GetMessages:_Set_OriginalMessage_variable": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "GetMessages:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): no messages supplied in triggerBody - need either or both of NACK message or Original message"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('NackMessage'), '')",
                                                        ""
                                                    ]
                                                }
                                            },
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('OriginalMessage'), '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Initialize_OriginalMessage_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Suspend_NACK": {
                            "actions": {
                                "SuspendNack:_Check_Status_Code": {
                                    "runAfter": {
                                        "SuspendNack:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "SuspendNack:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "SuspendNack"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "SuspendNack:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "SuspendNack:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "SuspendNack:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a NACK to the SuspendQueue in ServiceBus"
                                                        }
                                                    },
                                                    "SuspendNack:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('SuspendNack:_Send_to_ServiceBus')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "SuspendNack:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()['name'], '.', actions('SuspendNack:_Send_to_ServiceBus')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('SuspendNack:_Send_to_ServiceBus')?['statusCode'], outputs('SuspendNack:_Send_to_ServiceBus')?['body']?['statusCode'], actions('SuspendNack:_Send_to_ServiceBus')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('SuspendNack:_Send_to_ServiceBus')?['error']?['message'], outputs('SuspendNack:_Send_to_ServiceBus')?['body']?['message'], actions('SuspendNack:_Send_to_ServiceBus')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('SuspendNack:_Send_to_ServiceBus')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "SuspendNack:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "SuspendNack:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a NACK to the SuspendQueue in ServiceBus"
                                                            }
                                                        },
                                                        "SuspendNack:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "SuspendNack:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('SuspendNack:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('SuspendNack:_Send_to_ServiceBus')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "SuspendNack:_Send_to_ServiceBus": {
                                    "runAfter": {},
                                    "type": "ApiConnection",
                                    "inputs": {
                                        "body": {
                                            "ContentData": "@{base64(variables('NackMessage'))}",
                                            "ContentType": "application/json",
                                            "MessageId": "@coalesce(variables('NackMessage')?['header']?['properties']?['messageId'], guid())",
                                            "Properties": "@variables('NackMessage')?['header']?['routing']",
                                            "SessionId": "none"
                                        },
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['servicebuspublish']['connectionId']"
                                            }
                                        },
                                        "method": "post",
                                        "path": "/@{encodeURIComponent(coalesce(triggerBody()?['suspendQueueTopicName'], '(suspendqueue topic name not set)'))}/messages",
                                        "queries": {
                                            "systemProperties": "None"
                                        }
                                    }
                                },
                                "SuspendNack:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "SuspendNack:_Send_to_ServiceBus": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('SuspendNack:_Send_to_ServiceBus')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Messages": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetMessages"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Suspend_Original_Message": {
                            "actions": {
                                "SuspendOriginalMessage:_Check_FailedMessageRouting_value": {
                                    "actions": {
                                        "SuspendOriginalMessage:_Check_Status_Code": {
                                            "runAfter": {
                                                "SuspendOriginalMessage:_Set_StatusCode_variable": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "cases": {
                                                "Success": {
                                                    "case": 200,
                                                    "actions": {
                                                        "SuspendOriginalMessage:Success:_Set_Checkpoint_variable": {
                                                            "runAfter": {},
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "Checkpoint",
                                                                "value": "SuspendOriginalMessage"
                                                            }
                                                        }
                                                    }
                                                }
                                            },
                                            "default": {
                                                "actions": {
                                                    "SuspendOriginalMessage:Failure:_Do_we_have_a_Fault_Message": {
                                                        "actions": {
                                                            "SuspendOriginalMessage:Fault:_Set_ErrorMessage_variable": {
                                                                "runAfter": {
                                                                    "SuspendOriginalMessage:Fault:_Set_FaultMessage_variable": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "ErrorMessage",
                                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish an original message to the SuspendQueue in ServiceBus"
                                                                }
                                                            },
                                                            "SuspendOriginalMessage:Fault:_Set_FaultMessage_variable": {
                                                                "runAfter": {},
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "FaultMessage",
                                                                    "value": "@body('SuspendOriginalMessage:_Send_to_ServiceBus')"
                                                                }
                                                            }
                                                        },
                                                        "runAfter": {},
                                                        "else": {
                                                            "actions": {
                                                                "SuspendOriginalMessage:NoFault:_Create_Fault_Message": {
                                                                    "runAfter": {},
                                                                    "type": "Compose",
                                                                    "inputs": {
                                                                        "fault": {
                                                                            "faultActor": "@concat(workflow()['name'], '.', actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                            "faultCategory": "Error",
                                                                            "faultCode": "@{coalesce(outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['statusCode'], outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['body']?['statusCode'], actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['error']?['code'])}",
                                                                            "faultMessage": "@{coalesce(outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['error']?['message'], outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['body']?['message'], actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['error']?['message'])}",
                                                                            "faultReason": "@{actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['status']}"
                                                                        }
                                                                    }
                                                                },
                                                                "SuspendOriginalMessage:NoFault:_Set_ErrorMessage_variable": {
                                                                    "runAfter": {
                                                                        "SuspendOriginalMessage:NoFault:_Set_FaultMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ErrorMessage",
                                                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish an original message to the SuspendQueue in ServiceBus"
                                                                    }
                                                                },
                                                                "SuspendOriginalMessage:NoFault:_Set_FaultMessage_variable": {
                                                                    "runAfter": {
                                                                        "SuspendOriginalMessage:NoFault:_Create_Fault_Message": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "FaultMessage",
                                                                        "value": "@outputs('SuspendOriginalMessage:NoFault:_Create_Fault_Message')"
                                                                    }
                                                                }
                                                            }
                                                        },
                                                        "expression": {
                                                            "and": [
                                                                {
                                                                    "not": {
                                                                        "equals": [
                                                                            "@body('SuspendOriginalMessage:_Send_to_ServiceBus')?['fault']",
                                                                            null
                                                                        ]
                                                                    }
                                                                }
                                                            ]
                                                        },
                                                        "type": "If"
                                                    }
                                                }
                                            },
                                            "expression": "@variables('StatusCode')",
                                            "type": "Switch"
                                        },
                                        "SuspendOriginalMessage:_Send_to_ServiceBus": {
                                            "runAfter": {},
                                            "type": "ApiConnection",
                                            "inputs": {
                                                "body": {
                                                    "ContentData": "@{base64(variables('OriginalMessage'))}",
                                                    "ContentType": "application/json",
                                                    "MessageId": "@coalesce(variables('OriginalMessage')?['header']?['properties']?['messageId'], guid())",
                                                    "Properties": {
                                                        "messageType": "@variables('OriginalMessage')?['header']?['properties']?['messageType']",
                                                        "errorType": "FailedMessage"
                                                    },
                                                    "SessionId": "none"
                                                },
                                                "host": {
                                                    "connection": {
                                                        "name": "@parameters('$connections')['servicebuspublish']['connectionId']"
                                                    }
                                                },
                                                "method": "post",
                                                "path": "/@{encodeURIComponent(coalesce(triggerBody()?['suspendQueueTopicName'], '(suspendqueue topic name not set)'))}/messages",
                                                "queries": {
                                                    "systemProperties": "None"
                                                }
                                            }
                                        },
                                        "SuspendOriginalMessage:_Set_StatusCode_variable": {
                                            "runAfter": {
                                                "SuspendOriginalMessage:_Send_to_ServiceBus": [
                                                    "Succeeded",
                                                    "Failed",
                                                    "Skipped",
                                                    "TimedOut"
                                                ]
                                            },
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "StatusCode",
                                                "value": "@coalesce(outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['statusCode'], 500)"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "SuspendOriginalMessage:Skipped:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "SkippedSuspendOriginalMessage"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(triggerBody()?['failedMessageRouting'], false)",
                                                    true
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "if"
                                }
                            },
                            "runAfter": {
                                "Step:_Suspend_NACK": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SuspendNack"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "servicebuspublish": {
                                "connectionId": "[variables('serviceBusTopicPublishApiConnectionResourceId')]",
                                "connectionName": "[parameters('serviceBusTopicPublishApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
                            }
                        }
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\application\workflows\messagesuspendprocessor\messagesuspendprocessor.logicapp.prod.parameters.json.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\messagesuspendprocessorservicebus.apiconnection.dev.parameters.json.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\messagesuspendprocessorservicebus.apiconnection.json.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\messagesuspendprocessorservicebus.apiconnection.prod.parameters.json.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\New-MessageSuspendProcessor-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageSuspendProcessor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\xmlmessagesuspendprocessor.logicapp.json" -templateParameterFile ".\xmlmessageprocessor.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "xmlmessagesuspendprocessor.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the xml message suspend processor Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\application\workflows\messagesuspendprocessor\New-MessageSuspendProcessorServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Creates a service bus api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageSuspendProcessorServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\messagesuspendprocessorrsb.apiconnection.json" -templateParameterFile ".\messagesuspendprocessorsb.apiconnection.dev.parameters.json" -deploymentName "messagesuspendprocessorsb.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a service bus api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\application\workflows\messagesuspendprocessor\Remove-MessageSuspendProcessor-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-MessageSuspendProcessor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-messagesuspendprocessor-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\application\workflows\messagesuspendprocessor\Remove-MessageSuspendProcessorServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the message response handlers service bus api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-MessageSuspendProcessorServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -resourceName "apic-aimsuspendprocessorconnector-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the message suspend processor service bus api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the message suspend processor service bus api connection resource: $resourceName"
}
else {
    Write-Host "The message suspend processor service bus api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\application\workflows\messagesuspendprocessor\TearDown-80-MessageSuspendProcessorServiceBus-ApiConnection.ps1.liquid
 
tools\templates\application\workflows\messagesuspendprocessor\TearDown-85-MessageSuspendProcessor-LogicApp.ps1.liquid
 
tools\templates\channels\topicchannel\Deploy-20-TopicChannel-ServiceBus.ps1.liquid
 
tools\templates\channels\topicchannel\namespace\Deploy-15-Namespace-ServiceBus.ps1.liquid
 
tools\templates\channels\topicchannel\namespace\namespace.sb.dev.psparameters.json.liquid
 
tools\templates\channels\topicchannel\namespace\namespace.sb.prod.psparameters.json.liquid
 
tools\templates\channels\topicchannel\namespace\New-Namespace-ServiceBus.ps1
<#
.SYNOPSIS
Creates a Service Bus Namespace resource for use by various AIM components.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER location
The location to create the service bus in.

.PARAMETER namespace
Namespace to create the service bus with.

.PARAMETER sku
The SKU level for the namespace.

.PARAMETER tags
The tags to apply to the namespace.

.EXAMPLE
.\New-Namespace-ServiceBus.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth" -location "uksouth" -namespace "sb-aimmsgbox-dev-uksouth" -sku "Standard" 
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $location,
    [parameter(Mandatory = $true)]
    [string] $namespace,
    [parameter(Mandatory = $false)]
    [string] $sku = "Basic",
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

Write-Host "Deploying the namespace: $namespace"

az servicebus namespace create --resource-group $resourceGroupName --name $namespace --location $location --sku $sku --tags $tags

Write-Host "Deployment Complete"
tools\templates\channels\topicchannel\namespace\Remove-Namespace-ServiceBus.ps1
<#
.SYNOPSIS
Removes the namespace resource.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
The resource group the namespace is in.

.PARAMETER namespace.
The name of the namespace.

.EXAMPLE
.\Remove-Namespace-ServiceBus.ps1 -namespace "sb-aimmsgbox-dev-uksouth" -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $namespace
)

$resourceExists = az servicebus namespace list --resource-group $resourceGroupName --query "[?name=='$namespace'].{name:name}" -o tsv

if ($resourceExists) {
    Write-Host "Removing the namespace resource: $namespace"

    az servicebus namespace delete --name $namespace --resource-group $resourceGroupName
    
    Write-Host "Removed the namespace resource: $namespace"
}
else {
    Write-Host "The namespace resource $namespace does not exist in resource group $resourceGroupName"
}
tools\templates\channels\topicchannel\namespace\TearDown-15-Namespace-ServiceBus.ps1.liquid
 
tools\templates\channels\topicchannel\New-TopicChannel-ServiceBus.ps1
<#
.SYNOPSIS
Creates a Topic Channel resource for use by various AIM components.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER namespace
Namespace to create the topic on.

.PARAMETER topic
Topic name to create in the namespace.

.PARAMETER enablePartitioning
Defines if partitioning should be enabled (true) or not on the topic.

.PARAMETER tags
The tags to apply to the namespace.

.EXAMPLE
.\New-TopicChannel-ServiceBus.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth" -namespace "sb-aimmsgbox-dev-uksouth" -topic "messagebox"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $namespace,
    [parameter(Mandatory = $true)]
    [string] $topic,
    [parameter(Mandatory = $true)]
    [bool] $enablePartitioning,
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

Write-Host "Deploying the topic: $topic"

az servicebus topic create --resource-group $resourceGroupName --namespace-name $namespace --name $topic --enable-partitioning $enablePartitioning

Write-Host "Deployment Complete"
tools\templates\channels\topicchannel\Remove-TopicChannel-ServiceBus.ps1
<#
.SYNOPSIS
Removes the topic channel resource.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
The resource group name.

.PARAMETER namespace
The name of the namespace the topic is on.

.PARAMETER topic.
The topic to remove.

.EXAMPLE
.\Remove-TopicChannel-ServiceBus.ps1 -$resourceName "sb-aimmsgbox-dev-uksouth" -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth" -topic "messagebox"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $namespace,
    [parameter(Mandatory = $true)]
    [string] $topic
)

$namespaceResourceExists = az servicebus namespace list --resource-group $resourceGroupName --query "[?name=='$namespace'].{name:name}" -o tsv

if ($namespaceResourceExists) {

    $topicResourceExists = az servicebus topic list --resource-group $resourceGroupName --namespace-name $namespace --query "[?name=='$topic'].{name:name}" -o tsv
 
    if ($topicResourceExists) {

        Write-Host "Removing the topic resource: $topic"

        az servicebus topic delete --resource-group $resourceGroupName --namespace-name $namespace --name $topic

        Write-Host "Removed the topic resource: $topic"
    }
    else {
        Write-Host "The topic resource $topic does not exist in resource group $resourceGroupName with the namespace $namespace"
    }
}
else {
    Write-Host "The namespace $namespace does not exist in resource group $resourceGroupName when attempting to remove the topic $topic"
}
tools\templates\channels\topicchannel\subscriptions\Deploy-30-TopicChannelSubscription-ServiceBus.ps1.liquid
 
tools\templates\channels\topicchannel\subscriptions\New-TopicChannelSubscription-ServiceBus.ps1
<#
.SYNOPSIS
Creates a topic subscription and rules resources.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER name
Name of the subscription that will be created.

.PARAMETER serviceBusNamespace
Name of the Azure Service Bus namespace.

.PARAMETER serviceBusTopic
Name of the Azure Service Bus topic.

.PARAMETER serviceBusSessionsEnabled
Identifies if sessions are enabled (true) or not (false).

.PARAMETER rules
The rules to set on the subscription.

.EXAMPLE
./New-TopicChannelSubscription-ServiceBus.ps1 -resourceGroupName "rg-aimapp-app1-dev-uksouth" -name "sbs-aimmsgbox-ftp-passthru" -serviceBusNamespace "sb-aimmsgbox-dev-uksouth" -serviceBusTopic "messagebox" -serviceBusSessionsEnabled "true" -rules @{<rulesarray>}
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $name,
    [parameter(Mandatory = $true)]
    [string] $serviceBusNamespace,
    [parameter(Mandatory = $true)]
    [string] $serviceBusTopic,
    [parameter(Mandatory = $true)]
    [bool] $serviceBusSessionsEnabled,
    [parameter(Mandatory = $true)]
    [object[]] $rules
)

# --------------------------------------------------------------------------

Write-Host "Deploying the topic subscription $name"

az servicebus topic subscription create --name $name --resource-group $resourceGroupName --namespace-name $serviceBusNamespace --topic-name $serviceBusTopic --enable-session $serviceBusSessionsEnabled
if (!$?) {
    throw "Deployment failed, aborting"
}

Write-Host "Deployment complete"

# --------------------------------------------------------------------------

Write-Host "Creating rules for subscription $name"

ForEach ($rule in $rules) {
    $ruleName = $rule.name

    Write-Host "Creating rule $ruleName in subscription $name"

    az servicebus topic subscription rule create --name $ruleName --resource-group $resourceGroupName --namespace-name $serviceBusNamespace --topic-name $serviceBusTopic --subscription-name $name --filter-sql-expression $rule.expression
    if (!$?) {
        throw "Deployment failed, aborting"
    }
}

Write-Host "Created rules for subscription $name"
tools\templates\channels\topicchannel\subscriptions\Remove-TopicChannelSubscription-ServiceBus.ps1
<#
.SYNOPSIS
Removes a topic subscription.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be deleted.

.PARAMETER name
Name of the subscription that will be deleted.

.PARAMETER serviceBusNamespace
Name of the Azure Service Bus namespace.

.PARAMETER serviceBusTopic
Name of the Azure Service Bus topic.

.EXAMPLE
./Remove-TopicChannelSubscription-ServiceBus.ps1 -resourceGroupName "rg-aimapp-app1-dev-uksouth" -resourceName "sbs-aimmsgbox-ftp-passthru" -serviceBusNamespace "sb-aimmsgbox-dev-uksouth" -serviceBusTopic "messagebox"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,
    [parameter(Mandatory = $true)]
    [string] $serviceBusNamespace,
    [parameter(Mandatory = $true)]
    [string] $serviceBusTopic
)

$resourceExists = az servicebus topic subscription show --name $resourceName --resource-group $resourceGroupName --namespace-name $serviceBusNamespace --topic-name $serviceBusTopic

if ($resourceExists) {
    Write-Host "Removing the topic subscription resource: $resourceName"

    az servicebus topic subscription delete --name $resourceName --resource-group $resourceGroupName --namespace-name $serviceBusNamespace --topic-name $serviceBusTopic

    Write-Host "Removed the topic subscription resource: $resourceName"
}
else {
    Write-Host "The topic subscription resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\channels\topicchannel\subscriptions\TearDown-30-TopicChannelSubscription-ServiceBus.ps1.liquid
 
tools\templates\channels\topicchannel\subscriptions\topicchannelsubscription.sbs.dev.psparameters.json.liquid
 
tools\templates\channels\topicchannel\subscriptions\topicchannelsubscription.sbs.prod.psparameters.json.liquid
 
tools\templates\channels\topicchannel\TearDown-20-TopicChannel-ServiceBus.ps1.liquid
 
tools\templates\channels\topicchannel\topicchannel.sb.dev.psparameters.json.liquid
 
tools\templates\channels\topicchannel\topicchannel.sb.prod.psparameters.json.liquid
 
tools\templates\deploy\consumption\Deploy-All-Unattended.bat
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="

REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellCoreInstalled=Y"
)

REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellInstalled=Y"
)

REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
	ECHO PowerShell Core is installed - using this to execute script.
	pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
	PAUSE
	GOTO:EOF
)

REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled

ECHO PowerShell is installed. Checking what version is installed.

REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i

FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i

REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion

REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF

:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF

:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF

tools\templates\deploy\consumption\Deploy-All.bat
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
pause
tools\templates\deploy\consumption\Deploy-All.ps1.liquid
 
tools\templates\deploy\consumption\TearDown-All.bat
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
tools\templates\deploy\consumption\TearDown-All.ps1.liquid
 
tools\templates\deploy\consumptionlite\Deploy-All-Unattended.bat
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="

REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellCoreInstalled=Y"
)

REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellInstalled=Y"
)

REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
	ECHO PowerShell Core is installed - using this to execute script.
	pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
	PAUSE
	GOTO:EOF
)

REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled

ECHO PowerShell is installed. Checking what version is installed.

REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i

FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i

REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion

REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF

:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF

:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF

tools\templates\deploy\consumptionlite\Deploy-All.bat
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
pause
tools\templates\deploy\consumptionlite\Deploy-All.ps1.liquid
 
tools\templates\deploy\consumptionlite\TearDown-All.bat
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
tools\templates\deploy\consumptionlite\TearDown-All.ps1.liquid
 
tools\templates\deploy\standard\Deploy-All-Unattended.bat
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="

REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellCoreInstalled=Y"
)

REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellInstalled=Y"
)

REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
	ECHO PowerShell Core is installed - using this to execute script.
	pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
	PAUSE
	GOTO:EOF
)

REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled

ECHO PowerShell is installed. Checking what version is installed.

REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i

FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i

REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion

REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF

:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF

:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF

tools\templates\deploy\standard\Deploy-All.bat
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="

REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellCoreInstalled=Y"
)

REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellInstalled=Y"
)

REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
	ECHO PowerShell Core is installed - using this to execute script.
	pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
	PAUSE
	GOTO:EOF
)

REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled

ECHO PowerShell is installed. Checking what version is installed.

REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i

FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i

REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion

REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
PAUSE
GOTO:EOF

:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF

:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF

tools\templates\deploy\standard\Deploy-All.ps1.liquid
 
tools\templates\deploy\standard\TearDown-All.bat
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
tools\templates\deploy\standard\TearDown-All.ps1.liquid
 
tools\templates\deploy\standardlite\Deploy-All-Unattended.bat
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="

REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellCoreInstalled=Y"
)

REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellInstalled=Y"
)

REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
	ECHO PowerShell Core is installed - using this to execute script.
	pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
	PAUSE
	GOTO:EOF
)

REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled

ECHO PowerShell is installed. Checking what version is installed.

REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i

FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i

REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion

REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF

:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF

:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF

tools\templates\deploy\standardlite\Deploy-All.bat
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="

REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellCoreInstalled=Y"
)

REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
	SET "PowerShellInstalled=Y"
)

REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
	ECHO PowerShell Core is installed - using this to execute script.
	pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
	PAUSE
	GOTO:EOF
)

REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled

ECHO PowerShell is installed. Checking what version is installed.

REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i

FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i

REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion

REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
PAUSE
GOTO:EOF

:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF

:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF

tools\templates\deploy\standardlite\Deploy-All.ps1.liquid
 
tools\templates\deploy\standardlite\TearDown-All.bat
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
tools\templates\deploy\standardlite\TearDown-All.ps1.liquid
 
tools\templates\endpoints\file\datagateway\datagateway.onpremisedatagateway.dev.parameters.json.liquid
 
tools\templates\endpoints\file\datagateway\datagateway.onpremisedatagateway.dev.psparameters.json.liquid
 
tools\templates\endpoints\file\datagateway\datagateway.onpremisedatagateway.json
{
    "$schema": "https://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "dataGatewayName": {
            "type": "String"
        },
        "dataGatewayLocation": {
            "type": "String"
        },
        "connectionGatewayInstallationId": {
            "type": "String"
        },
        "connectionGatewayInstallationLocation": {
            "type": "String"
        },
        "tags": {
            "type": "object"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Web/connectionGateways",
            "name": "[parameters('dataGatewayName')]",
            "apiVersion": "2016-06-01",
            "location": "[parameters('dataGatewayLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "connectionGatewayInstallation": {
                    "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('connectionGatewayInstallationLocation'), '/connectionGatewayInstallations/', parameters('connectionGatewayInstallationId'))]"
                }
            }
        }
    ],
    "outputs": {
    }
}
tools\templates\endpoints\file\datagateway\datagateway.onpremisedatagateway.prod.parameters.json.liquid
 
tools\templates\endpoints\file\datagateway\datagateway.onpremisedatagateway.prod.psparameters.json.liquid
 
tools\templates\endpoints\file\datagateway\Deploy-30-DataGateway.ps1.liquid
 
tools\templates\endpoints\file\datagateway\New-DataGateway.ps1
<#
.SYNOPSIS
Creates an on-premise data gateway.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
The name of the Azure resource group to deploy the data gateway to.

.PARAMETER subscriptionId
"<azure-subs-id>"

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER connectionGatewayInstallationDisplayName
The name of the connection gateway installation to link the new data gateway to.

.PARAMETER connectionGatewayInstallationLocation
The location of the connection gateway installation to link the new data gateway to.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.
    
.EXAMPLE
.\New-DataGateway.ps1 -resourceGroupName $params.resourceGroupName -subscriptionId "<azure-subs-id>" -connectionGatewayInstallationDisplayName "cgw-aimmsgbus-dev-uksouth-xxxx" -connectionGatewayInstallationLocation "uksouth" -templateFile "datagateway.onpremisedatagateway.json" -templateParameterFile "datagateway.onpremisedatagateway.dev.parameters.json" -deploymentName "datagateway.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,        
    [parameter(Mandatory = $true)]    
    [string] $connectionGatewayInstallationDisplayName,
    [parameter(Mandatory = $true)]    
    [string] $connectionGatewayInstallationLocation,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id
    
    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

$connectionGatewayInstallationName = az rest --method get --uri /subscriptions/$subscriptionId/providers/Microsoft.Web/locations/$connectionGatewayInstallationLocation/connectionGatewayInstallations?api-version=2016-06-01 --query "value[?properties.displayName=='$connectionGatewayInstallationDisplayName'].{Name:name} | [0]" -o tsv

if ($connectionGatewayInstallationName -eq "") {
    throw "No connection gateway installation found in location: $connectionGatewayInstallationLocation with the display name: $connectionGatewayInstallationDisplayName "
}

Write-Host "Deploying the data gateway `r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName" 

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "connectionGatewayInstallationId=$connectionGatewayInstallationName" --parameters "connectionGatewayInstallationLocation=$connectionGatewayInstallationLocation" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\datagateway\Remove-DataGateway.ps1
<#
.SYNOPSIS
Removes an on-premise data gateway,.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
The name of the resource group name the connection gateway exists in.

.PARAMETER dataGatewayName
The name of the data gateway to remove.

.EXAMPLE
.\Remove-DataGateway.ps1 -resourceGroupName "rg-aimmsgbus-dev" -dataGatewayName "cgw-aimmsgbus-dev-uksouth-xxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $dataGatewayName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $dataGatewayName --namespace "Microsoft.Web" --resource-type "connectionGateways"

if ($resourceExists) {
    Write-Host "Removing the On-premises Data Gateway $dataGatewayName"

    az resource delete --resource-group $resourceGroupName --name $dataGatewayName --namespace "Microsoft.Web" --resource-type "connectionGateways"

    Write-Host "Removed the On-premises Data Gateway $dataGatewayName"
}
else {
    Write-Host "The On-premises Data Gateway $dataGatewayName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\file\datagateway\TearDown-30-DataGateway.ps1.liquid
 
tools\templates\endpoints\file\receive\Deploy-100-FileReceiveAdapterFileSystem-ApiConnection.ps1.liquid
 
tools\templates\endpoints\file\receive\Deploy-100-FileReceiveAdapterServiceBus-ApiConnection.ps1.liquid
 
tools\templates\endpoints\file\receive\Deploy-105-FileReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\file\receive\Deploy-110-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\file\receive\Deploy-110-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicApStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "systemApplicationResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that SystemApplication artifacts are deployed to (e.g. ServiceBus or MessageConstructor LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "string",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "messageConstructorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle File Message Construction and Sending."
            }
        },
        "messageSuspendProcessorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle suspending of messages."
            }
        },
        "suspendQueueTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic that suspended messages are sent to."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "fileSystemReceiveApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for Filesystem Receive operations."
            }
        },
        "fileReceiveFolder": {
            "type": "string",
            "metadata": {
                "description": "The path where the File connector looks for new/updated files."
            }
        },
        "fileMaxFileCount": {
            "defaultValue": 10,
            "type": "int",
            "metadata": {
                "description": "The max number of files the File Connector will retrieve per polling interval."
            }
        },
        "fileRecurrenceFrequency": {
            "type": "string",
            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
            "metadata": {
                "description": "The frequency with which to check for new files on the File server."
            }
        },
        "fileRecurrenceInterval": {
            "type": "int",
            "metadata": {
                "description": "The interval with which to check for new files on the File server."
            }
        },
        "serviceBusTopicPublishApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus SuspendQueue Publish operations."
            }
        },
        "scenario": {
            "type": "string",
            "metadata": {
                "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
            }
        },
        "scenarioStep": {
            "defaultValue": "fileReceiveAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. fileReceiveAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messageConstructorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageConstructorLogicAppName'))]",
        "messageSuspendProcessorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageSuspendProcessorLogicAppName'))]",
        "fileSystemApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('fileSystemReceiveApiConnectionName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]",
        "serviceBusTopicPublishApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicPublishApiConnectionName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicApStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "fileReceiveFolder": {
                            "type": "String",
                            "description": "The path where the File connector looks for new/updated files."
                        },
                        "fileMaxFileCount": {
                            "type": "Int",
                            "description": "The max number of files the File Connector will retrieve per polling interval."
                        },
                        "fileRecurrenceFrequency": {
                            "type": "string",
                            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
                            "description": "The frequency with which to check for new files on the File server."
                        },
                        "fileRecurrenceInterval": {
                            "type": "int",
                            "description": "The interval with which to check for new files on the File server."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        },
                        "scenario": {
                            "type": "String",
                            "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. FileReceiveAdapter."
                        },
                        "clearCache": {
                            "defaultValue": true,
                            "type": "Bool",
                            "description": "Indicates if we should clear APIM cache before retrieved config items e.g. configurationEntries or routingSlips."
                        },
                        "suspendQueueTopicName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic that suspended messages are sent to."
                        }
                    },
                    "triggers": {
                        "When_a_file_is_added_or_modified_(properties_only)": {
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['filesystemreceive']['connectionId']"
                                    }
                                },
                                "method": "get",
                                "path": "/datasets/default/triggers/batch/onupdatedfile",
                                "queries": {
                                    "folderId": "@{parameters('fileReceiveFolder')}",
                                    "maxFileCount": "@parameters('fileMaxFileCount')"
                                }
                            },
                            "recurrence": {
                                "frequency": "@parameters('fileRecurrenceFrequency')",
                                "interval": "@parameters('fileRecurrenceInterval')"
                            },
                            "splitOn": "@triggerBody()",
                            "type": "ApiConnection"
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Compose_FileNameMask": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "Compose",
                            "inputs": "@{coalesce(variables('Configuration')?['scenarioStep']?['fileNameMask'], '*.*')}"
                        },
                        "Respond:_Were_we_successful": {
                            "actions": {
                                "Terminate_with_ACK": {
                                    "runAfter": {},
                                    "type": "Terminate",
                                    "inputs": {
                                        "runStatus": "Succeeded"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Construct_Message": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Do_we_have_a_NACK": {
                                        "actions": {},
                                        "runAfter": {},
                                        "else": {
                                            "actions": {
                                                "Failure:_Build_NACK_message": {
                                                    "runAfter": {},
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "body": [
                                                            {
                                                                "$content": {
                                                                    "code": "500",
                                                                    "message": "@variables('ErrorMessage')",
                                                                    "lastCheckpoint": "@variables('Checkpoint')",
                                                                    "fault": "@variables('FaultMessage')"
                                                                },
                                                                "$contentType": "application/json",
                                                                "$part": 1,
                                                                "$partType": "http://schemas.microsoft.com/aim#nack"
                                                            }
                                                        ],
                                                        "header": {
                                                            "properties": {
                                                                "createDate": "@utcNow()",
                                                                "envelopeType": "nack",
                                                                "messageId": "@guid()",
                                                                "rootPart": 1,
                                                                "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                            },
                                                            "routing": {
                                                                "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                            },
                                                            "routingSlip": {},
                                                            "state": {}
                                                        }
                                                    }
                                                },
                                                "Failure:_Set_ResponseMessage_variable": {
                                                    "runAfter": {
                                                        "Failure:_Build_NACK_message": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "ResponseMessage",
                                                        "value": "@outputs('Failure:_Build_NACK_message')"
                                                    }
                                                }
                                            }
                                        },
                                        "expression": {
                                            "and": [
                                                {
                                                    "equals": [
                                                        "@{coalesce(variables('ResponseMessage')?['header']?['properties']?['envelopeType'], '(unknown)')}",
                                                        "nack"
                                                    ]
                                                }
                                            ]
                                        },
                                        "type": "If"
                                    },
                                    "Failure:_Send_NACK_to_SuspendQueue": {
                                        "runAfter": {
                                            "Failure:_Do_we_have_a_NACK": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Workflow",
                                        "inputs": {
                                            "body": {
                                                "nackMessage": "@variables('ResponseMessage')",
                                                "originalMessage": "@triggerBody()",
                                                "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                "scenario": "@{parameters('scenario')}"
                                            },
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                            },
                                            "host": {
                                                "triggerName": "manual",
                                                "workflow": {
                                                    "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                }
                                            }
                                        }
                                    },
                                    "Terminate_with_NACK": {
                                        "runAfter": {
                                            "Failure:_Send_NACK_to_SuspendQueue": [
                                                "Succeeded",
                                                "Failed",
                                                "TimedOut"
                                            ]
                                        },
                                        "type": "Terminate",
                                        "inputs": {
                                            "runError": {
                                                "code": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['code'], '500')}",
                                                "message": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['message'], '(unknown error)')}"
                                            },
                                            "runStatus": "Failed"
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "IgnoreFile"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ConstructMessageACK"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(parameters('scenario'))}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@parameters('clearCache')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Compose_FileNameMask": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Configuration": {
                            "actions": {
                                "ValidateConfiguration:_Have_Valid_Properties": {
                                    "actions": {
                                        "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "ValidateConfiguration"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property btsReceivePortName is not set in configuration"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Should_we_process_file": {
                            "actions": {
                                "ShouldWeProcessFile:_Check_FileMask": {
                                    "inputs": {
                                        "code": "var escapedFileMask = workflowContext.actions.Compose_FileNameMask.outputs;\r\nvar fileMaskRegex = \"^\" + escapedFileMask.replace(\".\", \"[.]\").replace(\"*\", \".*\").replace(\"?\", \".\") + \"$\";\r\nreturn workflowContext.trigger.outputs.body.Name.match(fileMaskRegex) !== null;"
                                    },
                                    "runAfter": {},
                                    "type": "JavaScriptCode"
                                },
                                "ShouldWeProcessFile:Failure:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:_Check_FileMask": [
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 500
                                    }
                                },
                                "ShouldWeProcessFile:Success:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:_Check_FileMask": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 200
                                    }
                                },
                                "ShouldWeProcessFile:_Check_StatusCode": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:Failure:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ],
                                        "ShouldWeProcessFile:Success:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ShouldWeProcessFile:Success:_Does_FileMask_match": {
                                                    "actions": {
                                                        "ShouldWeProcessFile:Process:_Set_Checkpoint_variable": {
                                                            "runAfter": {},
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "Checkpoint",
                                                                "value": "ProcessFile"
                                                            }
                                                        }
                                                    },
                                                    "runAfter": {},
                                                    "else": {
                                                        "actions": {
                                                            "ShouldWeProcessFile:Ignore:_Set_Checkpoint_variable": {
                                                                "runAfter": {},
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "IgnoreFile"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "expression": {
                                                        "and": [
                                                            {
                                                                "equals": [
                                                                    "@outputs('ShouldWeProcessFile:_Check_FileMask')?['body']",
                                                                    true
                                                                ]
                                                            }
                                                        ]
                                                    },
                                                    "type": "If"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ShouldWeProcessFile:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('ShouldWeProcessFile:_Check_FileMask')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['statusCode'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['statusCode'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['message'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'])}",
                                                        "faultReason": "@{actions('ShouldWeProcessFile:_Check_FileMask')?['status']}"
                                                    }
                                                }
                                            },
                                            "ShouldWeProcessFile:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to execute the FileMask Javascript"
                                                }
                                            },
                                            "ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "ShouldWeProcessFile:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('ShouldWeProcessFile:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Construct_Message": {
                            "actions": {
                                "ConstructMessage:_Call_MessageConstructor": {
                                    "runAfter": {
                                        "ConstructMessage:_Get_file_content": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": {
                                            "$content": "@{body('ConstructMessage:_Get_file_content')}",
                                            "$contentTransferEncoding": "none",
                                            "$contentType": "@triggerBody()?['MediaType']",
                                            "properties": {
                                                "receivedFileName": "@{triggerBody()?['Name']}",
                                                "scenario": "@{parameters('scenario')}",
                                                "btsReceivePortName": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '(unknownReceivePortName)')}",
                                                "btsReceivePortId": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortId'], '(unknownReceivePortId)')}"
                                            }
                                        },
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('messageConstructorLogicAppResourceId')]"
                                            }
                                        }
                                    }
                                },
                                "ConstructMessage:_Check_StatusCode": {
                                    "runAfter": {
                                        "ConstructMessage:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ConstructMessage:Success:_Check_EnvelopeType": {
                                                    "runAfter": {},
                                                    "cases": {
                                                        "ACK": {
                                                            "case": "ack",
                                                            "actions": {
                                                                "ACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "ACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "ACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageACK"
                                                                    }
                                                                }
                                                            }
                                                        },
                                                        "NACK": {
                                                            "case": "nack",
                                                            "actions": {
                                                                "NACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "NACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "NACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageNACK"
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "default": {
                                                        "actions": {
                                                            "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": {
                                                                "runAfter": {},
                                                                "type": "Compose",
                                                                "inputs": {
                                                                    "body": [
                                                                        {
                                                                            "$content": {
                                                                                "code": "500",
                                                                                "message": "@concat('Body returned by action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' is not an ACK or NACK. Envelope type is: ', coalesce(body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType'], '(unknown)'))"
                                                                            },
                                                                            "$contentType": "application/json",
                                                                            "$part": 1,
                                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                                        }
                                                                    ],
                                                                    "header": {
                                                                        "properties": {
                                                                            "createDate": "@utcNow()",
                                                                            "envelopeType": "nack",
                                                                            "messageId": "@guid()",
                                                                            "rootPart": 1,
                                                                            "trackingId": ""
                                                                        },
                                                                        "routing": {
                                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                                        },
                                                                        "routingSlip": {},
                                                                        "state": {}
                                                                    }
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "ResponseMessage",
                                                                    "value": "@outputs('ConstructMessage:UnknownEnvelope:_Compose_NACK_Message')"
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_Checkpoint_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "ConstructMessageNACK"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "expression": "@body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType']",
                                                    "type": "Switch"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ConstructMessage:Failure:_Create_NACK_Message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['error']?['message'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['message'])}",
                                                                    "faultReason": ""
                                                                },
                                                                "message": "@concat('Action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' resulted in an error response.')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": ""
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "ConstructMessage:Failure:_Set_ResponseMessage_variable": {
                                                "runAfter": {
                                                    "ConstructMessage:Failure:_Create_NACK_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ResponseMessage",
                                                    "value": "@outputs('ConstructMessage:Failure:_Create_NACK_Message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "ConstructMessage:_Get_file_content": {
                                    "runAfter": {},
                                    "type": "ApiConnection",
                                    "inputs": {
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['filesystemreceive']['connectionId']"
                                            }
                                        },
                                        "method": "get",
                                        "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(triggerBody()?['Id']))}/content",
                                        "queries": {
                                            "inferContentType": true
                                        }
                                    }
                                },
                                "ConstructMessage:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ConstructMessage:_Call_MessageConstructor": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Should_we_process_file": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ProcessFile"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "filesystemreceive": {
                                "connectionId": "[variables('fileSystemApiConnectionResourceId')]",
                                "connectionName": "[parameters('fileSystemReceiveApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/filesystem')]"
                            }
                        }
                    },
                    "fileReceiveFolder": {
                        "value": "[parameters('fileReceiveFolder')]"
                    },
                    "fileMaxFileCount": {
                        "value": "[parameters('fileMaxFileCount')]"
                    },
                    "fileRecurrenceFrequency": {
                        "value": "[parameters('fileRecurrenceFrequency')]"
                    },
                    "fileRecurrenceInterval": {
                        "value": "[parameters('fileRecurrenceInterval')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    },
                    "scenario": {
                        "value": "[parameters('scenario')]"
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "suspendQueueTopicName": {
                        "value": "[parameters('suspendQueueTopicName')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\file\receive\filereceiveadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterfilesystem.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterfilesystem.apiconnection.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterfilesystem.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterfilesystem.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterfilesystem.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\file\receive\filereceiveadapterfilesystem.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterservicebus.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterservicebus.apiconnection.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterservicebus.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\file\receive\filereceiveadapterservicebus.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\file\receive\filereceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\file\receive\New-FileReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates a file receive adapter for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth" -templateFile ".\filereceiveadapter.logicapp.json" -templateParameterFile ".\filereceiveadapter.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "filereceiveadapter.logicapp.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying a file receive adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\receive\New-FileReceiveAdapterFileSystem-ApiConnection.ps1
<#
.SYNOPSIS
Creates a file api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileReceiveAdapterFileSystem-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth" -templateFile ".\filereceiveadapterfile.apiconnection.json" -templateParameterFile ".\filereceiveadapterfile.apiconnection.dev.parameters.json" -deployment -deploymentName "filereceiveadapterfile
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a file system api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\receive\New-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates a file receive api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\filereceiveadapterfilesystem.apiconnpolicy.json" -templateParameterFile ".\filereceiveadapterfilesystem.apiconnpolicy.dev.parameters.json" -deploymentName "filereceiveadapterfile.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\receive\New-FileReceiveAdapterServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Creates a service bus api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileReceiveAdapterServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth" -templateFile ".\filereceiveadaptersb.apiconnection.json" -templateParameterFile ".\filereceiveadaptersb.apiconnection.dev.parameters.json" -deploymentName "filereceiveadaptersb.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a service bus api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\receive\New-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates a file receive service bus api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\filereceiveadapterservicebus.apiconnpolicy.json" -templateParameterFile ".\filereceiveadapterservicebus.apiconnpolicy.dev.parameters.json" -deploymentName "filereceiveadapterservicebus.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\receive\Remove-FileReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the file receive adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FileReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth-xxxxx" -resourceName "logic-Aim-FilePassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the file receive adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the file receive adapter resource: $resourceName"
}
else {
    Write-Host "The file receive adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\file\receive\Remove-FileReceiveAdapterFileSystem-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the file receive adapters file system api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FileReceiveAdapterFileSystem-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth" -resourceName "filereceiveconnector-Aim-filePassthru-ReceiveLocation-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the file receive adapters file system api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the file receive adapters file system api connection resource: $resourceName"
}
else {
    Write-Host "The file receive adapters file system api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\file\receive\Remove-FileReceiveAdapterServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the file receive adapters service bus api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FileReceiveAdapterServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth" -resourceName "topicpublisherconnector-filereceiveadapater-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the file receive adapters service bus api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the file receive adapters service bus api connection resource: $resourceName"
}
else {
    Write-Host "The file receive adapters service bus api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\file\receive\TearDown-100-FileReceiveAdapterFileSystem-ApiConnection.ps1.liquid
 
tools\templates\endpoints\file\receive\TearDown-100-FileReceiveAdapterServiceBus-ApiConnection.ps1.liquid
 
tools\templates\endpoints\file\receive\TearDown-105-FileReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\file\send\Deploy-100-FileSendAdapter-ApiConnection.ps1.liquid
 
tools\templates\endpoints\file\send\Deploy-105-FileSendAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\file\send\Deploy-110-FileSendAdapter-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\file\send\filesendadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\file\send\filesendadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "fileSystemSendApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for File Send operations."
            }
        },
        "scenarioStep": {
            "defaultValue": "fileSendAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. fileSendAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "fileSendApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('fileSystemSendApiConnectionName'))]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. fileSendAdapter."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_SendFileName_variable": {
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "SendFileName",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_CopyMode_variable": {
                            "runAfter": {
                                "Initialize_SendFileName_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "CopyMode",
                                        "type": "string",
                                        "value": "Create"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_SendToFile": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SendToFile"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_CopyMode_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Missing:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "NoBodyContent"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_GetSendFileName": {
                            "actions": {
                                "GetSendFileName:_Set_SendFileName_variable": {
                                    "description": "A full list of supported FileName macros can be found here: https://social.technet.microsoft.com/wiki/contents/articles/8823.biztalk-server-list-of-macros.aspx. At this time we are not supporting the Party macros.",
                                    "type": "SetVariable",
                                    "runAfter": {},
                                    "inputs": {
                                        "name": "SendFileName",
                                        "value": "@{replace(replace(replace(replace(replace(replace(replace(coalesce(variables('Configuration')?[parameters('scenarioStep')]?['fileName'], '%MessageID%.xml'), '%MessageID%', coalesce(triggerBody()?['header']?['properties']?['messageId'], guid())), '%SourceFileName%', coalesce(triggerBody()?['header']?['properties']?['receivedFileName'], 'myfile.txt')), '%datetime%', utcNow('yyyy-MM-ddThhmmss')), '%datetime_bts2000%', utcNow('yyyyMMddhhmmsss')), '%datetime.tz%', utcNow('yyyy-MM-ddThhmmssK')), '%time%', utcNow('hhmmss')), '%time.tz%', utcNow('hhmmssK'))}"
                                    }
                                },
                                "SendToFile:_Set_Checkpoint_variable": {
                                    "runAfter": {
                                        "GetSendFileName:_Set_SendFileName_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "GetSendFileName"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "NoBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_SendToFile": {
                            "actions": {
                                "SendToFile:_Check_Status_Code": {
                                    "runAfter": {
                                        "SendToFile:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "SendToFile:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "SendToFile"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "SendToFile:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "SendToFile:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "SendToFile:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FileSystem connector"
                                                        }
                                                    },
                                                    "SendToFile:Fault:_Create_Fault_Message": {
                                                        "runAfter": {},
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "fault": {
                                                                "faultActor": "@concat(workflow()?['name'], '.', actions('SendToFile:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                "faultCategory": "Error",
                                                                "faultCode": "@{coalesce(outputs('SendToFile:_Create_File')?['statusCode'], outputs('SendToFile:_Create_File')?['body']?['statusCode'], actions('SendToFile:_Create_File')?['error']?['code'])}",
                                                                "faultMessage": "@{coalesce(outputs('SendToFile:_Create_File')?['error']?['message'], outputs('SendToFile:_Create_File')?['body']?['message'], actions('SendToFile:_Create_File')?['error']?['message'])}",
                                                                "faultReason": "@{actions('SendToFile:_Create_File')?['status']}"
                                                            }
                                                        }
                                                    },
                                                    "SendToFile:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {
                                                            "SendToFile:Fault:_Create_Fault_Message": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('SendToFile:Fault:_Create_Fault_Message')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "SendToFile:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('SendToFile:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('SendToFile:_Create_File')?['statusCode'], outputs('SendToFile:_Create_File')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('SendToFile:_Create_File')?['error']?['message'], outputs('SendToFile:_Create_File')?['body']?['message'])}",
                                                                    "faultReason": "@actions('SendToFile:_Create_File')?['inputs']?['path']"
                                                                }
                                                            }
                                                        },
                                                        "SendToFile:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "SendToFile:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FileSystem connector"
                                                            }
                                                        },
                                                        "SendToFile:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "SendToFile:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('SendToFile:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('SendToFile:_Create_File')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "SendToFile:_Set_CopyMode_variable": {
                                    "runAfter": {},
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "CopyMode",
                                        "value": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['copyMode'], 'Create')}"
                                    }
                                },
                                "SendToFile:_Create_File": {
                                    "inputs": {
                                        "body": "@variables('BodyContent')",
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['filesystemsend']['connectionId']"
                                            }
                                        },
                                        "method": "@{if(equals(variables('CopyMode'), 'Create'), 'post', if(equals(variables('CopyMode'), 'Append'), 'patch', if(equals(variables('CopyMode'), 'Update'), 'put', 'undefined')))}",
                                        "path": "/datasets/default/files@{if(contains(createArray('Append', 'Update'), variables('CopyMode')), concat(coalesce(variables('Configuration')?[parameters('scenarioStep')]?['destinationFolder'], '(undefined)'), '\\', variables('SendFileName')), '')}",
                                        "queries": {
                                            "folderPath": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['destinationFolder'], '(undefined)')",
                                            "name": "@variables('SendFileName')",
                                            "queryParametersSingleEncoded": true
                                        }
                                    },
                                    "runAfter": {
                                        "SendToFile:_Set_CopyMode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "runtimeConfiguration": {
                                        "contentTransfer": {
                                            "transferMode": "Chunked"
                                        }
                                    },
                                    "type": "ApiConnection"
                                },
                                "SendToFile:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "SendToFile:_Create_File": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('SendToFile:_Create_File')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_GetSendFileName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetSendFileName"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "filesystemsend": {
                                "connectionId": "[variables('fileSendApiConnectionResourceId')]",
                                "connectionName": "[parameters('fileSystemSendApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/filesystem')]"
                            }
                        }
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\file\send\filesendadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\file\send\filesystemsendadapter.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\file\send\filesystemsendadapter.apiconnection.json.liquid
 
tools\templates\endpoints\file\send\filesystemsendadapter.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\file\send\filesystemsendadapter.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\file\send\filesystemsendadapter.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\file\send\filesystemsendadapter.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\file\send\New-FileSendAdapter-ApiConnection.ps1
<#
.SYNOPSIS
Creates a file send adapters api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileSendAdapter-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth-xxxxx" -templateFile ".\fileconnection.json" -templateParameterFile ".\fileconnection.dev.parameters.json" -deploymentName "filesendconnection"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a file send adapters api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\send\New-FileSendAdapter-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates a file send api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileSendAdapter-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\filesystemsendadapter.apiconnpolicy.json" -templateParameterFile ".\filesystemsendadapter.apiconnpolicy.dev.parameters.json" -deploymentName "filesystemsendadapter.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\send\New-FileSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates a file send adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FileSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth-xxxxx" -templateFile ".\fileadapter.json" -templateParameterFile ".\fileadapter.dev.parameters.json" -deploymentName "fileadapter"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for the routing slip router Logic App"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying a file send adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\file\send\Remove-FileSendAdapter-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the file send adapters api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FileSendAdapter-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth-xxxxx" -resourceName "filereceiveconnector-Aim-FilePassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the file send adapters api connection: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the file send adapters api connection: $resourceName"
}
else {
    Write-Host "The file send adapaters api connectionresource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\file\send\Remove-FileSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the file send adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FileSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-filepassthru-dev-uksouth-xxxxx" -resourceName "logic-Aim-FilePassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the file send adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the file send adapter resource: $resourceName"
}
else {
    Write-Host "The file send adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\file\send\TearDown-100-FileSendAdapter-ApiConnection.ps1.liquid
 
tools\templates\endpoints\file\send\TearDown-105-FileSendAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\ftp\receive\Deploy-100-FtpReceiveAdapterFtp-ApiConnection.ps1.liquid
 
tools\templates\endpoints\ftp\receive\Deploy-100-FtpReceiveAdapterServiceBus-ApiConnection.ps1.liquid
 
tools\templates\endpoints\ftp\receive\Deploy-105-FtpReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\ftp\receive\Deploy-110-FtpReceiveAdapterFtp-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\ftp\receive\Deploy-110-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicApStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "systemApplicationResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that SystemApplication artifacts are deployed to (e.g. ServiceBus or MessageConstructor LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "string",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "messageConstructorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle FTP Message Construction and Sending."
            }
        },
        "messageSuspendProcessorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle suspending of messages."
            }
        },
        "suspendQueueTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic that suspended messages are sent to."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "ftpReceiveApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for FTP Receive operations."
            }
        },
        "ftpReceiveFolder": {
            "type": "string",
            "metadata": {
                "description": "The path where the FTP connector looks for new/updated files."
            }
        },
        "ftpMaxFileCount": {
            "defaultValue": 10,
            "type": "int",
            "metadata": {
                "description": "The max number of files the FTP Connector will retrieve per polling interval."
            }
        },
        "ftpFileMask": {
            "type": "string",
            "metadata": {
                "description": "The mask to use to decide if we're processing a given file e.g. *.* or *.csv"
            }
        },
        "ftpRecurrenceFrequency": {
            "type": "string",
            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
            "metadata": {
                "description": "The frequency with which to check for new files on the FTP server."
            }
        },
        "ftpRecurrenceInterval": {
            "type": "int",
            "metadata": {
                "description": "The interval with which to check for new files on the FTP server."
            }
        },
        "serviceBusTopicPublishApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus SuspendQueue Publish operations."
            }
        },
        "scenario": {
            "type": "string",
            "metadata": {
                "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
            }
        },
        "scenarioStep": {
            "defaultValue": "ftpReceiveAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. ftpReceiveAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messageConstructorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageConstructorLogicAppName'))]",
        "messageSuspendProcessorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageSuspendProcessorLogicAppName'))]",
        "ftpApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('ftpReceiveApiConnectionName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]",
        "serviceBusTopicPublishApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicPublishApiConnectionName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicApStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "ftpReceiveFolder": {
                            "type": "String",
                            "description": "The path where the FTP connector looks for new/updated files."
                        },
                        "ftpMaxFileCount": {
                            "type": "Int",
                            "description": "The max number of files the FTP Connector will retrieve per polling interval."
                        },
                        "ftpRecurrenceFrequency": {
                            "type": "string",
                            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
                            "description": "The frequency with which to check for new files on the FTP server."
                        },
                        "ftpRecurrenceInterval": {
                            "type": "int",
                            "description": "The interval with which to check for new files on the FTP server."
                        },
                        "fileNameMask": {
                            "defaultValue": "*.*",
                            "type": "String",
                            "description": "The mask to use to decide if we're processing a given file e.g. *.* or *.csv"
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        },
                        "scenario": {
                            "type": "String",
                            "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. FTPReceiveAdapter."
                        },
                        "clearCache": {
                            "defaultValue": true,
                            "type": "Bool",
                            "description": "Indicates if we should clear APIM cache before retrieved config items e.g. configurationEntries or routingSlips."
                        },
                        "suspendQueueTopicName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic that suspended messages are sent to."
                        }
                    },
                    "triggers": {
                        "When_a_file_is_added_or_modified_(properties_only)": {
                            "recurrence": {
                                "frequency": "@{parameters('ftpRecurrenceFrequency')}",
                                "interval": "@parameters('ftpRecurrenceInterval')"
                            },
                            "splitOn": "@triggerBody()",
                            "type": "ApiConnection",
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['ftpreceive']['connectionId']"
                                    }
                                },
                                "method": "get",
                                "path": "/datasets/default/triggers/batch/onupdatedfile",
                                "queries": {
                                    "folderId": "@{parameters('ftpReceiveFolder')}",
                                    "maxFileCount": "@parameters('ftpMaxFileCount')"
                                }
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Compose_FileNameMask": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "Compose",
                            "inputs": "@parameters('fileNameMask')"
                        },
                        "Respond:_Were_we_successful": {
                            "actions": {
                                "Terminate_with_ACK": {
                                    "runAfter": {},
                                    "type": "Terminate",
                                    "inputs": {
                                        "runStatus": "Succeeded"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Construct Message": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Do_we_have_a_NACK": {
                                        "actions": {},
                                        "runAfter": {},
                                        "else": {
                                            "actions": {
                                                "Failure:_Build_NACK_message": {
                                                    "runAfter": {},
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "body": [
                                                            {
                                                                "$content": {
                                                                    "code": "500",
                                                                    "message": "@variables('ErrorMessage')",
                                                                    "lastCheckpoint": "@variables('Checkpoint')",
                                                                    "fault": "@variables('FaultMessage')"
                                                                },
                                                                "$contentType": "application/json",
                                                                "$part": 1,
                                                                "$partType": "http://schemas.microsoft.com/aim#nack"
                                                            }
                                                        ],
                                                        "header": {
                                                            "properties": {
                                                                "createDate": "@utcNow()",
                                                                "envelopeType": "nack",
                                                                "messageId": "@guid()",
                                                                "rootPart": 1,
                                                                "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                            },
                                                            "routing": {
                                                                "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                            },
                                                            "routingSlip": {},
                                                            "state": {}
                                                        }
                                                    }
                                                },
                                                "Failure:_Set_ResponseMessage_variable": {
                                                    "runAfter": {
                                                        "Failure:_Build_NACK_message": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "ResponseMessage",
                                                        "value": "@outputs('Failure:_Build_NACK_message')"
                                                    }
                                                }
                                            }
                                        },
                                        "expression": {
                                            "and": [
                                                {
                                                    "equals": [
                                                        "@{coalesce(variables('ResponseMessage')?['header']?['properties']?['envelopeType'], '(unknown)')}",
                                                        "nack"
                                                    ]
                                                }
                                            ]
                                        },
                                        "type": "If"
                                    },
                                    "Failure:_Send_NACK_to_SuspendQueue": {
                                        "runAfter": {
                                            "Failure:_Do_we_have_a_NACK": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Workflow",
                                        "inputs": {
                                            "body": {
                                                "nackMessage": "@variables('ResponseMessage')",
                                                "originalMessage": "@triggerBody()",
                                                "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                "scenario": "@{parameters('scenario')}"
                                            },
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                            },
                                            "host": {
                                                "triggerName": "manual",
                                                "workflow": {
                                                    "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                }
                                            }
                                        }
                                    },
                                    "Terminate_with_NACK": {
                                        "runAfter": {
                                            "Failure:_Send_NACK_to_SuspendQueue": [
                                                "Succeeded",
                                                "Failed",
                                                "Skipped",
                                                "TimedOut"
                                            ]
                                        },
                                        "type": "Terminate",
                                        "inputs": {
                                            "runError": {
                                                "code": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['code'], '500')}",
                                                "message": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['message'], '(unknown error)')}"
                                            },
                                            "runStatus": "Failed"
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "IgnoreFile"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ConstructMessageACK"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(parameters('scenario'))}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@parameters('clearCache')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Compose_FileNameMask": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Configuration": {
                            "actions": {
                                "ValidateConfiguration:_Have_Valid_Properties": {
                                    "actions": {
                                        "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "ValidateConfiguration"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property btsReceivePortName is not set in configuration"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Should_we_process_file": {
                            "actions": {
                                "ShouldWeProcessFile:_Check_FileMask": {
                                    "runAfter": {},
                                    "type": "JavaScriptCode",
                                    "inputs": {
                                        "code": "var escapedFileMask = workflowContext.actions.Compose_FileNameMask.outputs;\r\nvar fileMaskRegex = \"^\" + escapedFileMask.replace(\".\", \"[.]\").replace(\"*\", \".*\").replace(\"?\", \".\") + \"$\";\r\nreturn workflowContext.trigger.outputs.body.Name.match(fileMaskRegex) !== null;"
                                    }
                                },
                                "ShouldWeProcessFile:Failure:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:_Check_FileMask": [
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 500
                                    }
                                },
                                "ShouldWeProcessFile:Success:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:_Check_FileMask": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 200
                                    }
                                },
                                "ShouldWeProcessFile:_Check_StatusCode": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:Failure:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ],
                                        "ShouldWeProcessFile:Success:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ShouldWeProcessFile:Success:_Does_FileMask_match": {
                                                    "actions": {
                                                        "ShouldWeProcessFile:Process:_Set_Checkpoint_variable": {
                                                            "runAfter": {},
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "Checkpoint",
                                                                "value": "ProcessFile"
                                                            }
                                                        }
                                                    },
                                                    "runAfter": {},
                                                    "else": {
                                                        "actions": {
                                                            "ShouldWeProcessFile:Ignore:_Set_Checkpoint_variable": {
                                                                "runAfter": {},
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "IgnoreFile"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "expression": {
                                                        "and": [
                                                            {
                                                                "equals": [
                                                                    "@outputs('ShouldWeProcessFile:_Check_FileMask')?['body']",
                                                                    true
                                                                ]
                                                            }
                                                        ]
                                                    },
                                                    "type": "If"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ShouldWeProcessFile:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('ShouldWeProcessFile:_Check_FileMask')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['statusCode'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['statusCode'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['message'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'])}",
                                                        "faultReason": "@{actions('ShouldWeProcessFile:_Check_FileMask')?['status']}"
                                                    }
                                                }
                                            },
                                            "ShouldWeProcessFile:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to execute the FileMask Javascript"
                                                }
                                            },
                                            "ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "ShouldWeProcessFile:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('ShouldWeProcessFile:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Construct Message": {
                            "actions": {
                                "ConstructMessage:_Call_MessageConstructor": {
                                    "runAfter": {
                                        "ConstructMessage:_Get_file_content": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": {
                                            "$content": "@{body('ConstructMessage:_Get_file_content')}",
                                            "$contentTransferEncoding": "none",
                                            "$contentType": "@triggerBody()?['MediaType']",
                                            "properties": {
                                                "receivedFileName": "@{triggerBody()?['Name']}",
                                                "scenario": "@{parameters('scenario')}",
                                                "btsReceivePortName": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '(unknownReceivePortName)')}",
                                                "btsReceivePortId": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortId'], '(unknownReceivePortId)')}"
                                            }
                                        },
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('messageConstructorLogicAppResourceId')]"
                                            }
                                        }
                                    }
                                },
                                "ConstructMessage:_Check_StatusCode": {
                                    "runAfter": {
                                        "ConstructMessage:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ConstructMessage:Success:_Check_EnvelopeType": {
                                                    "runAfter": {},
                                                    "cases": {
                                                        "ACK": {
                                                            "case": "ack",
                                                            "actions": {
                                                                "ACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "ACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "ACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageACK"
                                                                    }
                                                                }
                                                            }
                                                        },
                                                        "NACK": {
                                                            "case": "nack",
                                                            "actions": {
                                                                "NACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "NACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "NACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageNACK"
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "default": {
                                                        "actions": {
                                                            "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": {
                                                                "runAfter": {},
                                                                "type": "Compose",
                                                                "inputs": {
                                                                    "body": [
                                                                        {
                                                                            "$content": {
                                                                                "code": "500",
                                                                                "message": "@concat('Body returned by action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' is not an ACK or NACK. Envelope type is: ', coalesce(body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType'], '(unknown)'))"
                                                                            },
                                                                            "$contentType": "application/json",
                                                                            "$part": 1,
                                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                                        }
                                                                    ],
                                                                    "header": {
                                                                        "properties": {
                                                                            "createDate": "@utcNow()",
                                                                            "envelopeType": "nack",
                                                                            "messageId": "@guid()",
                                                                            "rootPart": 1,
                                                                            "trackingId": ""
                                                                        },
                                                                        "routing": {
                                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                                        },
                                                                        "routingSlip": {},
                                                                        "state": {}
                                                                    }
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "ResponseMessage",
                                                                    "value": "@outputs('ConstructMessage:UnknownEnvelope:_Compose_NACK_Message')"
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_Checkpoint_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "ConstructMessageNACK"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "expression": "@body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType']",
                                                    "type": "Switch"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ConstructMessage:Failure:_Create_NACK_Message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['error']?['message'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['message'])}",
                                                                    "faultReason": ""
                                                                },
                                                                "message": "@concat('Action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' resulted in an error response.')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": ""
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "ConstructMessage:Failure:_Set_ResponseMessage_variable": {
                                                "runAfter": {
                                                    "ConstructMessage:Failure:_Create_NACK_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ResponseMessage",
                                                    "value": "@outputs('ConstructMessage:Failure:_Create_NACK_Message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "ConstructMessage:_Get_file_content": {
                                    "runAfter": {},
                                    "type": "ApiConnection",
                                    "inputs": {
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['ftpreceive']['connectionId']"
                                            }
                                        },
                                        "method": "get",
                                        "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(triggerBody()?['Id']))}/content",
                                        "queries": {
                                            "inferContentType": true
                                        }
                                    }
                                },
                                "ConstructMessage:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ConstructMessage:_Call_MessageConstructor": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Should_we_process_file": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ProcessFile"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "ftpreceive": {
                                "connectionId": "[variables('ftpApiConnectionResourceId')]",
                                "connectionName": "[parameters('ftpReceiveApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/ftp')]"
                            }
                        }
                    },
                    "ftpReceiveFolder": {
                        "value": "[parameters('ftpReceiveFolder')]"
                    },
                    "ftpMaxFileCount": {
                        "value": "[parameters('ftpMaxFileCount')]"
                    },
                    "ftpRecurrenceFrequency": {
                        "value": "[parameters('ftpRecurrenceFrequency')]"
                    },
                    "ftpRecurrenceInterval": {
                        "value": "[parameters('ftpRecurrenceInterval')]"
                    },
                    "fileNameMask": {
                        "value": "[parameters('ftpFileMask')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    },
                    "scenario": {
                        "value": "[parameters('scenario')]"
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "suspendQueueTopicName": {
                        "value": "[parameters('suspendQueueTopicName')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\ftp\receive\ftpreceiveadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterftp.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterftp.apiconnection.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterftp.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterftp.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterftp.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\ftp\receive\ftpreceiveadapterftp.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterservicebus.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterservicebus.apiconnection.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterservicebus.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\ftpreceiveadapterservicebus.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\ftp\receive\ftpreceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\receive\New-FtpReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates an ftp receive adapter for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FtpReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth" -templateFile ".\ftpreceiveadapter.logicapp.json" -templateParameterFile ".\ftpreceiveadapter.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "ftpreceiveadapter.logicapp.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying an ftp receive adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\receive\New-FtpReceiveAdapterFtp-ApiConnection.ps1
<#
.SYNOPSIS
Creates an ftp api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FtpReceiveAdapterFtp-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth" -templateFile ".\ftpreceiveadapterftp.apiconnection.json" -templateParameterFile ".\ftpreceiveadapterftp.apiconnection.dev.parameters.json" -deploymentName "ftpreceiveadapterftp.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an ftp api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\receive\New-FtpReceiveAdapterFtp-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates an ftp receive api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FtpReceiveAdapterFtp-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\ftpreceiveadapterftp.apiconnpolicy.json" -templateParameterFile ".\ftpreceiveadapterftp.apiconnpolicy.dev.parameters.json" -deploymentName "ftpreceiveadapterftp.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\receive\New-FtpReceiveAdapterServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Creates a service bus api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FtpReceiveAdapterServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth" -templateFile ".\ftpreceiveadaptersb.apiconnection.json" -templateParameterFile ".\ftpreceiveadaptersb.apiconnection.dev.parameters.json" -deploymentName "ftpreceiveadaptersb.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a service bus api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\receive\New-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates an ftp receive service bus api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\ftpreceiveadapterservicebus.apiconnpolicy.json" -templateParameterFile ".\ftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json" -deploymentName "ftpreceiveadapterservicebus.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\receive\Remove-FtpReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the ftp receive adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FtpReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -resourceName "logic-Aim-FtpPassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the ftp receive adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the ftp receive adapter resource: $resourceName"
}
else {
    Write-Host "The ftp receive adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\ftp\receive\Remove-FtpReceiveAdapterFtp-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the ftp api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FtpReceiveAdapterFtp-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth" -resourceName "ftpreceiveconnector-Aim-FtpPassthru-ReceiveLocation-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the ftp api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the ftp api connection resource: $resourceName"
}
else {
    Write-Host "The ftp api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\ftp\receive\Remove-FtpReceiveAdapterServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the ftp receive adapters service bus api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-FtpReceiveAdapterServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth" -resourceName "topicpublisherconnector-ftpreceiveadapater-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the ftp receive adapters service bus api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the ftp receive adapters service bus api connection resource: $resourceName"
}
else {
    Write-Host "The ftp receive adapters service bus api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\ftp\receive\TearDown-100-FtpReceiveAdapterFtp-ApiConnection.ps1.liquid
 
tools\templates\endpoints\ftp\receive\TearDown-100-FtpReceiveAdapterServiceBus-ApiConnection.ps1.liquid
 
tools\templates\endpoints\ftp\receive\TearDown-105-FtpReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\ftp\send\Deploy-100-FtpSendAdapter-ApiConnection.ps1.liquid
 
tools\templates\endpoints\ftp\send\Deploy-105-FtpSendAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\ftp\send\Deploy-110-FtpSendAdapter-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\ftp\send\ftpsendadapter.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\send\ftpsendadapter.apiconnection.json.liquid
 
tools\templates\endpoints\ftp\send\ftpsendadapter.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\send\ftpsendadapter.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\send\ftpsendadapter.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\ftp\send\ftpsendadapter.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\send\ftpsendadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\ftp\send\ftpsendadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "ftpSendApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for FTP Send operations."
            }
        },
        "ftpSendFolder": {
            "defaultValue": "/",
            "type": "string",
            "metadata": {
                "description": "The path where the FTP connector send files."
            }
        },
        "ftpSendFileName": {
            "defaultValue": "%MessageID%-%SourceFileName%",
            "type": "string",
            "metadata": {
                "description": "The name of the file to send (can include macro values e.g. %MessageID% or %SourceFileName%)."
            }
        },
        "scenarioStep": {
            "defaultValue": "ftpSendAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. ftpSendAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "ftpSendApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('ftpSendApiConnectionName'))]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "ftpSendFolder": {
                            "type": "String",
                            "description": "The path where the FTP connector send files."
                        },
                        "ftpSendFileName": {
                            "type": "String",
                            "description": "The name of the file to send (can include macro values e.g. %MessageID% or %SourceFileName%))."
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. ftpSendAdapter."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_SendFileName_variable": {
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "SendFileName",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_SendToFTP": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SendToFTP"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_SendFileName_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Missing:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "NoBodyContent"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_GetSendFileName": {
                            "actions": {
                                "GetSendFileName:_Set_SendFileName_variable": {
                                    "description": "A full list of supported FileName macros can be found here: https://social.technet.microsoft.com/wiki/contents/articles/8823.biztalk-server-list-of-macros.aspx. At this time we are not supporting the Party macros.",
                                    "type": "SetVariable",
                                    "runAfter": {},
                                    "inputs": {
                                        "name": "SendFileName",
                                        "value": "@{replace(replace(replace(replace(replace(replace(replace(parameters('ftpSendFileName'), '%MessageID%', coalesce(triggerBody()?['header']?['properties']?['messageId'], guid())), '%SourceFileName%', coalesce(triggerBody()?['header']?['properties']?['receivedFileName'], 'myfile.txt')), '%datetime%', utcNow('yyyy-MM-ddThhmmss')), '%datetime_bts2000%', utcNow('yyyyMMddhhmmsss')), '%datetime.tz%', utcNow('yyyy-MM-ddThhmmssK')), '%time%', utcNow('hhmmss')), '%time.tz%', utcNow('hhmmssK'))}"
                                    }
                                },
                                "SendToFTP:_Set_Checkpoint_variable": {
                                    "runAfter": {
                                        "GetSendFileName:_Set_SendFileName_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "GetSendFileName"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "NoBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_SendToFTP": {
                            "actions": {
                                "SendToFTP:_Check_Status_Code": {
                                    "runAfter": {
                                        "SendToFTP:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "SendToFTP:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "SendToFTP"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "SendToFTP:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "SendToFTP:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "SendToFTP:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FTP connector"
                                                        }
                                                    },
                                                    "SendToFTP:Fault:_Create_Fault_Message": {
                                                        "runAfter": {},
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "fault": {
                                                                "faultActor": "@concat(workflow()?['name'], '.', actions('SendToFTP:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                "faultCategory": "Error",
                                                                "faultCode": "@{coalesce(outputs('SendToFTP:_Create_File')?['statusCode'], outputs('SendToFTP:_Create_File')?['body']?['statusCode'], actions('SendToFTP:_Create_File')?['error']?['code'])}",
                                                                "faultMessage": "@{coalesce(outputs('SendToFTP:_Create_File')?['error']?['message'], outputs('SendToFTP:_Create_File')?['body']?['message'], actions('SendToFTP:_Create_File')?['error']?['message'])}",
                                                                "faultReason": "@{actions('SendToFTP:_Create_File')?['status']}"
                                                            }
                                                        }
                                                    },
                                                    "SendToFTP:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {
                                                            "SendToFTP:Fault:_Create_Fault_Message": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('SendToFTP:Fault:_Create_Fault_Message')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "SendToFTP:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('SendToFTP:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('SendToFTP:_Create_File')?['statusCode'], outputs('SendToFTP:_Create_File')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('SendToFTP:_Create_File')?['error']?['message'], outputs('SendToFTP:_Create_File')?['body']?['message'])}",
                                                                    "faultReason": "@actions('SendToFTP:_Create_File')?['inputs']?['path']"
                                                                }
                                                            }
                                                        },
                                                        "SendToFTP:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "SendToFTP:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FTP connector"
                                                            }
                                                        },
                                                        "SendToFTP:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "SendToFTP:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('SendToFTP:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('SendToFTP:_Create_File')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "SendToFTP:_Create_File": {
                                    "inputs": {
                                        "body": "@variables('BodyContent')",
                                        "headers": {
                                            "ReadFileMetadataFromServer": true
                                        },
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['ftpsend']['connectionId']"
                                            }
                                        },
                                        "method": "post",
                                        "path": "/datasets/default/files",
                                        "queries": {
                                            "folderPath": "@parameters('ftpSendFolder')",
                                            "name": "@variables('SendFileName')",
                                            "queryParametersSingleEncoded": true
                                        }
                                    },
                                    "runAfter": {},
                                    "runtimeConfiguration": {
                                        "contentTransfer": {
                                            "transferMode": "Chunked"
                                        }
                                    },
                                    "type": "ApiConnection"
                                },
                                "SendToFTP:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "SendToFTP:_Create_File": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('SendToFTP:_Create_File')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_GetSendFileName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetSendFileName"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "ftpsend": {
                                "connectionId": "[variables('ftpSendApiConnectionResourceId')]",
                                "connectionName": "[parameters('ftpSendApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/ftp')]"
                            }
                        }
                    },
                    "ftpSendFolder": {
                        "value": "[parameters('ftpSendFolder')]"
                    },
                    "ftpSendFileName": {
                        "value": "[parameters('ftpSendFileName')]"
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\ftp\send\ftpsendadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\ftp\send\New-FtpSendAdapter-ApiConnection.ps1
<#
.SYNOPSIS
Creates an ftp connector for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-FtpSendAdapter-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -templateFile ".\ftpconnection.json" -templateParameterFile ".\ftpconnection.dev.parameters.json" -deploymentName "ftpsendconnection"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an ftp connector`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\send\New-FtpSendAdapter-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates an ftp send api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FtpSendAdapter-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\ftpsendadapter.apiconnpolicy.json" -templateParameterFile ".\ftpsendadapter.apiconnpolicy.dev.parameters.json" -deploymentName "ftpsendadapter.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\send\New-FtpSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates an ftp adapter for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-FtpSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -templateFile ".\ftpadapter.json" -templateParameterFile ".\ftpadapter.dev.parameters.json" -deploymentName "ftpadapter"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for the routing slip router Logic App"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying an ftp adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\ftp\send\Remove-FtpSendAdapter-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the ftp connector.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-FtpSendAdapter-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -resourceName "ftpreceiveconnector-Aim-FtpPassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the ftp connector resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the ftp connector resource: $resourceName"
}
else {
    Write-Host "The ftp connector resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\ftp\send\Remove-FtpSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the ftp adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-FtpSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -resourceName "logic-Aim-FtpPassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the ftp adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the ftp adapter resource: $resourceName"
}
else {
    Write-Host "The ftp adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\ftp\send\TearDown-100-FtpSendAdapter-ApiConnection.ps1.liquid
 
tools\templates\endpoints\ftp\send\TearDown-105-FtpSendAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\http\receive\Deploy-105-HttpReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\http\receive\httpreceiveadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\http\receive\httpreceiveadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicApStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "systemApplicationResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that SystemApplication artifacts are deployed to (e.g. ServiceBus or MessageConstructor LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "string",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "messageConstructorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle File Message Construction and Sending."
            }
        },
        "messageResponseHandlerLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle retrieving the response in a two-way messaging scenario."
            }
        },
        "messageSuspendProcessorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle suspending of messages."
            }
        },
        "suspendQueueTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic that suspended messages are sent to."
            }
        },
        "responseTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic where response messages are found for two-way operations."
            }
        },
        "responseSubscriptionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Subscription used to get response messages for two-way operations."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },

        "scenario": {
            "type": "string",
            "metadata": {
                "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
            }
        },
        "scenarioStep": {
            "defaultValue": "httpReceiveAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. httpReceiveAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "messageConstructorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageConstructorLogicAppName'))]",
        "messageResponseHandlerLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageResponseHandlerLogicAppName'))]",
        "messageSuspendProcessorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageSuspendProcessorLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicApStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        },
                        "scenario": {
                            "type": "String",
                            "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. httpReceiveAdapter."
                        },
                        "clearCache": {
                            "defaultValue": true,
                            "type": "Bool",
                            "description": "Indicates if we should clear APIM cache before retrieved config items e.g. configurationEntries or routingSlips."
                        },
                        "suspendQueueTopicName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic that suspended messages are sent to."
                        },
                        "responseTopicName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic where response messages are found for two-way operations."
                        },
                        "responseSubscriptionName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Subscription used to get response messages for two-way operations."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_TwoWayResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "TwoWayResponseMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_TwoWayResponseContent_variable": {
                            "runAfter": {
                                "Initialize_TwoWayResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "TwoWayResponseContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Respond:_Were_we_successful": {
                            "actions": {
                                "Respond:_Is_this_a_TwoWay_adapter": {
                                    "actions": {
                                        "Respond:TwoWay:_Call_Response_Handler": {
                                            "runAfter": {},
                                            "type": "Workflow",
                                            "inputs": {
                                                "body": {
                                                    "responseTopicName": "@{parameters('responseTopicName')}",
                                                    "responseSubscriptionName": "@{parameters('responseSubscriptionName')}",
                                                    "correlationId": "@variables('ResponseMessage')?['header']?['properties']?['correlationId']",
                                                    "responseTimeoutInMinutes": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['responseTimeoutInMinutes'], 3)"
                                                },
                                                "headers": {
                                                    "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                    "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                                },
                                                "host": {
                                                    "triggerName": "manual",
                                                    "workflow": {
                                                        "id": "[variables('messageResponseHandlerLogicAppResourceId')]"
                                                    }
                                                }
                                            }
                                        },
                                        "Respond:TwoWay:_Check_StatusCode": {
                                            "runAfter": {
                                                "Respond:TwoWay:_Set_StatusCode_variable": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "cases": {
                                                "Success": {
                                                    "case": 200,
                                                    "actions": {
                                                        "Respond:TwoWay:Success:_Set_TwoWayResponseMessage_variable": {
                                                            "runAfter": {},
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "TwoWayResponseMessage",
                                                                "value": "@body('Respond:TwoWay:_Call_Response_Handler')"
                                                            }
                                                        },
                                                        "Respond:TwoWay:Success:_Check_TwoWayResponse_ContentType": {
                                                            "runAfter": {
                                                                "Respond:TwoWay:Success:_Set_TwoWayResponseMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "If",
                                                            "actions": {
                                                                "Respond:TwoWay:Success:_Get_Response_BodyContent": {
                                                                    "runAfter": {},
                                                                    "type": "ApiManagement",
                                                                    "inputs": {
                                                                        "api": {
                                                                            "id": "[variables('messagingManagerApiResourceId')]"
                                                                        },
                                                                        "body": "@if(equals(variables('TwoWayResponseMessage')?['$content-encoding'], 'Base64'), json(decodeBase64(variables('TwoWayResponseMessage')?['$content'])), variables('TwoWayResponseMessage')?['$content'])",
                                                                        "headers": {
                                                                            "Aim-Tracking-Id": "@{variables('ResponseMessage')?['header']?['properties']?['trackingId']}",
                                                                            "Content-Type": "application/json"
                                                                        },
                                                                        "method": "post",
                                                                        "pathTemplate": {
                                                                            "parameters": {},
                                                                            "template": "/aimmessagingmanager/getbodycontent"
                                                                        },
                                                                        "queries": {
                                                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                                                        },
                                                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                                                    }
                                                                },
                                                                "Respond:TwoWay:Success:GetBodyContent:_Check_Status_Code": {
                                                                    "runAfter": {
                                                                        "Respond:TwoWay:Success:GetBodyContent:_Set_StatusCode_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "cases": {
                                                                        "Success": {
                                                                            "case": 200,
                                                                            "actions": {
                                                                                "Respond:TwoWay:Success:GetBodyContent:_Set_TwoWayResponseContent_variable": {
                                                                                    "runAfter": {},
                                                                                    "type": "SetVariable",
                                                                                    "inputs": {
                                                                                        "name": "TwoWayResponseContent",
                                                                                        "value": "@decodeBase64(body('Respond:TwoWay:Success:_Get_Response_BodyContent')?['$content'])"
                                                                                    }
                                                                                },
                                                                                "Respond:TwoWay:Success:GetBodyContent:Success:_Send_Response": {
                                                                                    "inputs": {
                                                                                        "body": "@variables('TwoWayResponseContent')",
                                                                                        "statusCode": 200,
                                                                                        "headers": {
                                                                                            "Content-Type": "@body('Respond:TwoWay:Success:_Get_Response_BodyContent')?['$contentType']"
                                                                                        }
                                                                                    },
                                                                                    "kind": "Http",
                                                                                    "runAfter": {
                                                                                        "Respond:TwoWay:Success:GetBodyContent:_Set_TwoWayResponseContent_variable": [
                                                                                            "Succeeded"
                                                                                        ]
                                                                                    },
                                                                                    "type": "Response"
                                                                                }
                                                                            }
                                                                        }
                                                                    },
                                                                    "default": {
                                                                        "actions": {
                                                                            "Respond:TwoWay:Success:GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                                                "actions": {
                                                                                    "Respond:TwoWay:Success:GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                                                        "runAfter": {
                                                                                            "Respond:TwoWay:Success:GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                                                "Succeeded"
                                                                                            ]
                                                                                        },
                                                                                        "type": "SetVariable",
                                                                                        "inputs": {
                                                                                            "name": "ErrorMessage",
                                                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                                                        }
                                                                                    },
                                                                                    "Respond:TwoWay:Success:GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                                                        "runAfter": {},
                                                                                        "type": "SetVariable",
                                                                                        "inputs": {
                                                                                            "name": "FaultMessage",
                                                                                            "value": "@body('Respond:TwoWay:Success:_Get_Response_BodyContent')"
                                                                                        }
                                                                                    }
                                                                                },
                                                                                "runAfter": {},
                                                                                "else": {
                                                                                    "actions": {
                                                                                        "Respond:TwoWay:Success:GetBodyContent:NoFault:_Create_Fault_Message": {
                                                                                            "runAfter": {},
                                                                                            "type": "Compose",
                                                                                            "inputs": {
                                                                                                "fault": {
                                                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Respond:TwoWay:Success:_Get_Response_BodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                                                    "faultCategory": "Error",
                                                                                                    "faultCode": "@{coalesce(outputs('Respond:TwoWay:Success:_Get_Response_BodyContent')?['statusCode'], outputs('Respond:TwoWay:Success:_Get_Response_BodyContent')?['body']?['statusCode'], actions('Respond:TwoWay:Success:_Get_Response_BodyContent')?['error']?['code'])}",
                                                                                                    "faultMessage": "@{coalesce(outputs('Respond:TwoWay:Success:_Get_Response_BodyContent')?['error']?['message'], outputs('Respond:TwoWay:Success:_Get_Response_BodyContent')?['body']?['message'], actions('Respond:TwoWay:Success:_Get_Response_BodyContent')?['error']?['message'])}",
                                                                                                    "faultReason": "@{actions('Respond:TwoWay:Success:_Get_Response_BodyContent')?['status']}"
                                                                                                }
                                                                                            }
                                                                                        },
                                                                                        "Respond:TwoWay:Success:GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                                                            "runAfter": {
                                                                                                "Respond:TwoWay:Success:GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                                                    "Succeeded"
                                                                                                ]
                                                                                            },
                                                                                            "type": "SetVariable",
                                                                                            "inputs": {
                                                                                                "name": "ErrorMessage",
                                                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                                                            }
                                                                                        },
                                                                                        "Respond:TwoWay:Success:GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                                                            "runAfter": {
                                                                                                "Respond:TwoWay:Success:GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                                                    "Succeeded"
                                                                                                ]
                                                                                            },
                                                                                            "type": "SetVariable",
                                                                                            "inputs": {
                                                                                                "name": "FaultMessage",
                                                                                                "value": "@outputs('Respond:TwoWay:Success:GetBodyContent:NoFault:_Create_Fault_Message')"
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                },
                                                                                "expression": {
                                                                                    "and": [
                                                                                        {
                                                                                            "not": {
                                                                                                "equals": [
                                                                                                    "@body('Respond:TwoWay:Success:_Get_Response_BodyContent')?['fault']",
                                                                                                    null
                                                                                                ]
                                                                                            }
                                                                                        }
                                                                                    ]
                                                                                },
                                                                                "type": "If"
                                                                            },
                                                                            "Respond:TwoWay:Success:GetBodyContent:Failure:_Build_NACK_message": {
                                                                                "runAfter": {
                                                                                    "Respond:TwoWay:Success:GetBodyContent:Failure:_Do_we_have_a_Fault_Message": [
                                                                                        "Succeeded"
                                                                                    ]
                                                                                },
                                                                                "type": "Compose",
                                                                                "inputs": {
                                                                                    "body": [
                                                                                        {
                                                                                            "$content": {
                                                                                                "code": "500",
                                                                                                "message": "@variables('ErrorMessage')",
                                                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                                                "fault": "@variables('FaultMessage')"
                                                                                            },
                                                                                            "$contentType": "application/json",
                                                                                            "$part": 1,
                                                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                                                        }
                                                                                    ],
                                                                                    "header": {
                                                                                        "properties": {
                                                                                            "createDate": "@utcNow()",
                                                                                            "envelopeType": "nack",
                                                                                            "messageId": "@guid()",
                                                                                            "rootPart": 1,
                                                                                            "trackingId": "@body('Respond:TwoWay:_Call_Response_Handler')?['header']?['properties']?['trackingId']"
                                                                                        },
                                                                                        "routing": {
                                                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                                                        },
                                                                                        "routingSlip": {},
                                                                                        "state": {}
                                                                                    }
                                                                                }
                                                                            },
                                                                            "Respond:TwoWay:Success:GetBodyContent:Failure:_Send_to_SuspendQueue": {
                                                                                "runAfter": {
                                                                                    "Respond:TwoWay:Success:GetBodyContent:Failure:_Build_NACK_message": [
                                                                                        "Succeeded",
                                                                                        "Failed",
                                                                                        "TimedOut"
                                                                                    ]
                                                                                },
                                                                                "type": "Workflow",
                                                                                "inputs": {
                                                                                    "body": {
                                                                                        "nackMessage": "@outputs('Respond:TwoWay:Success:GetBodyContent:Failure:_Build_NACK_message')",
                                                                                        "originalMessage": "@body('Respond:TwoWay:_Call_Response_Handler')",
                                                                                        "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                                                        "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                                                        "scenario": "@{parameters('scenario')}"
                                                                                    },
                                                                                    "headers": {
                                                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                                                                    },
                                                                                    "host": {
                                                                                        "triggerName": "manual",
                                                                                        "workflow": {
                                                                                            "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                                                        }
                                                                                    }
                                                                                }
                                                                            },
                                                                            "Respond:TwoWay:Success:GetBodyContent:Failure:_Send_Response": {
                                                                                "inputs": {
                                                                                    "body": "@variables('FaultMessage')",
                                                                                    "statusCode": 500,
                                                                                    "headers": {
                                                                                        "Content-Type": "application/json"
                                                                                    }
                                                                                },
                                                                                "kind": "Http",
                                                                                "runAfter": {
                                                                                    "Respond:TwoWay:Success:GetBodyContent:Failure:_Send_to_SuspendQueue": [
                                                                                        "Succeeded",
                                                                                        "Failed",
                                                                                        "TimedOut"
                                                                                    ]
                                                                                },
                                                                                "type": "Response"
                                                                            }
                                                                        }
                                                                    },
                                                                    "expression": "@variables('StatusCode')",
                                                                    "type": "Switch"
                                                                },
                                                                "Respond:TwoWay:Success:GetBodyContent:_Set_StatusCode_variable": {
                                                                    "runAfter": {
                                                                        "Respond:TwoWay:Success:_Get_Response_BodyContent": [
                                                                            "Succeeded",
                                                                            "Failed",
                                                                            "Skipped",
                                                                            "TimedOut"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "StatusCode",
                                                                        "value": "@coalesce(outputs('Respond:TwoWay:Success:_Get_Response_BodyContent')['statusCode'], 500)"
                                                                    }
                                                                }
                                                            },
                                                            "else": {
                                                                "actions": {
                                                                    "Respond:TwoWay:Success:UnknownContentType:_Send_Response": {
                                                                        "inputs": {
                                                                            "body": "@if(equals(variables('TwoWayResponseMessage')?['$content-encoding'], 'Base64'), json(decodeBase64(variables('TwoWayResponseMessage')?['$content'])), variables('TwoWayResponseMessage')?['$content'])",
                                                                            "statusCode": 200,
                                                                            "headers": {
                                                                                "Content-Type": "@variables('TwoWayResponseMessage')?['$content-type']"
                                                                            }
                                                                        },
                                                                        "kind": "Http",
                                                                        "runAfter": {},
                                                                        "type": "Response"
                                                                    }
                                                                }
                                                            },
                                                            "expression": {
                                                                "or": [
                                                                    {
                                                                        "equals": [
                                                                            "@variables('TwoWayResponseMessage')?['$content-type']",
                                                                            "text/json"
                                                                        ]
                                                                    },
                                                                    {
                                                                        "equals": [
                                                                            "@variables('TwoWayResponseMessage')?['$content-type']",
                                                                            "application/json"
                                                                        ]
                                                                    }
                                                                ]
                                                            }
                                                        }
                                                    }   
                                                }
                                            },
                                            "default": {
                                                "actions": {
                                                    "Respond:TwoWay:Failure:_Create_Fault": {
                                                        "runAfter": {},
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "fault": {
                                                                "faultActor": "@concat(workflow()?['name'], '.', actions('Respond:TwoWay:_Call_Response_Handler')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                "faultCategory": "Error",
                                                                "faultCode": "@{outputs('Respond:TwoWay:_Call_Response_Handler')?['statusCode']}",
                                                                "faultMessage": "An error occurred whilst trying to get the response message for a two-way scenario.",
                                                                "faultReason": "@{coalesce(body('Respond:TwoWay:_Call_Response_Handler')?['fault']?['faultMessage'], body('Respond:TwoWay:_Call_Response_Handler')?['error']?['message'])}"
                                                            }
                                                        }
                                                    },
                                                    "Respond:TwoWay:Failure:_Set_FaultMessage_variable": {
                                                        "runAfter": {
                                                            "Respond:TwoWay:Failure:_Create_Fault": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@outputs('Respond:TwoWay:Failure:_Create_Fault')"
                                                        }
                                                    },
                                                    "Respond:TwoWay:Failure:_Create_NACK_Message": {
                                                        "runAfter": {
                                                            "Respond:TwoWay:Failure:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "body": [
                                                                {
                                                                    "$content": {
                                                                        "code": "500",
                                                                        "fault": "@variables('FaultMessage')",
                                                                        "message": "Action @{actions('Respond:TwoWay:_Call_Response_Handler')?['name']} resulted in an error response."
                                                                    },
                                                                    "$contentType": "application/json",
                                                                    "$part": 1,
                                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                                }
                                                            ],
                                                            "header": {
                                                                "properties": {
                                                                    "createDate": "@utcNow()",
                                                                    "envelopeType": "nack",
                                                                    "messageId": "@guid()",
                                                                    "rootPart": 1,
                                                                    "trackingId": "@body('Respond:TwoWay:_Call_Response_Handler')?['header']?['properties']?['trackingId']"
                                                                },
                                                                "routing": {
                                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                                },
                                                                "routingSlip": {},
                                                                "state": {}
                                                            }
                                                        }
                                                    },
                                                    "Respond:TwoWay:Failure:_Send_to_SuspendQueue": {
                                                        "runAfter": {
                                                            "Respond:TwoWay:Failure:_Create_NACK_Message": [
                                                                "Succeeded",
                                                                "Failed",
                                                                "TimedOut"
                                                            ]
                                                        },
                                                        "type": "Workflow",
                                                        "inputs": {
                                                            "body": {
                                                                "nackMessage": "@outputs('Respond:TwoWay:Failure:_Create_NACK_Message')",
                                                                "originalMessage": "@variables('ResponseMessage')",
                                                                "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                                "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                                "scenario": "@{parameters('scenario')}"
                                                            },
                                                            "headers": {
                                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                                            },
                                                            "host": {
                                                                "triggerName": "manual",
                                                                "workflow": {
                                                                    "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "Respond:TwoWay:Failure:_Send_Fault_Response": {
                                                        "inputs": {
                                                            "body": "@variables('FaultMessage')",
                                                            "statusCode": "@coalesce(outputs('Respond:TwoWay:_Call_Response_Handler')?['statusCode'], 500)",
                                                            "headers": {
                                                                "Content-Type": "application/json"
                                                            }
                                                        },
                                                        "kind": "Http",
                                                        "runAfter": {
                                                            "Respond:TwoWay:Failure:_Send_to_SuspendQueue": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "Response"
                                                    }
                                                }
                                            },
                                            "expression": "@variables('StatusCode')",
                                            "type": "Switch"
                                        },
                                        "Respond:TwoWay:_Set_StatusCode_variable": {
                                            "runAfter": {
                                                "Respond:TwoWay:_Call_Response_Handler": [
                                                    "Succeeded",
                                                    "Failed",
                                                    "Skipped",
                                                    "TimedOut"
                                                ]
                                            },
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "StatusCode",
                                                "value": "@coalesce(outputs('Respond:TwoWay:_Call_Response_Handler')?['statusCode'], 500)"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "Respond:OneWay:_Send_Accepted_Response": {
                                                "inputs": {
                                                    "statusCode": 202,
                                                    "headers": {
                                                        "Content-Type": "application/json"
                                                    }
                                                },
                                                "kind": "Http",
                                                "runAfter": {},
                                                "type": "Response"
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['isTwoWay'], false)",
                                                    true
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "if"
                                }
                            },
                            "runAfter": {
                                "Step:_Construct Message": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Do_we_have_a_NACK": {
                                        "actions": {},
                                        "runAfter": {},
                                        "else": {
                                            "actions": {
                                                "Failure:_Build_NACK_message": {
                                                    "runAfter": {},
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "body": [
                                                            {
                                                                "$content": {
                                                                    "code": "500",
                                                                    "message": "@variables('ErrorMessage')",
                                                                    "lastCheckpoint": "@variables('Checkpoint')",
                                                                    "fault": "@variables('FaultMessage')"
                                                                },
                                                                "$contentType": "application/json",
                                                                "$part": 1,
                                                                "$partType": "http://schemas.microsoft.com/aim#nack"
                                                            }
                                                        ],
                                                        "header": {
                                                            "properties": {
                                                                "createDate": "@utcNow()",
                                                                "envelopeType": "nack",
                                                                "messageId": "@guid()",
                                                                "rootPart": 1,
                                                                "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                            },
                                                            "routing": {
                                                                "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                            },
                                                            "routingSlip": {},
                                                            "state": {}
                                                        }
                                                    }
                                                },
                                                "Failure:_Set_ResponseMessage_variable": {
                                                    "runAfter": {
                                                        "Failure:_Build_NACK_message": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "ResponseMessage",
                                                        "value": "@outputs('Failure:_Build_NACK_message')"
                                                    }
                                                }
                                            }
                                        },
                                        "expression": {
                                            "and": [
                                                {
                                                    "equals": [
                                                        "@{coalesce(variables('ResponseMessage')?['header']?['properties']?['envelopeType'], '(unknown)')}",
                                                        "nack"
                                                    ]
                                                }
                                            ]
                                        },
                                        "type": "If"
                                    },
                                    "Failure:_Send_NACK_to_SuspendQueue": {
                                        "runAfter": {
                                            "Failure:_Do_we_have_a_NACK": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Workflow",
                                        "inputs": {
                                            "body": {
                                                "nackMessage": "@variables('ResponseMessage')",
                                                "originalMessage": "@triggerBody()",
                                                "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                "scenario": "@{parameters('scenario')}"
                                            },
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                            },
                                            "host": {
                                                "triggerName": "manual",
                                                "workflow": {
                                                    "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                }
                                            }
                                        }
                                    },
                                    "Failure:_Send_Fault_Response": {
                                        "inputs": {
                                            "body": {
                                                "fault": {
                                                    "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                    "faultCategory": "Error",
                                                    "faultCode": "500",
                                                    "faultMessage": "@variables('ErrorMessage')",
                                                    "faultReason": ""
                                                }
                                            },
                                            "headers": {
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 500
                                        },
                                        "kind": "Http",
                                        "runAfter": {
                                            "Failure:_Send_NACK_to_SuspendQueue": [
                                                "Succeeded",
                                                "Failed",
                                                "Skipped",
                                                "TimedOut"
                                            ]
                                        },
                                        "type": "Response"
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "IgnoreFile"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ConstructMessageACK"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(parameters('scenario'))}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@parameters('clearCache')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_TwoWayResponseContent_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Configuration": {
                            "actions": {
                                "ValidateConfiguration:_Have_Valid_Properties": {
                                    "actions": {
                                        "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "ValidateConfiguration"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property btsReceivePortName is not set in configuration"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Construct Message": {
                            "actions": {
                                "ConstructMessage:_Call_MessageConstructor": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": {
                                            "$content": "@triggerBody()",
                                            "$contentTransferEncoding": "none",
                                            "$contentType": "@triggerOutputs()?['headers']?['Content-Type']",
                                            "properties": {
                                                "scenario": "@{parameters('scenario')}",
                                                "btsReceivePortName": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '(unknownReceivePortName)')}",
                                                "btsReceivePortId": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortId'], '(unknownReceivePortId)')}"
                                            }
                                        },
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('messageConstructorLogicAppResourceId')]"
                                            }
                                        }
                                    }
                                },
                                "ConstructMessage:_Check_StatusCode": {
                                    "runAfter": {
                                        "ConstructMessage:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ConstructMessage:Success:_Check_EnvelopeType": {
                                                    "runAfter": {},
                                                    "cases": {
                                                        "ACK": {
                                                            "case": "ack",
                                                            "actions": {
                                                                "ACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "ACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "ACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageACK"
                                                                    }
                                                                }
                                                            }
                                                        },
                                                        "NACK": {
                                                            "case": "nack",
                                                            "actions": {
                                                                "NACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "NACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "NACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageNACK"
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "default": {
                                                        "actions": {
                                                            "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": {
                                                                "runAfter": {},
                                                                "type": "Compose",
                                                                "inputs": {
                                                                    "body": [
                                                                        {
                                                                            "$content": {
                                                                                "code": "500",
                                                                                "message": "@concat('Body returned by action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' is not an ACK or NACK. Envelope type is: ', coalesce(body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType'], '(unknown)'))"
                                                                            },
                                                                            "$contentType": "application/json",
                                                                            "$part": 1,
                                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                                        }
                                                                    ],
                                                                    "header": {
                                                                        "properties": {
                                                                            "createDate": "@utcNow()",
                                                                            "envelopeType": "nack",
                                                                            "messageId": "@guid()",
                                                                            "rootPart": 1,
                                                                            "trackingId": ""
                                                                        },
                                                                        "routing": {
                                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                                        },
                                                                        "routingSlip": {},
                                                                        "state": {}
                                                                    }
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "ResponseMessage",
                                                                    "value": "@outputs('ConstructMessage:UnknownEnvelope:_Compose_NACK_Message')"
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_Checkpoint_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "ConstructMessageNACK"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "expression": "@body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType']",
                                                    "type": "Switch"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ConstructMessage:Failure:_Create_NACK_Message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['error']?['message'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['message'])}",
                                                                    "faultReason": ""
                                                                },
                                                                "message": "@concat('Action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' resulted in an error response.')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": ""
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "ConstructMessage:Failure:_Set_ResponseMessage_variable": {
                                                "runAfter": {
                                                    "ConstructMessage:Failure:_Create_NACK_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ResponseMessage",
                                                    "value": "@outputs('ConstructMessage:Failure:_Create_NACK_Message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "ConstructMessage:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ConstructMessage:_Call_MessageConstructor": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    },
                    "scenario": {
                        "value": "[parameters('scenario')]"
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "suspendQueueTopicName": {
                        "value": "[parameters('suspendQueueTopicName')]"
                    },
                    "responseTopicName": {
                        "value": "[parameters('responseTopicName')]"
                    },
                    "responseSubscriptionName": {
                        "value": "[parameters('responseSubscriptionName')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\http\receive\httpreceiveadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\http\receive\New-HttpReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates a http receive adapter for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-HttpReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-httpjsonorch-dev-uksouth" -templateFile ".\httpreceiveadapter.logicapp.json" -templateParameterFile ".\httpreceiveadapter.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "httpreceiveadapter.logicapp.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying a http receive adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\http\receive\Remove-HttpReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the http receive adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-HttpReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-httpjsonorch-dev-uksouth-xxxxx" -resourceName "logic-aimhttpradapter-purchaseorderhttpjsonreceive-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the http receive adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the http receive adapter resource: $resourceName"
}
else {
    Write-Host "The http receive adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\http\receive\TearDown-105-HttpReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\http\send\Deploy-105-HttpSendAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\http\send\httpsendadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "httpSendAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. httpSendAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. httpSendAdapter."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_SendToHttp": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SendToHttp"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Missing:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "NoBodyContent"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_SendToHttp": {
                            "actions": {
                                "SendToHttp:_Check_Status_Code": {
                                    "runAfter": {
                                        "SendToHttp:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "SendToHttp:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "SendToHttp"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "SendToHttp:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "SendToHttp:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "SendToHttp:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send an HTTP request"
                                                        }
                                                    },
                                                    "SendToHttp:Fault:_Create_Fault_Message": {
                                                        "runAfter": {},
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "fault": {
                                                                "faultActor": "@concat(workflow()?['name'], '.', actions('SendToHttp:_SendHttp')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                "faultCategory": "Error",
                                                                "faultCode": "@{coalesce(outputs('SendToHttp:_SendHttp')?['statusCode'], outputs('SendToHttp:_SendHttp')?['body']?['statusCode'], actions('SendToHttp:_SendHttp')?['error']?['code'])}",
                                                                "faultMessage": "@{coalesce(outputs('SendToHttp:_SendHttp')?['error']?['message'], outputs('SendToHttp:_SendHttp')?['body']?['message'], actions('SendToHttp:_SendHttp')?['error']?['message'])}",
                                                                "faultReason": "@{actions('SendToHttp:_SendHttp')?['status']}"
                                                            }
                                                        }
                                                    },
                                                    "SendToHttp:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {
                                                            "SendToHttp:Fault:_Create_Fault_Message": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('SendToHttp:Fault:_Create_Fault_Message')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "SendToHttp:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('SendToHttp:_SendHttp')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('SendToHttp:_SendHttp')?['statusCode'], outputs('SendToHttp:_SendHttp')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('SendToHttp:_SendHttp')?['error']?['message'], outputs('SendToHttp:_SendHttp')?['body']?['message'])}",
                                                                    "faultReason": "@actions('SendToHttp:_SendHttp')?['inputs']?['path']"
                                                                }
                                                            }
                                                        },
                                                        "SendToHttp:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "SendToHttp:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send an HTTP request"
                                                            }
                                                        },
                                                        "SendToHttp:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "SendToHttp:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('SendToHttp:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('SendToHttp:_SendHttp')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "SendToHttp:_SendHttp": {
                                    "inputs": {
                                        "body": "@variables('BodyContent')",
                                        "headers": {
                                            "Content-Type": "@{body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$contentType']}"
                                        },
                                        "method": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['httpMethod'], 'POST')}",
                                        "uri": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['httpUri'], '')}"
                                    },
                                    "runAfter": {},
                                    "type": "Http"
                                },
                                "SendToHttp:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "SendToHttp:_SendHttp": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('SendToHttp:_SendHttp')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\http\send\httpsendadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\http\send\httpsnedadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\http\send\New-HttpSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates a http send adapter for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-HttpSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-httpjsonorch-dev-uksouth" -templateFile ".\httpsendadapter.logicapp.json" -templateParameterFile ".\httpsendadapter.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "httpsendadapter.logicapp.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying a http send adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\http\send\Remove-HttpSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the http send adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-HttpSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-httpjsonorch-dev-uksouth-xxxxx" -resourceName "logic-aimhttpsadapter-purchaseorderhttpjsonsend-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the http send adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the http send adapter resource: $resourceName"
}
else {
    Write-Host "The http send adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\http\send\TearDown-105-HttpSendAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\messageconstructor\Deploy-85-MessageConstructor-LogicApp.ps1.liquid
 
tools\templates\endpoints\messageconstructor\messageconstructor.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\messageconstructor\messageconstructor.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "defaultValue": "[resourceGroup().name]",
            "metadata": {
                "description": "Name of the ResourceGroup that APIM is deployed to (if different from the ResourceGroup that this LogicApp is deployed to)."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "messageConstructor",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. messageConstructor."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. messageConstructor."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {
                                    "properties": {
                                        "$content": {
                                            "type": "string"
                                        },
                                        "$contentTransferEncoding": {
                                            "type": "string"
                                        },
                                        "$contentType": {
                                            "type": "string"
                                        },
                                        "properties": {
                                            "properties": {},
                                            "type": "object"
                                        }
                                    },
                                    "type": "object"
                                }
                            },
                            "description": "We should be receiving a Body message that contains details about the received content, plus properties from the FTP adapter e.g. ReceivedFileName"
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value":  "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{variables('Envelope')?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{body('Routing:_Call_RoutingSlipRouter')?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Merge_Properties": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{variables('Envelope')?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "MergeProperties"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Build_Envelope": {
                            "actions": {
                                "BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@triggerBody()?['$content']",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['properties']?['trackingId']}",
                                            "Content-Encoding": "@{coalesce(triggerBody()?['$contentTransferEncoding'], 'none')}",
                                            "Content-Type": "@{triggerBody()?['$contentType']}"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {
                                                "envelopeType": "@{encodeURIComponent('document')}",
                                                "scenario": "@{encodeURIComponent(triggerBody()?['properties']?['scenario'])}"
                                            },
                                            "template": "/aimmessagingmanager/buildenvelope/{envelopeType}/{scenario}"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "encodeBody": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['encodeBody'], 'true')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "BuildEnvelope:_Check_Status_Code": {
                                    "runAfter": {
                                        "BuildEnvelope:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "BuildEnvelope:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "BuildEnvelope:Success:_Set_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "BuildEnvelope"
                                                    }
                                                },
                                                "BuildEnvelope:Success:_Set_Envelope_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@body('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "BuildEnvelope:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "BuildEnvelope:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "BuildEnvelope:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager BuildEnvelope operation"
                                                        }
                                                    },
                                                    "BuildEnvelope:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "BuildEnvelope:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['statusCode'], outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['body']?['statusCode'], actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['error']?['message'], outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['body']?['message'], actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "BuildEnvelope:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "BuildEnvelope:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager BuildEnvelope operation"
                                                            }
                                                        },
                                                        "BuildEnvelope:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "BuildEnvelope:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('BuildEnvelope:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['body']?.fault",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "BuildEnvelope:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Merge_Properties": {
                            "actions": {
                                "MergeProperties:_Call_APIM_MessagingManager.MergeProperties": {
                                    "runAfter": {
                                        "MergeProperties:_Create_Request_Message": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@outputs('MergeProperties:_Create_Request_Message')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@variables('Envelope')?['header']?['properties']?['trackingId']",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/mergeproperties"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "MergeProperties:_Check_StatusCode": {
                                    "runAfter": {
                                        "MergeProperties:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "MergeProperties:Success:_Copy_Properties_to_Envelope": {
                                                    "runAfter": {},
                                                    "type": "Compose",
                                                    "inputs": "@setProperty(variables('Envelope'), 'header', setProperty(variables('Envelope')?['header'], 'properties', body('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')))"
                                                },
                                                "MergeProperties:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "MergeProperties:Success_Set_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "MergeProperties"
                                                    }
                                                },
                                                "MergeProperties:Success_Set_Envelope_variable": {
                                                    "runAfter": {
                                                        "MergeProperties:Success:_Copy_Properties_to_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@outputs('MergeProperties:Success:_Copy_Properties_to_Envelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "MergeProperties:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "MergeProperties:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "MergeProperties:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager MergeProperties operation"
                                                        }
                                                    },
                                                    "MergeProperties:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "MergeProperties:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['statusCode'], outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['body']?['statusCode'], actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['error']?['message'], outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['body']?['message'], actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "MergeProperties:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "MergeProperties:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager MergeProperties operation"
                                                            }
                                                        },
                                                        "MergeProperties:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "MergeProperties:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('MergeProperties:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['body']?.fault",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "MergeProperties:_Create_Request_Message": {
                                    "runAfter": {},
                                    "type": "Compose",
                                    "inputs": "@createArray(variables('Envelope')?['header']?['properties'], triggerBody()?['properties'])"
                                },
                                "MergeProperties:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "MergeProperties:_Call_APIM_MessagingManager.MergeProperties": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Build_Envelope": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "BuildEnvelope"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\messageconstructor\messageconstructor.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\messageconstructor\New-MessageConstructor-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-MessageConstructor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\messageconstructor.logicapp.json" -templateParameterFile ".\messageconstructor.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "messageconstructor.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName 
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value

Write-Host "Deploying the message constructor Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\messageconstructor\Remove-MessageConstructor-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
./Remove-MessageConstructor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimmessageconstructor-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\messageconstructor\TearDown-85-MessageConstructor-LogicApp.ps1.liquid
 
tools\templates\endpoints\sftp\receive\Deploy-100-SftpReceiveAdapterServiceBus-ApiConnection.ps1.liquid
 
tools\templates\endpoints\sftp\receive\Deploy-100-SftpReceiveAdapterSftp-ApiConnection.ps1.liquid
 
tools\templates\endpoints\sftp\receive\Deploy-105-SftpReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\sftp\receive\Deploy-110-SftpReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\sftp\receive\Deploy-110-SftpReceiveAdapterSftp-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\sftp\receive\New-SftpReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates an sftp receive adapter for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SftpReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth" -templateFile ".\sftpreceiveadapter.logicapp.json" -templateParameterFile ".\sftpreceiveadapter.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "sftpreceiveadapter.logicapp.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying an sftp receive adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\receive\New-SftpReceiveAdapterServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Creates a service bus api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SftpReceiveAdapterServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth" -templateFile ".\sftpreceiveadaptersb.apiconnection.json" -templateParameterFile ".\sftpreceiveadaptersb.apiconnection.dev.parameters.json" -deploymentName "sftpreceiveadaptersb.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a service bus api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\receive\New-SftpReceiveAdapterServiceBus-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates an sftp receive service bus api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SftpReceiveAdapterServiceBus-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\sftpreceiveadapterservicebus.apiconnpolicy.json" -templateParameterFile ".\sftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json" -deploymentName "sftpreceiveadapterservicebus.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\receive\New-SftpReceiveAdapterSftp-ApiConnection.ps1
<#
.SYNOPSIS
Creates an sftp api connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SftpReceiveAdapterSftp-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth" -templateFile ".\sftpreceiveadaptersftp.apiconnection.json" -templateParameterFile ".\sftpreceiveadaptersftp.apiconnection.dev.parameters.json" -deploymentName "sftpreceiveadaptersftp.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an sftp api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\receive\New-SftpReceiveAdapterSftp-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates an sftp receive api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SftpReceiveAdapterSftp-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\sftpreceiveadaptersftp.apiconnpolicy.json" -templateParameterFile ".\sftpreceiveadaptersftp.apiconnpolicy.dev.parameters.json" -deploymentName "sftpreceiveadaptersftp.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\receive\Remove-SftpReceiveAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the sftp receive adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-SftpReceiveAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth-xxxxx" -resourceName "logic-Aim-SftpPassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the sftp receive adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the sftp receive adapter resource: $resourceName"
}
else {
    Write-Host "The sftp receive adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\sftp\receive\Remove-SftpReceiveAdapterServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the sftp receive adapters service bus api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-SftpReceiveAdapterServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth" -resourceName "topicpublisherconnector-sftpreceiveadapater-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the sftp receive adapters service bus api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the sftp receive adapters service bus api connection resource: $resourceName"
}
else {
    Write-Host "The sftp receive adapters service bus api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\sftp\receive\Remove-SftpReceiveAdapterSftp-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the sftp api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-SftpReceiveAdapterSftp-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth" -resourceName "sftpreceiveconnector-Aim-SftpPassthru-ReceiveLocation-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the sftp api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the sftp api connection resource: $resourceName"
}
else {
    Write-Host "The sftp api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\sftp\receive\sftpreceiveadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicApStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "systemApplicationResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that SystemApplication artifacts are deployed to (e.g. ServiceBus or MessageConstructor LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "string",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "messageConstructorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle FTP Message Construction and Sending."
            }
        },
        "messageSuspendProcessorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle suspending of messages."
            }
        },
        "suspendQueueTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic that suspended messages are sent to."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "sftpReceiveApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for SFTP Receive operations."
            }
        },
        "sftpReceiveFolder": {
            "type": "string",
            "metadata": {
                "description": "The path where the SFTP connector looks for new/updated files."
            }
        },
        "sftpMaxFileCount": {
            "defaultValue": 10,
            "type": "int",
            "metadata": {
                "description": "The max number of files the SFTP Connector will retrieve per polling interval."
            }
        },
        "sftpFileMask": {
            "type": "string",
            "metadata": {
                "description": "The mask to use to decide if we're processing a given file e.g. *.* or *.csv"
            }
        },
        "sftpRecurrenceFrequency": {
            "type": "string",
            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
            "metadata": {
                "description": "The frequency with which to check for new files on the SFTP server."
            }
        },
        "sftpRecurrenceInterval": {
            "type": "int",
            "metadata": {
                "description": "The interval with which to check for new files on the SFTP server."
            }
        },
        "scenario": {
            "type": "string",
            "metadata": {
                "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
            }
        },
        "scenarioStep": {
            "defaultValue": "sftpReceiveAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. sftpReceiveAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messageConstructorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageConstructorLogicAppName'))]",
        "messageSuspendProcessorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageSuspendProcessorLogicAppName'))]",
        "sftpApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('sftpReceiveApiConnectionName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]",
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicApStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "sftpReceiveFolder": {
                            "type": "String",
                            "description": "The path where the SFTP connector looks for new/updated files."
                        },
                        "sftpMaxFileCount": {
                            "type": "Int",
                            "description": "The max number of files the SFTP Connector will retrieve per polling interval."
                        },
                        "sftpRecurrenceFrequency": {
                            "type": "string",
                            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
                            "description": "The frequency with which to check for new files on the SFTP server."
                        },
                        "sftpRecurrenceInterval": {
                            "type": "int",
                            "description": "The interval with which to check for new files on the SFTP server."
                        },
                        "fileNameMask": {
                            "defaultValue": "*.*",
                            "type": "String",
                            "description": "The mask to use to decide if we're processing a given file e.g. *.* or *.csv"
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        },
                        "scenario": {
                            "type": "String",
                            "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. sftpReceiveAdapter."
                        },
                        "clearCache": {
                            "defaultValue": true,
                            "type": "Bool",
                            "description": "Indicates if we should clear APIM cache before retrieved config items e.g. configurationEntries or routingSlips."
                        },
                        "suspendQueueTopicName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic that suspended messages are sent to."
                        }
                    },
                    "triggers": {
                        "When_files_are_added_or_modified_(properties_only)": {
                            "recurrence": {
                                "frequency": "@{parameters('ftpRecurrenceFrequency')}",
                                "interval": "@parameters('ftpRecurrenceInterval')"
                            },
                            "splitOn": "@triggerBody()",
                            "type": "ApiConnection",
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['sftpreceive']['connectionId']"
                                    }
                                },
                                "method": "get",
                                "path": "/datasets/default/triggers/batch/onupdatedfile",
                                "queries": {
                                    "folderId": "@{parameters('sftpReceiveFolder')}",
                                    "maxFileCount": "@parameters('sftpMaxFileCount')"
                                }
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Compose_FileNameMask": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "Compose",
                            "inputs": "@parameters('fileNameMask')"
                        },
                        "Respond:_Were_we_successful": {
                            "actions": {
                                "Terminate_with_ACK": {
                                    "runAfter": {},
                                    "type": "Terminate",
                                    "inputs": {
                                        "runStatus": "Succeeded"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Construct Message": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Do_we_have_a_NACK": {
                                        "actions": {},
                                        "runAfter": {},
                                        "else": {
                                            "actions": {
                                                "Failure:_Build_NACK_message": {
                                                    "runAfter": {},
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "body": [
                                                            {
                                                                "$content": {
                                                                    "code": "500",
                                                                    "message": "@variables('ErrorMessage')",
                                                                    "lastCheckpoint": "@variables('Checkpoint')",
                                                                    "fault": "@variables('FaultMessage')"
                                                                },
                                                                "$contentType": "application/json",
                                                                "$part": 1,
                                                                "$partType": "http://schemas.microsoft.com/aim#nack"
                                                            }
                                                        ],
                                                        "header": {
                                                            "properties": {
                                                                "createDate": "@utcNow()",
                                                                "envelopeType": "nack",
                                                                "messageId": "@guid()",
                                                                "rootPart": 1,
                                                                "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                            },
                                                            "routing": {
                                                                "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                            },
                                                            "routingSlip": {},
                                                            "state": {}
                                                        }
                                                    }
                                                },
                                                "Failure:_Set_ResponseMessage_variable": {
                                                    "runAfter": {
                                                        "Failure:_Build_NACK_message": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "ResponseMessage",
                                                        "value": "@outputs('Failure:_Build_NACK_message')"
                                                    }
                                                }
                                            }
                                        },
                                        "expression": {
                                            "and": [
                                                {
                                                    "equals": [
                                                        "@{coalesce(variables('ResponseMessage')?['header']?['properties']?['envelopeType'], '(unknown)')}",
                                                        "nack"
                                                    ]
                                                }
                                            ]
                                        },
                                        "type": "If"
                                    },
                                    "Failure:_Send_NACK_to_SuspendQueue": {
                                        "runAfter": {
                                            "Failure:_Do_we_have_a_NACK": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Workflow",
                                        "inputs": {
                                            "body": {
                                                "nackMessage": "@variables('ResponseMessage')",
                                                "originalMessage": "@triggerBody()",
                                                "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                "scenario": "@{parameters('scenario')}"
                                            },
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                            },
                                            "host": {
                                                "triggerName": "manual",
                                                "workflow": {
                                                    "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                }
                                            }
                                        }
                                    },
                                    "Terminate_with_NACK": {
                                        "runAfter": {
                                            "Failure:_Send_NACK_to_SuspendQueue": [
                                                "Succeeded",
                                                "Failed",
                                                "Skipped",
                                                "TimedOut"
                                            ]
                                        },
                                        "type": "Terminate",
                                        "inputs": {
                                            "runError": {
                                                "code": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['code'], '500')}",
                                                "message": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['message'], '(unknown error)')}"
                                            },
                                            "runStatus": "Failed"
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "IgnoreFile"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ConstructMessageACK"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(parameters('scenario'))}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@parameters('clearCache')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Compose_FileNameMask": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Configuration": {
                            "actions": {
                                "ValidateConfiguration:_Have_Valid_Properties": {
                                    "actions": {
                                        "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "ValidateConfiguration"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property btsReceivePortName is not set in configuration"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Should_we_process_file": {
                            "actions": {
                                "ShouldWeProcessFile:_Check_FileMask": {
                                    "runAfter": {},
                                    "type": "JavaScriptCode",
                                    "inputs": {
                                        "code": "var escapedFileMask = workflowContext.actions.Compose_FileNameMask.outputs;\r\nvar fileMaskRegex = \"^\" + escapedFileMask.replace(\".\", \"[.]\").replace(\"*\", \".*\").replace(\"?\", \".\") + \"$\";\r\nreturn workflowContext.trigger.outputs.body.Name.match(fileMaskRegex) !== null;"
                                    }
                                },
                                "ShouldWeProcessFile:Failure:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:_Check_FileMask": [
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 500
                                    }
                                },
                                "ShouldWeProcessFile:Success:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:_Check_FileMask": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 200
                                    }
                                },
                                "ShouldWeProcessFile:_Check_StatusCode": {
                                    "runAfter": {
                                        "ShouldWeProcessFile:Failure:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ],
                                        "ShouldWeProcessFile:Success:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ShouldWeProcessFile:Success:_Does_FileMask_match": {
                                                    "actions": {
                                                        "ShouldWeProcessFile:Process:_Set_Checkpoint_variable": {
                                                            "runAfter": {},
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "Checkpoint",
                                                                "value": "ProcessFile"
                                                            }
                                                        }
                                                    },
                                                    "runAfter": {},
                                                    "else": {
                                                        "actions": {
                                                            "ShouldWeProcessFile:Ignore:_Set_Checkpoint_variable": {
                                                                "runAfter": {},
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "IgnoreFile"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "expression": {
                                                        "and": [
                                                            {
                                                                "equals": [
                                                                    "@outputs('ShouldWeProcessFile:_Check_FileMask')?['body']",
                                                                    true
                                                                ]
                                                            }
                                                        ]
                                                    },
                                                    "type": "If"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ShouldWeProcessFile:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('ShouldWeProcessFile:_Check_FileMask')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['statusCode'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['statusCode'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['message'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'])}",
                                                        "faultReason": "@{actions('ShouldWeProcessFile:_Check_FileMask')?['status']}"
                                                    }
                                                }
                                            },
                                            "ShouldWeProcessFile:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to execute the FileMask Javascript"
                                                }
                                            },
                                            "ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "ShouldWeProcessFile:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('ShouldWeProcessFile:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Construct Message": {
                            "actions": {
                                "ConstructMessage:_Call_MessageConstructor": {
                                    "runAfter": {
                                        "ConstructMessage:_Get_file_content": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": {
                                            "$content": "@{body('ConstructMessage:_Get_file_content')}",
                                            "$contentTransferEncoding": "none",
                                            "$contentType": "@triggerBody()?['MediaType']",
                                            "properties": {
                                                "receivedFileName": "@{triggerBody()?['Name']}",
                                                "scenario": "@{parameters('scenario')}",
                                                "btsReceivePortName": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '(unknownReceivePortName)')}",
                                                "btsReceivePortId": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortId'], '(unknownReceivePortId)')}"
                                            }
                                        },
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('messageConstructorLogicAppResourceId')]"
                                            }
                                        }
                                    }
                                },
                                "ConstructMessage:_Check_StatusCode": {
                                    "runAfter": {
                                        "ConstructMessage:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ConstructMessage:Success:_Check_EnvelopeType": {
                                                    "runAfter": {},
                                                    "cases": {
                                                        "ACK": {
                                                            "case": "ack",
                                                            "actions": {
                                                                "ACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "ACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "ACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageACK"
                                                                    }
                                                                }
                                                            }
                                                        },
                                                        "NACK": {
                                                            "case": "nack",
                                                            "actions": {
                                                                "NACK:_Set_ResponseMessage_variable": {
                                                                    "runAfter": {},
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ResponseMessage",
                                                                        "value": "@body('ConstructMessage:_Call_MessageConstructor')"
                                                                    }
                                                                },
                                                                "NACK:_Set_Checkpoint_variable": {
                                                                    "runAfter": {
                                                                        "NACK:_Set_ResponseMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    },
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "Checkpoint",
                                                                        "value": "ConstructMessageNACK"
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "default": {
                                                        "actions": {
                                                            "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": {
                                                                "runAfter": {},
                                                                "type": "Compose",
                                                                "inputs": {
                                                                    "body": [
                                                                        {
                                                                            "$content": {
                                                                                "code": "500",
                                                                                "message": "@concat('Body returned by action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' is not an ACK or NACK. Envelope type is: ', coalesce(body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType'], '(unknown)'))"
                                                                            },
                                                                            "$contentType": "application/json",
                                                                            "$part": 1,
                                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                                        }
                                                                    ],
                                                                    "header": {
                                                                        "properties": {
                                                                            "createDate": "@utcNow()",
                                                                            "envelopeType": "nack",
                                                                            "messageId": "@guid()",
                                                                            "rootPart": 1,
                                                                            "trackingId": ""
                                                                        },
                                                                        "routing": {
                                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                                        },
                                                                        "routingSlip": {},
                                                                        "state": {}
                                                                    }
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "ResponseMessage",
                                                                    "value": "@outputs('ConstructMessage:UnknownEnvelope:_Compose_NACK_Message')"
                                                                }
                                                            },
                                                            "ConstructMessage:UnknownEnvelope:_Set_Checkpoint_variable": {
                                                                "runAfter": {
                                                                    "ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "ConstructMessageNACK"
                                                                }
                                                            }
                                                        }
                                                    },
                                                    "expression": "@body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType']",
                                                    "type": "Switch"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ConstructMessage:Failure:_Create_NACK_Message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['error']?['message'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['message'])}",
                                                                    "faultReason": ""
                                                                },
                                                                "message": "@concat('Action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' resulted in an error response.')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": ""
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "ConstructMessage:Failure:_Set_ResponseMessage_variable": {
                                                "runAfter": {
                                                    "ConstructMessage:Failure:_Create_NACK_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ResponseMessage",
                                                    "value": "@outputs('ConstructMessage:Failure:_Create_NACK_Message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "ConstructMessage:_Get_file_content": {
                                    "runAfter": {},
                                    "type": "ApiConnection",
                                    "inputs": {
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['sftpreceive']['connectionId']"
                                            }
                                        },
                                        "method": "get",
                                        "path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(triggerBody()?['Id']))}/content",
                                        "queries": {
                                            "inferContentType": true
                                        }
                                    }
                                },
                                "ConstructMessage:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ConstructMessage:_Call_MessageConstructor": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Should_we_process_file": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ProcessFile"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "sftpreceive": {
                                "connectionId": "[variables('sftpApiConnectionResourceId')]",
                                "connectionName": "[parameters('sftpReceiveApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sftpwithssh')]"
                            }
                        }
                    },
                    "sftpReceiveFolder": {
                        "value": "[parameters('sftpReceiveFolder')]"
                    },
                    "sftpMaxFileCount": {
                        "value": "[parameters('sftpMaxFileCount')]"
                    },
                    "sftpRecurrenceFrequency": {
                        "value": "[parameters('sftpRecurrenceFrequency')]"
                    },
                    "sftpRecurrenceInterval": {
                        "value": "[parameters('sftpRecurrenceInterval')]"
                    },
                    "fileNameMask": {
                        "value": "[parameters('sftpFileMask')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    },
                    "scenario": {
                        "value": "[parameters('scenario')]"
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "suspendQueueTopicName": {
                        "value": "[parameters('suspendQueueTopicName')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\sftp\receive\sftpreceiveadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadapterservicebus.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadapterservicebus.apiconnection.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadapterservicebus.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadapterservicebus.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\sftp\receive\sftpreceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadaptersftp.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadaptersftp.apiconnection.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadaptersftp.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadaptersftp.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\sftpreceiveadaptersftp.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\sftp\receive\sftpreceiveadaptersftp.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\receive\TearDown-100-SftpReceiveAdapterServiceBus-ApiConnection.ps1.liquid
 
tools\templates\endpoints\sftp\receive\TearDown-100-SftpReceiveAdapterSftp-ApiConnection.ps1.liquid
 
tools\templates\endpoints\sftp\receive\TearDown-105-SftpReceiveAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\sftp\send\Deploy-100-SftpSendAdapter-ApiConnection.ps1.liquid
 
tools\templates\endpoints\sftp\send\Deploy-105-SftpSendAdapter-LogicApp.ps1.liquid
 
tools\templates\endpoints\sftp\send\Deploy-110-SftpSendAdapter-ApiConnPolicy.ps1.liquid
 
tools\templates\endpoints\sftp\send\New-SftpSendAdapter-ApiConnection.ps1
<#
.SYNOPSIS
Creates an sftp connector for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-SftpSendAdapter-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth-xxxxx" -templateFile ".\sftpconnection.json" -templateParameterFile ".\sftpconnection.dev.parameters.json" -deploymentName "sftpsendconnection"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an sftp connector`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\send\New-SftpSendAdapter-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates an sftp send api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SftpSendAdapter-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\sftpsendadapter.apiconnpolicy.json" -templateParameterFile ".\sftpsendadapter.apiconnpolicy.dev.parameters.json" -deploymentName "sftpsendadapter.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\send\New-SftpSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Creates an sftp adapter for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-SftpSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth-xxxxx" -templateFile ".\sftpadapter.json" -templateParameterFile ".\sftpadapter.dev.parameters.json" -deploymentName "sftpadapter"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for the routing slip router Logic App"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying an sftp adapter`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\endpoints\sftp\send\Remove-SftpSendAdapter-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the sftp connector.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-SftpSendAdapter-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth-xxxxx" -resourceName "sftpreceiveconnector-Aim-SftpPassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the sftp connector resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the sftp connector resource: $resourceName"
}
else {
    Write-Host "The sftp connector resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\sftp\send\Remove-SftpSendAdapter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the sftp adapter.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-SftpSendAdapter-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-sftppassthru-dev-uksouth-xxxxx" -resourceName "logic-Aim-SftpPassthru-ReceiveLocation-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

if ($resourceExists) {
    Write-Host "Removing the sftp adapter resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "workflows" --namespace "Microsoft.Logic"

    Write-Host "Removed the sftp adapter resource: $resourceName"
}
else {
    Write-Host "The sftp adapter resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\endpoints\sftp\send\sftpsendadapter.apiconnection.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\send\sftpsendadapter.apiconnection.json.liquid
 
tools\templates\endpoints\sftp\send\sftpsendadapter.apiconnection.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\send\sftpsendadapter.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\send\sftpsendadapter.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\endpoints\sftp\send\sftpsendadapter.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\send\sftpsendadapter.logicapp.dev.parameters.json.liquid
 
tools\templates\endpoints\sftp\send\sftpsendadapter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "sftpSendApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for SFTP Send operations."
            }
        },
        "sftpSendFolder": {
            "defaultValue": "/",
            "type": "string",
            "metadata": {
                "description": "The path where the SFTP connector send files."
            }
        },
        "sftpSendFileName": {
            "defaultValue": "%MessageID%-%SourceFileName%",
            "type": "string",
            "metadata": {
                "description": "The name of the file to send (can include macro values e.g. %MessageID% or %SourceFileName%)."
            }
        },
        "scenarioStep": {
            "defaultValue": "sftpSendAdapter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. sftpSendAdapter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "sftpSendApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('sftpSendApiConnectionName'))]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "sftpSendFolder": {
                            "type": "String",
                            "description": "The path where the SFTP connector send files."
                        },
                        "sftpSendFileName": {
                            "type": "String",
                            "description": "The name of the file to send (can include macro values e.g. %MessageID% or %SourceFileName%))."
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. sftpSendAdapter."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_SendFileName_variable": {
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "SendFileName",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_SendToSFTP": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SendToSFTP"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_SendFileName_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Missing:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "NoBodyContent"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_GetSendFileName": {
                            "actions": {
                                "GetSendFileName:_Set_SendFileName_variable": {
                                    "description": "A full list of supported FileName macros can be found here: https://social.technet.microsoft.com/wiki/contents/articles/8823.biztalk-server-list-of-macros.aspx. At this time we are not supporting the Party macros.",
                                    "type": "SetVariable",
                                    "runAfter": {},
                                    "inputs": {
                                        "name": "SendFileName",
                                        "value": "@{replace(replace(replace(replace(replace(replace(replace(parameters('sftpSendFileName'), '%MessageID%', coalesce(triggerBody()?['header']?['properties']?['messageId'], guid())), '%SourceFileName%', coalesce(triggerBody()?['header']?['properties']?['receivedFileName'], 'myfile.txt')), '%datetime%', utcNow('yyyy-MM-ddThhmmss')), '%datetime_bts2000%', utcNow('yyyyMMddhhmmsss')), '%datetime.tz%', utcNow('yyyy-MM-ddThhmmssK')), '%time%', utcNow('hhmmss')), '%time.tz%', utcNow('hhmmssK'))}"
                                    }
                                },
                                "SendToSFTP:_Set_Checkpoint_variable": {
                                    "runAfter": {
                                        "GetSendFileName:_Set_SendFileName_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "GetSendFileName"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "NoBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_SendToSFTP": {
                            "actions": {
                                "SendToSFTP:_Check_Status_Code": {
                                    "runAfter": {
                                        "SendToSFTP:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "SendToSFTP:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "SendToSFTP"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "SendToSFTP:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "SendToSFTP:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "SendToSFTP:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the SFTP connector"
                                                        }
                                                    },
                                                    "SendToSFTP:Fault:_Create_Fault_Message": {
                                                        "runAfter": {},
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "fault": {
                                                                "faultActor": "@concat(workflow()?['name'], '.', actions('SendToSFTP:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                "faultCategory": "Error",
                                                                "faultCode": "@{coalesce(outputs('SendToSFTP:_Create_File')?['statusCode'], outputs('SendToSFTP:_Create_File')?['body']?['statusCode'], actions('SendToSFTP:_Create_File')?['error']?['code'])}",
                                                                "faultMessage": "@{coalesce(outputs('SendToSFTP:_Create_File')?['error']?['message'], outputs('SendToSFTP:_Create_File')?['body']?['message'], actions('SendToSFTP:_Create_File')?['error']?['message'])}",
                                                                "faultReason": "@{actions('SendToSFTP:_Create_File')?['status']}"
                                                            }
                                                        }
                                                    },
                                                    "SendToSFTP:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {
                                                            "SendToSFTP:Fault:_Create_Fault_Message": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('SendToSFTP:Fault:_Create_Fault_Message')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "SendToSFTP:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('SendToSFTP:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('SendToSFTP:_Create_File')?['statusCode'], outputs('SendToSFTP:_Create_File')?['body']?['statusCode'])}",
                                                                    "faultMessage": "@{coalesce(outputs('SendToSFTP:_Create_File')?['error']?['message'], outputs('SendToSFTP:_Create_File')?['body']?['message'])}",
                                                                    "faultReason": "@actions('SendToSFTP:_Create_File')?['inputs']?['path']"
                                                                }
                                                            }
                                                        },
                                                        "SendToSFTP:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "SendToSFTP:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the SFTP connector"
                                                            }
                                                        },
                                                        "SendToSFTP:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "SendToSFTP:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('SendToSFTP:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('SendToSFTP:_Create_File')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "SendToSFTP:_Create_File": {
                                    "inputs": {
                                        "body": "@variables('BodyContent')",
                                        "headers": {
                                            "ReadFileMetadataFromServer": true
                                        },
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['sftpsend']['connectionId']"
                                            }
                                        },
                                        "method": "post",
                                        "path": "/datasets/default/files",
                                        "queries": {
                                            "folderPath": "@parameters('sftpSendFolder')",
                                            "name": "@variables('SendFileName')",
                                            "queryParametersSingleEncoded": true
                                        }
                                    },
                                    "runAfter": {},
                                    "runtimeConfiguration": {
                                        "contentTransfer": {
                                            "transferMode": "Chunked"
                                        }
                                    },
                                    "type": "ApiConnection"
                                },
                                "SendToSFTP:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "SendToSFTP:_Create_File": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('SendToSFTP:_Create_File')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_GetSendFileName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetSendFileName"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "sftpsend": {
                                "connectionId": "[variables('sftpSendApiConnectionResourceId')]",
                                "connectionName": "[parameters('sftpSendApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/sftp')]"
                            }
                        }
                    },
                    "sftpSendFolder": {
                        "value": "[parameters('sftpSendFolder')]"
                    },
                    "sftpSendFileName": {
                        "value": "[parameters('sftpSendFileName')]"
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\endpoints\sftp\send\sftpsendadapter.logicapp.prod.parameters.json.liquid
 
tools\templates\endpoints\sftp\send\TearDown-100-SftpSendAdapter-ApiConnection.ps1.liquid
 
tools\templates\endpoints\sftp\send\TearDown-105-SftpSendAdapter-LogicApp.ps1.liquid
 
tools\templates\intermediaries\contentdemoter\contentdemoter.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\contentdemoter\contentdemoter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "contentPromoter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. contentPromoter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "routingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimroutingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. contentPromoter."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_DemoteMessageProperties": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "DemoteMessageProperties"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_DemoteMessageProperties": {
                            "actions": {
                                "DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('routingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimroutingmanager/demotemessageproperties"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "DemoteMessageProperties:_Check_Status_Code": {
                                    "runAfter": {
                                        "DemoteMessageProperties:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "DemoteMessageProperties:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "DemoteMessageProperties:Success:_Set_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "DemoteMessageProperties"
                                                    }
                                                },
                                                "DemoteMessageProperties:Success:_Set_Envelope_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@body('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "DemoteMessageProperties:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "DemoteMessageProperties:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "DemoteMessageProperties:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager DemoteMessageProperties operation"
                                                        }
                                                    },
                                                    "DemoteMessageProperties:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "DemoteMessageProperties:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['statusCode'], outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['body']?['statusCode'], actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['error']?['message'], outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['body']?['message'], actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "DemoteMessageProperties:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "DemoteMessageProperties:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager DemoteMessageProperties operation"
                                                            }
                                                        },
                                                        "DemoteMessageProperties:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "DemoteMessageProperties:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('DemoteMessageProperties:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "DemoteMessageProperties:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\contentdemoter\contentdemoter.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\contentdemoter\Deploy-90-ContentDemoter-LogicApp.ps1.liquid
 
tools\templates\intermediaries\contentdemoter\New-ContentDemoter-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-ContentDemoter-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\contentdemoter.logicapp.json" -templateParameterFile ".\contentdemoter.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "contentdemoter.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the content demoter Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\contentdemoter\Remove-ContentDemoter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-ContentDemoter-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimcontentdemoter-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\contentdemoter\TearDown-90-ContentDemoter-LogicApp.ps1.liquid
 
tools\templates\intermediaries\contentpromoter\contentpromoter.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\contentpromoter\contentpromoter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "contentPromoter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. contentPromoter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "routingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimroutingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. contentPromoter."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_ResolveRoutingProperties": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ResolveRoutingProperties"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_ResolveRoutingProperties": {
                            "actions": {
                                "ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('routingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimroutingmanager/resolveroutingproperties"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "ResolveRoutingProperties:_Check_Status_Code": {
                                    "runAfter": {
                                        "ResolveRoutingProperties:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ResolveRoutingProperties:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "ResolveRoutingProperties:Success:_Set_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "ResolveRoutingProperties"
                                                    }
                                                },
                                                "ResolveRoutingProperties:Success:_Set_Envelope_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@body('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ResolveRoutingProperties:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "ResolveRoutingProperties:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "ResolveRoutingProperties:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager ResolveRoutingProperties operation"
                                                        }
                                                    },
                                                    "ResolveRoutingProperties:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "ResolveRoutingProperties:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['statusCode'], outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['body']?['statusCode'], actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['error']?['message'], outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['body']?['message'], actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "ResolveRoutingProperties:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "ResolveRoutingProperties:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager ResolveRoutingProperties operation"
                                                            }
                                                        },
                                                        "ResolveRoutingProperties:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "ResolveRoutingProperties:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('ResolveRoutingProperties:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "ResolveRoutingProperties:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\contentpromoter\contentpromoter.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\contentpromoter\Deploy-90-ContentPromoter-LogicApp.ps1.liquid
 
tools\templates\intermediaries\contentpromoter\New-ContentPromoter-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-ContentPromoter-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\contentpromoter.logicapp.json" -templateParameterFile ".\contentpromoter.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "contentpromoter.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the content promoter Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\contentpromoter\Remove-ContentPromoter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-ContentPromoter-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimcontentpromoter-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\contentpromoter\TearDown-90-ContentPromoter-LogicApp.ps1.liquid
 
tools\templates\intermediaries\flatfilemessageprocessor\Deploy-90-FlatFileMessageProcessor-LogicApp.ps1.liquid
 
tools\templates\intermediaries\flatfilemessageprocessor\flatfilemessageprocessor.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\flatfilemessageprocessor\flatfilemessageprocessor.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "flatFileDecoder",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. flatFileDecoder."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. flatFileDecoder."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow().Name} (@{workflow().run.name}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_StatusCode_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow().name, '.', actions('Routing:_Call_RoutingSlipRouter').name, ' (', workflow().run.name, ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?.statusCode, outputs('Routing:_Call_RoutingSlipRouter')?.body?.statusCode, actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?.error?.message, outputs('Routing:_Call_RoutingSlipRouter')?.body?.message, actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Decode_FlatFile": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "DecodeFlatFile"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow().name, '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep').name, ' (', workflow().run.name, ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?.statusCode, outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?.body?.statusCode, actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?.error?.message, outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?.body?.message, actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodySchemaName": {
                            "actions": {
                                "CheckBodySchemaName:_Is_BodySchemaName_blank": {
                                    "actions": {
                                        "CheckBodySchemaName:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}): No BodySchemaName is set in the configuration entry for this step."
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "CheckBodySchemaName:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodySchemaName"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['bodySchemaName'], '')}",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}): No Root Body content can be found in the supplied Envelope"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodySchemaName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodySchemaName"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Decode_BodyContent": {
                            "actions": {
                                "DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/decodebodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "DecodeBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "DecodeBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "DecodeBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "DecodeBodyContent"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "DecodeBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "DecodeBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "DecodeBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}) trying to call the MessageManager DecodeBodyContent operation"
                                                        }
                                                    },
                                                    "DecodeBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "DecodeBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow().name, '.', actions('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent').name, ' (', workflow().run.name, ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?.statusCode, outputs('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?.body?.statusCode, actions('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?.error?.message, outputs('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?.body?.message, actions('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "DecodeBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "DecodeBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}) trying to call the MessageManager DecodeBodyContent operation"
                                                            }
                                                        },
                                                        "DecodeBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "DecodeBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('DecodeBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "DecodeBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Decode_FlatFile": {
                            "actions": {
                                "DecodeFlatFile:Failure:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Decode_FlatFile": [
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 500
                                    }
                                },
                                "DecodeFlatFile:Success:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Decode_FlatFile": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 200
                                    }
                                },
                                "DecodeFlatFile:_Check_StatusCode": {
                                    "runAfter": {
                                        "DecodeFlatFile:Failure:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ],
                                        "DecodeFlatFile:Success:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "DecodeFlatFile:Success:_Add_new_Root_Body_Part_to_Envelope": {
                                                    "runAfter": {
                                                        "DecodeFlatFile:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('DecodeFlatFile:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('DecodeFlatFile:Success:_Create_new_Body_Part'))))"
                                                },
                                                "DecodeFlatFile:Success:_Create_new_Body_Part": {
                                                    "runAfter": {},
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "$content": "@base64(body('Decode_FlatFile'))",
                                                        "$contentTransferEncoding": "base64",
                                                        "$contentType": "text/xml",
                                                        "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                                                        "$partType": "http://schemas.myorg.com/part'@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                                                    }
                                                },
                                                "DecodeFlatFile:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                                                    "runAfter": {
                                                        "DecodeFlatFile:Success:_Create_new_Body_Part": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Query",
                                                    "inputs": {
                                                        "from": "@variables('Envelope')?['body']",
                                                        "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                                                    }
                                                },
                                                "DecodeFlatFile:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "DecodeFlatFile:Success:_Update_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "DecodeFlatFile"
                                                    }
                                                },
                                                "DecodeFlatFile:Success:_Update_Envelope_variable": {
                                                    "runAfter": {
                                                        "DecodeFlatFile:Success:_Add_new_Root_Body_Part_to_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@outputs('DecodeFlatFile:Success:_Add_new_Root_Body_Part_to_Envelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "DecodeFlatFile:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow().name, '.', actions('Decode_FlatFile').name, ' (', workflow().run.name, ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('Decode_FlatFile')?.statusCode, outputs('Decode_FlatFile')?.body?.statusCode, actions('Decode_FlatFile')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('Decode_FlatFile')?.error?.message, outputs('Decode_FlatFile')?.body?.message, actions('Decode_FlatFile')?['error']?['message'])}",
                                                        "faultReason": "@{actions('Decode_FlatFile')?['status']}"
                                                    }
                                                }
                                            },
                                            "DecodeFlatFile:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "DecodeFlatFile:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow().Name} (@{workflow().run.name}) trying to decode FlatFile content"
                                                }
                                            },
                                            "DecodeFlatFile:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "DecodeFlatFile:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('DecodeFlatFile:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Decode_FlatFile": {
                                    "runAfter": {},
                                    "type": "FlatFileDecoding",
                                    "inputs": {
                                        "content": "@{body('DecodeBodyContent:_Call_APIM_MessageManager.DecodeBodyContent')}",
                                        "integrationAccount": {
                                            "schema": {
                                                "name": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['bodySchemaName'], '')}"
                                            }
                                        }
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Decode_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "DecodeBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\flatfilemessageprocessor\flatfilemessageprocessor.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\flatfilemessageprocessor\New-FlatFileMessageProcessor-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-FlatFileMessageProcessor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\flatfilemessageprocessor.logicapp.json" -templateParameterFile ".\flatfilemessageprocessor.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "flatfilemessageprocessor.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the content promoter Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\flatfilemessageprocessor\Remove-FlatFileMessageProcessor-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-FlatFileMessageProcessor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimflatfilemessageprocessor-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\flatfilemessageprocessor\TearDown-90-FlatFileMessageProcessor-LogicApp.ps1.liquid
 
tools\templates\intermediaries\jsondecoder\Deploy-90-JsonDecoder-LogicApp.ps1.liquid
 
tools\templates\intermediaries\jsondecoder\jsondecoder.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\jsondecoder\jsondecoder.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "jsonDecoder",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. jsonDecoder."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. jsonDecoder."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Decode_Json": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "DecodeJson"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Configuration": {
                            "actions": {
                                "ValidateConfiguration:_Have_Valid_Properties": {
                                    "actions": {
                                        "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "ValidateConfiguration"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): properties rootNode and rootNodeNamespace are not both set in configuration"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['rootNode'], '')",
                                                        ""
                                                    ]
                                                }
                                            },
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['rootNodeNamespace'], '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContentType": {
                            "actions": {
                                "CheckBodyContentType:_Body_Content_Type_is_JSON": {
                                    "actions": {
                                        "CheckBodyContentType:Error:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Expected body to have a json content type. Content type is '@{coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')}'. Unable to continue."
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContentType:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContentType:Present:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContentType"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                                                        "text/json"
                                                    ]
                                                }
                                            },
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                                                        "application/json"
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContentType:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Missing": {
                                            "actions": {
                                                "CheckBodyContent:Missing:Continue:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "CheckBodyContentMissingContinue"
                                                    }
                                                }
                                            },
                                            "else": {
                                                "actions": {
                                                    "CheckBodyContent:Missing:Error:_Set_ErrorMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope and the addMessageBodyForEmptyMessage property if set to False in configuration. Unable to continue."
                                                        }
                                                    }
                                                }
                                            },
                                            "runAfter": {},
                                            "expression": {
                                                "and": [
                                                    {
                                                        "equals": [
                                                            "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['addMessageBodyForEmptyMessage'], 'false')",
                                                            "true"
                                                        ]
                                                    }
                                                ]
                                            },
                                            "type": "if"
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Present:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContentType": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContentType"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Decode_Json": {
                            "actions": {
                                "DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('BodyContent')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/convertjsontoxml"
                                        },
                                        "queries": {
                                            "addMessageBodyForEmptyMessage": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['addMessageBodyForEmptyMessage'], 'false')",
                                            "rootNode": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['rootNode'], '')",
                                            "rootNodeNamespace": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['rootNodeNamespace'], '')",
                                            "writeArrayAttribute": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['writeArrayAttribute'], 'true')",
                                            "encodeSpecialCharacters": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['encodeSpecialCharacters'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "DecodeJson:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')['statusCode'], 500)"
                                    }
                                },
                                "DecodeJson:_Check_StatusCode": {
                                    "runAfter": {
                                        "DecodeJson:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "DecodeJson:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{body('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')}"
                                                    }
                                                },
                                                "DecodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": {
                                                    "runAfter": {
                                                        "DecodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('DecodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('DecodeJson:Success:_Create_new_Body_Part'))))"
                                                },
                                                "DecodeJson:Success:_Create_new_Body_Part": {
                                                    "runAfter": {
                                                        "DecodeJson:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "$content": "@base64(variables('BodyContent'))",
                                                        "$contentTransferEncoding": "base64",
                                                        "$contentType": "text/xml",
                                                        "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                                                        "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                                                    }
                                                },
                                                "DecodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                                                    "runAfter": {
                                                        "DecodeJson:Success:_Create_new_Body_Part": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Query",
                                                    "inputs": {
                                                        "from": "@variables('Envelope')?['body']",
                                                        "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                                                    }
                                                },
                                                "DecodeJson:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "DecodeJson:Success:_Update_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "DecodeJson"
                                                    }
                                                },
                                                "DecodeJson:Success:_Update_Envelope_variable": {
                                                    "runAfter": {
                                                        "DecodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@outputs('DecodeJson:Success:_Add_new_Root_Body_Part_to_Envelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "DecodeJson:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['statusCode'], outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['statusCode'], actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'], outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['message'], actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'])}",
                                                        "faultReason": "@{actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['status']}"
                                                    }
                                                }
                                            },
                                            "DecodeJson:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "DecodeJson:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to decode JSON content"
                                                }
                                            },
                                            "DecodeJson:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "DecodeJson:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('DecodeJson:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContentMissingContinue"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\jsondecoder\jsondecoder.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\jsondecoder\New-JsonDecoder-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-JsonDecoder-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\jsondecoder.logicapp.json" -templateParameterFile ".\jsondecoder.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "jsondecoder.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the content promoter Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\jsondecoder\Remove-JsonDecoder-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-JsonDecoder-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimjsondecoder-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\jsondecoder\TearDown-90-JsonDecoder-LogicApp.ps1.liquid
 
tools\templates\intermediaries\jsonencoder\Deploy-90-JsonEncoder-LogicApp.ps1.liquid
 
tools\templates\intermediaries\jsonencoder\jsonencoder.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\jsonencoder\jsonencoder.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "jsonEncoder",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. jsonEncoder."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. jsonEncoder."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Encode_Json": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "EncodeJson"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Configuration": {
                            "actions": {
                                "ValidateConfiguration:_Have_Valid_Properties": {
                                    "actions": {
                                        "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "ValidateConfiguration"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property RemoveOuterEnvelope is not set in configuration."
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['RemoveOuterEnvelope'], '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContentType": {
                            "actions": {
                                "CheckBodyContentType:_Body_Content_Type_is_XML": {
                                    "actions": {
                                        "CheckBodyContentType:Error:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Expected body to have an XML content type. Content type is '@{coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')}'. Unable to continue."
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContentType:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContentType:Present:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContentType"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                                                        "text/xml"
                                                    ]
                                                }
                                            },
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                                                        "application/xml"
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContentType:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Missing": {
                                            "actions": {
                                                "CheckBodyContent:Missing:Continue:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "CheckBodyContentMissingContinue"
                                                    }
                                                }
                                            },
                                            "else": {
                                                "actions": {
                                                    "CheckBodyContent:Missing:Error:_Set_ErrorMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope. Unable to continue."
                                                        }
                                                    }
                                                }
                                            },
                                            "runAfter": {},
                                            "expression": {
                                                "and": [
                                                    {
                                                        "equals": [
                                                            "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['addMessageBodyForEmptyMessage'], 'false')",
                                                            "true"
                                                        ]
                                                    }
                                                ]
                                            },
                                            "type": "if"
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Present:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContentType": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContentType"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Encode_Json": {
                            "actions": {
                                "EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('BodyContent')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/convertxmltojson"
                                        },
                                        "queries": {
                                            "removeOuterEnvelope": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['RemoveOuterEnvelope'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "EncodeJson:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')['statusCode'], 500)"
                                    }
                                },
                                "EncodeJson:_Check_StatusCode": {
                                    "runAfter": {
                                        "EncodeJson:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "EncodeJson:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{body('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')}"
                                                    }
                                                },
                                                "EncodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": {
                                                    "runAfter": {
                                                        "EncodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('EncodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('EncodeJson:Success:_Create_new_Body_Part'))))"
                                                },
                                                "EncodeJson:Success:_Create_new_Body_Part": {
                                                    "runAfter": {
                                                        "EncodeJson:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "$content": "@base64(variables('BodyContent'))",
                                                        "$contentTransferEncoding": "base64",
                                                        "$contentType": "text/json",
                                                        "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                                                        "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                                                    }
                                                },
                                                "EncodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                                                    "runAfter": {
                                                        "EncodeJson:Success:_Create_new_Body_Part": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Query",
                                                    "inputs": {
                                                        "from": "@variables('Envelope')?['body']",
                                                        "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                                                    }
                                                },
                                                "EncodeJson:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "EncodeJson:Success:_Update_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "EncodeJson"
                                                    }
                                                },
                                                "EncodeJson:Success:_Update_Envelope_variable": {
                                                    "runAfter": {
                                                        "EncodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@outputs('EncodeJson:Success:_Add_new_Root_Body_Part_to_Envelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "EncodeJson:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['statusCode'], outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['statusCode'], actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'], outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['message'], actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'])}",
                                                        "faultReason": "@{actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['status']}"
                                                    }
                                                }
                                            },
                                            "EncodeJson:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "EncodeJson:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to encode JSON content"
                                                }
                                            },
                                            "EncodeJson:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "EncodeJson:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('EncodeJson:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContentMissingContinue"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\jsonencoder\jsonencoder.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\jsonencoder\New-JsonEncoder-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-JsonEncoder-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\jsonencoder.logicapp.json" -templateParameterFile ".\jsonencoder.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "jsonencoder.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the content promoter Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\jsonencoder\Remove-JsonEncoder-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-JsonEncoder-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimjsonencoder-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\jsonencoder\TearDown-90-JsonEncoder-LogicApp.ps1.liquid
 
tools\templates\intermediaries\procmgr\Deploy-100-ProcessManagerServiceBus-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\procmgr\Deploy-105-ProcessManager-LogicApp.ps1.liquid
 
tools\templates\intermediaries\procmgr\New-ProcessManager-LogicApp.ps1
<#
.SYNOPSIS
Creates a process manager Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-ProcessManager-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -templateFile "$PSScriptRoot\processmanager.logicapp.json" -templateParameterFile "$PSScriptRoot\processmanager.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "processmanager.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the process manager Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\procmgr\New-ProcessManagerServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Creates a process manager service bus connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-ProcessManagerServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -templateFile "$PSScriptRoot\processmanagerservicebus.apiconnection.json" -templateParameterFile "$PSScriptRoot\processmanagerservicebus.apiconnection.dev.parameters.json" -deploymentName "processmanagerservicebus.apic.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a process manager service bus api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\intermediaries\procmgr\processmanagerservicebus.apiconnection.dev.parameters.json.liquid
 
tools\templates\intermediaries\procmgr\processmanagerservicebus.apiconnection.json.liquid
 
tools\templates\intermediaries\procmgr\processmanagerservicebus.apiconnection.prod.parameters.json.liquid
 
tools\templates\intermediaries\procmgr\Remove-ProcessManager-LogicApp.ps1
<#
.SYNOPSIS
Tears down the process manager Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-ProcessManager-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimprocessmanager-processmanager-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\procmgr\Remove-ProcessManagerServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the process manager service bus api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-ProcessManagerServiceBus-ApiConnection.ps1 -resourceGroup "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -resourceName "apic-aimsbconnector-processmanager-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the process manager service bus api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the process manager service bus api connection resource: $resourceName"
}
else {
    Write-Host "The process manager service bus api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\procmgr\snippets\cons\act\processmanager.activitycontainer.workflow.sbmsg.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\act\processmanager.activitycontainer.workflow.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\act\processmanager.channel.trigger.servicebustopic.snippet.json
{
    "workflowTrigger": {
        "When_a_message_is_received_in_a_topic_subscription_(peek-lock)": {
            "inputs": {
                "host": {
                    "connection": {
                        "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                    }
                },
                "method": "get",
                "path": "/@{encodeURIComponent(parameters('serviceBusTopicName'))}/subscriptions/@{encodeURIComponent(parameters('serviceBusTopicSubscriptionName'))}/messages/head/peek",
                "queries": {
                    "sessionId": "None",
                    "subscriptionType": "Main"
                }
            },
            "recurrence": {
                "frequency": "@{parameters('serviceBusRecurrenceFrequency')}",
                "interval": "@parameters('serviceBusRecurrenceInterval')"
            },
            "type": "ApiConnection"
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\act\processmanager.parametersdefinition.snippet.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "value": "{{ resource_template.resource_name }}"
        },
        "logicAppLocation": {
            "value": "{{ resource_template.parameters.azure_primary_region }}"
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\act\processmanager.workflowdefinition.snippet.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {},
                    "triggers": {},
                    "actions": {},
                    "outputs": {}
                },
                "parameters": {}
            }
        }
    ]
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activity.codeexpression.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activity.invokeworkflow.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activity.messageconstruction.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activity.messagetransform.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activity.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activitycontainer.decision.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activitycontainer.decisionbranch.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activitycontainer.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activitycontainer.task.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.activitycontainer.workflow.getconfig.snippet.json
{
    "workflowDefinitionAction": {
        "Action:_Get_Configuration": {
            "runAfter": {},
            "type": "ApiManagement",
            "description": "Gets configuration for scenario step @(parameters('scenarioStep'))",
            "inputs": {
                "api": {
                    "id": "[variables('configurationManagerApiResourceId')]"
                },
                "method": "get",
                "pathTemplate": {
                    "parameters": {
                        "scenario": "@{encodeURIComponent(parameters('scenario'))}",
                        "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                    },
                    "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                },
                "queries": {
                    "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                },
                "retryPolicy": "[parameters('apimRetryPolicy')]",
                "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.channel.receive.servicebustopic.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.channel.send.servicebustopic.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.message.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.apimretrypolicy.snippet.json
{
    "armTemplateParameter": {
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.apimservice.snippet.json
{
    "armParameter": {
        "apimServiceName": {
            "value": "{{ resource_template.parameters.apim_service_name }}"
        }
    },
    "armTemplateParameter": {
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.apimsubscriptionkey.snippet.json
{
    "armTemplateParameter": {
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access the Message Bus API Management service."
            }
        }
    },
    "workflowParameter": {
        "apimSubscriptionKey": {
            "value": "[parameters('apimSubscriptionKey')]"
        }
    },
    "workflowDefinitionParameter": {
        "apimSubscriptionKey": {
            "type": "SecureString",
            "description": "Subscription Key used to access the Message Bus API Management service."
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.integrationaccount.snippet.json
{
    "armParameter": {
        "integrationAccountName": {
            "value": "{{ resource_template.parameters.azure_integration_account_name }}"
        }
    },
    "armTemplateParameter": {
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the integration account for the MessageBus."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.messagebusresourcegroup.snippet.json
{
    "armParameter": {
        "messageBusResourceGroupName": {
            "value": "{{ resource_template.parameters.azure_message_bus_resource_group_name }}"
        }
    },
    "armTemplateParameter": {
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the resource group that MessageBus artifacts are deployed to."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.messagesuspendprocessorlogicapp.snippet.json
{
    "armParameter": {
        "messageSuspendProcessorLogicAppName": {
            "value": "{{ resource_template.parameters.azure_message_suspend_processor_logic_app_name }}"
        }
    },
    "armTemplateParameter": {
        "messageSuspendProcessorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle failed messages."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.routingsliprouterlogicapp.snippet.json
{
    "armParameter": {
        "routingSlipRouterLogicAppName": {
            "value": "{{ resource_template.parameters.routing_slip_router_name }}"
        }
    },
    "armTemplateParameter": {
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.routingsliprouterretrypolicy.snippet.json
{
    "armTemplateParameter": {
        "routerRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.sbtopicpublishapiconnection.snippet.json
{
    "armParameter": {
        "serviceBusTopicPublishApiConnectionName": {
            "value": "{{ resource_template.parameters.azure_topic_publisher_api_connection_name }}"
        }
    },
    "armTemplateParameter": {
        "serviceBusTopicPublishApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus Topic Publish operations."
            }
        }
    },
    "workflowParameter": {
        "$connections": {
            "value": {
                "servicebuspublish": {
                    "connectionId": "[variables('serviceBusTopicPublishApiConnectionResourceId')]",
                    "connectionName": "[parameters('serviceBusTopicPublishApiConnectionName')]",
                    "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
                }
            }
        }
    },
    "workflowDefinitionParameter": {
        "$connections": {
            "defaultValue": {},
            "type": "Object"
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.sbtopicsubscribeapiconnection.snippet.json
{
    "armParameter": {
        "serviceBusTopicSubscribeApiConnectionName": {
            "value": "{{ resource_template.parameters.azure_topic_subscriber_api_connection_name }}"
        }
    },
    "armTemplateParameter": {
        "serviceBusTopicSubscribeApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus Topic Subscribe operations."
            }
        }
    },
    "workflowParameter": {
        "$connections": {
            "value": {
                "servicebussubscribe": {
                    "connectionId": "[variables('serviceBusTopicSubscribeApiConnectionResourceId')]",
                    "connectionName": "[parameters('serviceBusTopicSubscribeApiConnectionName')]",
                    "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
                }
            }
        }
    },
    "workflowDefinitionParameter": {
        "$connections": {
            "defaultValue": {},
            "type": "Object"
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.scenario.snippet.json
{
    "armParameter": {
        "scenario": {
            "value": "{{ resource_template.parameters.scenario_name }}"
        }
    },
    "armTemplateParameter": {
        "scenario": {
            "type": "string",
            "metadata": {
                "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
            }
        }
    },
    "workflowParameter": {
        "scenario": {
            "value": "[parameters('scenario')]"
        }
    },
    "workflowDefinitionParameter": {
        "scenario": {
            "type": "String",
            "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.scenariostep.snippet.json
{
    "armParameter": {
        "scenarioStep": {
            "value": "{{ resource_template.parameters.scenario_step_name }}"
        }
    },
    "armTemplateParameter": {
        "scenarioStep": {
            "type": "string",
            "defaultValue": "processManagerTemplate",
            "metadata": {
                "description": "The step within a route (scenario) that this LogicApp represents."
            }
        }
    },
    "workflowParameter": {
        "scenarioStep": {
            "value": "[parameters('scenarioStep')]"
        }
    },
    "workflowDefinitionParameter": {
        "scenarioStep": {
            "type": "String",
            "description": "The step within a route (scenario) that this LogicApp represents, for example, contentPromoter."
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.servicebusrecurrencefrequency.snippet.json
{
    "armParameter": {
        "serviceBusRecurrenceFrequency": {
            "value": "{{ resource_template.parameters.azure_service_bus_recurrence_frequency }}"
        }
    },
    "armTemplateParameter": {
        "serviceBusRecurrenceFrequency": {
            "type": "string",
            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
            "metadata": {
                "description": "The frequency with which to check for new messages on the ServiceBus Topic Subscription."
            }
        }
    },
    "workflowParameter": {
        "serviceBusRecurrenceFrequency": {
            "value": "[parameters('serviceBusRecurrenceFrequency')]"
        }
    },
    "workflowDefinitionParameter": {
        "serviceBusRecurrenceFrequency": {
            "type": "string",
            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
            "description": "The frequency with which to check for new messages on the ServiceBus Topic Subscription."
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.servicebusrecurrenceinterval.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.servicebustopic.snippet.json
{
    "armParameter": {
        "serviceBusTopicName": {
            "value": "{{ resource_template.parameters.azure_service_bus_topic_name }}"
        }
    },
    "armTemplateParameter": {
        "serviceBusTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic used to subscribe to messages."
            }
        }
    },
    "workflowParameter": {
        "serviceBusTopicName": {
            "value": "[parameters('serviceBusTopicName')]"
        }
    },
    "workflowDefinitionParameter": {
        "serviceBusTopicName": {
            "type": "String",
            "description": "Name of the ServiceBus Topic used to subscribe to messages."
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.servicebustopicsubscription.snippet.json
{
    "armParameter": {
        "serviceBusTopicSubscriptionName": {
            "value": "{{ resource_template.parameters.azure_service_bus_subscription_name }}"
        }
    },
    "armTemplateParameter": {
        "serviceBusTopicSubscriptionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic Subscription used to subscribe to messages."
            }
        }
    },
    "workflowParameter": {
        "serviceBusTopicSubscriptionName": {
            "value": "[parameters('serviceBusTopicSubscriptionName')]"
        }
    },
    "workflowDefinitionParameter": {
        "serviceBusTopicSubscriptionName": {
            "type": "String",
            "description": "Name of the ServiceBus Topic Subscription used to subscribe to messages."
        }        
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.suspendqueuetopic.snippet.json
{
    "armParameter": {
        "suspendQueueTopicName": {
            "value": "{{ resource_template.parameters.azure_service_bus_suspend_queue_topic_name }}"
        }
    },
    "armTemplateParameter": {
        "suspendQueueTopicName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Service Bus topic for the Suspend Queue."
            }
        }
    },
    "workflowParameter": {
        "suspendQueueTopicName": {
            "value": "[parameters('suspendQueueTopicName')]"
        }
    },
    "workflowDefinitionParameter": {
        "suspendQueueTopicName": {
            "type": "String",
            "description": "The name of the Service Bus topic for the Suspend Queue."
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.systemapplicationresourcegroup.snippet.json
{
    "armParameter": {
        "systemApplicationResourceGroupName": {
            "value": "{{ resource_template.parameters.azure_system_application_resource_group_name }}"
        }
    },
    "armTemplateParameter": {
        "systemApplicationResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the resource group that common system artifacts are deployed to."
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.parameter.tags.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.property.integrationaccount.snippet.json
{
    "workflowProperty": {
        "integrationAccount": {
            "id": "[variables('integrationAccountResourceId')]"
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.property.tags.snippet.json
{
    "workflowResourceProperty": {
        "tags": "[parameters('tags')]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.apimservice.snippet.json
{
    "armTemplateVariable": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.configurationmanager.snippet.json
{
    "armTemplateVariable": {
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.initialize.configuration.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_Configuration_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "Configuration",
                        "type": "object"
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.initialize.errormessage.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_ErrorMessage_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "ErrorMessage",
                        "type": "string",
                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp."
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.initialize.faultmessage.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_FaultMessage_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "FaultMessage",
                        "type": "object"
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.initialize.messagetype.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_MessageType_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "MessageType",
                        "type": "string"
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.initialize.statuscode.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_StatusCode_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "StatusCode",
                        "type": "integer",
                        "value": 500
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.integrationaccount.snippet.json
{
    "armTemplateVariable": {
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.messagesuspendprocessorlogicapp.snippet.json
{
    "armTemplateVariable": {
        "messageSuspendProcessorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageSuspendProcessorLogicAppName'))]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.messagingmanager.snippet.json
{
    "armTemplateVariable": {
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.routingmanager.snippet.json
{
    "armTemplateVariable": {
        "routingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimroutingmanager')]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.routingsliprouterlogicapp.snippet.json
{
    "armTemplateVariable": {
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.sbtopicpublishapiconnection.snippet.json
{
    "armTemplateVariable": {
        "serviceBusTopicPublishApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicPublishApiConnectionName'))]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\com\processmanager.variable.sbtopicsubscribeapiconnection.snippet.json
{
    "armTemplateVariable": {
        "serviceBusTopicSubscribeApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicSubscribeApiConnectionName'))]"
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\inv\processmanager.channel.trigger.http.snippet.json
{
    "workflowTrigger": {
        "manual": {
            "correlation": {
                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
            },
            "type": "Request",
            "kind": "Http",
            "inputs": {
                "schema": {}
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\inv\processmanager.parametersdefinition.snippet.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "value": "{{ resource_template.resource_name }}"
        },
        "logicAppLocation": {
            "value": "{{ resource_template.parameters.azure_primary_region }}"
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\cons\inv\processmanager.workflowdefinition.snippet.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {},
                    "triggers": {},
                    "actions": {},
                    "outputs": {}
                },
                "parameters": {}
            }
        }
    ]
}
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.activitycontainer.workflow.sbmsg.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.activitycontainer.workflow.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.appsettings.local.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.appsettings.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.channel.trigger.servicebustopic.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.connections.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.parameters.local.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.parameters.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\act\processmanager.workflowdefinition.snippet.json
{
	"definition": {
		"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
		"contentVersion": "1.0.0.0",
		"triggers": {},
		"actions": {},
		"outputs": {}
	},
	"kind": "Stateful"
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activity.codeexpression.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activity.invokeworkflow.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activity.messageconstruction.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activity.messagetransform.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activity.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activitycontainer.decision.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activitycontainer.decisionbranch.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activitycontainer.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activitycontainer.task.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.activitycontainer.workflow.getconfig.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.channel.receive.servicebustopic.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.channel.send.servicebustopic.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.message.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.parameter.scenario.snippet.json
{
	"{{ workflow_object_name }}.processManager.scenarioName": {
		"value": "{{ resource_template.parameters.scenario_name }}",
		"description": "The name of the scenario for this Process Manager.",
		"type": "String"
	}
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.parameter.scenariostep.snippet.json
{
	"{{ workflow_object_name }}.processManager.scenarioStep": {
		"value": "{{ resource_template.parameters.scenario_step_name }}",
		"description": "The name of the scenario for this Process Manager.",
		"type": "String"
	}
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.parameter.servicebustopic.snippet.json
{
	"{{ workflow_object_name }}.processManager.topicName": {
		"type": "String",
		"value": "{{ resource_template.parameters.azure_service_bus_topic_name }}",
		"description": "The name of the topic used for this specific Scenario."
	}
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.parameter.servicebustopicsubscription.snippet.json
{
	"{{ workflow_object_name }}.processManager.subscriptionName": {
		"type": "String",
		"value": "{{ resource_template.parameters.azure_service_bus_subscription_name }}",
		"description": "The name of the topic subscription used for this specific Scenario."
	}
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.variable.initialize.configuration.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_Configuration_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "Configuration",
                        "type": "object"
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.variable.initialize.errormessage.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_ErrorMessage_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "ErrorMessage",
                        "type": "string",
                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow."
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.variable.initialize.faultmessage.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_FaultMessage_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "FaultMessage",
                        "type": "object"
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.variable.initialize.messagetype.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_MessageType_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "MessageType",
                        "type": "string"
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.variable.initialize.statuscode.snippet.json
{
    "workflowDefinitionVariable": {
        "Initialize_StatusCode_variable": {
            "runAfter": {},
            "type": "InitializeVariable",
            "inputs": {
                "variables": [
                    {
                        "name": "StatusCode",
                        "type": "integer",
                        "value": 500
                    }
                ]
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\std\com\processmanager.variable.placeholder.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\inv\processmanager.appsettings.local.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\inv\processmanager.appsettings.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\inv\processmanager.channel.trigger.http.snippet.json
{
    "workflowTrigger": {
        "manual": {
            "correlation": {
                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
            },
            "type": "Request",
            "kind": "Http",
            "inputs": {
                "schema": {}
            }
        }
    }
}
tools\templates\intermediaries\procmgr\snippets\std\inv\processmanager.connections.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\inv\processmanager.parameters.local.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\inv\processmanager.parameters.snippet.json.liquid
 
tools\templates\intermediaries\procmgr\snippets\std\inv\processmanager.workflowdefinition.snippet.json
{
	"definition": {
		"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
		"contentVersion": "1.0.0.0",
		"triggers": {},
		"actions": {},
		"outputs": {}
	},
	"kind": "Stateful"
}
tools\templates\intermediaries\procmgr\TearDown-100-ProcessManagerServiceBus-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\procmgr\TearDown-105-ProcessManager-LogicApp.ps1.liquid
 
tools\templates\intermediaries\standard\Deploy-120-SystemApplication-ClearUrlCache.ps1.liquid
 
tools\templates\intermediaries\standard\Deploy-80-SystemApplicationServiceBus-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\standard\Deploy-90-SystemApplication-LogicApp.ps1.liquid
 
tools\templates\intermediaries\standard\Deploy-95-SystemApplicationServiceBus-ApiConnPolicy.ps1.liquid
 
tools\templates\intermediaries\standard\New-SystemApplication-ClearUrlCache.ps1
<#
.SYNOPSIS
Clears the Url Cache for all Workflows in this Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the Logic App is located.

.PARAMETER resourceName
Name of the Logic App.

.PARAMETER apimInstanceName
Name of the APIM instance used to clear the cache.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.EXAMPLE
.\New-Application-ClearUrlCache.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth-xxxxx" -resourceName "logic-aimsystemapplication-dev-xxxxx" -apimInstanceName "apim-aimmsgbussvc-dev-xxxxx" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,	
    [parameter(Mandatory = $true)]    
    [string] $apimInstanceName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

$apimBaseUrl = "https://$apimInstanceName.azure-api.net/aimroutingmanager/standardlogicappcallbackurl/$resourceGroupName/$resourceName"
Write-Host "Using base url: $apimBaseUrl"

Write-Host "Clearing cache for each Workflow"

Write-Host "contentdemoter"
az rest --method get --url "$apimBaseUrl/contentdemoter?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "contentpromoter"
az rest --method get --url "$apimBaseUrl/contentpromoter?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "jsondecoder"
az rest --method get --url "$apimBaseUrl/jsondecoder?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "jsonencoder"
az rest --method get --url "$apimBaseUrl/jsonencoder?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "messageconstructor"
az rest --method get --url "$apimBaseUrl/messageconstructor?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "messageresponsehandler"
az rest --method get --url "$apimBaseUrl/messageresponsehandler?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "messagesuspendprocessor"
az rest --method get --url "$apimBaseUrl/messagesuspendprocessor?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "routingsliprouter"
az rest --method get --url "$apimBaseUrl/routingsliprouter?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "topicpublisher"
az rest --method get --url "$apimBaseUrl/topicpublisher?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "xmlenvelopewrapper"
az rest --method get --url "$apimBaseUrl/xmlenvelopewrapper?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "xmlmessageprocessor"
az rest --method get --url "$apimBaseUrl/xmlmessageprocessor?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "xmlmessagevalidator"
az rest --method get --url "$apimBaseUrl/xmlmessagevalidator?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none

Write-Host "Cache Clearing complete"
tools\templates\intermediaries\standard\New-SystemApplication-LogicApp.ps1
<#
.SYNOPSIS
Creates the SystemApplication Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER workflowFolder
Name of the folder containing the Logic App Workflows.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SystemApplication-LogicApp.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth-xxxxx" -resourceName "logic-aimsystemapplication-dev-xxxxx" -templateFile "$PSScriptRoot\systemapplication.logicapp.json" -templateParameterFile "$PSScriptRoot\systemapplication.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -workflowFolder "$PSScriptRoot\systemapplication.logic.workflows" -deploymentName "systemapplication.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,	
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
	[parameter(Mandatory = $true)]
    [string] $workflowFolder,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the system application Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"

Write-Host "Creating a ZIP file from the workflow folder"
# create the zip
$zipFile = "$workflowFolder.zip"
if(Test-path $zipFile) {Remove-item $zipFile}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($workflowFolder, $zipFile)

Write-Host "Zip File creation complete"

Write-Host "Uploading the system application logic app zip package $zipFile"

if (!(Test-Path $zipFile)) {
    throw "Zip file $zipFile doesn't exist, unable to upload"
}

az logicapp deployment source config-zip --resource-group $resourceGroupName --name $resourceName --src "$zipFile"

Write-Host "Upload complete"
tools\templates\intermediaries\standard\New-SystemApplicationServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Creates a service bus api connection for the system application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SystemApplicationServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\systemapplicationservicebus.apiconnection.json" -templateParameterFile ".\systemapplicationservicebus.apiconnection.dev.parameters.json" -deploymentName "systemapplicationsb.apiconnection.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a service bus api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\intermediaries\standard\New-SystemApplicationServiceBus-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates a service bus api connection access policy for the system application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-SystemApplicationServiceBus-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth-xxxxx" -templateFile ".\systemapplicationservicebus.apicaccesspolicy.json" -templateParameterFile ".\systemapplicationservicebus.apicaccesspolicy.dev.parameters.json" -deploymentName "systemapplicationsb.apicaccesspolicy.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a service bus api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\intermediaries\standard\Remove-SystemApplication-LogicApp.ps1
<#
.SYNOPSIS
Tears down the system application Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER logicAppName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-SystemApplication-LogicApp.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth-xxxxx" -logicAppName "logic-aimsystemapplication-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $logicAppName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $logicAppName --resource-type "Microsoft.Web/sites"

if ($resourceExists) {
    Write-Host "Removing the Logic App $logicAppName"

    az resource delete --resource-group $resourceGroupName --name $logicAppName --resource-type "Microsoft.Web/sites"

    Write-Host "Removed the Logic App $logicAppName"
}
else {
    Write-Host "The Logic App $logicAppName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\standard\Remove-SystemApplicationServiceBus-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the system application's service bus api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-SystemApplicationServiceBus-ApiConnection.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth-xxxxx" -resourceName "apic-systemapplicationservicebus-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the system application service bus api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the system application service bus api connection resource: $resourceName"
}
else {
    Write-Host "The system application service bus api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\standard\systemapplication.logic.dev.parameters.json.liquid
 
tools\templates\intermediaries\standard\systemapplication.logic.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"logicAppName": {
			"type": "string",
			"metadata": {
				"description": "The name of this Standard Logic App service (note that this differs from the name of the workflows contained within this Logic App)."
			}
		},
		"logicAppLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "The region that this Standard Logic App service should be deployed to."
			}
		},
		"appServicePlanName": {
			"type": "string",
			"metadata": {
				"description": "The name of the App Service Plan used by this Standard Logic App service."
			}
		},
		"storageAccountName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Storage Account used by this Standard Logic App service."
			}
		},
		"messageBusResourceGroupName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Resource group that the Message Bus resources are deployed to."
			}
		},
		"serviceBusResourceGroupName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Resource group that the Service Bus resource is deployed to."
			}
		},
		"serviceBusNamespaceName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Service Bus namespace this Logic App connects to."
			}
		},
		"serviceBusPublishPolicyName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Service Bus Policy we're authenticating against to get a connection string for publish operations."
			}
		},
		"serviceBusSubscribePolicyName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Service Bus Policy we're authenticating against to get a connection string for subscribe operations."
			}
		},
		"appInsightsName": {
			"type": "string",
			"metadata": {
				"description": "Name of the Application Insights instance used by this logic app."
			}
		},
		"apimServiceName": {
			"type": "string",
			"metadata": {
				"description": "Name of the APIM Service used for SystemApplication operations."
			}
		},
		"apimSubscriptionKey": {
			"type": "securestring",
			"metadata": {
				"description": "Subscription Key used to access APIM."
			}
		},
		"serviceBusSubscribeApiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Name of the API Connection used to connect to Service Bus subscriptions."
			}
		},
		"tags": {
			"type": "object",
			"defaultValue": {
				"Environment": "dev"
			},
			"metadata": {
				"description": "Tags for this resource."
			}
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/sites",
			"apiVersion": "2021-01-15",
			"name": "[parameters('logicAppName')]",
			"location": "[parameters('logicAppLocation')]",
			"kind": "functionapp,workflowapp",
			"identity": {
				"type": "SystemAssigned"
			},
			"dependsOn": [],
			"tags": "[parameters('tags')]",
			"properties": {
				"enabled": true,
				"hostNameSslStates": [
					{
						"name": "[concat(parameters('logicAppName'), '.azurewebsites.net')]",
						"sslState": "Disabled",
						"hostType": "Standard"
					},
					{
						"name": "[concat(parameters('logicAppName'), '.scm.azurewebsites.net')]",
						"sslState": "Disabled",
						"hostType": "Repository"
					}
				],
				"serverFarmId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
				"reserved": false,
				"isXenon": false,
				"hyperV": false,
				"siteConfig": {
					"numberOfWorkers": 1,
					"acrUseManagedIdentityCreds": false,
					"alwaysOn": false,
					"http20Enabled": false,
					"functionAppScaleLimit": 0,
					"minimumElasticInstanceCount": 1
				},
				"scmSiteAlsoStopped": false,
				"clientAffinityEnabled": false,
				"clientCertEnabled": false,
				"clientCertMode": "Required",
				"hostNamesDisabled": false,
				"containerSize": 1536,
				"dailyMemoryTimeQuota": 0,
				"keyVaultReferenceIdentity": "SystemAssigned",
				"httpsOnly": false,
				"redundancyMode": "None",
				"storageAccountRequired": false,
				"siteConfig": {
					"appSettings": [
						{
							"name": "APP_KIND",
							"value": "workflowApp"
						},
						{
							"name": "AzureFunctionsJobHost__extensionBundle__id",
							"value": "Microsoft.Azure.Functions.ExtensionBundle.Workflows"
						},
						{
							"name": "AzureFunctionsJobHost__extensionBundle__version",
							"value": "[1.*, 2.0.0)"
						},
						{
							"name": "AzureWebJobsDashboard",
							"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
						},
						{
							"name": "AzureWebJobsStorage",
							"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
						},
						{
							"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
							"value": "[reference(resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"
						},
						{
							"name": "FUNCTIONS_EXTENSION_VERSION",
							"value": "~3"
						},
						{
							"name": "FUNCTIONS_V2_COMPATIBILITY_MODE",
							"value": "true"
						},
						{
							"name": "FUNCTIONS_WORKER_RUNTIME",
							"value": "node"
						},
						{
							"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
							"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
						},
						{
							"name": "WEBSITE_CONTENTSHARE",
							"value": "[parameters('logicAppName')]"
						},
						{
							"name": "WEBSITE_NODE_DEFAULT_VERSION",
							"value": "~12"
						},
						{
							"name": "apiConnectionSubscriptionId",
							"value": "[subscription().subscriptionId]"
						},
						{
							"name": "apiConnectionResourceGroupName",
							"value": "[resourceGroup().name]"
						},
						{
							"name": "apiConnectionLocation",
							"value": "[resourceGroup().location]"
						},
						{
							"name": "apimBaseUrl",
							"value": "[concat('https://', parameters('apimServiceName'), '.azure-api.net')]"
						},
						{
							"name": "apimSubscriptionKey",
							"value": "[parameters('apimSubscriptionKey')]"
						},
						{
							"name": "servicebusPublishConnectionString",
							"value": "[listKeys(resourceId(parameters('serviceBusResourceGroupName'), 'Microsoft.ServiceBus/namespaces/AuthorizationRules', parameters('serviceBusNamespaceName'), parameters('serviceBusPublishPolicyName')), '2017-04-01').primaryConnectionString]"
						},
						{
							"name": "servicebusSubscribeConnectionString",
							"value": "[listKeys(resourceId(parameters('serviceBusResourceGroupName'), 'Microsoft.ServiceBus/namespaces/AuthorizationRules', parameters('serviceBusNamespaceName'), parameters('serviceBusSubscribePolicyName')), '2017-04-01').primaryConnectionString]"
						},
						{
							"name": "servicebusSubscribeConnectionName",
							"value": "[parameters('serviceBusSubscribeApiConnectionName')]"
						},
						{
							"name": "servicebusSubscribeConnectionApiId",
							"value": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('logicAppLocation'), 'servicebus')]"
						},
						{
							"name": "servicebusSubscribeConnectionResourceId",
							"value": "[resourceId('Microsoft.Web/connections', parameters('serviceBusSubscribeApiConnectionName'))]"
						},
						{
							"name": "servicebusSubscribeConnectionRuntimeUrl",
							"value": "[reference(resourceId('Microsoft.Web/connections', parameters('serviceBusSubscribeApiConnectionName')),'2016-06-01', 'full').properties.connectionRuntimeUrl]"
						}
					]
				},
				"redundancyMode": "None"
			}
		},
		{
			"type": "Microsoft.Web/sites/config",
			"apiVersion": "2021-01-15",
			"name": "[concat(parameters('logicAppName'), '/web')]",
			"location": "[parameters('logicAppLocation')]",
			"tags": "[parameters('tags')]",
			"dependsOn": [
				"[resourceId('Microsoft.Web/sites', parameters('logicAppName'))]"
			],
			"properties": {
				"numberOfWorkers": 1,
				"defaultDocuments": [
					"Default.htm",
					"Default.html",
					"Default.asp",
					"index.htm",
					"index.html",
					"iisstart.htm",
					"default.aspx",
					"index.php"
				],
				"netFrameworkVersion": "v4.0",
				"phpVersion": "5.6",
				"requestTracingEnabled": false,
				"remoteDebuggingEnabled": false,
				"httpLoggingEnabled": false,
				"acrUseManagedIdentityCreds": false,
				"logsDirectorySizeLimit": 35,
				"detailedErrorLoggingEnabled": false,
				"publishingUsername": "[concat('$', parameters('logicAppName'))]",
				"azureStorageAccounts": {},
				"scmType": "None",
				"use32BitWorkerProcess": true,
				"webSocketsEnabled": false,
				"alwaysOn": false,
				"managedPipelineMode": "Integrated",
				"virtualApplications": [
					{
						"virtualPath": "/",
						"physicalPath": "site\\wwwroot",
						"preloadEnabled": false
					}
				],
				"loadBalancing": "LeastRequests",
				"experiments": {
					"rampUpRules": []
				},
				"autoHealEnabled": false,
				"localMySqlEnabled": false,
				"ipSecurityRestrictions": [
					{
						"ipAddress": "Any",
						"action": "Allow",
						"priority": 1,
						"name": "Allow all",
						"description": "Allow all access"
					}
				],
				"scmIpSecurityRestrictions": [
					{
						"ipAddress": "Any",
						"action": "Allow",
						"priority": 1,
						"name": "Allow all",
						"description": "Allow all access"
					}
				],
				"scmIpSecurityRestrictionsUseMain": false,
				"http20Enabled": false,
				"minTlsVersion": "1.2",
				"scmMinTlsVersion": "1.0",
				"ftpsState": "AllAllowed",
				"preWarmedInstanceCount": 1,
				"functionAppScaleLimit": 0,
				"functionsRuntimeScaleMonitoringEnabled": false,
				"minimumElasticInstanceCount": 1
			}
		},
		{
			"type": "Microsoft.Web/sites/hostNameBindings",
			"apiVersion": "2021-01-15",
			"name": "[concat(parameters('logicAppName'), '/', parameters('logicAppName'), '.azurewebsites.net')]",
			"location": "[parameters('logicAppLocation')]",
			"tags": "[parameters('tags')]",
			"dependsOn": [
				"[resourceId('Microsoft.Web/sites', parameters('logicAppName'))]"
			],
			"properties": {
				"siteName": "[parameters('logicAppName')]",
				"hostNameType": "Verified"
			}
		}
	]
}
tools\templates\intermediaries\standard\systemapplication.logic.prod.parameters.json.liquid
 
tools\templates\intermediaries\standard\systemapplication.logic.workflows\.funcignore
 
tools\templates\intermediaries\standard\systemapplication.logic.workflows\.vscode\extensions.json
{
  "recommendations": [
    "ms-azuretools.vscode-azurefunctions"
  ]
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\.vscode\launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:azureLogicAppsStandard.pickProcess}"
    }
  ]
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\.vscode\settings.json
{
  "azureLogicAppsStandard.deploySubpath": ".",
  "azureLogicAppsStandard.projectLanguage": "JavaScript",
  "azureLogicAppsStandard.projectRuntime": "~3",
  "debug.internalConsoleOptions": "neverOpen"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\.vscode\tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "generateDebugSymbols",
      "command": "dotnet",
      "args": [
        "${input:getDebugSymbolDll}"
      ],
      "type": "process",
      "problemMatcher": "$msCompile"
    },
    {
      "type": "func",
      "command": "host start",
      "problemMatcher": "$func-watch",
      "isBackground": true
    }
  ],
  "inputs": [
    {
      "id": "getDebugSymbolDll",
      "type": "command",
      "command": "azureLogicAppsStandard.getDebugSymbolDll"
    }
  ]
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\connections.json
{
	"serviceProviderConnections": {
		"serviceBusPublish": {
			"parameterValues": {
				"connectionString": "@appsetting('servicebusPublishConnectionString')"
			},
			"serviceProvider": {
				"id": "/serviceProviders/serviceBus"
			},
			"displayName": "servicebuspublish"
		},
		"serviceBusSubscribe": {
			"parameterValues": {
				"connectionString": "@appsetting('servicebusSubscribeConnectionString')"
			},
			"serviceProvider": {
				"id": "/serviceProviders/serviceBus"
			},
			"displayName": "servicebussubscribe"
		}
	},
	"managedApiConnections": {
		"serviceBusSubscribe": {
			"api": {
				"id": "@parameters('servicebusSubscribeConnectionApiId')"
			},
			"connection": {
				"id": "@parameters('servicebusSubscribeConnectionResourceId')"
			},
			"connectionRuntimeUrl": "@appsetting('servicebusSubscribeConnectionRuntimeUrl')",
			"authentication": "@parameters('servicebusSubscribeManagedApiAuthentication')"
		}
	}
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\contentdemoter\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_DemoteMessageProperties": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "DemoteMessageProperties"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/contentDemoter",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_DemoteMessageProperties": {
        "actions": {
          "DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimroutingmanager/demotemessageproperties",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "DemoteMessageProperties:_Check_Status_Code": {
            "runAfter": {
              "DemoteMessageProperties:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "DemoteMessageProperties:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "DemoteMessageProperties:Success:_Set_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "DemoteMessageProperties"
                    }
                  },
                  "DemoteMessageProperties:Success:_Set_Envelope_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@body('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "DemoteMessageProperties:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "DemoteMessageProperties:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "DemoteMessageProperties:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingManager DemoteMessageProperties operation"
                      }
                    },
                    "DemoteMessageProperties:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "DemoteMessageProperties:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['statusCode'], outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['body']?['statusCode'], actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['error']?['message'], outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['body']?['message'], actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['error']?['message'])}",
                            "faultReason": "@{actions('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['status']}"
                          }
                        }
                      },
                      "DemoteMessageProperties:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "DemoteMessageProperties:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingManager DemoteMessageProperties operation"
                        }
                      },
                      "DemoteMessageProperties:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "DemoteMessageProperties:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('DemoteMessageProperties:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "DemoteMessageProperties:_Set_StatusCode_variable": {
            "runAfter": {
              "DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('DemoteMessageProperties:_Call_APIM_RoutingManager.DemoteMessageProperties')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\contentpromoter\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_ResolveRoutingProperties": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "ResolveRoutingProperties"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/contentPromoter",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_ResolveRoutingProperties": {
        "actions": {
          "ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimroutingmanager/resolveroutingproperties",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "ResolveRoutingProperties:_Check_Status_Code": {
            "runAfter": {
              "ResolveRoutingProperties:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "ResolveRoutingProperties:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "ResolveRoutingProperties:Success:_Set_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "ResolveRoutingProperties"
                    }
                  },
                  "ResolveRoutingProperties:Success:_Set_Envelope_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@body('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "ResolveRoutingProperties:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "ResolveRoutingProperties:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "ResolveRoutingProperties:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingManager ResolveRoutingProperties operation"
                      }
                    },
                    "ResolveRoutingProperties:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "ResolveRoutingProperties:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['statusCode'], outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['body']?['statusCode'], actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['error']?['message'], outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['body']?['message'], actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['error']?['message'])}",
                            "faultReason": "@{actions('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['status']}"
                          }
                        }
                      },
                      "ResolveRoutingProperties:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "ResolveRoutingProperties:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingManager ResolveRoutingProperties operation"
                        }
                      },
                      "ResolveRoutingProperties:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "ResolveRoutingProperties:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('ResolveRoutingProperties:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "ResolveRoutingProperties:_Set_StatusCode_variable": {
            "runAfter": {
              "ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('ResolveRoutingProperties:_Call_APIM_RoutingManager.ResolveRoutingProperties')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\host.json
{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": "[1.*, 2.0.0)"
  }
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\jsondecoder\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_ResponseMessage_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ResponseMessage",
              "type": "object",
              "value": null
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ResponseMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_BodyContent_variable": {
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "BodyContent",
              "type": "string"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Decode_Json": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "DecodeJson"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/jsonDecoder",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_BodyContent_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Validate_Configuration": {
        "actions": {
          "ValidateConfiguration:_Have_Valid_Properties": {
            "actions": {
              "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "Checkpoint",
                  "value": "ValidateConfiguration"
                }
              }
            },
            "runAfter": {},
            "else": {
              "actions": {
                "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "ErrorMessage",
                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): properties rootNode and rootNodeNamespace are not both set in configuration"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "not": {
                    "equals": [
                      "@coalesce(variables('Configuration')?['jsonDecoder']?['rootNode'], '')",
                      ""
                    ]
                  }
                },
                {
                  "not": {
                    "equals": [
                      "@coalesce(variables('Configuration')?['jsonDecoder']?['rootNodeNamespace'], '')",
                      ""
                    ]
                  }
                }
              ]
            },
            "type": "If"
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContentType": {
        "actions": {
          "CheckBodyContentType:_Body_Content_Type_is_JSON": {
            "actions": {
              "CheckBodyContentType:Error:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Expected body to have a json content type. Content type is '@{coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')}'. Unable to continue."
                }
              }
            },
            "runAfter": {
              "CheckBodyContentType:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContentType:Present:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContentType"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "not": {
                    "equals": [
                      "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                      "text/json"
                    ]
                  }
                },
                {
                  "not": {
                    "equals": [
                      "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                      "application/json"
                    ]
                  }
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContentType:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Validate_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "ValidateConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContent": {
        "actions": {
          "CheckBodyContent:_Body_Content_is_missing": {
            "actions": {
              "CheckBodyContent:Missing": {
                "actions": {
                  "CheckBodyContent:Missing:Continue:_Set_Checkpoint_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "CheckBodyContentMissingContinue"
                    }
                  }
                },
                "else": {
                  "actions": {
                    "CheckBodyContent:Missing:Error:_Set_ErrorMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope and the addMessageBodyForEmptyMessage property if set to False in configuration. Unable to continue."
                      }
                    }
                  }
                },
                "runAfter": {},
                "expression": {
                  "and": [
                    {
                      "equals": [
                        "@coalesce(variables('Configuration')?['jsonDecoder']?['addMessageBodyForEmptyMessage'], 'false')",
                        "true"
                      ]
                    }
                  ]
                },
                "type": "if"
              }
            },
            "runAfter": {
              "CheckBodyContent:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContent:Present:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContent"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContent:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContentType": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContentType"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_BodyContent": {
        "actions": {
          "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/getbodycontent",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetBodyContent:_Check_Status_Code": {
            "runAfter": {
              "GetBodyContent:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetBodyContent:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetBodyContent:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetBodyContent"
                    }
                  },
                  "GetBodyContent:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                      }
                    },
                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetBodyContent:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                            "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                          }
                        }
                      },
                      "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                        }
                      },
                      "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetBodyContent:_Set_StatusCode_variable": {
            "runAfter": {
              "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Decode_Json": {
        "actions": {
          "DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('BodyContent')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/convertjsontoxml",
              "queries": {
                "addMessageBodyForEmptyMessage": "@coalesce(variables('Configuration')?['jsonDecoder']?['addMessageBodyForEmptyMessage'], 'false')",
                "rootNode": "@coalesce(variables('Configuration')?['jsonDecoder']?['rootNode'], '')",
                "rootNodeNamespace": "@coalesce(variables('Configuration')?['jsonDecoder']?['rootNodeNamespace'], '')",
                "writeArrayAttribute": "@coalesce(variables('Configuration')?['jsonDecoder']?['writeArrayAttribute'], 'true')",
                "encodeSpecialCharacters": "@coalesce(variables('Configuration')?['jsonDecoder']?['encodeSpecialCharacters'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "DecodeJson:_Set_StatusCode_variable": {
            "runAfter": {
              "DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')['statusCode'], 500)"
            }
          },
          "DecodeJson:_Check_StatusCode": {
            "runAfter": {
              "DecodeJson:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "DecodeJson:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{body('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')}"
                    }
                  },
                  "DecodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": {
                    "runAfter": {
                      "DecodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('DecodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('DecodeJson:Success:_Create_new_Body_Part'))))"
                  },
                  "DecodeJson:Success:_Create_new_Body_Part": {
                    "runAfter": {
                      "DecodeJson:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": {
                      "$content": "@base64(variables('BodyContent'))",
                      "$contentTransferEncoding": "base64",
                      "$contentType": "text/xml",
                      "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                      "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                    }
                  },
                  "DecodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                    "runAfter": {
                      "DecodeJson:Success:_Create_new_Body_Part": [
                        "Succeeded"
                      ]
                    },
                    "type": "Query",
                    "inputs": {
                      "from": "@variables('Envelope')?['body']",
                      "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                    }
                  },
                  "DecodeJson:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "DecodeJson:Success:_Update_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "DecodeJson"
                    }
                  },
                  "DecodeJson:Success:_Update_Envelope_variable": {
                    "runAfter": {
                      "DecodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@outputs('DecodeJson:Success:_Add_new_Root_Body_Part_to_Envelope')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "DecodeJson:Failure:_Create_Fault_message": {
                  "runAfter": {},
                  "type": "Compose",
                  "inputs": {
                    "fault": {
                      "faultActor": "@concat(workflow()?['name'], '.', actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                      "faultCategory": "Error",
                      "faultCode": "@{coalesce(outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['statusCode'], outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['statusCode'], actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['code'])}",
                      "faultMessage": "@{coalesce(outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'], outputs('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['message'], actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'])}",
                      "faultReason": "@{actions('DecodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['status']}"
                    }
                  }
                },
                "DecodeJson:Failure:_Set_ErrorMessage_variable": {
                  "runAfter": {
                    "DecodeJson:Failure:_Set_FaultMessage_variable": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "ErrorMessage",
                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to decode JSON content"
                  }
                },
                "DecodeJson:Failure:_Set_FaultMessage_variable": {
                  "runAfter": {
                    "DecodeJson:Failure:_Create_Fault_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "FaultMessage",
                    "value": "@outputs('DecodeJson:Failure:_Create_Fault_message')"
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          }
        },
        "runAfter": {
          "Step:_Get_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "or": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetBodyContent"
              ]
            },
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContentMissingContinue"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\jsonencoder\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_ResponseMessage_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ResponseMessage",
              "type": "object",
              "value": null
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ResponseMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_BodyContent_variable": {
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "BodyContent",
              "type": "string"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Encode_Json": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "EncodeJson"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/jsonEncoder",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_BodyContent_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Validate_Configuration": {
        "actions": {
          "ValidateConfiguration:_Have_Valid_Properties": {
            "actions": {
              "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "Checkpoint",
                  "value": "ValidateConfiguration"
                }
              }
            },
            "runAfter": {},
            "else": {
              "actions": {
                "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "ErrorMessage",
                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property RemoveOuterEnvelope is not set in configuration."
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "not": {
                    "equals": [
                      "@coalesce(variables('Configuration')?['jsonEncoder']?['RemoveOuterEnvelope'], '')",
                      ""
                    ]
                  }
                }
              ]
            },
            "type": "If"
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContentType": {
        "actions": {
          "CheckBodyContentType:_Body_Content_Type_is_XML": {
            "actions": {
              "CheckBodyContentType:Error:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Expected body to have an XML content type. Content type is '@{coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')}'. Unable to continue."
                }
              }
            },
            "runAfter": {
              "CheckBodyContentType:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContentType:Present:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContentType"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "not": {
                    "equals": [
                      "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                      "text/xml"
                    ]
                  }
                },
                {
                  "not": {
                    "equals": [
                      "@coalesce(body('CheckBodyContentType:_Select_Root_Part')?[0]?['$contentType'], '')",
                      "application/xml"
                    ]
                  }
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContentType:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Validate_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "ValidateConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContent": {
        "actions": {
          "CheckBodyContent:_Body_Content_is_missing": {
            "actions": {
              "CheckBodyContent:Missing": {
                "actions": {
                  "CheckBodyContent:Missing:Continue:_Set_Checkpoint_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "CheckBodyContentMissingContinue"
                    }
                  }
                },
                "else": {
                  "actions": {
                    "CheckBodyContent:Missing:Error:_Set_ErrorMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope. Unable to continue."
                      }
                    }
                  }
                },
                "runAfter": {},
                "expression": {
                  "and": [
                    {
                      "equals": [
                        "@coalesce(variables('Configuration')?['jsonEncoder']?['addMessageBodyForEmptyMessage'], 'false')",
                        "true"
                      ]
                    }
                  ]
                },
                "type": "if"
              }
            },
            "runAfter": {
              "CheckBodyContent:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContent:Present:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContent"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContent:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContentType": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContentType"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_BodyContent": {
        "actions": {
          "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/getbodycontent",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetBodyContent:_Check_Status_Code": {
            "runAfter": {
              "GetBodyContent:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetBodyContent:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetBodyContent:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetBodyContent"
                    }
                  },
                  "GetBodyContent:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                      }
                    },
                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetBodyContent:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                            "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                          }
                        }
                      },
                      "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                        }
                      },
                      "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetBodyContent:_Set_StatusCode_variable": {
            "runAfter": {
              "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Encode_Json": {
        "actions": {
          "EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('BodyContent')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/convertxmltojson",
              "queries": {
                "removeOuterEnvelope": "@coalesce(variables('Configuration')?['jsonEncoder']?['RemoveOuterEnvelope'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "EncodeJson:_Set_StatusCode_variable": {
            "runAfter": {
              "EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')['statusCode'], 500)"
            }
          },
          "EncodeJson:_Check_StatusCode": {
            "runAfter": {
              "EncodeJson:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "EncodeJson:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{body('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')}"
                    }
                  },
                  "EncodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": {
                    "runAfter": {
                      "EncodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('EncodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('EncodeJson:Success:_Create_new_Body_Part'))))"
                  },
                  "EncodeJson:Success:_Create_new_Body_Part": {
                    "runAfter": {
                      "EncodeJson:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": {
                      "$content": "@base64(variables('BodyContent'))",
                      "$contentTransferEncoding": "base64",
                      "$contentType": "text/json",
                      "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                      "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                    }
                  },
                  "EncodeJson:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                    "runAfter": {
                      "EncodeJson:Success:_Create_new_Body_Part": [
                        "Succeeded"
                      ]
                    },
                    "type": "Query",
                    "inputs": {
                      "from": "@variables('Envelope')?['body']",
                      "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                    }
                  },
                  "EncodeJson:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "EncodeJson:Success:_Update_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "EncodeJson"
                    }
                  },
                  "EncodeJson:Success:_Update_Envelope_variable": {
                    "runAfter": {
                      "EncodeJson:Success:_Add_new_Root_Body_Part_to_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@outputs('EncodeJson:Success:_Add_new_Root_Body_Part_to_Envelope')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "EncodeJson:Failure:_Create_Fault_message": {
                  "runAfter": {},
                  "type": "Compose",
                  "inputs": {
                    "fault": {
                      "faultActor": "@concat(workflow()?['name'], '.', actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                      "faultCategory": "Error",
                      "faultCode": "@{coalesce(outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['statusCode'], outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['statusCode'], actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['code'])}",
                      "faultMessage": "@{coalesce(outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'], outputs('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['body']?['message'], actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['error']?['message'])}",
                      "faultReason": "@{actions('EncodeJson:_Call_APIM_MessageManager.ConvertJsonToXml')?['status']}"
                    }
                  }
                },
                "EncodeJson:Failure:_Set_ErrorMessage_variable": {
                  "runAfter": {
                    "EncodeJson:Failure:_Set_FaultMessage_variable": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "ErrorMessage",
                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to encode JSON content"
                  }
                },
                "EncodeJson:Failure:_Set_FaultMessage_variable": {
                  "runAfter": {
                    "EncodeJson:Failure:_Create_Fault_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "FaultMessage",
                    "value": "@outputs('EncodeJson:Failure:_Create_Fault_message')"
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          }
        },
        "runAfter": {
          "Step:_Get_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "or": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetBodyContent"
              ]
            },
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContentMissingContinue"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\local.settings.json
{
	"IsEncrypted": false,
	"Values": {
		"AzureWebJobsStorage": "UseDevelopmentStorage=true",
		"FUNCTIONS_WORKER_RUNTIME": "node",
		"WORKFLOWS_TENANT_ID": "",
		"WORKFLOWS_SUBSCRIPTION_ID": "",
		"WORKFLOWS_RESOURCE_GROUP_NAME": "",
		"WORKFLOWS_LOCATION_NAME": "",
		"WORKFLOWS_MANAGEMENT_BASE_URI": "https://management.azure.com/",
		"apiConnectionSubscriptionId": "",
		"apiConnectionResourceGroupName": "",
		"apiConnectionLocation": "",
		"apimBaseUrl": "",
		"apimSubscriptionKey": "",
		"servicebusPublishConnectionString": "",
		"servicebusSubscribeConnectionString": "",
		"servicebusSubscribeConnectionName": "",
		"servicebusSubscribeConnectionApiId": "",
		"servicebusSubscribeConnectionResourceId": "",
		"servicebusSubscribeConnectionRuntimeUrl": "",
		"servicebusSubscribeConnectionKey": ""
	}
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\messageconstructor\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {
            "properties": {
              "$content": {
                "type": "string"
              },
              "$contentTransferEncoding": {
                "type": "string"
              },
              "$contentType": {
                "type": "string"
              },
              "properties": {
                "properties": {},
                "type": "object"
              }
            },
            "type": "object"
          }
        },
        "description": "We should be receiving a Body message that contains details about the received content, plus properties from the relevant adapter e.g. ReceivedFileName"
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_ResponseMessage_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ResponseMessage",
              "type": "object",
              "value": null
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ResponseMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{variables('Envelope')?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{body('Routing:_Call_RoutingSlipRouter')?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Merge_Properties": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{variables('Envelope')?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "MergeProperties"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['properties']?['scenario'])}/messageConstructor",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Build_Envelope": {
        "actions": {
          "BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@triggerBody()?['$content']",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/buildenvelope/@{encodeURIComponent('document')}/@{encodeURIComponent(triggerBody()?['properties']?['scenario'])}",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "encodeBody": "@coalesce(variables('Configuration')?['messageConstructor']?['encodeBody'], 'true')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['properties']?['trackingId']}",
                "Content-Encoding": "@{coalesce(triggerBody()?['$contentTransferEncoding'], 'none')}",
                "Content-Type": "@{triggerBody()?['$contentType']}",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "BuildEnvelope:_Check_Status_Code": {
            "runAfter": {
              "BuildEnvelope:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "BuildEnvelope:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "BuildEnvelope:Success:_Set_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "BuildEnvelope"
                    }
                  },
                  "BuildEnvelope:Success:_Set_Envelope_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@body('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "BuildEnvelope:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "BuildEnvelope:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "BuildEnvelope:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager BuildEnvelope operation"
                      }
                    },
                    "BuildEnvelope:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "BuildEnvelope:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['statusCode'], outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['body']?['statusCode'], actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['error']?['message'], outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['body']?['message'], actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['error']?['message'])}",
                            "faultReason": "@{actions('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['status']}"
                          }
                        }
                      },
                      "BuildEnvelope:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "BuildEnvelope:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager BuildEnvelope operation"
                        }
                      },
                      "BuildEnvelope:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "BuildEnvelope:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('BuildEnvelope:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['body']?.fault",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "BuildEnvelope:_Set_StatusCode_variable": {
            "runAfter": {
              "BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('BuildEnvelope:_Call_APIM_MessagingManager.BuildEnvelope')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Merge_Properties": {
        "actions": {
          "MergeProperties:_Call_APIM_MessagingManager.MergeProperties": {
            "runAfter": {
              "MergeProperties:_Create_Request_Message": [
                "Succeeded"
              ]
            },
            "type": "Http",
            "inputs": {
              "body": "@outputs('MergeProperties:_Create_Request_Message')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/mergeproperties",
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@variables('Envelope')?['header']?['properties']?['trackingId']",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "MergeProperties:_Check_StatusCode": {
            "runAfter": {
              "MergeProperties:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "MergeProperties:Success:_Copy_Properties_to_Envelope": {
                    "runAfter": {},
                    "type": "Compose",
                    "inputs": "@setProperty(variables('Envelope'), 'header', setProperty(variables('Envelope')?['header'], 'properties', body('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')))"
                  },
                  "MergeProperties:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "MergeProperties:Success_Set_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "MergeProperties"
                    }
                  },
                  "MergeProperties:Success_Set_Envelope_variable": {
                    "runAfter": {
                      "MergeProperties:Success:_Copy_Properties_to_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@outputs('MergeProperties:Success:_Copy_Properties_to_Envelope')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "MergeProperties:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "MergeProperties:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "MergeProperties:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager MergeProperties operation"
                      }
                    },
                    "MergeProperties:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "MergeProperties:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['statusCode'], outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['body']?['statusCode'], actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['error']?['message'], outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['body']?['message'], actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['error']?['message'])}",
                            "faultReason": "@{actions('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['status']}"
                          }
                        }
                      },
                      "MergeProperties:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "MergeProperties:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager MergeProperties operation"
                        }
                      },
                      "MergeProperties:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "MergeProperties:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('MergeProperties:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['body']?.fault",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "MergeProperties:_Create_Request_Message": {
            "runAfter": {},
            "type": "Compose",
            "inputs": "@createArray(variables('Envelope')?['header']?['properties'], triggerBody()?['properties'])"
          },
          "MergeProperties:_Set_StatusCode_variable": {
            "runAfter": {
              "MergeProperties:_Call_APIM_MessagingManager.MergeProperties": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('MergeProperties:_Call_APIM_MessagingManager.MergeProperties')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Build_Envelope": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "BuildEnvelope"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\messageresponsehandler\workflow.json
{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Initialize_StatusCode_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "StatusCode",
                            "type": "integer",
                            "value": 500
                        }
                    ]
                },
                "runAfter": {}
            },
            "Initialize_FaultMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "FaultMessage",
                            "type": "object",
                            "value": null
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_StatusCode_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_ErrorMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ErrorMessage",
                            "type": "string",
                            "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_FaultMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Checkpoint_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Checkpoint",
                            "type": "string"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_ErrorMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_ResponseBodyArray_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ResponseBodyArray",
                            "type": "array"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Checkpoint_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_ResponseCount_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ResponseCount",
                            "type": "integer",
                            "value": 0
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_ResponseBodyArray_variable": [
                        "Succeeded"
                    ]
                }
            },
            "SendResponse:_Check_Outcome": {
                "type": "If",
                "expression": {
                    "or": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "WaitForResponseSuccess"
                            ]
                        },
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "WaitForResponseFailure"
                            ]
                        },
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "WaitForResponseTimeout"
                            ]
                        }
                    ]
                },
                "actions": {
                    "SendResponse:_Switch_on_Checkpoint": {
                        "type": "Switch",
                        "expression": "@variables('Checkpoint')",
                        "cases": {
                            "Success": {
                                "case": "WaitForResponseSuccess",
                                "actions": {
                                    "SendResponse:Success:_Complete_each_Response_Message": {
                                        "type": "Foreach",
                                        "foreach": "@variables('ResponseBodyArray')",
                                        "actions": {
                                            "SendResponse:Success:_Complete_Current_Response_message": {
                                                "type": "ApiConnection",
                                                "inputs": {
                                                    "host": {
                                                        "connection": {
                                                            "referenceName": "serviceBusSubscribe"
                                                        }
                                                    },
                                                    "method": "delete",
                                                    "path": "/@{encodeURIComponent(triggerBody()?['responseTopicName'])}/subscriptions/@{encodeURIComponent(triggerBody()?['responseSubscriptionName'])}/messages/complete",
                                                    "queries": {
                                                        "lockToken": "@items('SendResponse:Success:_Complete_each_Response_Message')?['LockToken']",
                                                        "subscriptionType": "Main",
                                                        "sessionId": "@items('SendResponse:Success:_Complete_each_Response_Message')?['SessionId']"
                                                    },
                                                    "retryPolicy": {
                                                        "type": "none"
                                                    }
                                                },
                                                "runAfter": {}
                                            }
                                        },
                                        "runAfter": {}
                                    },
                                    "SendResponse:Success:_Build_Response": {
                                        "type": "Compose",
                                        "inputs": {
                                            "$content-type": "@variables('ResponseBodyArray')?[0]?['ContentType']",
                                            "$content": "@variables('ResponseBodyArray')?[0]?['ContentData']",
                                            "$content-encoding": "@variables('ResponseBodyArray')?[0]?['ContentTransferEncoding']"
                                        },
                                        "runAfter": {
                                            "SendResponse:Success:_Complete_each_Response_Message": [
                                                "Succeeded"
                                            ]
                                        }
                                    },
                                    "SendResponse:Success:_Send_Response": {
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "statusCode": 200,
                                            "headers": {
                                                "Content-Type": "application/json"
                                            },
                                            "body": "@outputs('SendResponse:Success:_Build_Response')"
                                        },
                                        "runAfter": {
                                            "SendResponse:Success:_Build_Response": [
                                                "Succeeded"
                                            ]
                                        }
                                    },
                                    "SendResponse:Success:_Send_Fault_Response": {
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "statusCode": 500,
                                            "headers": {
                                                "Content-Type": "application/json"
                                            },
                                            "body": {
                                                "fault": {
                                                    "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                    "faultCategory": "Error",
                                                    "faultCode": "500",
                                                    "faultMessage": "An error occurred trying to complete the response messages received for this session.",
                                                    "faultReason": ""
                                                }
                                            }
                                        },
                                        "runAfter": {
                                            "SendResponse:Success:_Complete_each_Response_Message": [
                                                "Failed",
                                                "Skipped",
                                                "TimedOut"
                                            ]
                                        }
                                    }
                                }
                            },
                            "Failure": {
                                "case": "WaitForResponseFailure",
                                "actions": {
                                    "SendResponse:Failure:_Send_Fault_Response": {
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "statusCode": 500,
                                            "headers": {
                                                "Content-Type": "application/json"
                                            },
                                            "body": "@variables('FaultMessage')"
                                        },
                                        "runAfter": {}
                                    }
                                }
                            },
                            "Timeout": {
                                "case": "WaitForResponseTimeout",
                                "actions": {
                                    "SendResponse:Timeout:_Send_Fault_Response": {
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "statusCode": 504,
                                            "headers": {
                                                "Content-Type": "application/json"
                                            },
                                            "body": {
                                                "fault": {
                                                    "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                    "faultCategory": "Error",
                                                    "faultCode": "504",
                                                    "faultMessage": "Timed out waiting for a response message.",
                                                    "faultReason": ""
                                                }
                                            }
                                        },
                                        "runAfter": {}
                                    }
                                }
                            }
                        },
                        "default": {
                            "actions": {
                                "SendResponse:UnknownCheckpoint:_Send_Fault_Response": {
                                    "type": "Response",
                                    "kind": "Http",
                                    "inputs": {
                                        "statusCode": 500,
                                        "headers": {
                                            "Content-Type": "application/json"
                                        },
                                        "body": {
                                            "fault": {
                                                "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                "faultCategory": "Error",
                                                "faultCode": "500",
                                                "faultMessage": "Unexpected Checkpoint value of '@{variables('Checkpoint')}' in LogicApp @{workflow()['name']}. Unable to continue.",
                                                "faultReason": ""
                                            }
                                        }
                                    },
                                    "runAfter": {}
                                }
                            }
                        },
                        "runAfter": {}
                    }
                },
                "runAfter": {
                    "Step:_Wait_for_Response": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                },
                "else": {
                    "actions": {
                        "Failure:_Do_we_have_a_Fault": {
                            "type": "If",
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@coalesce(variables('FaultMessage'), '')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "actions": {
                                "Failure:NoFault:_Send_Fault_Response": {
                                    "type": "Response",
                                    "kind": "Http",
                                    "inputs": {
                                        "statusCode": 500,
                                        "headers": {
                                            "Content-Type": "application/json"
                                        },
                                        "body": {
                                            "fault": {
                                                "faultActor": "@{workflow()['name']} (@{workflow()?['run']?['name']})",
                                                "faultCategory": "Error",
                                                "faultCode": "500",
                                                "faultMessage": "An error occurred in LogicApp @{workflow()['name']}. Unable to continue. Expected a Checkpoint of WaitForResponseSuccess/WaitForResponseFailure/WaitForResponseTimeout but received a Checkpoint of '@{variables('Checkpoint')}'.",
                                                "faultReason": ""
                                            }
                                        }
                                    },
                                    "runAfter": {}
                                }
                            },
                            "runAfter": {},
                            "else": {
                                "actions": {
                                    "Failure:HaveFault:_Send_Fault_Response": {
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "statusCode": 500,
                                            "headers": {
                                                "Content-Type": "application/json"
                                            },
                                            "body": "@variables('FaultMessage')"
                                        },
                                        "runAfter": {}
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "Step:_Wait_for_Response": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                ""
                            ]
                        }
                    ]
                },
                "actions": {
                    "WaitForResponse:_Loop_until_we_get_Response_or_TimeOut": {
                        "type": "Until",
                        "expression": "@or(greater(variables('ResponseCount'), 0), equals(variables('Checkpoint'), 'WaitForResponseFailure'))",
                        "limit": {
                            "count": "@mul(coalesce(triggerBody()?['responseTimeoutInMinutes'], 3), 2)",
                            "timeout": "PT@{coalesce(triggerBody()?['responseTimeoutInMinutes'], 3)}M"
                        },
                        "actions": {
                            "WaitForResponse:_Get_Response_Message_from_Topic": {
                                "type": "ApiConnection",
                                "inputs": {
                                    "host": {
                                        "connection": {
                                            "referenceName": "serviceBusSubscribe"
                                        }
                                    },
                                    "method": "get",
                                    "path": "/@{encodeURIComponent(encodeURIComponent(triggerBody()?['responseTopicName']))}/subscriptions/@{encodeURIComponent(triggerBody()?['responseSubscriptionName'])}/messages/batch/peek",
                                    "queries": {
                                        "maxMessageCount": 1,
                                        "subscriptionType": "Main",
                                        "sessionId": "@{triggerBody()?['correlationId']}"
                                    },
                                    "retryPolicy": {
                                        "type": "none"
                                    }
                                },
                                "runAfter": {}
                            },
                            "WaitForResponse:_Set_StatusCode_variable": {
                                "type": "SetVariable",
                                "inputs": {
                                    "name": "StatusCode",
                                    "value": "@coalesce(outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['statusCode'], 500)"
                                },
                                "runAfter": {
                                    "WaitForResponse:_Get_Response_Message_from_Topic": [
                                        "Succeeded",
                                        "Failed",
                                        "Skipped",
                                        "TimedOut"
                                    ]
                                }
                            },
                            "WaitForResponse:_Check_Status_Code": {
                                "type": "Switch",
                                "expression": "@variables('StatusCode')",
                                "cases": {
                                    "Success": {
                                        "case": 200,
                                        "actions": {
                                            "WaitForResponse:Success:_Set_ResponseBodyArray_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ResponseBodyArray",
                                                    "value": "@array(body('WaitForResponse:_Get_Response_Message_from_Topic'))"
                                                },
                                                "runAfter": {}
                                            },
                                            "WaitForResponse:Success:_Set_ResponseCount_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ResponseCount",
                                                    "value": "@length(variables('ResponseBodyArray'))"
                                                },
                                                "runAfter": {
                                                    "WaitForResponse:Success:_Set_ResponseBodyArray_variable": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                },
                                "default": {
                                    "actions": {
                                        "WaitForResponse:Failure:_Create_Fault_Message": {
                                            "type": "Compose",
                                            "inputs": {
                                                "fault": {
                                                    "faultActor": "@{workflow()?['name']}.@{actions('WaitForResponse:_Get_Response_Message_from_Topic')?['name']} (@{workflow()?['run']?['name']})",
                                                    "faultCategory": "Error",
                                                    "faultCode": "@{coalesce(outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['statusCode'], outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['body']?['statusCode'], actions('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['code'])}",
                                                    "faultMessage": "@{coalesce(outputs('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['message'], body('WaitForResponse:_Get_Response_Message_from_Topic')?['message'], body('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['message'], actions('WaitForResponse:_Get_Response_Message_from_Topic')?['error']?['message'])}",
                                                    "faultReason": "@{actions('WaitForResponse:_Get_Response_Message_from_Topic')?['status']}"
                                                }
                                            },
                                            "runAfter": {}
                                        },
                                        "WaitForResponse:Failure:_Set_FaultMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "FaultMessage",
                                                "value": "@outputs('WaitForResponse:Failure:_Create_Fault_Message')"
                                            },
                                            "runAfter": {
                                                "WaitForResponse:Failure:_Create_Fault_Message": [
                                                    "Succeeded"
                                                ]
                                            }
                                        },
                                        "WaitForResponse:Failure:_Set_ErrorMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred executing the @{actions('WaitForResponse:_Get_Response_Message_from_Topic')?['name']} action to get the response message."
                                            },
                                            "runAfter": {
                                                "WaitForResponse:Failure:_Set_FaultMessage_variable": [
                                                    "Succeeded"
                                                ]
                                            }
                                        },
                                        "WaitForResponse:Failure:_Set_Checkpoint_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "WaitForResponseFailure"
                                            },
                                            "runAfter": {
                                                "WaitForResponse:Failure:_Set_ErrorMessage_variable": [
                                                    "Succeeded"
                                                ]
                                            }
                                        }
                                    }
                                },
                                "runAfter": {
                                    "WaitForResponse:_Set_StatusCode_variable": [
                                        "Succeeded"
                                    ]
                                }
                            }
                        },
                        "runAfter": {}
                    },
                    "WaitForResponse:_Check_Outcome": {
                        "type": "If",
                        "expression": {
                            "and": [
                                {
                                    "equals": [
                                        "@variables('Checkpoint')",
                                        ""
                                    ]
                                },
                                {
                                    "greater": [
                                        "@variables('ResponseCount')",
                                        0
                                    ]
                                }
                            ]
                        },
                        "actions": {
                            "WaitForResponse:Success:_Set_Checkpoint_variable": {
                                "type": "SetVariable",
                                "inputs": {
                                    "name": "Checkpoint",
                                    "value": "WaitForResponseSuccess"
                                },
                                "runAfter": {}
                            }
                        },
                        "runAfter": {
                            "WaitForResponse:_Loop_until_we_get_Response_or_TimeOut": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        },
                        "else": {
                            "actions": {
                                "WaitForResponse:TimeOut:_Set_Checkpoint_variable": {
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "WaitForResponseTimeout"
                                    },
                                    "runAfter": {}
                                }
                            }
                        }
                    }
                },
                "runAfter": {
                    "Initialize_ResponseCount_variable": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            }
        },
        "triggers": {
            "manual": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                    "schema": {
                        "properties": {
                            "correlationId": {
                                "type": "string"
                            },
                            "responseSubscriptionName": {
                                "type": "string"
                            },
                            "responseTimeoutInMinutes": {
                                "type": "integer"
                            },
                            "responseTopicName": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "correlationId",
                            "responseTopicName",
                            "responseSubscriptionName",
                            "responseTimeoutInMinutes"
                        ],
                        "type": "object"
                    }
                },
                "operationOptions": "EnableSchemaValidation",
                "correlation": {}
            }
        },
        "contentVersion": "1.0.0.0"
    },
    "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\messagesuspendprocessor\workflow.json
{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Initialize_StatusCode_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "StatusCode",
                            "type": "integer",
                            "value": 500
                        }
                    ]
                },
                "runAfter": {}
            },
            "Initialize_FaultMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "FaultMessage",
                            "type": "object",
                            "value": null
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_StatusCode_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_ErrorMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ErrorMessage",
                            "type": "string",
                            "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_FaultMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Checkpoint_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Checkpoint",
                            "type": "string"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_ErrorMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_NackMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "NackMessage",
                            "type": "object"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Checkpoint_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_OriginalMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "OriginalMessage",
                            "type": "object"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_NackMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "MessageSender:_Were_we_Successful": {
                "type": "If",
                "expression": {
                    "or": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "SuspendOriginalMessage"
                            ]
                        },
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "SkippedSuspendOriginalMessage"
                            ]
                        }
                    ]
                },
                "actions": {
                    "Success:_Build_ACK_message": {
                        "type": "Compose",
                        "inputs": {
                            "body": [
                                {
                                    "$content": {
                                        "result": "Successfully published a NACK@{if(equals(variables('Checkpoint'), 'SuspendOriginalMessage'), ' and Original message', '')} to the SuspendQueue in ServiceBus"
                                    },
                                    "$contentType": "application/json",
                                    "$part": 1,
                                    "$partType": "http://schemas.microsoft.com/aim#ack"
                                }
                            ],
                            "header": {
                                "properties": {
                                    "createDate": "@utcNow()",
                                    "envelopeType": "ack",
                                    "messageId": "@guid()",
                                    "rootPart": 1,
                                    "trackingId": "@variables('NackMessage')?['header']?['properties']?['trackingId']"
                                },
                                "routing": {
                                    "messageType": "http://schemas.microsoft.com/aim#ack"
                                },
                                "routingSlip": {},
                                "state": {}
                            }
                        },
                        "runAfter": {}
                    },
                    "Routing:Success:_Send_ACK-Content_response": {
                        "type": "Response",
                        "kind": "Http",
                        "inputs": {
                            "statusCode": 200,
                            "headers": {
                                "Aim-Tracking-Id": "@{variables('NackMessage')?['header']?['properties']?['trackingId']}",
                                "Aim-Clear-Cache": "@coalesce(trigger()?['headers']?['Aim-Clear-Cache'], 'false')",
                                "Aim-Enable-Trace": "@coalesce(trigger()?['headers']?['Aim-Enable-Trace'], 'false')",
                                "Content-Type": "application/json"
                            },
                            "body": "@outputs('Success:_Build_ACK_message')"
                        },
                        "runAfter": {
                            "Success:_Build_ACK_message": [
                                "Succeeded"
                            ]
                        }
                    }
                },
                "runAfter": {
                    "Step:_Suspend_Original_Message": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                },
                "else": {
                    "actions": {
                        "Failure:_Build_NACK_message": {
                            "type": "Compose",
                            "inputs": {
                                "body": [
                                    {
                                        "$content": {
                                            "code": "500",
                                            "message": "@variables('ErrorMessage')",
                                            "lastCheckpoint": "@variables('Checkpoint')",
                                            "fault": "@variables('FaultMessage')"
                                        },
                                        "$contentType": "application/json",
                                        "$part": 1,
                                        "$partType": "http://schemas.microsoft.com/aim#nack"
                                    }
                                ],
                                "header": {
                                    "properties": {
                                        "createDate": "@utcNow()",
                                        "envelopeType": "nack",
                                        "messageId": "@guid()",
                                        "rootPart": 1,
                                        "trackingId": "@variables('NackMessage')?['header']?['properties']?['trackingId']"
                                    },
                                    "routing": {
                                        "messageType": "http://schemas.microsoft.com/aim#nack"
                                    },
                                    "routingSlip": {},
                                    "state": {}
                                }
                            },
                            "runAfter": {}
                        },
                        "Failure:_Send_NACK_response": {
                            "type": "Response",
                            "kind": "Http",
                            "inputs": {
                                "statusCode": 200,
                                "headers": {
                                    "Aim-Tracking-Id": "@{variables('NackMessage')?['header']?['properties']?['trackingId']}",
                                    "Aim-Clear-Cache": "@coalesce(trigger()?['headers']?['Aim-Clear-Cache'], 'false')",
                                    "Aim-Enable-Trace": "@coalesce(trigger()?['headers']?['Aim-Enable-Trace'], 'false')",
                                    "Content-Type": "application/json"
                                },
                                "body": "@outputs('Failure:_Build_NACK_message')"
                            },
                            "runAfter": {
                                "Failure:_Build_NACK_message": [
                                    "Succeeded"
                                ]
                            }
                        }
                    }
                }
            },
            "Step:_Get_Messages": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                ""
                            ]
                        }
                    ]
                },
                "actions": {
                    "GetMessages:_Set_NackMessage_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "NackMessage",
                            "value": "@triggerBody()?['nackMessage']"
                        },
                        "runAfter": {}
                    },
                    "GetMessages:_Set_OriginalMessage_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "OriginalMessage",
                            "value": "@triggerBody()?['originalMessage']"
                        },
                        "runAfter": {
                            "GetMessages:_Set_NackMessage_variable": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        }
                    },
                    "GetMessages:_Have_Valid_Messages": {
                        "type": "If",
                        "expression": {
                            "and": [
                                {
                                    "not": {
                                        "equals": [
                                            "@coalesce(variables('NackMessage'), '')",
                                            ""
                                        ]
                                    }
                                },
                                {
                                    "not": {
                                        "equals": [
                                            "@coalesce(variables('OriginalMessage'), '')",
                                            ""
                                        ]
                                    }
                                }
                            ]
                        },
                        "actions": {
                            "GetMessages:Success:_Set_Checkpoint_variable": {
                                "type": "SetVariable",
                                "inputs": {
                                    "name": "Checkpoint",
                                    "value": "GetMessages"
                                },
                                "runAfter": {}
                            }
                        },
                        "runAfter": {
                            "GetMessages:_Set_OriginalMessage_variable": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        },
                        "else": {
                            "actions": {
                                "GetMessages:Failure:_Set_Checkpoint_variable": {
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "ErrorMessage",
                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): no messages supplied in triggerBody - need either or both of NACK message or Original message"
                                    },
                                    "runAfter": {}
                                }
                            }
                        }
                    }
                },
                "runAfter": {
                    "Initialize_OriginalMessage_variable": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "Step:_Suspend_NACK": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "GetMessages"
                            ]
                        }
                    ]
                },
                "actions": {
                    "SuspendNack:_Check_Status_Code": {
                        "type": "Switch",
                        "expression": "@variables('StatusCode')",
                        "cases": {
                            "Success": {
                                "case": 200,
                                "actions": {
                                    "SuspendNack:Success:_Set_Checkpoint_variable": {
                                        "type": "SetVariable",
                                        "inputs": {
                                            "name": "Checkpoint",
                                            "value": "SuspendNack"
                                        },
                                        "runAfter": {}
                                    }
                                }
                            }
                        },
                        "default": {
                            "actions": {
                                "SuspendNack:Failure:_Do_we_have_a_Fault_Message": {
                                    "type": "If",
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@body('SuspendNack:_Send_to_ServiceBus')?['fault']",
                                                        null
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "actions": {
                                        "SuspendNack:Fault:_Set_ErrorMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a NACK to the SuspendQueue in ServiceBus"
                                            },
                                            "runAfter": {
                                                "SuspendNack:Fault:_Set_FaultMessage_variable": [
                                                    "Succeeded"
                                                ]
                                            }
                                        },
                                        "SuspendNack:Fault:_Set_FaultMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "FaultMessage",
                                                "value": "@body('SuspendNack:_Send_to_ServiceBus')"
                                            },
                                            "runAfter": {}
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "SuspendNack:NoFault:_Create_Fault_Message": {
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()['name'], '.', actions('SuspendNack:_Send_to_ServiceBus')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('SuspendNack:_Send_to_ServiceBus')?['statusCode'], outputs('SuspendNack:_Send_to_ServiceBus')?['body']?['statusCode'], actions('SuspendNack:_Send_to_ServiceBus')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('SuspendNack:_Send_to_ServiceBus')?['error']?['message'], outputs('SuspendNack:_Send_to_ServiceBus')?['body']?['message'], actions('SuspendNack:_Send_to_ServiceBus')?['error']?['message'])}",
                                                        "faultReason": "@{actions('SuspendNack:_Send_to_ServiceBus')?['status']}"
                                                    }
                                                },
                                                "runAfter": {}
                                            },
                                            "SuspendNack:NoFault:_Set_ErrorMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a NACK to the SuspendQueue in ServiceBus"
                                                },
                                                "runAfter": {
                                                    "SuspendNack:NoFault:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            },
                                            "SuspendNack:NoFault:_Set_FaultMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('SuspendNack:NoFault:_Create_Fault_Message')"
                                                },
                                                "runAfter": {
                                                    "SuspendNack:NoFault:_Create_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "runAfter": {
                            "SuspendNack:_Set_StatusCode_variable": [
                                "Succeeded"
                            ]
                        }
                    },
                    "SuspendNack:_Send_to_ServiceBus": {
                        "type": "ServiceProvider",
                        "inputs": {
                            "parameters": {
                                "entityName": "@coalesce(triggerBody()?['suspendQueueTopicName'], '(suspendqueue topic name not set)')",
                                "message": {
									"contentData": "@variables('NackMessage')",
                                    "contentType": "application/json",
                                    "UserProperties": "@variables('NackMessage')?['header']?['routing']",
                                    "messageId": "@coalesce(variables('NackMessage')?['header']?['properties']?['messageId'], guid())"
                                }
                            },
                            "serviceProviderConfiguration": {
                                "connectionName": "serviceBusPublish",
                                "operationId": "sendMessage",
                                "serviceProviderId": "/serviceProviders/serviceBus"
                            }
                        },
                        "runAfter": {}
                    },
                    "SuspendNack:_Set_StatusCode_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "StatusCode",
                            "value": "@if(equals(outputs('SuspendNack:_Send_to_ServiceBus')?['statusCode'], 'OK'), 200, 500)"
                        },
                        "runAfter": {
                            "SuspendNack:_Send_to_ServiceBus": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        }
                    }
                },
                "runAfter": {
                    "Step:_Get_Messages": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "Step:_Suspend_Original_Message": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "SuspendNack"
                            ]
                        }
                    ]
                },
                "actions": {
                    "SuspendOriginalMessage:_Check_FailedMessageRouting_value": {
                        "type": "If",
                        "expression": {
                            "and": [
                                {
                                    "equals": [
                                        "@coalesce(triggerBody()?['failedMessageRouting'], false)",
                                        true
                                    ]
                                }
                            ]
                        },
                        "actions": {
                            "SuspendOriginalMessage:_Check_Status_Code": {
                                "type": "Switch",
                                "expression": "@variables('StatusCode')",
                                "cases": {
                                    "Success": {
                                        "case": 200,
                                        "actions": {
                                            "SuspendOriginalMessage:Success:_Set_Checkpoint_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "SuspendOriginalMessage"
                                                },
                                                "runAfter": {}
                                            }
                                        }
                                    }
                                },
                                "default": {
                                    "actions": {
                                        "SuspendOriginalMessage:Failure:_Do_we_have_a_Fault_Message": {
                                            "type": "If",
                                            "expression": {
                                                "and": [
                                                    {
                                                        "not": {
                                                            "equals": [
                                                                "@body('SuspendOriginalMessage:_Send_to_ServiceBus')?['fault']",
                                                                null
                                                            ]
                                                        }
                                                    }
                                                ]
                                            },
                                            "actions": {
                                                "SuspendOriginalMessage:Fault:_Set_ErrorMessage_variable": {
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "ErrorMessage",
                                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish an original message to the SuspendQueue in ServiceBus"
                                                    },
                                                    "runAfter": {
                                                        "SuspendOriginalMessage:Fault:_Set_FaultMessage_variable": [
                                                            "Succeeded"
                                                        ]
                                                    }
                                                },
                                                "SuspendOriginalMessage:Fault:_Set_FaultMessage_variable": {
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "FaultMessage",
                                                        "value": "@body('SuspendOriginalMessage:_Send_to_ServiceBus')"
                                                    },
                                                    "runAfter": {}
                                                }
                                            },
                                            "runAfter": {},
                                            "else": {
                                                "actions": {
                                                    "SuspendOriginalMessage:NoFault:_Create_Fault_Message": {
                                                        "type": "Compose",
                                                        "inputs": {
                                                            "fault": {
                                                                "faultActor": "@concat(workflow()['name'], '.', actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                "faultCategory": "Error",
                                                                "faultCode": "@{coalesce(outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['statusCode'], outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['body']?['statusCode'], actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['error']?['code'])}",
                                                                "faultMessage": "@{coalesce(outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['error']?['message'], outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['body']?['message'], actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['error']?['message'])}",
                                                                "faultReason": "@{actions('SuspendOriginalMessage:_Send_to_ServiceBus')?['status']}"
                                                            }
                                                        },
                                                        "runAfter": {}
                                                    },
                                                    "SuspendOriginalMessage:NoFault:_Set_ErrorMessage_variable": {
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish an original message to the SuspendQueue in ServiceBus"
                                                        },
                                                        "runAfter": {
                                                            "SuspendOriginalMessage:NoFault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        }
                                                    },
                                                    "SuspendOriginalMessage:NoFault:_Set_FaultMessage_variable": {
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@outputs('SuspendOriginalMessage:NoFault:_Create_Fault_Message')"
                                                        },
                                                        "runAfter": {
                                                            "SuspendOriginalMessage:NoFault:_Create_Fault_Message": [
                                                                "Succeeded"
                                                            ]
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                },
                                "runAfter": {
                                    "SuspendOriginalMessage:_Set_StatusCode_variable": [
                                        "Succeeded"
                                    ]
                                }
                            },
                            "SuspendOriginalMessage:_Send_to_ServiceBus": {
                                "type": "ServiceProvider",
                                "inputs": {
                                    "parameters": {
                                        "entityName": "@coalesce(triggerBody()?['suspendQueueTopicName'], '(suspendqueue topic name not set)')",
                                        "message": {
											"contentData": "@variables('OriginalMessage')",
											"contentType": "application/json",
											"UserProperties": {
												"messageType": "@variables('OriginalMessage')?['header']?['properties']?['messageType']",
                                                "errorType": "FailedMessage"
											},
											"messageId": "@guid()"
                                        }
                                    },
                                    "serviceProviderConfiguration": {
                                        "connectionName": "serviceBusPublish",
                                        "operationId": "sendMessage",
                                        "serviceProviderId": "/serviceProviders/serviceBus"
                                    }
                                },
                                "runAfter": {}
                            },
                            "SuspendOriginalMessage:_Set_StatusCode_variable": {
                                "type": "SetVariable",
                                "inputs": {
                                    "name": "StatusCode",
                                    "value": "@if(equals(outputs('SuspendOriginalMessage:_Send_to_ServiceBus')?['statusCode'], 'OK'), 200, 500)"
                                },
                                "runAfter": {
                                    "SuspendOriginalMessage:_Send_to_ServiceBus": [
                                        "Succeeded",
                                        "Failed",
                                        "Skipped",
                                        "TimedOut"
                                    ]
                                }
                            }
                        },
                        "runAfter": {},
                        "else": {
                            "actions": {
                                "SuspendOriginalMessage:Skipped:_Set_Checkpoint_variable": {
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "SkippedSuspendOriginalMessage"
                                    },
                                    "runAfter": {}
                                }
                            }
                        }
                    }
                },
                "runAfter": {
                    "Step:_Suspend_NACK": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            }
        },
        "triggers": {
            "manual": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                    "schema": {
                        "properties": {
                            "nackMessage": {
                                "properties": {},
                                "type": "object"
                            },
                            "originalMessage": {
                                "properties": {},
                                "type": "object"
                            },
                            "suspendQueueTopicName": {
                                "type": "string"
                            },
                            "failedMessageRouting": {
                                "type": "boolean"
                            },
                            "scenario": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "nackMessage",
                            "suspendQueueTopicName",
                            "failedMessageRouting",
                            "scenario"
                        ],
                        "type": "object"
                    }
                },
                "operationOptions": "EnableSchemaValidation",
                "correlation": {
                    "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                }
            }
        },
        "contentVersion": "1.0.0.0"
    },
    "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\parameters.json
{
	"apimRetryPolicy": {
		"type": "Object",
		"value": {
			"count": 3,
			"interval": "PT5S",
			"type": "fixed"
		}
	},
	"routerRetryPolicy": {
		"type": "Object",
		"value": {
			"count": 3,
			"interval": "PT5S",
			"type": "fixed"
		}
	},
	"servicebusSubscribeConnectionApiId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/providers/Microsoft.Web/locations/@appsetting('apiConnectionLocation')/managedApis/servicebus"
	},
	"servicebusSubscribeConnectionResourceId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/resourceGroups/@appsetting('apiConnectionResourceGroupName')/providers/Microsoft.Web/connections/@appsetting('servicebusSubscribeConnectionName')"
	},
	"servicebusSubscribeManagedApiAuthentication": {
		"type": "Object",
		"value": {
			"type": "ManagedServiceIdentity"
		}
	},
	"clearCache": {
		"type": "Bool",
		"value": false,
		"description": "Flag indicating if the cache should be cleared when calling APIM."
	},
	"suspendQueueTopicName": {
		"type": "String",
		"value": "suspendqueue",
		"description": "Name of the ServiceBus Topic that suspended messages are sent to."
	},
	"responseTopicName": {
		"type": "String",
		"value": "",
		"description": "Name of the ServiceBus Topic where response messages are found for two-way operations."
	},
	"responseSubscriptionName": {
		"type": "String",
		"value": "",
		"description": "Name of the ServiceBus Subscription used to get response messages for two-way operations."
	}
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\parameters.local.json
{
	"apimRetryPolicy": {
		"type": "Object",
		"value": {
			"count": 3,
			"interval": "PT5S",
			"type": "fixed"
		}
	},
	"routerRetryPolicy": {
		"type": "Object",
		"value": {
			"count": 3,
			"interval": "PT5S",
			"type": "fixed"
		}
	},
	"servicebusSubscribeConnectionApiId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/providers/Microsoft.Web/locations/@appsetting('apiConnectionLocation')/managedApis/servicebus"
	},
	"servicebusSubscribeConnectionResourceId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/resourceGroups/@appsetting('apiConnectionResourceGroupName')/providers/Microsoft.Web/connections/@appsetting('servicebusSubscribeConnectionName')"
	},
	"servicebusSubscribeManagedApiAuthentication": {
		"type": "Object",
		"value": {
			"type": "Raw",
			"scheme": "Key",
			"parameter": "@appsetting('servicebusSubscribeConnectionKey')"
		}
	},
	"clearCache": {
		"type": "Bool",
		"value": false,
		"description": "Flag indicating if the cache should be cleared when calling APIM."
	},
	"suspendQueueTopicName": {
		"type": "String",
		"value": "suspendqueue",
		"description": "Name of the ServiceBus Topic that suspended messages are sent to."
	},
	"responseTopicName": {
		"type": "String",
		"value": "",
		"description": "Name of the ServiceBus Topic where response messages are found for two-way operations."
	},
	"responseSubscriptionName": {
		"type": "String",
		"value": "",
		"description": "Name of the ServiceBus Subscription used to get response messages for two-way operations."
	}
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\routingsliprouter\workflow.json
{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Initialize_StatusCode_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "StatusCode",
                            "type": "integer",
                            "value": 500
                        }
                    ]
                },
                "runAfter": {}
            },
            "Initialize_FaultMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "FaultMessage",
                            "type": "object"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_StatusCode_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_ErrorMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ErrorMessage",
                            "type": "string",
                            "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow."
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_FaultMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_ResponseMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ResponseMessage",
                            "type": "object",
                            "value": null
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_ErrorMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Checkpoint_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Checkpoint",
                            "type": "string"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_ResponseMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Envelope_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Envelope",
                            "type": "object",
                            "value": "@triggerBody()"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Checkpoint_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Configuration_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Configuration",
                            "type": "object"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Envelope_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_RouteIndex_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "RouteIndex",
                            "type": "integer",
                            "value": -1
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Configuration_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Set_RouteIndex_variable": {
                "type": "SetVariable",
                "inputs": {
                    "name": "RouteIndex",
                    "value": "@int(coalesce(triggerBody()?['header']?['routingSlip']?['nextRoute'], '-1'))"
                },
                "runAfter": {
                    "Initialize_RouteIndex_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Route_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Route",
                            "type": "object",
                            "value": "@triggerBody()?['header']?['routingSlip']?['routes']?[variables('RouteIndex')]"
                        }
                    ]
                },
                "runAfter": {
                    "Set_RouteIndex_variable": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "Initialize_ChannelType_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ChannelType",
                            "type": "string",
                            "value": "@variables('Route')?['routingSteps']?['channelType']"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Route_variable": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "MessageSender:_Were_we_successful": {
                "type": "If",
                "expression": {
                    "or": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "NoMoreRoutes"
                            ]
                        },
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "ProcessChannel"
                            ]
                        }
                    ]
                },
                "actions": {
                    "Success:_Send_ACK_response": {
                        "type": "Response",
                        "kind": "Http",
                        "inputs": {
                            "statusCode": 200,
                            "headers": {
                                "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                "Content-Type": "application/json"
                            },
                            "body": "@variables('ResponseMessage')"
                        },
                        "runAfter": {}
                    }
                },
                "runAfter": {
                    "Step:_Process_Channel": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                },
                "else": {
                    "actions": {
                        "Failure:_Build_NACK_message": {
                            "type": "Compose",
                            "inputs": {
                                "body": [
                                    {
                                        "$content": {
                                            "code": "500",
                                            "message": "@variables('ErrorMessage')",
                                            "lastCheckpoint": "@variables('Checkpoint')",
                                            "fault": "@variables('FaultMessage')"
                                        },
                                        "$contentType": "application/json",
                                        "$part": 1,
                                        "$partType": "http://schemas.microsoft.com/aim#nack"
                                    }
                                ],
                                "header": {
                                    "properties": {
                                        "createDate": "@utcNow()",
                                        "envelopeType": "nack",
                                        "messageId": "@guid()",
                                        "rootPart": 1,
                                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                    },
                                    "routing": {
                                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                                    },
                                    "routingSlip": {},
                                    "state": {}
                                }
                            },
                            "runAfter": {}
                        },
                        "Failure:_Send_NACK_response": {
                            "type": "Response",
                            "kind": "Http",
                            "inputs": {
                                "statusCode": 200,
                                "headers": {
                                    "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                    "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                    "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                    "Content-Type": "application/json"
                                },
                                "body": "@outputs('Failure:_Build_NACK_message')"
                            },
                            "runAfter": {
                                "Failure:_Build_NACK_message": [
                                    "Succeeded"
                                ]
                            }
                        }
                    }
                }
            },
            "Step:_Get_Configuration": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                ""
                            ]
                        }
                    ]
                },
                "actions": {
                    "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                        "type": "Http",
                        "inputs": {
                            "method": "GET",
                            "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/routingSlipRouter",
                            "headers": {
                                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
                            },
                            "queries": {
                                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                            },
                            "retryPolicy": {
                                "type": "none"
                            }
                        },
                        "runAfter": {}
                    },
                    "GetConfiguration:_Check_Status_Code": {
                        "type": "Switch",
                        "expression": "@variables('StatusCode')",
                        "cases": {
                            "Success": {
                                "case": 200,
                                "actions": {
                                    "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                        "type": "SetVariable",
                                        "inputs": {
                                            "name": "Checkpoint",
                                            "value": "GetConfiguration"
                                        },
                                        "runAfter": {
                                            "GetConfiguration:Success:_Set_Configuration_variable": [
                                                "Succeeded"
                                            ]
                                        }
                                    },
                                    "GetConfiguration:Success:_Set_Configuration_variable": {
                                        "type": "SetVariable",
                                        "inputs": {
                                            "name": "Configuration",
                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                        },
                                        "runAfter": {}
                                    }
                                }
                            }
                        },
                        "default": {
                            "actions": {
                                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                    "type": "If",
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                        null
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "actions": {
                                        "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                            },
                                            "runAfter": {
                                                "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                    "Succeeded"
                                                ]
                                            }
                                        },
                                        "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "FaultMessage",
                                                "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                            },
                                            "runAfter": {}
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                        "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                    }
                                                },
                                                "runAfter": {}
                                            },
                                            "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                },
                                                "runAfter": {
                                                    "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            },
                                            "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                },
                                                "runAfter": {
                                                    "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "runAfter": {
                            "GetConfiguration:_Set_StatusCode_variable": [
                                "Succeeded"
                            ]
                        }
                    },
                    "GetConfiguration:_Set_StatusCode_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "StatusCode",
                            "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                        },
                        "runAfter": {
                            "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        }
                    }
                },
                "runAfter": {
                    "Initialize_ChannelType_variable": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "Step:_Check_if_have_processed_all_routes": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "GetConfiguration"
                            ]
                        }
                    ]
                },
                "actions": {
                    "Have_we_processed_all_routes": {
                        "type": "If",
                        "expression": {
                            "or": [
                                {
                                    "greaterOrEquals": [
                                        "@variables('RouteIndex')",
                                        "@length(triggerBody()?['header']?['routingSlip']?['routes'])"
                                    ]
                                },
                                {
                                    "less": [
                                        "@variables('RouteIndex')",
                                        0
                                    ]
                                }
                            ]
                        },
                        "actions": {
                            "NoMoreRoutes:_Build_ACK": {
                                "type": "Compose",
                                "inputs": {
                                    "body": [
                                        {
                                            "$content": "No more routes to process",
                                            "$contentType": "text/plain",
                                            "$part": 1,
                                            "$partType": "http://schemas.microsoft.com/aim#ack"
                                        }
                                    ],
                                    "header": {
                                        "properties": {
                                            "createDate": "@{utcNow()}",
                                            "envelopeType": "ack",
                                            "messageId": "@{guid()}",
                                            "rootPart": 1,
                                            "trackingId": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "correlationId": "@{triggerBody()?['header']?['properties']?['messageId']}"
                                        },
                                        "routing": {
                                            "MessageType": "http://schemas.microsoft.com/aim#ack"
                                        },
                                        "routingSlip": {},
                                        "state": {}
                                    }
                                },
                                "runAfter": {}
                            },
                            "NoMoreRoutes:_Set_ResponseMessage": {
                                "type": "SetVariable",
                                "inputs": {
                                    "name": "ResponseMessage",
                                    "value": "@outputs('NoMoreRoutes:_Build_ACK')"
                                },
                                "runAfter": {
                                    "NoMoreRoutes:_Build_ACK": [
                                        "Succeeded"
                                    ]
                                }
                            },
                            "NoMoreRoutes:_Set_Checkpoint_variable": {
                                "type": "SetVariable",
                                "inputs": {
                                    "name": "Checkpoint",
                                    "value": "NoMoreRoutes"
                                },
                                "runAfter": {
                                    "NoMoreRoutes:_Set_ResponseMessage": [
                                        "Succeeded"
                                    ]
                                }
                            }
                        },
                        "runAfter": {},
                        "else": {
                            "actions": {
                                "RoutesToProcess:_Set_Checkpoint_variable": {
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "RoutesToProcess"
                                    },
                                    "runAfter": {}
                                }
                            }
                        }
                    }
                },
                "runAfter": {
                    "Step:_Get_Configuration": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "Step:_Process_Channel": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "RoutesToProcess"
                            ]
                        }
                    ]
                },
                "actions": {
                    "ProcessChannel:Failure:_Get_Failed_Items": {
                        "type": "Query",
                        "inputs": {
                            "from": "@result('ProcessChannel:_Exception_Scope')",
                            "where": "@or(equals(item()['status'], 'Failed'), equals(item()['status'], 'TimedOut'))"
                        },
                        "runAfter": {
                            "ProcessChannel:_Exception_Scope": [
                                "Failed",
                                "TimedOut"
                            ]
                        }
                    },
                    "ProcessChannel:Failure:_Set_ErrorMessage_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "ErrorMessage",
                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) in an ExceptionScope. Error: Action: @{body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['name']}, StatusCode: @{body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['outputs']?['statusCode']}, Message: @{concat(body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['error']?['message'], body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['outputs']?['body']?['message'])}"
                        },
                        "runAfter": {
                            "ProcessChannel:Failure:_Get_Failed_Items": [
                                "Succeeded"
                            ]
                        }
                    },
                    "ProcessChannel:_Exception_Scope": {
                        "type": "Scope",
                        "actions": {
                            "ProcessChannel:_Switch_on_ChannelType": {
                                "type": "Switch",
                                "expression": "@variables('ChannelType')",
                                "cases": {
                                    "APIM": {
                                        "case": "microsoft.channels.trigger.azure-apim",
                                        "actions": {
                                            "APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute": {
                                                "type": "Http",
                                                "inputs": {
                                                    "method": "POST",
                                                    "uri": "@{appsetting('apimBaseUrl')}/aimroutingmanager/sendtonextroute",
                                                    "headers": {
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Transfer-Encoding": "none",
                                                        "Content-Type": "application/json",
                                                        "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
                                                    },
                                                    "queries": {
                                                        "clearCache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                        "enableTrace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)"
                                                    },
                                                    "body": "@triggerBody()",
                                                    "retryPolicy": {
                                                        "type": "none"
                                                    }
                                                },
                                                "runAfter": {}
                                            },
                                            "APIMRouting:_Check_StatusCode": {
                                                "type": "Switch",
                                                "expression": "@variables('StatusCode')",
                                                "cases": {
                                                    "Success": {
                                                        "case": 200,
                                                        "actions": {
                                                            "APIMRouting:Success:_Set_Checkpoint_variable": {
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "Checkpoint",
                                                                    "value": "ProcessChannel"
                                                                },
                                                                "runAfter": {
                                                                    "APIMRouting:Success:_Set_ResponseMessage_variable": [
                                                                        "Succeeded"
                                                                    ]
                                                                }
                                                            },
                                                            "APIMRouting:Success:_Set_ResponseMessage_variable": {
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "ResponseMessage",
                                                                    "value": "@body('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')"
                                                                },
                                                                "runAfter": {}
                                                            }
                                                        }
                                                    }
                                                },
                                                "default": {
                                                    "actions": {
                                                        "APIMRouting:Failure:_Do_we_have_a_Fault_Message": {
                                                            "type": "If",
                                                            "expression": {
                                                                "and": [
                                                                    {
                                                                        "not": {
                                                                            "equals": [
                                                                                "@body('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['fault']",
                                                                                null
                                                                            ]
                                                                        }
                                                                    }
                                                                ]
                                                            },
                                                            "actions": {
                                                                "APIMRouting:Fault:_Set_ErrorMessage_variable": {
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "ErrorMessage",
                                                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager SendToNextRoute operation"
                                                                    },
                                                                    "runAfter": {
                                                                        "APIMRouting:Fault:_Set_FaultMessage_variable": [
                                                                            "Succeeded"
                                                                        ]
                                                                    }
                                                                },
                                                                "APIMRouting:Fault:_Set_FaultMessage_variable": {
                                                                    "type": "SetVariable",
                                                                    "inputs": {
                                                                        "name": "FaultMessage",
                                                                        "value": "@body('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')"
                                                                    },
                                                                    "runAfter": {}
                                                                }
                                                            },
                                                            "runAfter": {},
                                                            "else": {
                                                                "actions": {
                                                                    "APIMRouting:NoFault:_Create_Fault_Message": {
                                                                        "type": "Compose",
                                                                        "inputs": {
                                                                            "fault": {
                                                                                "faultActor": "@concat(workflow()?['name'], '.', actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                                "faultCategory": "Error",
                                                                                "faultCode": "@{coalesce(outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['statusCode'], outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['body']?['statusCode'], actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['error']?['code'])}",
                                                                                "faultMessage": "@{coalesce(outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['error']?['message'], outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['body']?['message'], actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['error']?['message'])}",
                                                                                "faultReason": "@{actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['status']}"
                                                                            }
                                                                        },
                                                                        "runAfter": {}
                                                                    },
                                                                    "APIMRouting:NoFault:_Set_ErrorMessage_variable": {
                                                                        "type": "SetVariable",
                                                                        "inputs": {
                                                                            "name": "ErrorMessage",
                                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager SendToNextRoute operation"
                                                                        },
                                                                        "runAfter": {
                                                                            "APIMRouting:NoFault:_Set_FaultMessage_variable": [
                                                                                "Succeeded"
                                                                            ]
                                                                        }
                                                                    },
                                                                    "APIMRouting:NoFault:_Set_FaultMessage_variable": {
                                                                        "type": "SetVariable",
                                                                        "inputs": {
                                                                            "name": "FaultMessage",
                                                                            "value": "@outputs('APIMRouting:NoFault:_Create_Fault_Message')"
                                                                        },
                                                                        "runAfter": {
                                                                            "APIMRouting:NoFault:_Create_Fault_Message": [
                                                                                "Succeeded"
                                                                            ]
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                },
                                                "runAfter": {
                                                    "APIMRouting:_Set_StatusCode_variable": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            },
                                            "APIMRouting:_Set_StatusCode_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "StatusCode",
                                                    "value": "@coalesce(outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')['statusCode'], 500)"
                                                },
                                                "runAfter": {
                                                    "APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute": [
                                                        "Succeeded",
                                                        "Failed",
                                                        "TimedOut",
                                                        "Skipped"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                },
                                "default": {
                                    "actions": {
                                        "Unsupported_ChannelType:_Set_ErrorMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Have an unsupported ChannelType value of @{coalesce(variables('ChannelType'), '(not supplied)')}"
                                            },
                                            "runAfter": {}
                                        }
                                    }
                                },
                                "runAfter": {}
                            }
                        },
                        "runAfter": {}
                    }
                },
                "runAfter": {
                    "Step:_Check_if_have_processed_all_routes": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            }
        },
        "triggers": {
            "manual": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                    "schema": {}
                },
                "correlation": {
                    "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                }
            }
        },
        "contentVersion": "1.0.0.0"
    },
    "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\topicpublisher\workflow.json
{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Initialize_StatusCode_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "StatusCode",
                            "type": "integer",
                            "value": 500
                        }
                    ]
                },
                "runAfter": {}
            },
            "Initialize_FaultMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "FaultMessage",
                            "type": "object",
                            "value": null
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_StatusCode_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_ErrorMessage_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "ErrorMessage",
                            "type": "string",
                            "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_FaultMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Checkpoint_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Checkpoint",
                            "type": "string"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_ErrorMessage_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Envelope_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Envelope",
                            "type": "object",
                            "value": "@triggerBody()"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Checkpoint_variable": [
                        "Succeeded"
                    ]
                }
            },
            "Initialize_Configuration_variable": {
                "type": "InitializeVariable",
                "inputs": {
                    "variables": [
                        {
                            "name": "Configuration",
                            "type": "object"
                        }
                    ]
                },
                "runAfter": {
                    "Initialize_Envelope_variable": [
                        "Succeeded"
                    ]
                }
            },
            "MessageSender:_Were_we_Successful": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "PublishToTopic"
                            ]
                        }
                    ]
                },
                "actions": {
                    "Routing:_Call_RoutingSlipRouter": {
                        "runAfter": {},
                        "type": "Workflow",
                        "inputs": {
                            "body": "@variables('Envelope')",
                            "headers": {
                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                "Content-Type": "application/json"
                            },
                            "host": {
                                "workflow": {
                                    "id": "routingsliprouter"
                                }
                            },
                            "retryPolicy": {
                                "type": "none"
                            }
                        }
                    },
                    "Routing:_Check_StatusCode": {
                        "type": "Switch",
                        "expression": "@variables('StatusCode')",
                        "cases": {
                            "Success": {
                                "case": 200,
                                "actions": {
                                    "Routing:Success:_Send_ACK-Content_response": {
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "statusCode": 200,
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "body": "@body('Routing:_Call_RoutingSlipRouter')"
                                        },
                                        "runAfter": {}
                                    }
                                }
                            }
                        },
                        "default": {
                            "actions": {
                                "Routing:Error:_Build_NACK_message": {
                                    "type": "Compose",
                                    "inputs": {
                                        "body": [
                                            {
                                                "$content": {
                                                    "code": "500",
                                                    "message": "@variables('ErrorMessage')",
                                                    "lastCheckpoint": "@variables('Checkpoint')",
                                                    "fault": "@variables('FaultMessage')"
                                                },
                                                "$contentType": "application/json",
                                                "$part": 1,
                                                "$partType": "http://schemas.microsoft.com/aim#nack"
                                            }
                                        ],
                                        "header": {
                                            "properties": {
                                                "createDate": "@utcNow()",
                                                "envelopeType": "nack",
                                                "messageId": "@guid()",
                                                "rootPart": 1,
                                                "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                            },
                                            "routing": {
                                                "MessageType": "http://schemas.microsoft.com/aim#nack"
                                            },
                                            "routingSlip": {},
                                            "state": {}
                                        }
                                    },
                                    "runAfter": {
                                        "Routing:Error:_Do_we_have_a_Fault_Message": [
                                            "Succeeded"
                                        ]
                                    }
                                },
                                "Routing:Error:_Do_we_have_a_Fault_Message": {
                                    "type": "If",
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                        null
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "actions": {
                                        "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                            },
                                            "runAfter": {
                                                "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                    "Succeeded"
                                                ]
                                            }
                                        },
                                        "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "FaultMessage",
                                                "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                            },
                                            "runAfter": {}
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "Routing:Error:NoFault:_Create_Fault_Message": {
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                        "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                    }
                                                },
                                                "runAfter": {}
                                            },
                                            "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                },
                                                "runAfter": {
                                                    "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            },
                                            "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                },
                                                "runAfter": {
                                                    "Routing:Error:NoFault:_Create_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                },
                                "Routing:Error:_Send_NACK_response": {
                                    "type": "Response",
                                    "kind": "Http",
                                    "inputs": {
                                        "statusCode": 200,
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "body": "@outputs('Routing:Error:_Build_NACK_message')"
                                    },
                                    "runAfter": {
                                        "Routing:Error:_Build_NACK_message": [
                                            "Succeeded"
                                        ]
                                    }
                                }
                            }
                        },
                        "runAfter": {
                            "Routing:_Set_StatusCode_variable": [
                                "Succeeded"
                            ]
                        }
                    },
                    "Routing:_Set_StatusCode_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "StatusCode",
                            "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                        },
                        "runAfter": {
                            "Routing:_Call_RoutingSlipRouter": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        }
                    }
                },
                "runAfter": {
                    "Step:_Publish_To_Topic": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                },
                "else": {
                    "actions": {
                        "Failure:_Build_NACK_message": {
                            "type": "Compose",
                            "inputs": {
                                "body": [
                                    {
                                        "$content": {
                                            "code": "500",
                                            "message": "@variables('ErrorMessage')",
                                            "lastCheckpoint": "@variables('Checkpoint')",
                                            "fault": "@variables('FaultMessage')"
                                        },
                                        "$contentType": "application/json",
                                        "$part": 1,
                                        "$partType": "http://schemas.microsoft.com/aim#nack"
                                    }
                                ],
                                "header": {
                                    "properties": {
                                        "createDate": "@utcNow()",
                                        "envelopeType": "nack",
                                        "messageId": "@guid()",
                                        "rootPart": 1,
                                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                    },
                                    "routing": {
                                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                                    },
                                    "routingSlip": {},
                                    "state": {}
                                }
                            },
                            "runAfter": {}
                        },
                        "Failure:_Send_NACK_response": {
                            "type": "Response",
                            "kind": "Http",
                            "inputs": {
                                "statusCode": 200,
                                "headers": {
                                    "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                    "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                    "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                    "Content-Type": "application/json"
                                },
                                "body": "@outputs('Failure:_Build_NACK_message')"
                            },
                            "runAfter": {
                                "Failure:_Build_NACK_message": [
                                    "Succeeded"
                                ]
                            }
                        }
                    }
                }
            },
            "Step:_Get_Configuration": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                ""
                            ]
                        }
                    ]
                },
                "actions": {
                    "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                        "type": "Http",
                        "inputs": {
                            "method": "GET",
                            "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/topicPublisher",
                            "headers": {
                                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
                            },
                            "queries": {
                                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                            },
                            "retryPolicy": {
                                "type": "none"
                            }
                        },
                        "runAfter": {}
                    },
                    "GetConfiguration:_Check_Status_Code": {
                        "type": "Switch",
                        "expression": "@variables('StatusCode')",
                        "cases": {
                            "Success": {
                                "case": 200,
                                "actions": {
                                    "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                        "type": "SetVariable",
                                        "inputs": {
                                            "name": "Checkpoint",
                                            "value": "GetConfiguration"
                                        },
                                        "runAfter": {
                                            "GetConfiguration:Success:_Set_Configuration_variable": [
                                                "Succeeded"
                                            ]
                                        }
                                    },
                                    "GetConfiguration:Success:_Set_Configuration_variable": {
                                        "type": "SetVariable",
                                        "inputs": {
                                            "name": "Configuration",
                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                        },
                                        "runAfter": {}
                                    }
                                }
                            }
                        },
                        "default": {
                            "actions": {
                                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                    "type": "If",
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                        null
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "actions": {
                                        "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                            },
                                            "runAfter": {
                                                "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                    "Succeeded"
                                                ]
                                            }
                                        },
                                        "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "FaultMessage",
                                                "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                            },
                                            "runAfter": {}
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                        "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                    }
                                                },
                                                "runAfter": {}
                                            },
                                            "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                },
                                                "runAfter": {
                                                    "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            },
                                            "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                },
                                                "runAfter": {
                                                    "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "runAfter": {
                            "GetConfiguration:_Set_StatusCode_variable": [
                                "Succeeded"
                            ]
                        }
                    },
                    "GetConfiguration:_Set_StatusCode_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "StatusCode",
                            "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                        },
                        "runAfter": {
                            "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        }
                    }
                },
                "runAfter": {
                    "Initialize_Configuration_variable": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "Step:_Check_TopicName": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "GetConfiguration"
                            ]
                        }
                    ]
                },
                "actions": {
                    "CheckTopicName:_TopicName_is_blank": {
                        "type": "If",
                        "expression": {
                            "and": [
                                {
                                    "equals": [
                                        "@{coalesce(variables('Configuration')?['topicPublisher']?['topicName'], '')}",
                                        ""
                                    ]
                                }
                            ]
                        },
                        "actions": {
                            "CheckTopicName:Failure:_Set_ErrorMessage": {
                                "type": "SetVariable",
                                "inputs": {
                                    "name": "ErrorMessage",
                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No TopicName is set in the configuration entry for this step"
                                },
                                "runAfter": {}
                            }
                        },
                        "runAfter": {},
                        "else": {
                            "actions": {
                                "CheckTopicName:Success:_Set_Checkpoint_variable": {
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "CheckTopicName"
                                    },
                                    "runAfter": {}
                                }
                            }
                        }
                    }
                },
                "runAfter": {
                    "Step:_Get_Configuration": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            },
            "Step:_Publish_To_Topic": {
                "type": "If",
                "expression": {
                    "and": [
                        {
                            "equals": [
                                "@variables('Checkpoint')",
                                "CheckTopicName"
                            ]
                        }
                    ]
                },
                "actions": {
                    "PublishToTopic:_Check_Status_Code": {
                        "type": "Switch",
                        "expression": "@variables('StatusCode')",
                        "cases": {
                            "Success": {
                                "case": 200,
                                "actions": {
                                    "PublishToTopic:Success:_Set_Checkpoint_variable": {
                                        "type": "SetVariable",
                                        "inputs": {
                                            "name": "Checkpoint",
                                            "value": "PublishToTopic"
                                        },
                                        "runAfter": {}
                                    }
                                }
                            }
                        },
                        "default": {
                            "actions": {
                                "PublishToTopic:Failure:_Do_we_have_a_Fault_Message": {
                                    "type": "If",
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@body('PublishToTopic:_Send_to_ServiceBus')?['fault']",
                                                        null
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "actions": {
                                        "PublishToTopic:Fault:_Set_ErrorMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a message to ServiceBus"
                                            },
                                            "runAfter": {
                                                "PublishToTopic:Fault:_Set_FaultMessage_variable": [
                                                    "Succeeded"
                                                ]
                                            }
                                        },
                                        "PublishToTopic:Fault:_Set_FaultMessage_variable": {
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "FaultMessage",
                                                "value": "@body('PublishToTopic:_Send_to_ServiceBus')"
                                            },
                                            "runAfter": {}
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "PublishToTopic:NoFault:_Create_Fault_Message": {
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('PublishToTopic:_Send_to_ServiceBus')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('PublishToTopic:_Send_to_ServiceBus')?['statusCode'], outputs('PublishToTopic:_Send_to_ServiceBus')?['body']?['statusCode'], actions('PublishToTopic:_Send_to_ServiceBus')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('PublishToTopic:_Send_to_ServiceBus')?['error']?['message'], outputs('PublishToTopic:_Send_to_ServiceBus')?['body']?['message'], actions('PublishToTopic:_Send_to_ServiceBus')?['error']?['message'])}",
                                                        "faultReason": "@{actions('PublishToTopic:_Send_to_ServiceBus')?['status']}"
                                                    }
                                                },
                                                "runAfter": {}
                                            },
                                            "PublishToTopic:NoFault:_Set_ErrorMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a message to ServiceBus"
                                                },
                                                "runAfter": {
                                                    "PublishToTopic:NoFault:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            },
                                            "PublishToTopic:NoFault:_Set_FaultMessage_variable": {
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('PublishToTopic:NoFault:_Create_Fault_Message')"
                                                },
                                                "runAfter": {
                                                    "PublishToTopic:NoFault:_Create_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "runAfter": {
                            "PublishToTopic:_Set_StatusCode_variable": [
                                "Succeeded"
                            ]
                        }
                    },
                    "PublishToTopic:_Send_to_ServiceBus": {
                        "type": "ServiceProvider",
                        "inputs": {
                            "parameters": {
                                "entityName": "@coalesce(variables('Configuration')?['topicPublisher']?['topicName'], '(topic name not set)')",
                                "message": {
                                    "contentData": "@variables('Envelope')",
                                    "contentType": "application/json",
                                    "sessionid": "@if(equals(coalesce(variables('Configuration')?['topicPublisher']?['useSessions'], false), true), coalesce(variables('Envelope')?['header']?['properties']?[variables('Configuration')?['topicPublisher']?['sessionPropertyName']], 'none'), 'none')",
                                    "UserProperties": "@variables('Envelope')?['header']?['routing']",
                                    "messageId": "@coalesce(variables('Envelope')?['header']?['properties']?['messageId'], guid())"
                                }
                            },
                            "serviceProviderConfiguration": {
                                "connectionName": "serviceBusPublish",
                                "operationId": "sendMessage",
                                "serviceProviderId": "/serviceProviders/serviceBus"
                            }
                        },
                        "runAfter": {}
                    },
                    "PublishToTopic:_Set_StatusCode_variable": {
                        "type": "SetVariable",
                        "inputs": {
                            "name": "StatusCode",
                            "value": "@if(equals(outputs('PublishToTopic:_Send_to_ServiceBus')?['statusCode'], 'OK'), 200, 500)"
                        },
                        "runAfter": {
                            "PublishToTopic:_Send_to_ServiceBus": [
                                "Succeeded",
                                "Failed",
                                "Skipped",
                                "TimedOut"
                            ]
                        }
                    }
                },
                "runAfter": {
                    "Step:_Check_TopicName": [
                        "Succeeded",
                        "Failed",
                        "Skipped",
                        "TimedOut"
                    ]
                }
            }
        },
        "triggers": {
            "manual": {
                "type": "Request",
                "kind": "Http",
                "inputs": {
                    "schema": {}
                },
                "correlation": {
                    "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                }
            }
        },
        "contentVersion": "1.0.0.0"
    },
    "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\workflow-designtime\host.json
{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": "[1.*, 2.0.0)"
  },
  "extensions": {
    "workflow": {
      "settings": {
        "Runtime.WorkflowOperationDiscoveryHostMode": "true"
      }
    }
  }
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\workflow-designtime\local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsSecretStorageType": "Files",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\xmlenvelopewrapper\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_ResponseMessage_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ResponseMessage",
              "type": "object",
              "value": null
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ResponseMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_BodyContent_variable": {
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "BodyContent",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_UpdatedBodyContent_variable": {
        "runAfter": {
          "Initialize_BodyContent_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "UpdatedBodyContent",
              "type": "string"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_WrapXmlEnvelope": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "or": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "WrapXmlEnvelope"
              ]
            },
            {
              "equals": [
                "@variables('Checkpoint')",
                "SkipXmlWrapping"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/xmlEnvelopeWrapper",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_UpdatedBodyContent_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Validate_Configuration": {
        "actions": {
          "ValidateConfiguration:_Have_Valid_Properties": {
            "actions": {
              "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "Checkpoint",
                  "value": "ValidateConfiguration"
                }
              }
            },
            "runAfter": {},
            "else": {
              "actions": {
                "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "ErrorMessage",
                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property envelopeSpecNames is not set in configuration"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "not": {
                    "equals": [
                      "@coalesce(variables('Configuration')?['xmlEnvelopeWrapper']?['envelopeSpecNames'], '')",
                      ""
                    ]
                  }
                }
              ]
            },
            "type": "If"
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_MessageType": {
        "actions": {
          "CheckMessageType:_Is_MessageType_blank": {
            "actions": {
              "CheckMessageType:Failure:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a btsMessageType property for this envelope."
                }
              }
            },
            "runAfter": {},
            "else": {
              "actions": {
                "CheckMessageType:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckMessageType"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@{coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '')}",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          }
        },
        "runAfter": {
          "Step:_Validate_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "ValidateConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContent": {
        "actions": {
          "CheckBodyContent:_Body_Content_is_missing": {
            "actions": {
              "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                }
              }
            },
            "runAfter": {
              "CheckBodyContent:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContent"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContent:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Check_MessageType": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckMessageType"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_BodyContent": {
        "actions": {
          "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/getbodycontent",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetBodyContent:_Check_Status_Code": {
            "runAfter": {
              "GetBodyContent:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetBodyContent:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetBodyContent:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetBodyContent"
                    }
                  },
                  "GetBodyContent:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                      }
                    },
                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetBodyContent:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                            "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                          }
                        }
                      },
                      "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                        }
                      },
                      "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetBodyContent:_Set_StatusCode_variable": {
            "runAfter": {
              "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_WrapXmlEnvelope": {
        "actions": {
          "WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('BodyContent')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimroutingmanager/wrapxmlenvelope/@{coalesce(variables('Configuration')?['xmlEnvelopeWrapper']?['envelopeSpecNames'], '')}",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/xml",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "WrapXmlEnvelope:_Check_Status_Code": {
            "runAfter": {
              "WrapXmlEnvelope:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "WrapXmlEnvelope:Success:_Set_UpdatedBodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "UpdatedBodyContent",
                      "value": "@body('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')"
                    }
                  },
                  "WrapXmlEnvelope:Success:_Create_new_Body_Part": {
                    "runAfter": {
                      "WrapXmlEnvelope:Success:_Set_UpdatedBodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": {
                      "$content": "@base64(variables('UpdatedBodyContent'))",
                      "$contentTransferEncoding": "base64",
                      "$contentType": "application/xml",
                      "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                      "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                    }
                  },
                  "WrapXmlEnvelope:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                    "runAfter": {
                      "WrapXmlEnvelope:Success:_Create_new_Body_Part": [
                        "Succeeded"
                      ]
                    },
                    "type": "Query",
                    "inputs": {
                      "from": "@variables('Envelope')?['body']",
                      "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                    }
                  },
                  "WrapXmlEnvelope:Success:_Add_new_Root_Body_Part_to_Envelope": {
                    "runAfter": {
                      "WrapXmlEnvelope:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('WrapXmlEnvelope:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('WrapXmlEnvelope:Success:_Create_new_Body_Part'))))"
                  },
                  "WrapXmlEnvelope:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "WrapXmlEnvelope:Success:_Update_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "WrapXmlEnvelope"
                    }
                  },
                  "WrapXmlEnvelope:Success:_Update_Envelope_variable": {
                    "runAfter": {
                      "WrapXmlEnvelope:Success:_Add_new_Root_Body_Part_to_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@outputs('WrapXmlEnvelope:Success:_Add_new_Root_Body_Part_to_Envelope')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "WrapXmlEnvelope:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "WrapXmlEnvelope:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "WrapXmlEnvelope:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessagingManager WrapXmlEnvelope operation"
                      }
                    },
                    "WrapXmlEnvelope:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "WrapXmlEnvelope:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['statusCode'], outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['body']?['statusCode'], actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['error']?['message'], outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['body']?['message'], actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['error']?['message'])}",
                            "faultReason": "@{actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['status']}"
                          }
                        }
                      },
                      "WrapXmlEnvelope:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "WrapXmlEnvelope:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessagingManager WrapXmlEnvelope operation"
                        }
                      },
                      "WrapXmlEnvelope:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "WrapXmlEnvelope:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('WrapXmlEnvelope:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "WrapXmlEnvelope:_Set_StatusCode_variable": {
            "runAfter": {
              "WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Get_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\xmlmessageprocessor\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_ResponseMessage_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ResponseMessage",
              "type": "object",
              "value": null
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ResponseMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_BodyContent_variable": {
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "BodyContent",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_MessageType_variable": {
        "runAfter": {
          "Initialize_BodyContent_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "MessageType",
              "type": "string"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Set_MessageType": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "SetMessageType"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/xmlMessageProcessor",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_MessageType_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContent": {
        "actions": {
          "CheckBodyContent:_Body_Content_is_missing": {
            "actions": {
              "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                }
              }
            },
            "runAfter": {
              "CheckBodyContent:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContent"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContent:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_BodyContent": {
        "actions": {
          "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/getbodycontent",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetBodyContent:_Check_Status_Code": {
            "runAfter": {
              "GetBodyContent:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetBodyContent:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetBodyContent:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetBodyContent"
                    }
                  },
                  "GetBodyContent:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                      }
                    },
                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetBodyContent:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                            "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                          }
                        }
                      },
                      "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                        }
                      },
                      "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetBodyContent:_Set_StatusCode_variable": {
            "runAfter": {
              "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Set_MessageType": {
        "actions": {
          "SetMessageType:_Set_MessageType_variable": {
            "runAfter": {},
            "type": "SetVariable",
            "inputs": {
              "name": "MessageType",
              "value": "@{coalesce(xpath(xml(variables('BodyContent')), 'namespace-uri(/*)'), '')}#@{coalesce(xpath(xml(variables('BodyContent')), 'local-name(/*)'), '')}"
            }
          },
          "SetMessageType:Failure:_Set_ErrorMessage_variable": {
            "runAfter": {
              "SetMessageType:_Set_MessageType_variable": [
                "Failed",
                "TimedOut",
                "Skipped"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "ErrorMessage",
              "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to get the MessageType: @{coalesce(outputs('SetMessageType:_Set_MessageType_variable')?['error']?['message'], actions('SetMessageType:_Set_MessageType_variable')?['error']?['message'], '(unknown error)')}"
            }
          },
          "SetMessageType:Success:_Update_Properties": {
            "runAfter": {
              "SetMessageType:_Set_MessageType_variable": [
                "Succeeded"
              ]
            },
            "type": "Compose",
            "inputs": "@setProperty(variables('Envelope'), 'header', setProperty(variables('Envelope')?['header'], 'properties', setProperty(variables('Envelope')?['header']?['properties'], 'btsMessageType', variables('MessageType'))))"
          },
          "SetMessageType:Success:_Update_Routing": {
            "runAfter": {
              "SetMessageType:Success:_Update_Properties": [
                "Succeeded"
              ]
            },
            "type": "Compose",
            "inputs": "@setProperty(outputs('SetMessageType:Success:_Update_Properties'), 'header', setProperty(outputs('SetMessageType:Success:_Update_Properties')?['header'], 'routing', setProperty(outputs('SetMessageType:Success:_Update_Properties')?['header']?['routing'], 'btsMessageType', variables('MessageType'))))"
          },
          "SetMessageType:Success:_Set_Envelope_variable": {
            "runAfter": {
              "SetMessageType:Success:_Update_Routing": [
                "Succeeded"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "Envelope",
              "value": "@outputs('SetMessageType:Success:_Update_Routing')"
            }
          },
          "SetMessageType:Success:_Set_Checkpoint_variable": {
            "runAfter": {
              "SetMessageType:Success:_Set_Envelope_variable": [
                "Succeeded"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "Checkpoint",
              "value": "SetMessageType"
            }
          }
        },
        "runAfter": {
          "Step:_Get_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\xmlmessagetranslator\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_ResponseMessage_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ResponseMessage",
              "type": "object",
              "value": null
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ResponseMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_BodyContent_variable": {
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "BodyContent",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_MessageType_variable": {
        "runAfter": {
          "Initialize_BodyContent_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "MessageType",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_MapName_variable": {
        "runAfter": {
          "Initialize_MessageType_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "MapName",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_TransformedContent_variable": {
        "runAfter": {
          "Initialize_MapName_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "TransformedContent",
              "type": "object"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Update_MessageType": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "or": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "SkipXmlTranslation"
              ]
            },
            {
              "equals": [
                "@variables('Checkpoint')",
                "UpdateMessageType"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/xmlMessageTranslator",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_TransformedContent_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_MapName": {
        "actions": {
          "GetMapName:_Filter_Maps_Array": {
            "inputs": {
              "from": "@coalesce(variables('Configuration')?['xmlMessageTranslator']?['maps'], array(''))",
              "where": "@equals(item()?['messageType'], coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '(undefined)'))"
            },
            "runAfter": {},
            "type": "Query"
          },
          "GetMapName:_Set_MapName_variable": {
            "inputs": {
              "name": "MapName",
              "value": "@if(equals(length(body('GetMapName:_Filter_Maps_Array')), 1), body('GetMapName:_Filter_Maps_Array')?[0]?['mapName'], '')"
            },
            "runAfter": {
              "GetMapName:_Filter_Maps_Array": [
                "Succeeded"
              ]
            },
            "type": "SetVariable"
          },
          "GetMapName:Success:_Set_Checkpoint_variable": {
            "runAfter": {
              "GetMapName:_Set_MapName_variable": [
                "Succeeded"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "Checkpoint",
              "value": "GetMapName"
            }
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_MapName": {
        "actions": {
          "CheckMapName:_Is_MapName_blank": {
            "actions": {
              "CheckMapName:MapNameBlank:_Allow_unrecognized_MessageType": {
                "actions": {
                  "CheckMapName:MapNameBlank:SkipXmlTranslation:_Set_Checkpoint_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "SkipXmlTranslation"
                    }
                  }
                },
                "runAfter": {},
                "else": {
                  "actions": {
                    "CheckMapName:Failure:_Set_ErrorMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a Map for the current MessageType for this envelope, and the allowUnrecognizedMessages config value is set to False. MessageType is: '@{coalesce(variables('Envelope')?['properties']?['btsMessageType'], '(undefined)')}'."
                      }
                    }
                  }
                },
                "expression": {
                  "and": [
                    {
                      "equals": [
                        "@coalesce(variables('Configuration')?['xmlMessageTranslator']?['allowUnrecognizedMessages'], true)",
                        true
                      ]
                    }
                  ]
                },
                "type": "If"
              }
            },
            "runAfter": {},
            "else": {
              "actions": {
                "CheckMapName:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "PerformXmlTranslation"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@{coalesce(variables('MapName'), '')}",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          }
        },
        "runAfter": {
          "Step:_Get_MapName": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetMapName"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContent": {
        "actions": {
          "CheckBodyContent:_Body_Content_is_missing": {
            "actions": {
              "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                }
              }
            },
            "runAfter": {
              "CheckBodyContent:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContent"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContent:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Check_MapName": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "PerformXmlTranslation"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_BodyContent": {
        "actions": {
          "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/getbodycontent",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetBodyContent:_Check_Status_Code": {
            "runAfter": {
              "GetBodyContent:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetBodyContent:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetBodyContent:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetBodyContent"
                    }
                  },
                  "GetBodyContent:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                      }
                    },
                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetBodyContent:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                            "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                          }
                        }
                      },
                      "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                        }
                      },
                      "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetBodyContent:_Set_StatusCode_variable": {
            "runAfter": {
              "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Transform_Xml": {
        "actions": {
          "TransformXml:Failure:_Set_StatusCode_variable": {
            "runAfter": {
              "TransformXml:_Transform_Xml": [
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": 500
            }
          },
          "TransformXml:Success:_Set_StatusCode_variable": {
            "runAfter": {
              "TransformXml:_Transform_Xml": [
                "Succeeded"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": 200
            }
          },
          "TransformXml:_Check_StatusCode": {
            "runAfter": {
              "TransformXml:Failure:_Set_StatusCode_variable": [
                "Succeeded",
                "Skipped"
              ],
              "TransformXml:Success:_Set_StatusCode_variable": [
                "Succeeded",
                "Skipped"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "TransformXml:Success:_Set_TransformedContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "TransformedContent",
                      "value": "@body('TransformXml:_Transform_Xml')"
                    }
                  },
                  "TransformXml:Success:_Add_new_Root_Body_Part_to_Envelope": {
                    "runAfter": {
                      "TransformXml:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('TransformXml:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('TransformXml:Success:_Create_new_Body_Part'))))"
                  },
                  "TransformXml:Success:_Create_new_Body_Part": {
                    "runAfter": {
                      "TransformXml:Success:_Set_TransformedContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "Compose",
                    "inputs": {
                      "$content": "@base64(variables('TransformedContent'))",
                      "$contentTransferEncoding": "base64",
                      "$contentType": "application/xml",
                      "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                      "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                    }
                  },
                  "TransformXml:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                    "runAfter": {
                      "TransformXml:Success:_Create_new_Body_Part": [
                        "Succeeded"
                      ]
                    },
                    "type": "Query",
                    "inputs": {
                      "from": "@variables('Envelope')?['body']",
                      "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                    }
                  },
                  "TransformXml:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "TransformXml:Success:_Update_Envelope_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "TransformXml"
                    }
                  },
                  "TransformXml:Success:_Update_Envelope_variable": {
                    "runAfter": {
                      "TransformXml:Success:_Add_new_Root_Body_Part_to_Envelope": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Envelope",
                      "value": "@outputs('TransformXml:Success:_Add_new_Root_Body_Part_to_Envelope')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "TransformXml:Failure:_Create_Fault_message": {
                  "runAfter": {},
                  "type": "Compose",
                  "inputs": {
                    "fault": {
                      "faultActor": "@concat(workflow()?['name'], '.', actions('TransformXml:_Transform_Xml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                      "faultCategory": "Error",
                      "faultCode": "@{coalesce(outputs('TransformXml:_Transform_Xml')?['statusCode'], outputs('TransformXml:_Transform_Xml')?['body']?['statusCode'], actions('TransformXml:_Transform_Xml')?['error']?['code'])}",
                      "faultMessage": "@{coalesce(outputs('TransformXml:_Transform_Xml')?['error']?['message'], outputs('TransformXml:_Transform_Xml')?['body']?['message'], actions('TransformXml:_Transform_Xml')?['error']?['message'])}",
                      "faultReason": "@{actions('TransformXml:_Transform_Xml')?['status']}"
                    }
                  }
                },
                "TransformXml:Failure:_Set_ErrorMessage_variable": {
                  "runAfter": {
                    "TransformXml:Failure:_Set_FaultMessage_variable": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "ErrorMessage",
                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to transform Xml"
                  }
                },
                "TransformXml:Failure:_Set_FaultMessage_variable": {
                  "runAfter": {
                    "TransformXml:Failure:_Create_Fault_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "FaultMessage",
                    "value": "@outputs('TransformXml:Failure:_Create_Fault_message')"
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "TransformXml:_Transform_Xml": {
            "runAfter": {},
            "type": "Xslt",
            "inputs": {
              "content": "@variables('BodyContent')",
              "map": {
                "name": "@{coalesce(variables('MapName'), '')}.xslt"
              },
              "xsltParameters": {
                "ApplyXsltOutputAttributes": true
              }
            }
          }
        },
        "runAfter": {
          "Step:_Get_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Update_MessageType": {
        "actions": {
          "UpdateMessageType:_Set_MessageType_variable": {
            "runAfter": {},
            "type": "SetVariable",
            "inputs": {
              "name": "MessageType",
              "value": "@{coalesce(xpath(xml(variables('TransformedContent')), 'namespace-uri(/*)'), '')}#@{coalesce(xpath(xml(variables('TransformedContent')), 'local-name(/*)'), '')}"
            }
          },
          "UpdateMessageType:Failure:_Set_ErrorMessage_variable": {
            "runAfter": {
              "UpdateMessageType:_Set_MessageType_variable": [
                "Failed",
                "TimedOut",
                "Skipped"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "ErrorMessage",
              "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to update the MessageType: @{coalesce(outputs('UpdateMessageType:_Set_MessageType_variable')?['error']?['message'], actions('UpdateMessageType:_Set_MessageType_variable')?['error']?['message'], '(unknown error)')}"
            }
          },
          "UpdateMessageType:Success:_Update_Properties": {
            "runAfter": {
              "UpdateMessageType:_Set_MessageType_variable": [
                "Succeeded"
              ]
            },
            "type": "Compose",
            "inputs": "@setProperty(variables('Envelope'), 'header', setProperty(variables('Envelope')?['header'], 'properties', setProperty(variables('Envelope')?['header']?['properties'], 'btsMessageType', variables('MessageType'))))"
          },
          "UpdateMessageType:Success:_Update_Routing": {
            "runAfter": {
              "UpdateMessageType:Success:_Update_Properties": [
                "Succeeded"
              ]
            },
            "type": "Compose",
            "inputs": "@setProperty(outputs('UpdateMessageType:Success:_Update_Properties'), 'header', setProperty(outputs('UpdateMessageType:Success:_Update_Properties')?['header'], 'routing', setProperty(outputs('UpdateMessageType:Success:_Update_Properties')?['header']?['routing'], 'btsMessageType', variables('MessageType'))))"
          },
          "UpdateMessageType:Success:_Set_Envelope_variable": {
            "runAfter": {
              "UpdateMessageType:Success:_Update_Routing": [
                "Succeeded"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "Envelope",
              "value": "@outputs('UpdateMessageType:Success:_Update_Routing')"
            }
          },
          "UpdateMessageType:Success:_Set_Checkpoint_variable": {
            "runAfter": {
              "UpdateMessageType:Success:_Set_Envelope_variable": [
                "Succeeded"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "Checkpoint",
              "value": "UpdateMessageType"
            }
          }
        },
        "runAfter": {
          "Step:_Transform_Xml": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "TransformXml"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplication.logic.workflows\xmlmessagevalidator\workflow.json
{
  "definition": {
    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
    "contentVersion": "1.0.0.0",
    "triggers": {
      "manual": {
        "correlation": {
          "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
        },
        "type": "Request",
        "kind": "Http",
        "inputs": {
          "schema": {}
        }
      }
    },
    "actions": {
      "Initialize_StatusCode_variable": {
        "runAfter": {},
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "StatusCode",
              "type": "integer",
              "value": 500
            }
          ]
        }
      },
      "Initialize_FaultMessage_variable": {
        "runAfter": {
          "Initialize_StatusCode_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "FaultMessage",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_ErrorMessage_variable": {
        "runAfter": {
          "Initialize_FaultMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ErrorMessage",
              "type": "string",
              "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) workflow"
            }
          ]
        }
      },
      "Initialize_ResponseMessage_variable": {
        "runAfter": {
          "Initialize_ErrorMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "ResponseMessage",
              "type": "object",
              "value": null
            }
          ]
        }
      },
      "Initialize_Checkpoint_variable": {
        "runAfter": {
          "Initialize_ResponseMessage_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Checkpoint",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_Envelope_variable": {
        "runAfter": {
          "Initialize_Checkpoint_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Envelope",
              "type": "object",
              "value": "@triggerBody()"
            }
          ]
        }
      },
      "Initialize_Configuration_variable": {
        "runAfter": {
          "Initialize_Envelope_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "Configuration",
              "type": "object"
            }
          ]
        }
      },
      "Initialize_BodyContent_variable": {
        "runAfter": {
          "Initialize_Configuration_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "BodyContent",
              "type": "string"
            }
          ]
        }
      },
      "Initialize_SchemaName_variable": {
        "runAfter": {
          "Initialize_BodyContent_variable": [
            "Succeeded"
          ]
        },
        "type": "InitializeVariable",
        "inputs": {
          "variables": [
            {
              "name": "SchemaName",
              "type": "string"
            }
          ]
        }
      },
      "MessageSender:_Were_we_Successful": {
        "actions": {
          "Routing:_Call_RoutingSlipRouter": {
            "runAfter": {},
            "type": "Workflow",
            "inputs": {
              "body": "@variables('Envelope')",
              "headers": {
                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json"
              },
              "host": {
                "workflow": {
                    "id": "routingsliprouter"
                }
              },
              "retryPolicy": {
                "type": "none"
              }
            }
          },
          "Routing:_Check_StatusCode": {
            "runAfter": {
              "Routing:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "Routing:Success:_Send_ACK-Content_response": {
                    "runAfter": {},
                    "type": "Response",
                    "kind": "Http",
                    "inputs": {
                      "body": "@body('Routing:_Call_RoutingSlipRouter')",
                      "headers": {
                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                        "Content-Type": "application/json"
                      },
                      "statusCode": 200
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "Routing:Error:_Build_NACK_message": {
                  "runAfter": {
                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Compose",
                  "inputs": {
                    "body": [
                      {
                        "$content": {
                          "code": "500",
                          "message": "@variables('ErrorMessage')",
                          "lastCheckpoint": "@variables('Checkpoint')",
                          "fault": "@variables('FaultMessage')"
                        },
                        "$contentType": "application/json",
                        "$part": 1,
                        "$partType": "http://schemas.microsoft.com/aim#nack"
                      }
                    ],
                    "header": {
                      "properties": {
                        "createDate": "@utcNow()",
                        "envelopeType": "nack",
                        "messageId": "@guid()",
                        "rootPart": 1,
                        "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                      },
                      "routing": {
                        "MessageType": "http://schemas.microsoft.com/aim#nack"
                      },
                      "routingSlip": {},
                      "state": {}
                    }
                  }
                },
                "Routing:Error:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "Routing:Error:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                      }
                    },
                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('Routing:_Call_RoutingSlipRouter')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "Routing:Error:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                            "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                          }
                        }
                      },
                      "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                        }
                      },
                      "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "Routing:Error:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                },
                "Routing:Error:_Send_NACK_response": {
                  "runAfter": {
                    "Routing:Error:_Build_NACK_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "Response",
                  "kind": "Http",
                  "inputs": {
                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                    "headers": {
                      "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                      "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                      "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                      "Content-Type": "application/json"
                    },
                    "statusCode": 200
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "Routing:_Set_StatusCode_variable": {
            "runAfter": {
              "Routing:_Call_RoutingSlipRouter": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Validate_Xml": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "else": {
          "actions": {
            "Failure:_Build_NACK_message": {
              "runAfter": {},
              "type": "Compose",
              "inputs": {
                "body": [
                  {
                    "$content": {
                      "code": "500",
                      "message": "@variables('ErrorMessage')",
                      "lastCheckpoint": "@variables('Checkpoint')",
                      "fault": "@variables('FaultMessage')"
                    },
                    "$contentType": "application/json",
                    "$part": 1,
                    "$partType": "http://schemas.microsoft.com/aim#nack"
                  }
                ],
                "header": {
                  "properties": {
                    "createDate": "@utcNow()",
                    "envelopeType": "nack",
                    "messageId": "@guid()",
                    "rootPart": 1,
                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                  },
                  "routing": {
                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                  },
                  "routingSlip": {},
                  "state": {}
                }
              }
            },
            "Failure:_Send_NACK_response": {
              "runAfter": {
                "Failure:_Build_NACK_message": [
                  "Succeeded"
                ]
              },
              "type": "Response",
              "kind": "Http",
              "inputs": {
                "body": "@outputs('Failure:_Build_NACK_message')",
                "headers": {
                  "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                  "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                  "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                  "Content-Type": "application/json"
                },
                "statusCode": 200
              }
            }
          }
        },
        "expression": {
          "or": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "ValidateXml"
              ]
            },
            {
              "equals": [
                "@variables('Checkpoint')",
                "SkipXmlValidation"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_Configuration": {
        "actions": {
          "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}/xmlMessageValidator",
              "queries": {
                "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetConfiguration:_Check_Status_Code": {
            "runAfter": {
              "GetConfiguration:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetConfiguration:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetConfiguration:Success:_Set_Configuration_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetConfiguration"
                    }
                  },
                  "GetConfiguration:Success:_Set_Configuration_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Configuration",
                      "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                      }
                    },
                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetConfiguration:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                            "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                          }
                        }
                      },
                      "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                        }
                      },
                      "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetConfiguration:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetConfiguration:_Set_StatusCode_variable": {
            "runAfter": {
              "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Initialize_SchemaName_variable": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                ""
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_MessageType": {
        "actions": {
          "CheckMessageType:_Is_MessageType_blank": {
            "actions": {
              "CheckMessageType:Failure:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a btsMessageType property for this envelope."
                }
              }
            },
            "runAfter": {},
            "else": {
              "actions": {
                "CheckMessageType:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckMessageType"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@{coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '')}",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          }
        },
        "runAfter": {
          "Step:_Get_Configuration": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetConfiguration"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_SchemaName": {
        "actions": {
          "GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "method": "GET",
              "uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/schemabymessagetype/@{encodeUriComponent(coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '(undefined)'))}",
              "queries": {
                "clearCache": "@{coalesce(variables('Configuration')?['xmlMessageValidator']?['clearCache'], 'false')}"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetSchemaName:_Check_Status_Code": {
            "runAfter": {
              "GetSchemaName:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetSchemaName:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetSchemaName:Success:_Set_SchemaName_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetSchemaName"
                    }
                  },
                  "GetSchemaName:Success:_Set_SchemaName_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "SchemaName",
                      "value": "@body('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['schemaName']"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetSchemaName:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetSchemaName:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetSchemaName:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetSchemaNameByMessageType operation"
                      }
                    },
                    "GetSchemaName:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetSchemaName:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['statusCode'], outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['body']?['statusCode'], actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['error']?['message'], outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['body']?['message'], actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['error']?['message'])}",
                            "faultReason": "@{actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['status']}"
                          }
                        }
                      },
                      "GetSchemaName:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetSchemaName:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetSchemaNameByMessageType operation"
                        }
                      },
                      "GetSchemaName:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetSchemaName:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetSchemaName:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetSchemaName:_Set_StatusCode_variable": {
            "runAfter": {
              "GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Check_MessageType": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckMessageType"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_SchemaName": {
        "actions": {
          "CheckSchemaName:_Is_SchemaName_blank": {
            "actions": {
              "CheckSchemaName:SchemaNameBlank:_Allow_unrecognized_MessageType": {
                "actions": {
                  "CheckMapName:MapNameBlank:SpipXmlValidation:_Set_Checkpoint_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "SkipXmlValidation"
                    }
                  }
                },
                "runAfter": {},
                "else": {
                  "actions": {
                    "CheckSchemaName:Failure:_Set_ErrorMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a Schema for the current MessageType for this envelope, and the allowUnrecognizedMessages config value is set to False. MessageType is: '@{coalesce(variables('Envelope')?['properties']?['btsMessageType'], '(undefined)')}'."
                      }
                    }
                  }
                },
                "expression": {
                  "and": [
                    {
                      "equals": [
                        "@coalesce(variables('Configuration')?['xmlMessageValidator']?['allowUnrecognizedMessages'], true)",
                        true
                      ]
                    }
                  ]
                },
                "type": "If"
              }
            },
            "runAfter": {},
            "else": {
              "actions": {
                "CheckSchemaName:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "PerformXmlValidation"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@{coalesce(variables('SchemaName'), '')}",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          }
        },
        "runAfter": {
          "Step:_Get_SchemaName": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetSchemaName"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Check_BodyContent": {
        "actions": {
          "CheckBodyContent:_Body_Content_is_missing": {
            "actions": {
              "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                "runAfter": {},
                "type": "SetVariable",
                "inputs": {
                  "name": "ErrorMessage",
                  "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                }
              }
            },
            "runAfter": {
              "CheckBodyContent:_Select_Root_Part": [
                "Succeeded"
              ]
            },
            "else": {
              "actions": {
                "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                  "runAfter": {},
                  "type": "SetVariable",
                  "inputs": {
                    "name": "Checkpoint",
                    "value": "CheckBodyContent"
                  }
                }
              }
            },
            "expression": {
              "and": [
                {
                  "equals": [
                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                    ""
                  ]
                }
              ]
            },
            "type": "If"
          },
          "CheckBodyContent:_Select_Root_Part": {
            "runAfter": {},
            "type": "Query",
            "inputs": {
              "from": "@variables('Envelope')?['body']",
              "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
            }
          }
        },
        "runAfter": {
          "Step:_Check_SchemaName": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "PerformXmlValidation"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Get_BodyContent": {
        "actions": {
          "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
            "runAfter": {},
            "type": "Http",
            "inputs": {
              "body": "@variables('Envelope')",
              "method": "POST",
              "uri": "@{appsetting('apimBaseUrl')}/aimmessagingmanager/getbodycontent",
              "queries": {
                "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
              },
              "retryPolicy": {
                "type": "none"
              },
              "headers": {
                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                "Content-Type": "application/json",
                "Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
              }
            }
          },
          "GetBodyContent:_Check_Status_Code": {
            "runAfter": {
              "GetBodyContent:_Set_StatusCode_variable": [
                "Succeeded"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "GetBodyContent:Success:_Set_Checkpoint_variable": {
                    "runAfter": {
                      "GetBodyContent:Success:_Set_BodyContent_variable": [
                        "Succeeded"
                      ]
                    },
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "GetBodyContent"
                    }
                  },
                  "GetBodyContent:Success:_Set_BodyContent_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "BodyContent",
                      "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                  "actions": {
                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                      "runAfter": {
                        "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                          "Succeeded"
                        ]
                      },
                      "type": "SetVariable",
                      "inputs": {
                        "name": "ErrorMessage",
                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                      }
                    },
                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                      "runAfter": {},
                      "type": "SetVariable",
                      "inputs": {
                        "name": "FaultMessage",
                        "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                      }
                    }
                  },
                  "runAfter": {},
                  "else": {
                    "actions": {
                      "GetBodyContent:NoFault:_Create_Fault_Message": {
                        "runAfter": {},
                        "type": "Compose",
                        "inputs": {
                          "fault": {
                            "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                            "faultCategory": "Error",
                            "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                            "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                            "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                          }
                        }
                      },
                      "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "ErrorMessage",
                          "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                        }
                      },
                      "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                        "runAfter": {
                          "GetBodyContent:NoFault:_Create_Fault_Message": [
                            "Succeeded"
                          ]
                        },
                        "type": "SetVariable",
                        "inputs": {
                          "name": "FaultMessage",
                          "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                        }
                      }
                    }
                  },
                  "expression": {
                    "and": [
                      {
                        "not": {
                          "equals": [
                            "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                            null
                          ]
                        }
                      }
                    ]
                  },
                  "type": "If"
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "GetBodyContent:_Set_StatusCode_variable": {
            "runAfter": {
              "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                "Succeeded",
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
            }
          }
        },
        "runAfter": {
          "Step:_Check_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "CheckBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      },
      "Step:_Validate_Xml": {
        "actions": {
          "ValidateXml:Failure:_Set_StatusCode_variable": {
            "runAfter": {
              "ValidateXml:_Validate_Xml": [
                "Failed",
                "Skipped",
                "TimedOut"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": 500
            }
          },
          "ValidateXml:Success:_Set_StatusCode_variable": {
            "runAfter": {
              "ValidateXml:_Validate_Xml": [
                "Succeeded"
              ]
            },
            "type": "SetVariable",
            "inputs": {
              "name": "StatusCode",
              "value": 200
            }
          },
          "ValidateXml:_Check_StatusCode": {
            "runAfter": {
              "ValidateXml:Failure:_Set_StatusCode_variable": [
                "Succeeded",
                "Skipped"
              ],
              "ValidateXml:Success:_Set_StatusCode_variable": [
                "Succeeded",
                "Skipped"
              ]
            },
            "cases": {
              "Success": {
                "case": 200,
                "actions": {
                  "ValidateXml:Success:_Set_Checkpoint_variable": {
                    "runAfter": {},
                    "type": "SetVariable",
                    "inputs": {
                      "name": "Checkpoint",
                      "value": "ValidateXml"
                    }
                  }
                }
              }
            },
            "default": {
              "actions": {
                "ValidateXml:Failure:_Create_Fault_message": {
                  "runAfter": {},
                  "type": "Compose",
                  "inputs": {
                    "fault": {
                      "faultActor": "@concat(workflow()?['name'], '.', actions('ValidateXml:_Validate_Xml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                      "faultCategory": "Error",
                      "faultCode": "@{coalesce(outputs('ValidateXml:_Validate_Xml')?['statusCode'], outputs('ValidateXml:_Validate_Xml')?['body']?['statusCode'], actions('ValidateXml:_Validate_Xml')?['error']?['code'])}",
                      "faultMessage": "@{coalesce(if(greater(length(outputs('ValidateXml:_Validate_Xml')?['errors']), 0), outputs('ValidateXml:_Validate_Xml')?['errors']?[0]?['message'], null), outputs('ValidateXml:_Validate_Xml')?['error']?['message'], outputs('ValidateXml:_Validate_Xml')?['body']?['message'], actions('ValidateXml:_Validate_Xml')?['error']?['message'])}",
                      "faultReason": "@{actions('ValidateXml:_Validate_Xml')?['status']}"
                    }
                  }
                },
                "ValidateXml:Failure:_Set_ErrorMessage_variable": {
                  "runAfter": {
                    "ValidateXml:Failure:_Set_FaultMessage_variable": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "ErrorMessage",
                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to validate XML"
                  }
                },
                "ValidateXml:Failure:_Set_FaultMessage_variable": {
                  "runAfter": {
                    "ValidateXml:Failure:_Create_Fault_message": [
                      "Succeeded"
                    ]
                  },
                  "type": "SetVariable",
                  "inputs": {
                    "name": "FaultMessage",
                    "value": "@outputs('ValidateXml:Failure:_Create_Fault_message')"
                  }
                }
              }
            },
            "expression": "@variables('StatusCode')",
            "type": "Switch"
          },
          "ValidateXml:_Validate_Xml": {
            "runAfter": {},
            "type": "XmlValidation",
            "inputs": {
              "content": "@variables('BodyContent')",
              "schema": {
                "name": "@{coalesce(variables('SchemaName'), '')}.xsd"
              }
            }
          }
        },
        "runAfter": {
          "Step:_Get_BodyContent": [
            "Succeeded",
            "Failed",
            "Skipped",
            "TimedOut"
          ]
        },
        "expression": {
          "and": [
            {
              "equals": [
                "@variables('Checkpoint')",
                "GetBodyContent"
              ]
            }
          ]
        },
        "type": "If"
      }
    }
  },
  "kind": "Stateful"
}
tools\templates\intermediaries\standard\systemapplicationservicebus.apicaccesspolicy.dev.parameters.json.liquid
 
tools\templates\intermediaries\standard\systemapplicationservicebus.apicaccesspolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\intermediaries\standard\systemapplicationservicebus.apicaccesspolicy.prod.parameters.json.liquid
 
tools\templates\intermediaries\standard\systemapplicationservicebus.apiconnection.dev.parameters.json.liquid
 
tools\templates\intermediaries\standard\systemapplicationservicebus.apiconnection.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "apiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Resource Name of the API Connection"
            }
        },
        "apiConnectionDisplayName": {
            "type": "string",
            "defaultValue": "[parameters('apiConnectionName')]",
            "metadata": {
                "description": "Display Name of the API Connection"
            }
        },
        "apiConnectionLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
			"metadata": {
                "description": "Location that we're deploying this resource to."
            }
        },
        "serviceBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that contains the Azure Service Bus resource."
            }
        },
        "serviceBusNamespaceName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ServiceBus Namespace this API Connection connects to."
            }
        },
        "serviceBusPolicyName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ServiceBus Policy this API Connection connects to."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Web/connections",
            "apiVersion": "2016-06-01",
            "name": "[parameters('apiConnectionName')]",
            "location": "[parameters('apiConnectionLocation')]",
			"kind": "V2",
            "tags": "[parameters('tags')]",
            "properties": {
                "api": {
                    "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('apiConnectionLocation'), '/managedApis/', 'servicebus')]"
                },
                "displayName": "[parameters('apiConnectionDisplayName')]",
                "parameterValues": {
                    "connectionString": "[listKeys(resourceId(parameters('serviceBusResourceGroupName'), 'Microsoft.ServiceBus/namespaces/AuthorizationRules', parameters('serviceBusNamespaceName'), parameters('serviceBusPolicyName')), '2017-04-01').primaryConnectionString]"
                }
            }
        }
    ],
    "outputs": {}
}
tools\templates\intermediaries\standard\systemapplicationservicebus.apiconnection.prod.parameters.json.liquid
 
tools\templates\intermediaries\standard\TearDown-80-SystemApplicationServiceBus-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\standard\TearDown-90-SystemApplication-LogicApp.ps1.liquid
 
tools\templates\intermediaries\topicpublisher\Deploy-90-TopicPublisher-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\topicpublisher\Deploy-95-TopicPublisher-LogicApp.ps1.liquid
 
tools\templates\intermediaries\topicpublisher\New-TopicPublisher-ApiConnection.ps1
<#
.SYNOPSIS
Creates an API connection resource for the topic publisher.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-TopicPublisher-ApiConnection.ps1 -resourceGroupName "sb-aimmsgbox-dev-uksouth-xxxxx" -templateFile ".\topicpublisher.apiconnection.json" -templateParameterFile ".\topicpublisher.apiconnection.dev.parameters.json" -deploymentName "topicpublisher.apiconnection.xxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying the topic publisher api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\intermediaries\topicpublisher\New-TopicPublisher-LogicApp.ps1
<#
.SYNOPSIS
Creates a topic publisher Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-TopicPublisher-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\topicpublisher.logicapp.json" -templateParameterFile ".\topicpublisher.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "topicpublisher.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the topic publisher Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\topicpublisher\Remove-TopicPublisher-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the api connection for the topic publisher.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-TopicPublisher.ApiConnection.ps1 -resourceGroupName "sb-aimmsgbox-dev-uksouth-xxxxx" -resourceName "Aim-TopicPublisher-Channel"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the topic publisher api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the topic publisher api connection resource: $resourceName"
}
else {
    Write-Host "The topic publisher api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\topicpublisher\Remove-TopicPublisher-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-TopicPublisher-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimtopicpublisher-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\topicpublisher\TearDown-90-TopicPublisher-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\topicpublisher\TearDown-95-TopicPublisher-LogicApp.ps1.liquid
 
tools\templates\intermediaries\topicpublisher\topicpublisher.apiconnection.dev.parameters.json.liquid
 
tools\templates\intermediaries\topicpublisher\topicpublisher.apiconnection.json.liquid
 
tools\templates\intermediaries\topicpublisher\topicpublisher.apiconnection.prod.parameters.json.liquid
 
tools\templates\intermediaries\topicpublisher\topicpublisher.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\topicpublisher\topicpublisher.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "serviceBusTopicPublishApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus Topic Publish operations."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "topicPublisher",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. topicPublisher."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "serviceBusTopicPublishApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicPublishApiConnectionName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. topicPublisher."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Publish_To_Topic": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "PublishToTopic"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_TopicId": {
                            "actions": {
                                "CheckTopicId:_TopicId_is_blank": {
                                    "actions": {
                                        "CheckTopicId:Failure:_Set_ErrorMessage": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No TopicId is set in the configuration entry for this step"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "CheckTopicId:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckTopicId"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['topicName'], '')}",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Publish_To_Topic": {
                            "actions": {
                                "PublishToTopic:_Check_Status_Code": {
                                    "runAfter": {
                                        "PublishToTopic:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "PublishToTopic:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "PublishToTopic"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "PublishToTopic:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "PublishToTopic:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "PublishToTopic:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a message to ServiceBus"
                                                        }
                                                    },
                                                    "PublishToTopic:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('PublishToTopic:_Send_to_ServiceBus')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "PublishToTopic:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('PublishToTopic:_Send_to_ServiceBus')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('PublishToTopic:_Send_to_ServiceBus')?['statusCode'], outputs('PublishToTopic:_Send_to_ServiceBus')?['body']?['statusCode'], actions('PublishToTopic:_Send_to_ServiceBus')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('PublishToTopic:_Send_to_ServiceBus')?['error']?['message'], outputs('PublishToTopic:_Send_to_ServiceBus')?['body']?['message'], actions('PublishToTopic:_Send_to_ServiceBus')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('PublishToTopic:_Send_to_ServiceBus')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "PublishToTopic:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "PublishToTopic:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to publish a message to ServiceBus"
                                                            }
                                                        },
                                                        "PublishToTopic:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "PublishToTopic:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('PublishToTopic:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('PublishToTopic:_Send_to_ServiceBus')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "PublishToTopic:_Send_to_ServiceBus": {
                                    "runAfter": {},
                                    "type": "ApiConnection",
                                    "inputs": {
                                        "body": {
                                            "ContentData": "@{base64(variables('Envelope'))}",
                                            "ContentType": "application/json",
                                            "MessageId": "@coalesce(variables('Envelope')?['header']?['properties']?['messageId'], guid())",
                                            "Properties": "@variables('Envelope')?['header']?['routing']",
                                            "SessionId": "@if(equals(coalesce(variables('Configuration')?[parameters('scenarioStep')]?['useSessions'], false), true), coalesce(variables('Envelope')?['header']?['properties']?[variables('Configuration')?[parameters('scenarioStep')]?['sessionPropertyName']], 'none'), 'none')"
                                        },
                                        "host": {
                                            "connection": {
                                                "name": "@parameters('$connections')['servicebuspublish']['connectionId']"
                                            }
                                        },
                                        "method": "post",
                                        "path": "/@{encodeURIComponent(coalesce(variables('Configuration')?[parameters('scenarioStep')]?['topicName'], '(topic name not set)'))}/messages",
                                        "queries": {
                                            "systemProperties": "None"
                                        }
                                    }
                                },
                                "PublishToTopic:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "PublishToTopic:_Send_to_ServiceBus": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('PublishToTopic:_Send_to_ServiceBus')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_TopicId": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckTopicId"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "servicebuspublish": {
                                "connectionId": "[variables('serviceBusTopicPublishApiConnectionResourceId')]",
                                "connectionName": "[parameters('serviceBusTopicPublishApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
                            }
                        }
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\topicpublisher\topicpublisher.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\topicsubscriber\Deploy-100-TopicSubscriber-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\topicsubscriber\Deploy-105-TopicSubscriber-LogicApp.ps1.liquid
 
tools\templates\intermediaries\topicsubscriber\Deploy-110-TopicSubscriber-ApiConnPolicy.ps1.liquid
 
tools\templates\intermediaries\topicsubscriber\New-TopicSubscriber-ApiConnection.ps1
<#
.SYNOPSIS
Creates a topic subscriber connection for an application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-TopicSubscriber-ApiConnection.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -templateFile "$PSScriptRoot\topicsubscriber.apiconnection.json" -templateParameterFile "$PSScriptRoot\topicsubscriber.apiconnection.dev.parameters.json" -deploymentName "topicsubscriber.apic.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a topic subscriber api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\intermediaries\topicsubscriber\New-TopicSubscriber-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates a topic subscriber api connection access policy.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-TopicSubscriber-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\topicsubscriber.apiconnpolicy.json" -templateParameterFile ".\topicsubscriber.apiconnpolicy.dev.parameters.json" -deploymentName "topicsubscriber.apicaccesspolicy.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\intermediaries\topicsubscriber\New-TopicSubscriber-LogicApp.ps1
<#
.SYNOPSIS
Creates a topic subscriber Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-TopicSubscriber-LogicApp.ps1 -resourceGroupName "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -templateFile "$PSScriptRoot\topicsubscriber.logicapp.json" -templateParameterFile "$PSScriptRoot\topicsubscriber.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "topicsubscriber.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the topic subscriber Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\topicsubscriber\Remove-TopicSubscriber-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the topic subscriber api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-TopicSubscriber-ApiConnection.ps1 -resourceGroup "rg-aimapp-aim-ftppassthru-dev-uksouth-xxxxx" -resourceName "topicsubscriberconnector-aim-ftppassthru-sendport-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the topic subscriber api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the topic subscriber api connection resource: $resourceName"
}
else {
    Write-Host "The topic subscriber api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\topicsubscriber\Remove-TopicSubscriber-LogicApp.ps1
<#
.SYNOPSIS
Tears down the topic subscriber Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-TopicSubscriber-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-aimtopicpublisher-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\topicsubscriber\TearDown-100-TopicSubscriber-ApiConnection.ps1.liquid
 
tools\templates\intermediaries\topicsubscriber\TearDown-105-TopicSubscriber-LogicApp.ps1.liquid
 
tools\templates\intermediaries\topicsubscriber\topicsubscriber.apiconnection.dev.parameters.json.liquid
 
tools\templates\intermediaries\topicsubscriber\topicsubscriber.apiconnection.json.liquid
 
tools\templates\intermediaries\topicsubscriber\topicsubscriber.apiconnection.prod.parameters.json.liquid
 
tools\templates\intermediaries\topicsubscriber\topicsubscriber.apiconnpolicy.dev.parameters.json.liquid
 
tools\templates\intermediaries\topicsubscriber\topicsubscriber.apiconnpolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\intermediaries\topicsubscriber\topicsubscriber.apiconnpolicy.prod.parameters.json.liquid
 
tools\templates\intermediaries\topicsubscriber\topicsubscriber.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\topicsubscriber\topicsubscriber.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "systemApplicationResourceGroupName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ResourceGroup that SystemApplication artifacts are deployed to (e.g. ServiceBus or MessageConstructor LogicApp)."
            }
        },
        "messageSuspendProcessorLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to handle suspending of messages."
            }
        },
        "suspendQueueTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic that suspended messages are sent to."
            }
        },
        "serviceBusTopicSubscribeApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for ServiceBus Topic Subscribe operations."
            }
        },
        "serviceBusTopicName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic used to subscribe to messages."
            }
        },
        "serviceBusTopicSubscriptionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the ServiceBus Topic Subscription used to subscribe to messages."
            }
        },
        "serviceBusRecurrenceFrequency": {
            "type": "string",
            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
            "metadata": {
                "description": "The frequency with which to check for new messages on the ServiceBus Topic Subscription."
            }
        },
        "serviceBusRecurrenceInterval": {
            "type": "int",
            "metadata": {
                "description": "The interval with which to check for new messages on the ServiceBus Topic Subscription."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenario": {
            "type": "string",
            "metadata": {
                "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
            }
        },
        "scenarioStep": {
            "defaultValue": "messageSubscriber",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. messageSubscriber."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "messageSuspendProcessorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageSuspendProcessorLogicAppName'))]",
        "serviceBusTopicSubscribeApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicSubscribeApiConnectionName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "serviceBusTopicName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic used to subscribe to messages."
                        },
                        "serviceBusTopicSubscriptionName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic Subscription used to subscribe to messages."
                        },
                        "serviceBusRecurrenceFrequency": {
                            "type": "string",
                            "allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
                            "description": "The frequency with which to check for new messages on the ServiceBus Topic Subscription."
                        },
                        "serviceBusRecurrenceInterval": {
                            "type": "int",
                            "description": "The interval with which to check for new messages on the ServiceBus Topic Subscription."
                        },
                        "scenario": {
                            "type": "String",
                            "description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
                        },
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. template."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        },
                        "clearCache": {
                            "defaultValue": true,
                            "type": "Bool",
                            "description": "Indicates if we should clear APIM cache before retrieved config items e.g. configurationEntries or routingSlips."
                        },
                        "suspendQueueTopicName": {
                            "type": "String",
                            "description": "Name of the ServiceBus Topic that suspended messages are sent to."
                        }
                    },
                    "triggers": {
                        "When_a_message_is_received_in_a_topic_subscription_(peek-lock)": {
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                                    }
                                },
                                "method": "get",
                                "path": "/@{encodeURIComponent(parameters('serviceBusTopicName'))}/subscriptions/@{encodeURIComponent(parameters('serviceBusTopicSubscriptionName'))}/messages/head/peek",
                                "queries": {
                                    "sessionId": "None",
                                    "subscriptionType": "Main"
                                }
                            },
                            "recurrence": {
                                "frequency": "@{parameters('serviceBusRecurrenceFrequency')}",
                                "interval": "@parameters('serviceBusRecurrenceInterval')"
                            },
                            "type": "ApiConnection"
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_NewEnvelope_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "NewEnvelope",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_NewEnvelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('NewEnvelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                            "Aim-Tracking-Id": "@{variables('Envelope')?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Do_we_have_an_ACK": {
                                                    "actions": {
                                                        "Routing:Success:_Complete_the_message": {
                                                            "inputs": {
                                                                "host": {
                                                                    "connection": {
                                                                        "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                                                                    }
                                                                },
                                                                "method": "delete",
                                                                "path": "/@{encodeURIComponent(parameters('serviceBusTopicName'))}/subscriptions/@{encodeURIComponent(parameters('serviceBusTopicSubscriptionName'))}/messages/complete",
                                                                "queries": {
                                                                    "lockToken": "@triggerBody()?['LockToken']",
                                                                    "subscriptionType": "Main"
                                                                }
                                                            },
                                                            "runAfter": {},
                                                            "type": "ApiConnection"
                                                        }
                                                    },
                                                    "expression": {
                                                        "and": [
                                                            {
                                                                "equals": [
                                                                    "@{body('Routing:_Call_RoutingSlipRouter')?['header']?['properties']?['envelopeType']}",
                                                                    "ack"
                                                                ]
                                                            }
                                                        ]
                                                    },
                                                    "runAfter": {},
                                                    "else": {
                                                        "actions": {
                                                            "Routing:Failure:_Set_ErrorMessage_variable": {
                                                                "runAfter": {},
                                                                "type": "SetVariable",
                                                                "inputs": {
                                                                    "name": "ErrorMessage",
                                                                    "value": "An NACK was returned by RoutingSlipRouter in @{workflow()?['name']} (@{workflow()?['run']?['name']})"
                                                                }
                                                            },
                                                            "Routing:Failure:_Suspend_Messages": {
                                                                "runAfter": {
                                                                    "Routing:Failure:_Set_ErrorMessage_variable": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "Workflow",
                                                                "inputs": {
                                                                    "body": {
                                                                        "nackMessage": "@body('Routing:_Call_RoutingSlipRouter')",
                                                                        "originalMessage": "@variables('Envelope')",
                                                                        "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                                        "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                                        "scenario": "@{parameters('scenario')}"
                                                                    },
                                                                    "headers": {
                                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                                                    },
                                                                    "host": {
                                                                        "triggerName": "manual",
                                                                        "workflow": {
                                                                            "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                                        }
                                                                    }
                                                                }
                                                            },
                                                            "Routing:Failure:_Dead-letter_the_message": {
                                                                "inputs": {
                                                                    "host": {
                                                                        "connection": {
                                                                            "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                                                                        }
                                                                    },
                                                                    "method": "post",
                                                                    "path": "/@{encodeURIComponent(parameters('serviceBusTopicName'))}/subscriptions/@{encodeURIComponent(parameters('serviceBusTopicSubscriptionName'))}/messages/deadletter",
                                                                    "queries": {
                                                                        "deadLetterErrorDescription": "@string(body('Routing:_Call_RoutingSlipRouter'))",
                                                                        "deadLetterReason": "@variables('ErrorMessage')",
                                                                        "lockToken": "@triggerBody()?['LockToken']"
                                                                    }
                                                                },
                                                                "runAfter": {
                                                                    "Routing:Failure:_Suspend_Messages": [
                                                                        "Succeeded"
                                                                    ]
                                                                },
                                                                "type": "ApiConnection"
                                                            }
                                                        }
                                                    },
                                                    "type": "If"
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@variables('Envelope')?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Suspend_Messages": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Workflow",
                                                "inputs": {
                                                    "body": {
                                                        "nackMessage": "@outputs('Routing:Error:_Build_NACK_message')",
                                                        "originalMessage": "@variables('Envelope')",
                                                        "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                        "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                        "scenario": "@{parameters('scenario')}"
                                                    },
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                                    },
                                                    "host": {
                                                        "triggerName": "manual",
                                                        "workflow": {
                                                            "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                        }
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Dead-letter_the_message": {
                                                "inputs": {
                                                    "host": {
                                                        "connection": {
                                                            "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                                                        }
                                                    },
                                                    "method": "post",
                                                    "path": "/@{encodeURIComponent(parameters('serviceBusTopicName'))}/subscriptions/@{encodeURIComponent(parameters('serviceBusTopicSubscriptionName'))}/messages/deadletter",
                                                    "queries": {
                                                        "deadLetterErrorDescription": "@outputs('Routing:Error:_Build_NACK_message')",
                                                        "deadLetterReason": "@variables('ErrorMessage')",
                                                        "lockToken": "@triggerBody()?['LockToken']"
                                                    }
                                                },
                                                "runAfter": {
                                                    "Routing:Error:_Suspend_Messages": [
                                                        "Succeeded",
                                                        "Failed",
                                                        "TimedOut"
                                                    ]
                                                },
                                                "type": "ApiConnection"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Merge_Properties": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Suspend_Messages": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Workflow",
                                        "inputs": {
                                            "body": {
                                                "nackMessage": "@outputs('Failure:_Build_NACK_message')",
                                                "originalMessage": "@variables('Envelope')",
                                                "suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
                                                "failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
                                                "scenario": "@{parameters('scenario')}"
                                            },
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                            },
                                            "host": {
                                                "triggerName": "manual",
                                                "workflow": {
                                                    "id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
                                                }
                                            }
                                        }
                                    },
                                    "Failure:_Dead-letter_the_message": {
                                        "inputs": {
                                            "host": {
                                                "connection": {
                                                    "name": "@parameters('$connections')['servicebussubscribe']['connectionId']"
                                                }
                                            },
                                            "method": "post",
                                            "path": "/@{encodeURIComponent(parameters('serviceBusTopicName'))}/subscriptions/@{encodeURIComponent(parameters('serviceBusTopicSubscriptionName'))}/messages/deadletter",
                                            "queries": {
                                                "deadLetterErrorDescription": "@outputs('Failure:_Build_NACK_message')",
                                                "deadLetterReason": "@variables('ErrorMessage')",
                                                "lockToken": "@triggerBody()?['LockToken']",
                                                "sessionId": "@triggerBody()?['SessionId']"
                                            }
                                        },
                                        "runAfter": {
                                            "Failure:_Suspend_Messages": [
                                                "Succeeded",
                                                "Failed",
                                                "TimedOut"
                                            ]
                                        },
                                        "type": "ApiConnection"
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "MergeProperties"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Envelope": {
                            "cases": {
                                "Json": {
                                    "actions": {
                                        "GetEnvelope:Json:_Set_Envelope_variable": {
                                            "inputs": {
                                                "name": "Envelope",
                                                "value": "@if(equals(triggerBody()?['ContentTransferEncoding'], 'Base64'), json(decodeBase64(triggerBody()?['ContentData'])), triggerBody()?['ContentData'])"
                                            },
                                            "runAfter": {},
                                            "type": "SetVariable"
                                        },
                                        "GetEnvelope:Json:_Set_Checkpoint_variable": {
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "GetEnvelope"
                                            },
                                            "runAfter": {
                                                "GetEnvelope:Json:_Set_Envelope_variable": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "type": "SetVariable"
                                        }
                                    },
                                    "case": "json"
                                },
                                "Xml": {
                                    "actions": {
                                        "GetEnvelope:Xml:_Build_Content_Message": {
                                            "inputs": {
                                                "$content": "@triggerBody()?['ContentData']",
                                                "$contentTransferEncoding": "@triggerBody()?['ContentTransferEncoding']",
                                                "$contentType": "@triggerBody()?['ContentType']"
                                            },
                                            "runAfter": {},
                                            "type": "Compose"
                                        },
                                        "GetEnvelope:Xml:_Set_Envelope_variable": {
                                            "inputs": {
                                                "name": "Envelope",
                                                "value": "@outputs('GetEnvelope:Xml:_Build_Content_Message')"
                                            },
                                            "runAfter": {
                                                "GetEnvelope:Xml:_Build_Content_Message": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "type": "SetVariable"
                                        },
                                        "GetEnvelope:Xml:_Set_Checkpoint_variable": {
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "GetEnvelope"
                                            },
                                            "runAfter": {
                                                "GetEnvelope:Xml:_Set_Envelope_variable": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "type": "SetVariable"
                                        }
                                    },
                                    "case": "xml"
                                }
                            },
                            "default": {
                                "actions": {
                                    "GetInboundMessage:Unsupported:_Set_ErrorMessage_variable": {
                                        "inputs": {
                                            "name": "ErrorMessage",
                                            "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp: the subscribed ServiceBus message has an unsupported ContentType value of @{coalesce(triggerBody()?['ContentType'], '(none)')}."
                                        },
                                        "runAfter": {},
                                        "type": "SetVariable"
                                    }
                                }
                            },
                            "expression": "@if(greaterOrEquals(indexOf(triggerBody()?['ContentType'], '/'), 0), split(triggerBody()?['ContentType'], '/')?[1], triggerBody()?['ContentType'])",
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "type": "Switch"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(parameters('scenario'))}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@parameters('clearCache')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Envelope": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetEnvelope"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Build_New_Envelope": {
                            "actions": {
                                "BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "headers": {
                                            "Content-Transfer-Encoding": "none",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {
                                                "envelopeType": "@{encodeURIComponent('document')}",
                                                "scenario": "@{encodeURIComponent(parameters('scenario'))}"
                                            },
                                            "template": "/aimmessagingmanager/buildenvelope/{envelopeType}/{scenario}"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "BuildNewEnvelope:_Check_Status_Code": {
                                    "runAfter": {
                                        "BuildNewEnvelope:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "BuildNewEnvelope:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "BuildNewEnvelope:Success:_Set_NewEnvelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "BuildNewEnvelope"
                                                    }
                                                },
                                                "BuildNewEnvelope:Success:_Set_NewEnvelope_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "NewEnvelope",
                                                        "value": "@body('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "BuildNewEnvelope:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "BuildNewEnvelope:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "BuildNewEnvelope:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager BuildNewEnvelope operation"
                                                        }
                                                    },
                                                    "BuildNewEnvelope:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "BuildNewEnvelope:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['statusCode'], outputs('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['body']?['statusCode'], actions('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['error']?['message'], outputs('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['body']?['message'], actions('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "BuildNewEnvelope:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "BuildNewEnvelope:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager BuildNewEnvelope operation"
                                                            }
                                                        },
                                                        "BuildNewEnvelope:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "BuildNewEnvelope:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('BuildNewEnvelope:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@outputs('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['body']?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "BuildNewEnvelope:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('BuildNewEnvelope:_Call_APIM_MessagingManager.BuildNewEnvelope')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Merge_Properties": {
                            "actions": {
                                "MergeProperties:_Exception_Scope": {
                                    "actions": {
                                        "MergeProperties:_Merge_RoutingSlip": {
                                            "runAfter": {},
                                            "type": "Compose",
                                            "inputs": "@setProperty(variables('Envelope'), 'header', setProperty(variables('Envelope')?['header'], 'routingSlip', variables('NewEnvelope')?['header']?['routingSlip']))"
                                        },
                                        "MergeProperties:_Update_Scenario": {
                                            "runAfter": {
                                                "MergeProperties:_Merge_RoutingSlip": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "type": "Compose",
                                            "inputs": "@setProperty(outputs('MergeProperties:_Merge_RoutingSlip'), 'header', setProperty(outputs('MergeProperties:_Merge_RoutingSlip')?['header'], 'properties', setProperty(outputs('MergeProperties:_Merge_RoutingSlip')?['header']?['properties'], 'scenario', parameters('scenario'))))"
                                        },
                                        "MergeProperties:Success_Set_NewEnvelope_variable": {
                                            "runAfter": {
                                                "MergeProperties:_Update_Scenario": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "NewEnvelope",
                                                "value": "@outputs('MergeProperties:_Update_Scenario')"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "type": "Scope"
                                },
                                "MergeProperties:Failure:_Get_Failed_Items": {
                                    "runAfter": {
                                        "MergeProperties:_Exception_Scope": [
                                            "Failed",
                                            "TimedOut",
                                            "Skipped"
                                        ]
                                    },
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@result('MergeProperties:_Exception_Scope')",
                                        "where": "@or(equals(item()['status'], 'Failed'), equals(item()['status'], 'TimedOut'), equals(item()['status'], 'Skipped'))"
                                    }
                                },
                                "MergeProperties:Failure:_Set_ErrorMessage_variable": {
                                    "runAfter": {
                                        "MergeProperties:Failure:_Get_Failed_Items": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "ErrorMessage",
                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) in an ExceptionScope. Error: Action: @{body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['name']}, StatusCode: @{body('MergeProperties:Failure:_Get_Failed_Items')?[0]?.outputs?['statusCode']}, Message: @{coalesce(body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['error']?['message'], body('MergeProperties:Failure:_Get_Failed_Items')?[0]?.outputs?['body']?['message'])}"
                                    }
                                },
                                "MergeProperties:Failure:_Create_Fault_Message": {
                                    "runAfter": {
                                        "MergeProperties:Failure:_Set_ErrorMessage_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "Compose",
                                    "inputs": {
                                        "fault": {
                                            "faultActor": "@concat(workflow()?['name'], '.', body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['name'], ' (', workflow()?['run']?['name'], ')')",
                                            "faultCategory": "Error",
                                            "faultCode": "@{coalesce(body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['outputs']?['statusCode'], body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['outputs']?['body']?['statusCode'], body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['error']?['code'])}",
                                            "faultMessage": "@{coalesce(body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['outputs']?['error']?['message'], body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['outputs']?['body']?['message'], body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['error']?['message'])}",
                                            "faultReason": "@{body('MergeProperties:Failure:_Get_Failed_Items')?[0]?['status']}"
                                        }
                                    }
                                },
                                "MergeProperties:Failure:_Set_FaultMessage_variable": {
                                    "runAfter": {
                                        "MergeProperties:Failure:_Create_Fault_Message": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "FaultMessage",
                                        "value": "@outputs('MergeProperties:Failure:_Create_Fault_Message')"
                                    }
                                },
                                "MergeProperties:Success:_Set_Checkpoint_variable": {
                                    "runAfter": {
                                        "MergeProperties:_Exception_Scope": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "MergeProperties"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Build_New_Envelope": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "BuildNewEnvelope"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "servicebussubscribe": {
                                "connectionId": "[variables('serviceBusTopicSubscribeApiConnectionResourceId')]",
                                "connectionName": "[parameters('serviceBusTopicSubscribeApiConnectionName')]",
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
                            }
                        }
                    },
                    "serviceBusTopicName": {
                        "value": "[parameters('serviceBusTopicName')]"
                    },
                    "serviceBusTopicSubscriptionName": {
                        "value": "[parameters('serviceBusTopicSubscriptionName')]"
                    },
                    "serviceBusRecurrenceFrequency": {
                        "value": "[parameters('serviceBusRecurrenceFrequency')]"
                    },
                    "serviceBusRecurrenceInterval": {
                        "value": "[parameters('serviceBusRecurrenceInterval')]"
                    },
                    "scenario": {
                        "value": "[parameters('scenario')]"
                    },
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    },
                    "suspendQueueTopicName": {
                        "value": "[parameters('suspendQueueTopicName')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\topicsubscriber\topicsubscriber.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\xmlenvelopewrapper\Deploy-85-XmlEnvelopeWrapper-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlenvelopewrapper\New-XmlEnvelopeWrapper-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-XmlEnvelopeWrapper-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\xmlenvelopewrapper.logicapp.json" -templateParameterFile ".\xmlenvelopewrapper.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "xmlenvelopewrapper.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the xml message processor Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\xmlenvelopewrapper\Remove-XmlEnvelopeWrapper-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-XmlEnvelopeWrapper-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-xmlenvelopewrapper-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\xmlenvelopewrapper\TearDown-85-XmlEnvelopeWrapper-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlenvelopewrapper\xmlenvelopewrapper.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\xmlenvelopewrapper\xmlenvelopewrapper.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "xmlMessageProcessor",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageProcessor."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageProcessor."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_UpdatedBodyContent_variable": {
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "UpdatedBodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_WrapXmlEnvelope": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "WrapXmlEnvelope"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SkipXmlWrapping"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_UpdatedBodyContent_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Configuration": {
                            "actions": {
                                "ValidateConfiguration:_Have_Valid_Properties": {
                                    "actions": {
                                        "ValidateConfiguration:Success:_Set_Checkpoint_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "ValidateConfiguration"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property envelopeSpecNames is not set in configuration"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "not": {
                                                    "equals": [
                                                        "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['envelopeSpecNames'], '')",
                                                        ""
                                                    ]
                                                }
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_MessageType": {
                            "actions": {
                                "CheckMessageType:_Is_MessageType_blank": {
                                    "actions": {
                                        "CheckMessageType:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a btsMessageType property for this envelope."
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "CheckMessageType:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckMessageType"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@{coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '')}",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_MessageType": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckMessageType"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_WrapXmlEnvelope": {
                            "actions": {
                                "WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('BodyContent')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/xml"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {
                                                "envelopeSpecNames": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['envelopeSpecNames'], '')}"
                                            },
                                            "template": "/aimroutingmanager/wrapxmlenvelope/{envelopeSpecNames}"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "WrapXmlEnvelope:_Check_Status_Code": {
                                    "runAfter": {
                                        "WrapXmlEnvelope:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "WrapXmlEnvelope:Success:_Set_UpdatedBodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "UpdatedBodyContent",
                                                        "value": "@body('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')"
                                                    }
                                                },
                                                "WrapXmlEnvelope:Success:_Create_new_Body_Part": {
                                                    "runAfter": {
                                                        "WrapXmlEnvelope:Success:_Set_UpdatedBodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "$content": "@base64(variables('UpdatedBodyContent'))",
                                                        "$contentTransferEncoding": "base64",
                                                        "$contentType": "application/xml",
                                                        "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                                                        "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                                                    }
                                                },
                                                "WrapXmlEnvelope:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                                                    "runAfter": {
                                                        "WrapXmlEnvelope:Success:_Create_new_Body_Part": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Query",
                                                    "inputs": {
                                                        "from": "@variables('Envelope')?['body']",
                                                        "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                                                    }
                                                },
                                                "WrapXmlEnvelope:Success:_Add_new_Root_Body_Part_to_Envelope": {
                                                    "runAfter": {
                                                        "WrapXmlEnvelope:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('WrapXmlEnvelope:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('WrapXmlEnvelope:Success:_Create_new_Body_Part'))))"
                                                },
                                                "WrapXmlEnvelope:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "WrapXmlEnvelope:Success:_Update_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "WrapXmlEnvelope"
                                                    }
                                                },
                                                "WrapXmlEnvelope:Success:_Update_Envelope_variable": {
                                                    "runAfter": {
                                                        "WrapXmlEnvelope:Success:_Add_new_Root_Body_Part_to_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@outputs('WrapXmlEnvelope:Success:_Add_new_Root_Body_Part_to_Envelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "WrapXmlEnvelope:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "WrapXmlEnvelope:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "WrapXmlEnvelope:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessagingManager WrapXmlEnvelope operation"
                                                        }
                                                    },
                                                    "WrapXmlEnvelope:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "WrapXmlEnvelope:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['statusCode'], outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['body']?['statusCode'], actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['error']?['message'], outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['body']?['message'], actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "WrapXmlEnvelope:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "WrapXmlEnvelope:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessagingManager WrapXmlEnvelope operation"
                                                            }
                                                        },
                                                        "WrapXmlEnvelope:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "WrapXmlEnvelope:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('WrapXmlEnvelope:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "WrapXmlEnvelope:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('WrapXmlEnvelope:_Call_APIM_MessagingManager.WrapXmlEnvelope')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\xmlenvelopewrapper\xmlenvelopewrapper.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessageprocessor\Deploy-85-XmlMessageProcessor-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessageprocessor\New-XmlMessageProcessor-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-XmlMessageProcessor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\xmlmessageprocessor.logicapp.json" -templateParameterFile ".\xmlmessageprocessor.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "xmlmessageprocessor.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the xml message processor Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\xmlmessageprocessor\Remove-XmlMessageProcessor-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-XmlMessageProcessor-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-xmlmessageprocessor-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\xmlmessageprocessor\TearDown-85-XmlMessageProcessor-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessageprocessor\xmlmessageprocessor.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessageprocessor\xmlmessageprocessor.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "xmlMessageProcessor",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageProcessor."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageProcessor."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_MessageType_variable": {
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "MessageType",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Set_MessageType": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SetMessageType"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_MessageType_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Set_MessageType": {
                            "actions": {
                                "SetMessageType:_Set_MessageType_variable": {
                                    "runAfter": {},
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "MessageType",
                                        "value": "@{coalesce(xpath(xml(variables('BodyContent')), 'namespace-uri(/*)'), '')}#@{coalesce(xpath(xml(variables('BodyContent')), 'local-name(/*)'), '')}"
                                    }
                                },
                                "SetMessageType:Failure:_Set_ErrorMessage_variable": {
                                    "runAfter": {
                                        "SetMessageType:_Set_MessageType_variable": [
                                            "Failed",
                                            "TimedOut",
                                            "Skipped"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "ErrorMessage",
                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to get the MessageType: @{coalesce(outputs('SetMessageType:_Set_MessageType_variable')?['error']?['message'], actions('SetMessageType:_Set_MessageType_variable')?['error']?['message'], '(unknown error)')}"
                                    }
                                },
                                "SetMessageType:Success:_Update_Properties": {
                                    "runAfter": {
                                        "SetMessageType:_Set_MessageType_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "Compose",
                                    "inputs": "@setProperty(variables('Envelope'), 'header', setProperty(variables('Envelope')?['header'], 'properties', setProperty(variables('Envelope')?['header']?['properties'], 'btsMessageType', variables('MessageType'))))"
                                },
                                "SetMessageType:Success:_Update_Routing": {
                                    "runAfter": {
                                        "SetMessageType:Success:_Update_Properties": [
                                            "Succeeded"
                                        ]

                                    },
                                    "type": "Compose",
                                    "inputs": "@setProperty(outputs('SetMessageType:Success:_Update_Properties'), 'header', setProperty(outputs('SetMessageType:Success:_Update_Properties')?['header'], 'routing', setProperty(outputs('SetMessageType:Success:_Update_Properties')?['header']?['routing'], 'btsMessageType', variables('MessageType'))))"
                                },
                                "SetMessageType:Success:_Set_Envelope_variable": {
                                    "runAfter": {
                                        "SetMessageType:Success:_Update_Routing": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Envelope",
                                        "value": "@outputs('SetMessageType:Success:_Update_Routing')"
                                    }
                                },
                                "SetMessageType:Success:_Set_Checkpoint_variable": {
                                    "runAfter": {
                                        "SetMessageType:Success:_Set_Envelope_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "SetMessageType"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\xmlmessageprocessor\xmlmessageprocessor.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessagetranslator\Deploy-85-XmlMessageTranslator-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessagetranslator\New-XmlMessageTranslator-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-XmlMessageTranslator-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\xmlmessagetranslator.logicapp.json" -templateParameterFile ".\xmlmessagetranslator.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "xmlmessagetranslator.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the xml message translator Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\xmlmessagetranslator\Remove-XmlMessageTranslator-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-XmlMessageTranslator-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-xmlmessagetranslator-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\xmlmessagetranslator\TearDown-85-XmlMessageTranslator-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessagetranslator\xmlmessagetranslator.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessagetranslator\xmlmessagetranslator.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "xmlMessageTranslator",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageTranslator."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageTranslator."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_MessageType_variable": {
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "MessageType",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_MapName_variable": {
                            "runAfter": {
                                "Initialize_MessageType_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "MapName",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_TransformedContent_variable": {
                            "runAfter": {
                                "Initialize_MapName_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "TransformedContent",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Update_MessageType": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SkipXmlTranslation"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "UpdateMessageType"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_TransformedContent_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_MapName": {
                            "actions": {
                                "GetMapName:_Filter_Maps_Array": {
                                    "inputs": {
                                        "from": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['maps'], array(''))",
                                        "where": "@equals(item()?['messageType'], coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '(undefined)'))"
                                    },
                                    "runAfter": {},
                                    "type": "Query"
                                },
                                "GetMapName:_Set_MapName_variable": {
                                    "inputs": {
                                        "name": "MapName",
                                        "value": "@if(equals(length(body('GetMapName:_Filter_Maps_Array')), 1), body('GetMapName:_Filter_Maps_Array')?[0]?['mapName'], '')"
                                    },
                                    "runAfter": {
                                        "GetMapName:_Filter_Maps_Array": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable"
                                },
                                "GetMapName:Success:_Set_Checkpoint_variable": {
                                    "runAfter": {
                                        "GetMapName:_Set_MapName_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "GetMapName"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_MapName": {
                            "actions": {
                                "CheckMapName:_Is_MapName_blank": {
                                    "actions": {
                                        "CheckMapName:MapNameBlank:_Allow_unrecognized_MessageType": {
                                            "actions": {
                                                "CheckMapName:MapNameBlank:SKipXmlTranslation:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "SkipXmlTranslation"
                                                    }
                                                }
                                            },
                                            "runAfter": {},
                                            "else": {
                                                "actions": {
                                                    "CheckMapName:Failure:_Set_ErrorMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a Map for the current MessageType for this envelope, and the allowUnrecognizedMessages config value is set to False. MessageType is: '@{coalesce(variables('Envelope')?['properties']?['btsMessageType'], '(undefined)')}'."
                                                        }
                                                    }
                                                }
                                            },
                                            "expression": {
                                                "and": [
                                                    {
                                                        "equals": [
                                                            "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['allowUnrecognizedMessages'], true)",
                                                            true
                                                        ]
                                                    }
                                                ]
                                            },
                                            "type": "If"
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "CheckMapName:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "PerformXmlTranslation"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@{coalesce(variables('MapName'), '')}",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_MapName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetMapName"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_MapName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "PerformXmlTranslation"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Transform_Xml": {
                            "actions": {
                                "TransformXml:Failure:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "TransformXml:_Transform_Xml": [
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 500
                                    }
                                },
                                "TransformXml:Success:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "TransformXml:_Transform_Xml": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 200
                                    }
                                },
                                "TransformXml:_Check_StatusCode": {
                                    "runAfter": {
                                        "TransformXml:Failure:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "TransformXml:Success:_Set_TransformedContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "TransformedContent",
                                                        "value": "@body('TransformXml:_Transform_Xml')"
                                                    }
                                                },
                                                "TransformXml:Success:_Add_new_Root_Body_Part_to_Envelope": {
                                                    "runAfter": {
                                                        "TransformXml:Success:_Remove_existing_Root_Body_Part_from_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": "@setProperty(variables('Envelope'), 'body', union(outputs('TransformXml:Success:_Remove_existing_Root_Body_Part_from_Envelope')?['body'], array(outputs('TransformXml:Success:_Create_new_Body_Part'))))"
                                                },
                                                "TransformXml:Success:_Create_new_Body_Part": {
                                                    "runAfter": {
                                                        "TransformXml:Success:_Set_TransformedContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Compose",
                                                    "inputs": {
                                                        "$content": "@base64(variables('TransformedContent'))",
                                                        "$contentTransferEncoding": "base64",
                                                        "$contentType": "application/xml",
                                                        "$part": "@variables('Envelope')?['header']?['properties']?['rootPart']",
                                                        "$partType": "http://schemas.myorg.com/part@{variables('Envelope')?['header']?['properties']?['rootPart']}#root"
                                                    }
                                                },
                                                "TransformXml:Success:_Remove_existing_Root_Body_Part_from_Envelope": {
                                                    "runAfter": {
                                                        "TransformXml:Success:_Create_new_Body_Part": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "Query",
                                                    "inputs": {
                                                        "from": "@variables('Envelope')?['body']",
                                                        "where": "@not(equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart']))"
                                                    }
                                                },
                                                "TransformXml:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "TransformXml:Success:_Update_Envelope_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "TransformXml"
                                                    }
                                                },
                                                "TransformXml:Success:_Update_Envelope_variable": {
                                                    "runAfter": {
                                                        "TransformXml:Success:_Add_new_Root_Body_Part_to_Envelope": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Envelope",
                                                        "value": "@outputs('TransformXml:Success:_Add_new_Root_Body_Part_to_Envelope')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "TransformXml:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('TransformXml:_Transform_Xml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('TransformXml:_Transform_Xml')?['statusCode'], outputs('TransformXml:_Transform_Xml')?['body']?['statusCode'], actions('TransformXml:_Transform_Xml')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(outputs('TransformXml:_Transform_Xml')?['error']?['message'], outputs('TransformXml:_Transform_Xml')?['body']?['message'], actions('TransformXml:_Transform_Xml')?['error']?['message'])}",
                                                        "faultReason": "@{actions('TransformXml:_Transform_Xml')?['status']}"
                                                    }
                                                }
                                            },
                                            "TransformXml:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "TransformXml:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to transform Xml"
                                                }
                                            },
                                            "TransformXml:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "TransformXml:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('TransformXml:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "TransformXml:_Transform_Xml": {
                                    "runAfter": {},
                                    "type": "Xslt",
                                    "inputs": {
                                        "content": "@variables('BodyContent')",
                                        "integrationAccount": {
                                            "map": {
                                                "name": "@{coalesce(variables('MapName'), '')}"
                                            }
                                        },
                                        "transformOptions": "ApplyXsltOutputAttributes"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Update_MessageType": {
                            "actions": {
                                "UpdateMessageType:_Set_MessageType_variable": {
                                    "runAfter": {},
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "MessageType",
                                        "value": "@{coalesce(xpath(xml(variables('TransformedContent')), 'namespace-uri(/*)'), '')}#@{coalesce(xpath(xml(variables('TransformedContent')), 'local-name(/*)'), '')}"
                                    }
                                },
                                "UpdateMessageType:Failure:_Set_ErrorMessage_variable": {
                                    "runAfter": {
                                        "UpdateMessageType:_Set_MessageType_variable": [
                                            "Failed",
                                            "TimedOut",
                                            "Skipped"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "ErrorMessage",
                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to update the MessageType: @{coalesce(outputs('UpdateMessageType:_Set_MessageType_variable')?['error']?['message'], actions('UpdateMessageType:_Set_MessageType_variable')?['error']?['message'], '(unknown error)')}"
                                    }
                                },
                                "UpdateMessageType:Success:_Update_Properties": {
                                    "runAfter": {
                                        "UpdateMessageType:_Set_MessageType_variable": [
                                            "Succeeded"
                                        ]

                                    },
                                    "type": "Compose",
                                    "inputs": "@setProperty(variables('Envelope'), 'header', setProperty(variables('Envelope')?['header'], 'properties', setProperty(variables('Envelope')?['header']?['properties'], 'btsMessageType', variables('MessageType'))))"
                                },
                                "UpdateMessageType:Success:_Update_Routing": {
                                    "runAfter": {
                                        "UpdateMessageType:Success:_Update_Properties": [
                                            "Succeeded"
                                        ]

                                    },
                                    "type": "Compose",
                                    "inputs": "@setProperty(outputs('UpdateMessageType:Success:_Update_Properties'), 'header', setProperty(outputs('UpdateMessageType:Success:_Update_Properties')?['header'], 'routing', setProperty(outputs('UpdateMessageType:Success:_Update_Properties')?['header']?['routing'], 'btsMessageType', variables('MessageType'))))"
                                },
                                "UpdateMessageType:Success:_Set_Envelope_variable": {
                                    "runAfter": {
                                        "UpdateMessageType:Success:_Update_Routing": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Envelope",
                                        "value": "@outputs('UpdateMessageType:Success:_Update_Routing')"
                                    }
                                },
                                "UpdateMessageType:Success:_Set_Checkpoint_variable": {
                                    "runAfter": {
                                        "UpdateMessageType:Success:_Set_Envelope_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "Checkpoint",
                                        "value": "UpdateMessageType"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Transform_Xml": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "TransformXml"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\xmlmessagetranslator\xmlmessagetranslator.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessagetranslatorlite\Deploy-85-XmlMessageTranslatorLite-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessagetranslatorlite\New-XmlMessageTranslatorLite-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-XmlMessageTranslatorLite-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\xmlmessagetranslatorlite.logicapp.json" -templateParameterFile ".\xmlmessagetranslatorlite.logicapp.dev.parameters" -deploymentName "xmlmessagetranslator.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Deploying the xml message translator lite Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\xmlmessagetranslatorlite\Remove-XmlMessageTranslatorLite-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-XmlMessageTranslatorLite-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-xmlmessagetranslatorlite-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\xmlmessagetranslatorlite\TearDown-85-XmlMessageTranslatorLite-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessagetranslatorlite\xmlmessagetranslatorlite.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessagetranslatorlite\xmlmessagetranslatorlite.logicapp.json
{
	"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"logicAppName": {
			"type": "string",
			"metadata": {
				"description": "Name of this LogicApp."
			}
		},
		"logicAppLocation": {
			"defaultValue": "[resourceGroup().location]",
			"type": "string",
			"metadata": {
				"description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
			}
		},
		"logicAppStartupState": {
			"type": "string",
			"defaultValue": "Enabled",
			"allowedValues": [
				"Enabled",
				"Disabled"
			],
			"metadata": {
				"description": "Initial state of the LogicApp after it is deployed."
			}
		},
		"messageBusResourceGroupName": {
			"type": "String",
			"metadata": {
				"description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
			}
		},
		"integrationAccountName": {
			"type": "String",
			"metadata": {
				"description": "Name of the IntegrationAccount connected to this LogicApp."
			}
		},
		"scenarioStep": {
			"defaultValue": "xmlMessageTranslatorLite",
			"type": "string",
			"metadata": {
				"description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageTranslatorLite."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {
		"integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
	},
	"resources": [
		{
			"type": "Microsoft.Logic/workflows",
			"apiVersion": "2017-07-01",
			"name": "[parameters('logicAppName')]",
			"location": "[parameters('logicAppLocation')]",
			"tags": "[parameters('tags')]",
			"properties": {
				"state": "[parameters('logicAppStartupState')]",
				"integrationAccount": {
					"id": "[variables('integrationAccountResourceId')]"
				},
				"definition": {
					"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
					"contentVersion": "1.0.0.0",
					"parameters": {
						"scenarioStep": {
							"type": "String",
							"description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageTranslatorLite."
						}
					},
					"triggers": {
						"manual": {
							"type": "Request",
							"inputs": {
								"schema": {
									"properties": {
										"bodyContent": {
											"type": "string"
										},
										"mapName": {
											"type": "string"
										}
									},
									"type": "object"
								}
							},
							"kind": "Http",
							"operationOptions": "EnableSchemaValidation"
						}
					},
					"actions": {
						"Initialize_StatusCode_variable": {
							"runAfter": {},
							"type": "InitializeVariable",
							"inputs": {
								"variables": [
									{
										"name": "StatusCode",
										"type": "integer",
										"value": 500
									}
								]
							}
						},
						"Initialize_FaultMessage_variable": {
							"runAfter": {
								"Initialize_StatusCode_variable": [
									"Succeeded"
								]
							},
							"type": "InitializeVariable",
							"inputs": {
								"variables": [
									{
										"name": "FaultMessage",
										"type": "object"
									}
								]
							}
						},
						"Initialize_ErrorMessage_variable": {
							"runAfter": {
								"Initialize_FaultMessage_variable": [
									"Succeeded"
								]
							},
							"type": "InitializeVariable",
							"inputs": {
								"variables": [
									{
										"name": "ErrorMessage",
										"type": "string",
										"value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
									}
								]
							}
						},
						"Initialize_Checkpoint_variable": {
							"runAfter": {
								"Initialize_ErrorMessage_variable": [
									"Succeeded"
								]
							},
							"type": "InitializeVariable",
							"inputs": {
								"variables": [
									{
										"name": "Checkpoint",
										"type": "string"
									}
								]
							}
						},
						"Initialize_TransformedContent_variable": {
							"runAfter": {
								"Initialize_Checkpoint_variable": [
									"Succeeded"
								]
							},
							"type": "InitializeVariable",
							"inputs": {
								"variables": [
									{
										"name": "TransformedContent",
										"type": "object"
									}
								]
							}
						},
						"MessageSender:_Were_we_Successful": {
							"actions": {
								"Sucess:_Return_Transformed_Content": {
									"runAfter": {},
									"type": "Response",
									"kind": "Http",
									"inputs": {
										"body": "@variables('TransformedContent')",
										"headers": {
											"Content-Type": "text/xml"
										},
										"statusCode": 200
									}
								}
							},
							"runAfter": {
								"Step:_Transform_Xml": [
									"Succeeded",
									"Failed",
									"Skipped",
									"TimedOut"
								]
							},
							"else": {
								"actions": {
									"Failure:_Send_Fault_response": {
										"runAfter": {},
										"type": "Response",
										"kind": "Http",
										"inputs": {
											"body": "@variables('FaultMessage')",
											"headers": {
												"Content-Type": "application/json"
											},
											"statusCode": 500
										}
									}
								}
							},
							"expression": {
								"or": [
									{
										"equals": [
											"@variables('Checkpoint')",
											"TransformXml"
										]
									}
								]
							},
							"type": "If"
						},
						"Step:_Transform_Xml": {
							"actions": {
								"TransformXml:_Set_StatusCode_variable": {
									"inputs": {
										"name": "StatusCode",
										"value": "@coalesce(outputs('TransformXml:_Transform_Xml')?['statusCode'], 500)"
									},
									"runAfter": {
										"TransformXml:_Transform_Xml": [
											"Succeeded",
											"Failed",
											"Skipped",
											"TimedOut"
										]
									},
									"type": "SetVariable"
								},
								"TransformXml:_Check_StatusCode": {
									"runAfter": {
										"TransformXml:_Set_StatusCode_variable": [
											"Succeeded"
										]
									},
									"cases": {
										"Success": {
											"case": 200,
											"actions": {
												"TransformXml:Success:_Set_TransformedContent_variable": {
													"runAfter": {},
													"type": "SetVariable",
													"inputs": {
														"name": "TransformedContent",
														"value": "@body('TransformXml:_Transform_Xml')"
													}
												},
												"TransformXml:Success:_Set_Checkpoint_variable": {
													"runAfter": {
														"TransformXml:Success:_Set_TransformedContent_variable": [
															"Succeeded"
														]
													},
													"type": "SetVariable",
													"inputs": {
														"name": "Checkpoint",
														"value": "TransformXml"
													}
												}
											}
										}
									},
									"default": {
										"actions": {
											"TransformXml:Failure:_Create_Fault_message": {
												"runAfter": {},
												"type": "Compose",
												"inputs": {
													"fault": {
														"faultActor": "@concat(workflow()?['name'], '.', actions('TransformXml:_Transform_Xml')?['name'], ' (', workflow()?['run']?['name'], ')')",
														"faultCategory": "Error",
														"faultCode": "@{coalesce(outputs('TransformXml:_Transform_Xml')?['statusCode'], outputs('TransformXml:_Transform_Xml')?['body']?['statusCode'], actions('TransformXml:_Transform_Xml')?['error']?['code'])}",
														"faultMessage": "@{coalesce(outputs('TransformXml:_Transform_Xml')?['error']?['message'], outputs('TransformXml:_Transform_Xml')?['body']?['message'], actions('TransformXml:_Transform_Xml')?['error']?['message'])}",
														"faultReason": "@{actions('TransformXml:_Transform_Xml')?['status']}"
													}
												}
											},
											"TransformXml:Failure:_Set_ErrorMessage_variable": {
												"runAfter": {
													"TransformXml:Failure:_Set_FaultMessage_variable": [
														"Succeeded"
													]
												},
												"type": "SetVariable",
												"inputs": {
													"name": "ErrorMessage",
													"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to transform Xml"
												}
											},
											"TransformXml:Failure:_Set_FaultMessage_variable": {
												"runAfter": {
													"TransformXml:Failure:_Create_Fault_message": [
														"Succeeded"
													]
												},
												"type": "SetVariable",
												"inputs": {
													"name": "FaultMessage",
													"value": "@outputs('TransformXml:Failure:_Create_Fault_message')"
												}
											}
										}
									},
									"expression": "@variables('StatusCode')",
									"type": "Switch"
								},
								"TransformXml:_Transform_Xml": {
									"runAfter": {},
									"type": "Xslt",
									"inputs": {
										"content": "@xml(decodeBase64(triggerBody()?['bodyContent']))",
										"integrationAccount": {
											"map": {
												"name": "@{coalesce(triggerBody()?['mapName'], '')}"
											}
										},
										"transformOptions": "ApplyXsltOutputAttributes"
									}
								}
							},
							"runAfter": {
								"Initialize_TransformedContent_variable": [
									"Succeeded",
									"Failed",
									"Skipped",
									"TimedOut"
								]
							},
							"expression": {
								"and": [
									{
										"equals": [
											"@variables('Checkpoint')",
											""
										]
									}
								]
							},
							"type": "If"
						}
					},
					"outputs": {}
				},
				"parameters": {
					"scenarioStep": {
						"value": "[parameters('scenarioStep')]"
					}
				}
			}
		}
	]
}
tools\templates\intermediaries\xmlmessagetranslatorlite\xmlmessagetranslatorlite.logicapp.prod.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessagevalidator\Deploy-85-XmlMessageValidator-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessagevalidator\New-XmlMessageValidator-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-XmlMessageValidator-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\xmlmessagevalidator.logicapp.json" -templateParameterFile ".\xmlmessagevalidator.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "xmlmessagevalidator.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName    
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the xml message validator Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"
tools\templates\intermediaries\xmlmessagevalidator\Remove-XmlMessageValidator-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-XmlMessageValidator-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "logic-xmlmessagevalidator-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\intermediaries\xmlmessagevalidator\TearDown-85-XmlMessageValidator-LogicApp.ps1.liquid
 
tools\templates\intermediaries\xmlmessagevalidator\xmlmessagevalidator.logicapp.dev.parameters.json.liquid
 
tools\templates\intermediaries\xmlmessagevalidator\xmlmessagevalidator.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "metadata": {
                "description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
            }
        },
        "integrationAccountName": {
            "type": "String",
            "metadata": {
                "description": "Name of the IntegrationAccount connected to this LogicApp."
            }
        },
        "routingSlipRouterLogicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of the LogicApp to call to route via the RoutingSlip."
            }
        },
        "routerRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling RoutingSlipRouter."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "xmlMessageTranslator",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageTranslator."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]",
        "integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "integrationAccount": {
                    "id": "[variables('integrationAccountResourceId')]"
                },
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. xmlMessageTranslator."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_BodyContent_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "BodyContent",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_SchemaName_variable": {
                            "runAfter": {
                                "Initialize_BodyContent_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "SchemaName",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_Successful": {
                            "actions": {
                                "Routing:_Call_RoutingSlipRouter": {
                                    "runAfter": {},
                                    "type": "Workflow",
                                    "inputs": {
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "host": {
                                            "triggerName": "manual",
                                            "workflow": {
                                                "id": "[variables('routingSlipRouterLogicAppResourceId')]"
                                            }
                                        },
                                        "retryPolicy": "[parameters('routerRetryPolicy')]"
                                    }
                                },
                                "Routing:_Check_StatusCode": {
                                    "runAfter": {
                                        "Routing:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "Routing:Success:_Send_ACK-Content_response": {
                                                    "runAfter": {},
                                                    "type": "Response",
                                                    "kind": "Http",
                                                    "inputs": {
                                                        "body": "@body('Routing:_Call_RoutingSlipRouter')",
                                                        "headers": {
                                                            "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                            "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                            "Content-Type": "application/json"
                                                        },
                                                        "statusCode": 200
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "Routing:Error:_Build_NACK_message": {
                                                "runAfter": {
                                                    "Routing:Error:_Do_we_have_a_Fault_Message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Compose",
                                                "inputs": {
                                                    "body": [
                                                        {
                                                            "$content": {
                                                                "code": "500",
                                                                "message": "@variables('ErrorMessage')",
                                                                "lastCheckpoint": "@variables('Checkpoint')",
                                                                "fault": "@variables('FaultMessage')"
                                                            },
                                                            "$contentType": "application/json",
                                                            "$part": 1,
                                                            "$partType": "http://schemas.microsoft.com/aim#nack"
                                                        }
                                                    ],
                                                    "header": {
                                                        "properties": {
                                                            "createDate": "@utcNow()",
                                                            "envelopeType": "nack",
                                                            "messageId": "@guid()",
                                                            "rootPart": 1,
                                                            "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                        },
                                                        "routing": {
                                                            "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                        },
                                                        "routingSlip": {},
                                                        "state": {}
                                                    }
                                                }
                                            },
                                            "Routing:Error:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "Routing:Error:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "Routing:Error:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                        }
                                                    },
                                                    "Routing:Error:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('Routing:_Call_RoutingSlipRouter')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "Routing:Error:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
                                                            }
                                                        },
                                                        "Routing:Error:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "Routing:Error:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('Routing:_Call_RoutingSlipRouter')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            },
                                            "Routing:Error:_Send_NACK_response": {
                                                "runAfter": {
                                                    "Routing:Error:_Build_NACK_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "Response",
                                                "kind": "Http",
                                                "inputs": {
                                                    "body": "@outputs('Routing:Error:_Build_NACK_message')",
                                                    "headers": {
                                                        "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                        "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                        "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "Content-Type": "application/json"
                                                    },
                                                    "statusCode": 200
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "Routing:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "Routing:_Call_RoutingSlipRouter": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Validate_Xml": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                                "Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ValidateXml"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "SkipXmlValidation"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_SchemaName_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_MessageType": {
                            "actions": {
                                "CheckMessageType:_Is_MessageType_blank": {
                                    "actions": {
                                        "CheckMessageType:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a btsMessageType property for this envelope."
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "CheckMessageType:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckMessageType"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@{coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '')}",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_SchemaName": {
                            "actions": {
                                "GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "messageType": "@{encodeUriComponent(coalesce(variables('Envelope')?['header']?['properties']?['btsMessageType'], '(undefined)'))}"
                                            },
                                            "template": "/aimconfigurationmanager/schemabymessagetype/{messageType}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['clearCache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetSchemaName:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetSchemaName:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetSchemaName:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetSchemaName:Success:_Set_SchemaName_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetSchemaName"
                                                    }
                                                },
                                                "GetSchemaName:Success:_Set_SchemaName_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "SchemaName",
                                                        "value": "@body('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['schemaName']"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetSchemaName:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetSchemaName:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetSchemaName:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetSchemaNameByMessageType operation"
                                                        }
                                                    },
                                                    "GetSchemaName:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetSchemaName:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['statusCode'], outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['body']?['statusCode'], actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['error']?['message'], outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['body']?['message'], actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetSchemaName:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetSchemaName:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetSchemaNameByMessageType operation"
                                                            }
                                                        },
                                                        "GetSchemaName:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetSchemaName:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetSchemaName:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetSchemaName:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetSchemaName:_Call_APIM_ConfigurationManager.GetSchemaNameByMessageType')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_MessageType": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckMessageType"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_SchemaName": {
                            "actions": {
                                "CheckSchemaName:_Is_SchemaName_blank": {
                                    "actions": {
                                        "CheckSchemaName:SchemaNameBlank:_Allow_unrecognized_MessageType": {
                                            "actions": {
                                                "CheckMapName:MapNameBlank:SKipXmlTranslation:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "SkipXmlValidation"
                                                    }
                                                }
                                            },
                                            "runAfter": {},
                                            "else": {
                                                "actions": {
                                                    "CheckSchemaName:Failure:_Set_ErrorMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Unable to find a Schema for the current MessageType for this envelope, and the allowUnrecognizedMessages config value is set to False. MessageType is: '@{coalesce(variables('Envelope')?['properties']?['btsMessageType'], '(undefined)')}'."
                                                        }
                                                    }
                                                }
                                            },
                                            "expression": {
                                                "and": [
                                                    {
                                                        "equals": [
                                                            "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['allowUnrecognizedMessages'], true)",
                                                            true
                                                        ]
                                                    }
                                                ]
                                            },
                                            "type": "If"
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "CheckSchemaName:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "PerformXmlValidation"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@{coalesce(variables('SchemaName'), '')}",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_SchemaName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetSchemaName"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_BodyContent": {
                            "actions": {
                                "CheckBodyContent:_Body_Content_is_missing": {
                                    "actions": {
                                        "CheckBodyContent:Failure:_Set_ErrorMessage_variable": {
                                            "runAfter": {},
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ErrorMessage",
                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): No Root Body content can be found in the supplied Envelope"
                                            }
                                        }
                                    },
                                    "runAfter": {
                                        "CheckBodyContent:_Select_Root_Part": [
                                            "Succeeded"
                                        ]
                                    },
                                    "else": {
                                        "actions": {
                                            "CheckBodyContent:Success:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "CheckBodyContent"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "and": [
                                            {
                                                "equals": [
                                                    "@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
                                                    ""
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                },
                                "CheckBodyContent:_Select_Root_Part": {
                                    "runAfter": {},
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@variables('Envelope')?['body']",
                                        "where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_SchemaName": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "PerformXmlValidation"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_BodyContent": {
                            "actions": {
                                "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('messagingManagerApiResourceId')]"
                                        },
                                        "body": "@variables('Envelope')",
                                        "headers": {
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "method": "post",
                                        "pathTemplate": {
                                            "parameters": {},
                                            "template": "/aimmessagingmanager/getbodycontent"
                                        },
                                        "queries": {
                                            "clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
                                            "enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetBodyContent:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetBodyContent:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetBodyContent:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetBodyContent:Success:_Set_BodyContent_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetBodyContent"
                                                    }
                                                },
                                                "GetBodyContent:Success:_Set_BodyContent_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "BodyContent",
                                                        "value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetBodyContent:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetBodyContent:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                        }
                                                    },
                                                    "GetBodyContent:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetBodyContent:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
                                                            }
                                                        },
                                                        "GetBodyContent:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetBodyContent:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetBodyContent:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Check_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "CheckBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Validate_Xml": {
                            "actions": {
                                "ValidateXml:Failure:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ValidateXml:_Validate_Xml": [
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 500
                                    }
                                },
                                "ValidateXml:Success:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "ValidateXml:_Validate_Xml": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": 200
                                    }
                                },
                                "ValidateXml:_Check_StatusCode": {
                                    "runAfter": {
                                        "ValidateXml:Failure:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ],
                                        "ValidateXml:Success:_Set_StatusCode_variable": [
                                            "Succeeded",
                                            "Skipped"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "ValidateXml:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "ValidateXml"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "ValidateXml:Failure:_Create_Fault_message": {
                                                "runAfter": {},
                                                "type": "Compose",
                                                "inputs": {
                                                    "fault": {
                                                        "faultActor": "@concat(workflow()?['name'], '.', actions('ValidateXml:_Validate_Xml')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                        "faultCategory": "Error",
                                                        "faultCode": "@{coalesce(outputs('ValidateXml:_Validate_Xml')?['statusCode'], outputs('ValidateXml:_Validate_Xml')?['body']?['statusCode'], actions('ValidateXml:_Validate_Xml')?['error']?['code'])}",
                                                        "faultMessage": "@{coalesce(if(greater(length(outputs('ValidateXml:_Validate_Xml')?['errors']), 0), outputs('ValidateXml:_Validate_Xml')?['errors']?[0]?['message'], null), outputs('ValidateXml:_Validate_Xml')?['error']?['message'], outputs('ValidateXml:_Validate_Xml')?['body']?['message'], actions('ValidateXml:_Validate_Xml')?['error']?['message'])}",
                                                        "faultReason": "@{actions('ValidateXml:_Validate_Xml')?['status']}"
                                                    }
                                                }
                                            },
                                            "ValidateXml:Failure:_Set_ErrorMessage_variable": {
                                                "runAfter": {
                                                    "ValidateXml:Failure:_Set_FaultMessage_variable": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "ErrorMessage",
                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to validate XML"
                                                }
                                            },
                                            "ValidateXml:Failure:_Set_FaultMessage_variable": {
                                                "runAfter": {
                                                    "ValidateXml:Failure:_Create_Fault_message": [
                                                        "Succeeded"
                                                    ]
                                                },
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "FaultMessage",
                                                    "value": "@outputs('ValidateXml:Failure:_Create_Fault_message')"
                                                }
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "ValidateXml:_Validate_Xml": {
                                    "runAfter": {},
                                    "type": "XmlValidation",
                                    "inputs": {
                                        "content": "@variables('BodyContent')",
                                        "integrationAccount": {
                                            "schema": {
                                                "name": "@{coalesce(variables('SchemaName'), '')}"
                                            }
                                        }
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Get_BodyContent": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetBodyContent"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\intermediaries\xmlmessagevalidator\xmlmessagevalidator.logicapp.prod.parameters.json.liquid
 
tools\templates\messagebus\artifactstore\artifactstore.dev.parameters.json.liquid
 
tools\templates\messagebus\artifactstore\artifactstore.json.liquid
 
tools\templates\messagebus\artifactstore\artifactstore.prod.parameters.json.liquid
 
tools\templates\messagebus\artifactstore\Deploy-20-ArtifactStore.ps1.liquid
 
tools\templates\messagebus\artifactstore\New-ArtifactStore.ps1.liquid
 
tools\templates\messagebus\artifactstore\Remove-ArtifactStore.ps1.liquid
 
tools\templates\messagebus\artifactstore\TearDown-20-ArtifactStore.ps1.liquid
 
tools\templates\messagebus\configmanager\configmanager.apim.dev.parameters.json.liquid
 
tools\templates\messagebus\configmanager\configmanager.apim.json.liquid
 
tools\templates\messagebus\configmanager\configmanager.apim.prod.parameters.json.liquid
 
tools\templates\messagebus\configmanager\Deploy-40-ConfigManager-ApiManagement.ps1.liquid
 
tools\templates\messagebus\configmanager\New-ConfigManager-ApiManagement.ps1
<#
.SYNOPSIS
Creates an API resource in API Management for the configuration manager.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the API Management service is located.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER apimServiceName
The name of the API Management service.

.PARAMETER apiName
The name of the API being deployed.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-ConfigManager-ApiManagement.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -apimServiceName "apim-aimmsgbussvc-dev" -apiName "aimconfigurationmanager" -templateFile ".\configmanager.apim.json" -templateParameterFile ".\configmanager.apim.dev.parameters" -deploymentName "configmanager.apim"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $apimServiceName,
    [parameter(Mandatory = $true)]
    [string] $apiName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

Write-Host "Deploying the API for the configuration manager`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"

Write-Host "Associating the API Management service $apimServiceName products to the API $apiName"

$products = az rest -m GET -u https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products?api-version=2018-01-01 | ConvertFrom-Json | Select-Object -ExpandProperty value

if ($products) {
    Write-Host "Found products for API Management service $apimServiceName"

    ForEach ($product in $products) {
        $productName = $product.name

        Write-Host "Associating product $productName with the configuration manager API"

        # PowerShell doesn't like variable expansion when a ? follows the variable
        $url = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products/$productName/apis/" + $apiName + "?api-version=2018-01-01"
		
        az rest -m PUT -u $url
    }
}
else {
    throw "Failed to get products for API Management service $apimServiceName"
}
tools\templates\messagebus\configmanager\Remove-ConfigManager-ApiManagement.ps1
<#
.SYNOPSIS
Tears down the API resource in API Management for the configuration manager.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER serviceName
The name of the API Management service to find the resource.

.PARAMETER apiName
The name of the API resource in API Management to remove.

.EXAMPLE
./Remove-ConfigManager-ApiManagement.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -serviceName "apim-aimmsgbussvc-dev" -apiName "aimconfigurationmanager"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $serviceName,
    [parameter(Mandatory = $true)]
    [string] $apiName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

if ($resourceExists) {
    Write-Host "Removing the API resource for service $serviceName : $apiName"

    az resource delete --resource-group $resourceGroupName --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

    Write-Host "Removed the API resource for service $serviceName : $apiName"
}
else {
    Write-Host "The API resource $apiName for service $serviceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\configmanager\TearDown-40-ConfigManager-ApiManagement.ps1.liquid
 
tools\templates\messagebus\messagebusgroup\Deploy-10-MessageBusGroup.ps1.liquid
 
tools\templates\messagebus\messagebusgroup\messagebusgroup.dev.parameters.json.liquid
 
tools\templates\messagebus\messagebusgroup\messagebusgroup.json.liquid
 
tools\templates\messagebus\messagebusgroup\messagebusgroup.prod.parameters.json.liquid
 
tools\templates\messagebus\messagebusgroup\New-MessageBusGroup.ps1.liquid
 
tools\templates\messagebus\messagebusgroup\Remove-MessageBusGroup.ps1.liquid
 
tools\templates\messagebus\messagebusgroup\TearDown-10-MessageBusGroup.ps1.liquid
 
tools\templates\messagebus\messagebusops\Deploy-20-MessageBusOps-AppInsights.ps1.liquid
 
tools\templates\messagebus\messagebusops\messagebusops.appi.dev.psparameters.json.liquid
 
tools\templates\messagebus\messagebusops\messagebusops.appi.prod.psparameters.json.liquid
 
tools\templates\messagebus\messagebusops\New-MessageBusOps-AppInsights.ps1.liquid
 
tools\templates\messagebus\messagebusops\Remove-MessageBusOps-AppInsights.ps1.liquid
 
tools\templates\messagebus\messagebusops\TearDown-20-MessageBusOps-AppInsights.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Deploy-20-MessageBusService-StorageAccount.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Deploy-30-MessageBusService-ApiManagement.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Deploy-30-MessageBusService-AppService.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Deploy-30-MessageBusService-LogicAppPlan.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Deploy-35-MessageBusService-ApiManagement-RoleAssignment.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Deploy-5-MessageBusService-Role.ps1.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.apim.dev.psparameters.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.apim.prod.psparameters.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.logicapp.plan.dev.parameters.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.logicapp.plan.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.logicapp.plan.prod.parameters.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.logicappsrole.json
{
    "Name": "Get Logic App Callback Url",
    "IsCustom": true,
    "Description": "Allows API Management to get the Logic App callback URL.",
    "Actions": [
        "Microsoft.Logic/workflows/triggers/listCallbackUrl/action",
        "Microsoft.Logic/workflows/listCallbackUrl/action",
        "*/listCallbackUrl/action"
    ],
    "DataActions": [
    ],
    "NotDataActions": [
    ],
    "AssignableScopes": [
        "/subscriptions/{subscriptionId}"
    ]
}
tools\templates\messagebus\messagebusservice\messagebusservice.plan.dev.parameters.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.plan.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.plan.prod.parameters.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.st.dev.psparameters.json.liquid
 
tools\templates\messagebus\messagebusservice\messagebusservice.st.prod.psparameters.json.liquid
 
tools\templates\messagebus\messagebusservice\New-MessageBusService-ApiManagement-RoleAssignment.ps1
<#
.SYNOPSIS
Assigns a role to the specified resource group for the managed identity of the API Management service.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the resource group is located.

.PARAMETER resourceGroupName
Name of the resource group for the role assignment scope.

.PARAMETER name
Name of the API Management service that will be used for the role assignment.

.PARAMETER messageBusResourceGroupName
Name of the resource group where the API Management service is located.

.PARAMETER role
The role to assign to the resource group for the API Management service managed identity.

.EXAMPLE
./New-MessageBusService-ApiManagement-RoleAssignment.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -name "apim-aimmsgbussvc-dev" -messageBusResourceGroupName "rg-aimmsgbus-dev-uksouth" -role "Get Logic App Callback Url xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $name,
    [parameter(Mandatory = $true)]
    [string] $messageBusResourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $role
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

# --------------------------------------------------------------------------

Write-Host "Getting managed identity principal ID for API Management service $name"

$principalId = az apim show --name $name --resource-group $messageBusResourceGroupName | ConvertFrom-Json | Select-Object -ExpandProperty identity | Select-Object -ExpandProperty principalId

# Reset console colour because the show command breaks the colours and outputs black on black
[Console]::ResetColor()

if ($principalId) {
    Write-Host "Principal ID is $principalId"
}
else {
    throw "Unable to get managed identity principal ID for $name"
}

Write-Host "Adding role assignment for $principalId to role $role for resource group $resourceGroupName"

az role assignment create --assignee $principalId --role "$role" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroupName

Write-Host "Assigned managed identity of API Management service $name to $resourceGroupName"
tools\templates\messagebus\messagebusservice\New-MessageBusService-ApiManagement.ps1
<#
.SYNOPSIS
Creates an API Management resource for use by various AIM components.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the App Configuration service is located.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER name
Name of the API Management service that will be created.

.PARAMETER location
Location where the resource will be created.

.PARAMETER appConfigName
The name of the Azure App Configuration service.

.PARAMETER keyVaultName
The name of the Azure Key Vault service.

.PARAMETER publisherName
Name of the publisher organisation.

.PARAMETER publisherEmail
Email address that will receive emails from Azure when the service is published.

.PARAMETER sku
The SKU level for the API Management service.

.PARAMETER skuCapacity
The SKU capacity level for the API Management service.

.PARAMETER tags
The tags to apply to the API Management service.

.EXAMPLE
./New-MessageBusService-ApiManagement.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -name "apim-aimmsgbussvc-dev" -location "UK South" -appConfigName "appcfg-aimrstore-dev"  -keyVaultName "kv-aimrstore-dev" -publisherName "Microsoft" -publisherEmail "[email protected]"
./New-MessageBusService-ApiManagement.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -name "apim-aimmsgbussvc-dev" -location "UK South" -appConfigName "appcfg-aimrstore-dev"  -keyVaultName "kv-aimrstore-dev" -publisherName "Microsoft" -publisherEmail "[email protected]" -sku "Premium" -skuCapacity 5
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $name,
    [parameter(Mandatory = $true)]
    [string] $location,
    [parameter(Mandatory = $true)]
    [string] $appConfigName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $publisherName,
    [parameter(Mandatory = $true)]
    [string] $publisherEmail,
    [parameter(Mandatory = $false)]
    [string] $sku = "Developer",
    [parameter(Mandatory = $false)]
    [int] $skuCapacity = 1,
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

# --------------------------------------------------------------------------

Write-Host "Deploying the API management service"

az apim create --name $name --location $location --publisher-email $publisherEmail --publisher-name $publisherName --resource-group $resourceGroupName --sku-name $sku --sku-capacity $skuCapacity --tags $tags #--enable-managed-identity
if (!$?)
{
    # API Management is a global resource, so this may cause a failure if it already exists in
    # another subscription.
    throw "Deployment failed, aborting"
}

# Update apim instance to enable managed identities due to az CLI issue.
# https://github.com/Azure/azure-cli/issues/11614
az apim update --name $name --resource-group $resourceGroupName --enable-managed-identity

Write-Host "Deployment complete"

# --------------------------------------------------------------------------

Write-Host "Getting managed identity principal ID for API Management service $name"

$principalId = az apim show --name $name --resource-group $resourceGroupName | ConvertFrom-Json | Select-Object -ExpandProperty identity | Select-Object -ExpandProperty principalId

# Reset console colour because the show command breaks the colours and outputs black on black
[Console]::ResetColor()

if ($principalId) {
    Write-Host "Principal ID is $principalId"
}
else {
    throw "Unable to get managed identity principal ID for $name"
}

$role = "Contributor"

Write-Host "Adding role assignment for $principalId to role $role for App Configuration service $appConfigName"

az role assignment create --assignee $principalId --role "$role" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.AppConfiguration/configurationStores/$appConfigName

Write-Host "Assigned managed identity of API Management service $name to $appConfigName"

# --------------------------------------------------------------------------

Write-Host "Uploading product subscription keys for API Management service $name products to Key Vault $keyVaultName"

$products = az rest -m GET -u https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$name/products?api-version=2018-01-01 | ConvertFrom-Json | Select-Object -ExpandProperty value
$subscriptions = az rest -m GET -u https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$name/subscriptions?api-version=2018-01-01 | ConvertFrom-Json | Select-Object -ExpandProperty value | Select-Object -ExpandProperty properties

if ($products -and $subscriptions) {
    Write-Host "Found products and subscriptions for API Management service $name"

    ForEach ($product in $products)
    {
        $productName = $product.name
        $subscriptionKey = $null

        Write-Host "Finding subscription key for product $productName"

        ForEach ($subscription in $subscriptions)
        {
            if ($subscription.productId -eq $product.Id) {
                Write-Host "Found subscription key for product $productName"

                $subscriptionKey = $subscription.primaryKey

                Break
            }
        }

        if ($subscriptionKey) {
            Write-Host "Uploading subscription key for product $productName to Key Vault"

            az keyvault secret set --name "aim-apim-subscriptionkey-$productName" --vault-name $keyVaultName --value "$subscriptionKey"
        }
        else {
            throw "Failed to find subscription key for product $productName"
        }
    }
}
else {
    throw "Failed to get products and subscriptions for API Management service $name"
}
tools\templates\messagebus\messagebusservice\New-MessageBusService-AppService.ps1.liquid
 
tools\templates\messagebus\messagebusservice\New-MessageBusService-LogicAppPlan.ps1
<#
.SYNOPSIS
Creates an App Service Plan for Logic Apps for the Message Bus.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-MessageBusService-LogicAppPlan.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -templateFile ".\messagebusservice.logicapp.plan.json" -templateParameterFile ".\messagebusservice.logicapp.plan.dev.parameters" -deploymentName "messagebusservice.logicapp.plan"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying the app service plan`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\messagebus\messagebusservice\New-MessageBusService-Role.ps1
<#
.SYNOPSIS
Creates a custom Role resource for use by API Management service.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the Key Vault service is located.

.EXAMPLE
./New-MessageBusService-Role.ps1 -subscriptionId "<azure-subs-id>" -role "Get Logic App Callback Url xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]
    [string] $role
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

# --------------------------------------------------------------------------

Write-Host "Load role definition and update subscription scope"

$roleDefinition = Get-Content -Raw -Path "$PSScriptRoot\messagebusservice.logicappsrole.json" | ConvertFrom-Json

if ($roleDefinition) {
    Write-Host "Updating role name to $role"

    $roleDefinition.Name = "$role"
    
    Write-Host "Updating subscription assignable scope to $subscriptionId"

    $roleDefinition.AssignableScopes[0] = "/subscriptions/$subscriptionId"
}
else {
    throw "Unable to load role definition"
}

Write-Host "Checking for existing role $role"

$resourceExists = az role definition list --name "$role" --custom-role-only true -o tsv

if ($resourceExists) {
    Write-Host "Updating the role $role"

    # When a command is invoked in PowerShell, there is a lot of removing of double quotes in strings when the command is
    # invoked.  There is also some weirdness around having spaces in values.  The replace calls escape the double quotes
    # and the spaces in the string, which allows it to work.  Key also is the -Compress on the ConvertTo-Json call so the
    # json is a single line string.
    az role definition update --role-definition ($roleDefinition | ConvertTo-Json -Compress).Replace('"', '\"').Replace(' ', '\u0020')
    if (!$?) {
        throw "Update failed, aborting"
    }

    Write-Host "Updated the role $role"
}
else {
    Write-Host "Deploying the role $role"

    # See above for comment on double quote and space escaping.
    az role definition create --role-definition ($roleDefinition | ConvertTo-Json -Compress).Replace('"', '\"').Replace(' ', '\u0020')
    if (!$?) {
        throw "Deployment failed, aborting"
    }
    
    Write-Host "Deployment complete"
}
tools\templates\messagebus\messagebusservice\New-MessageBusService-StorageAccount.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Remove-MessageBusService-ApiManagement-RoleAssignment.ps1
<#
.SYNOPSIS
Removes a role assignment from the specified resource group for the managed identity of the API Management service.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the resource group is located.

.PARAMETER resourceGroupName
Name of the resource group for the role assignment scope.

.PARAMETER name
Name of the API Management service that will be used for the operation.

.PARAMETER messageBusResourceGroupName
Name of the resource group where the API Management service is located.

.PARAMETER role
The role to delete from the resource group for the API Management service managed identity.

.EXAMPLE
./Remove-MessageBusService-ApiManagement-RoleAssignment.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -name "apim-aimmsgbussvc-dev" -messageBusResourceGroupName "rg-aimmsgbus-dev-uksouth" -role "Get Logic App Callback Url xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $name,
    [parameter(Mandatory = $true)]
    [string] $messageBusResourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $role
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

# --------------------------------------------------------------------------

Write-Host "Getting managed identity principal ID for API Management service $name"

$principalId = az apim show --name $name --resource-group $messageBusResourceGroupName | ConvertFrom-Json | Select-Object -ExpandProperty identity | Select-Object -ExpandProperty principalId

# Reset console colour because the show command breaks the colours and outputs black on black
[Console]::ResetColor()

if ($principalId) {
    Write-Host "Principal ID is $principalId"
}
else {
    throw "Unable to get managed identity principal ID for $name"
}

Write-Host "Deleting role assignment for $principalId for role $role from resource group $resourceGroupName"

az role assignment delete --assignee $principalId --role "$role" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroupName --yes

Write-Host "Deleted managed identity of API Management service $name from $resourceGroupName"
tools\templates\messagebus\messagebusservice\Remove-MessageBusService-ApiManagement.ps1
<#
.SYNOPSIS
Tears down the API Management resource.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-MessageBusService-ApiManagement.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -resourceName "apim-aimmsgbussvc-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az apim show --name $resourceName --resource-group $resourceGroupName

# Reset console colour because the show command breaks the colours and outputs black on black
[Console]::ResetColor()

if ($resourceExists) {
    Write-Host "Removing the API management resource: $resourceName"

    az apim delete --name $resourceName --resource-group $resourceGroupName --yes

    Write-Host "Removed the API management resource: $resourceName"
}
else {
    Write-Host "The API management resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\messagebusservice\Remove-MessageBusService-AppService.ps1.liquid
 
tools\templates\messagebus\messagebusservice\Remove-MessageBusService-LogicAppPlan.ps1
<#
.SYNOPSIS
Tears down the App Service Plan for Logic Apps for the Message Bus.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-MessageBusService-LogicAppPlan.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -resourceName "plan-logicapp-aimmsgbussvc-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az appservice plan show --name $resourceName --resource-group $resourceGroupName

if ($resourceExists) {
    Write-Host "Removing the app service plan resource: $resourceName"

    az appservice plan delete --name $resourceName --resource-group $resourceGroupName --yes

    Write-Host "Removed the app service plan resource: $resourceName"
}
else {
    Write-Host "The app service plan resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\messagebusservice\Remove-MessageBusService-Role.ps1
<#
.SYNOPSIS
Tears down the Role resource.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.EXAMPLE
./Remove-MessageBusService-Role.ps1 -role "Get Logic App Callback Url xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $role
)

$resourceExists = az role definition list --name "$role" --custom-role-only true

if ($resourceExists) {
    Write-Host "Removing the role $role"

    az role definition delete --name "$role"

    Write-Host "Removed the role $role"
}
else {
    Write-Host "The role $role does not exist in the subscription"
}
tools\templates\messagebus\messagebusservice\Remove-MessageBusService-StorageAccount.ps1.liquid
 
tools\templates\messagebus\messagebusservice\TearDown-20-MessageBusService-StorageAccount.ps1.liquid
 
tools\templates\messagebus\messagebusservice\TearDown-30-MessageBusService-ApiManagement.ps1.liquid
 
tools\templates\messagebus\messagebusservice\TearDown-30-MessageBusService-AppService.ps1.liquid
 
tools\templates\messagebus\messagebusservice\TearDown-30-MessageBusService-LogicAppPlan.ps1.liquid
 
tools\templates\messagebus\messagebusservice\TearDown-35-MessageBusService-ApiManagement-RoleAssignment.ps1.liquid
 
tools\templates\messagebus\messagebusservice\TearDown-5-MessageBusService-Role.ps1.liquid
 
tools\templates\messagebus\messagingmanager\Deploy-50-MessagingManager-Function.ps1.liquid
 
tools\templates\messagebus\messagingmanager\Deploy-60-MessagingManager-ApiManagement.ps1.liquid
 
tools\templates\messagebus\messagingmanager\messagingmanager.apim.dev.parameters.json.liquid
 
tools\templates\messagebus\messagingmanager\messagingmanager.apim.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "apimServiceName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50
        },
        "apiName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "defaultValue": "aimmessagingmanager"
        },
        "messagingManagerAppServiceName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 60
        }
    },
    "variables": {
        "apiTagName": "[concat(parameters('apiName'), 'tag')]"
    },
    "resources": [
        {
            "type": "Microsoft.ApiManagement/service/apis",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'))]",
            "dependsOn": [
            ],
            "properties": {
                "displayName": "Messaging Manager",
                "description": "AIM Message Manager API - handles creation and update of messages.",
                "apiRevision": "1",
                "subscriptionRequired": true,
                "path": "aimmessagingmanager",
                "protocols": [
                    "https"
                ],
                "isCurrent": true
            },
            "resources": [
            ]
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/tags",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/', variables('apiTagName'))]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/tags', parameters('apimServiceName'), variables('apiTagName'))]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/backends",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'))]",
            "dependsOn": [],
            "properties": {
                "description": "AIM Messaging Manager Function Backend",
                "url": "[concat('https://', parameters('messagingManagerAppServiceName'), '.azurewebsites.net/api')]",
                "protocol": "http",
                "resourceId": "[concat('https://management.azure.com', resourceId('Microsoft.Web/sites', parameters('messagingManagerAppServiceName')))]",
                "credentials": {
                    "header": {
                        "x-functions-key": [
                            "[listkeys(concat(resourceId('Microsoft.Web/sites/', parameters('messagingManagerAppServiceName')), '/host/default/'),'2016-08-01').functionKeys.apiManagement]"
                        ]
                    }
                }
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/buildenvelope')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "displayName": "BuildEnvelope",
                "description": "Builds an envelope using the supplied body.",
                "method": "POST",
                "urlTemplate": "/buildenvelope/{envelopeType}/{scenario}",
                "templateParameters": [
                    {
                        "name": "envelopeType",
                        "description": "Type of envelope to build.",
                        "type": "string",
                        "required": true,
                        "values": []
                    },
                    {
                        "name": "scenario",
                        "description": "Name of the scenario to build the envelope for.",
                        "type": "string",
                        "required": false,
                        "values": []
                    }
                ],
                "request": {
                    "description": "Body content to use for the envelope's root part.",
                    "queryParameters": [
                        {
                            "name": "clearCache",
                            "description": "If true, then any cached config is cleared, and config is retrieved from App Config again.",
                            "type": "bool",
                            "defaultValue": "false",
                            "values": [
                                "true",
								"false"
                            ]
                        },
                        {
                            "name": "enableTrace",
                            "description": "If true, then an APIM trace URL is returned as a response header.",
                            "type": "bool",
                            "defaultValue": "false",
                            "values": [
                                "true",
								"false"
                            ]
                        },
                        {
                            "name": "encodeBody",
                            "description": "If true, then body content is always encoded using Bse64.",
                            "type": "bool",
                            "defaultValue": "true",
                            "values": [
                                "true",
								"false"
                            ]
                        }
                    ],
                    "headers": [
                        {
                            "name": "Content-Transfer-Encoding",
                            "description": "Transfer encoding used for the supplied body.",
                            "type": "string",
                            "required": false,
                            "defaultValue": "none",
                            "values": [
                                "none",
                                "base64"
                            ]
                        },
                        {
                            "name": "Aim-Tracking-Id",
                            "description": "Tracking ID used to link disparate messages together by AIM.",
                            "type": "string",
                            "required": false,
                            "defaultValue": ""
                        }
                    ],
                    "representations": [
                        {
                            "contentType": "text/plain"
                        },
                        {
                            "contentType": "text/json"
                        },
                        {
                            "contentType": "text/xml"
                        },
                        {
                            "contentType": "text/csv"
                        },
                        {
                            "contentType": "application/json"
                        },
                        {
                            "contentType": "application/xml"
                        }
                    ]
                },
                "responses": [
                    {
                        "statusCode": 200,
                        "description": "Have successfully built and returned an envelope message.",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n    \"header\": {\r\n        \"properties\": {\r\n            \"createDate\": \"2020-06-18T12:07:48.8125659Z\",\r\n            \"envelopeType\": \"ack\",\r\n            \"messageId\": \"f655c39f-55af-4255-afc2-813d765b6156\",\r\n            \"rootPart\": 1\r\n        },\r\n        \"routing\": {\r\n            \"MessageType\": \"http://schemas.microsoft.com/aim#ack\"\r\n        },\r\n        \"routingSlip\": {},\r\n        \"state\": {}\r\n    }\r\n    \"body\": [\r\n        {\r\n            \"$contentType\": \"application/json\",\r\n            \"$part\": 1,\r\n            \"$partType\": \"http://schemas.microsoft.com/aim#ack\",\r\n\t\t\t\"$content\": \"No more routes to process in RoutingSlip\"\r\n        }\r\n    ]\r\n}"
                            }
                        ],
                        "headers": []
                    },
                    {
                        "statusCode": 500,
                        "description": "An internal error has occurred, and a fault object has been returned.",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n  \"fault\": {\r\n    \"faultActor\": \"BuildEnvelope\",\r\n    \"faultCode\": \"500\",\r\n    \"faultReason\": \"Unknown error\",\r\n    \"faultCategory\": \"Error\",\r\n    \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n  }\r\n}"
                            }
                        ],
                        "headers": []
                    }
                ]
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/convertxmltojson')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "displayName": "ConvertXmlToJson",
                "method": "POST",
                "urlTemplate": "/convertxmltojson",
                "templateParameters": [],
                "description": "Converts a given XML Body to JSON. Can optionally remove the root node form the XML before converting.",
                "request": {
                    "queryParameters": [
                        {
                            "name": "removeOuterEnvelope",
                            "description": "Indicates if we should remove the outer element from the supplied XML before converting it.",
                            "type": "boolean",
                            "defaultValue": "false",
                            "values": [
                                "true",
                                "false"
                            ]
                        }
                    ],
                    "headers": [],
                    "representations": [
                        {
                            "contentType": "application/json"
                        }
                    ]
                },
                "responses": [
                    {
                        "statusCode": 200,
                        "description": "The supplied XML has been successfully converted to JSON.",
                        "representations": [
                            {
                                "contentType": "application/xml"
                            }
                        ],
                        "headers": []
                    },
                    {
                        "statusCode": 500,
                        "description": "An error occurred trying to convert the XML to JSON and a Fault object has been returned.",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n  \"fault\": {\r\n    \"faultActor\": \"ConvertXmlToJson\",\r\n    \"faultCode\": \"500\",\r\n    \"faultReason\": \"Unknown error\",\r\n    \"faultCategory\": \"Error\",\r\n    \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n  }\r\n}"
                            }
                        ],
                        "headers": []
                    }
                ]
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/convertjsontoxml')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "displayName": "ConvertJsonToXml",
                "method": "POST",
                "urlTemplate": "/convertjsontoxml",
                "templateParameters": [],
                "description": "Converts a given JSON Body to XML. Can optionally wrap the converted JSON in a root node with a namespace. Note: if the JSON message contains multiple root properties, an XML Root Node must be supplied.",
                "request": {
                    "queryParameters": [
                        {
                            "name": "addMessageBodyForEmptyMessage",
                            "description": "Indicates if we create an XML body if an empty JSON message is supplied.",
                            "type": "boolean",
                            "defaultValue": "false",
                            "values": [
                                "true",
                                "false"
                            ]
                        },
                        {
                            "name": "rootNode",
                            "description": "Optional XML Root Node name, used to wrap the generated XML.",
                            "type": "string",
                            "values": []
                        },
                        {
                            "name": "rootNodeNamespace",
                            "description": "Optional XML Root Node Namespace to use.",
                            "type": "string",
                            "values": []
                        },
                        {
                            "name": "writeArrayAttribute",
                            "description": "Indicates if we should add a special attribute to arrays, so that if we convert back to JSON, arrays with a single element are correctly handled",
                            "type": "boolean",
                            "defaultValue": "true",
                            "values": [
                                "true",
                                "false"
                            ]
                        },
                        {
                            "name": "encodeSpecialCharacters",
                            "description": "Indicates if we encode JSON control characters.",
                            "type": "boolean",
                            "defaultValue": "false",
                            "values": [
                                "true",
                                "false"
                            ]
                        }
                    ],
                    "headers": [],
                    "representations": [
                        {
                            "contentType": "application/json"
                        }
                    ]
                },
                "responses": [
                    {
                        "statusCode": 200,
                        "description": "The supplied JSON has been successfully converted to XML.",
                        "representations": [
                            {
                                "contentType": "application/xml"
                            }
                        ],
                        "headers": []
                    },
                    {
                        "statusCode": 500,
                        "description": "An error occurred trying to convert the JSON to XML and a Fault object has been returned",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n  \"fault\": {\r\n    \"faultActor\": \"ConvertJsonToXml\",\r\n    \"faultCode\": \"500\",\r\n    \"faultReason\": \"Unknown error\",\r\n    \"faultCategory\": \"Error\",\r\n    \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n  }\r\n}"
                            }
                        ],
                        "headers": []
                    }
                ]
            }
        },
         {
            "type": "Microsoft.ApiManagement/service/apis/operations",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/wrapxmlenvelope')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "displayName": "WrapXmlEnvelope",
                "method": "POST",
                "urlTemplate": "/wrapxmlenvelope",
                "templateParameters": [],
                "description": "Wraps an XML envelope around the supplied XML body content.",
                "request": {
                    "queryParameters": [
                        {
                            "name": "emitXMlDeclaration",
                            "description": "Indicates if we emit an XML Declaration at the start of the returned content.",
                            "type": "boolean",
                            "defaultValue": "false",
                            "values": [
                                "true",
                                "false"
                            ]
                        },
                        {
                            "name": "envelopeSpecNames",
                            "description": "Pipe-separated list of envelope schema names.",
                            "type": "string",
                            "values": []
                        }
                    ],
                    "headers": [],
                    "representations": [
                        {
                            "contentType": "application/xml"
                        },
                        {
                            "contentType": "text/xml"
                        }
                    ]
                },
                "responses": [
                    {
                        "statusCode": 200,
                        "description": "The supplied XML content has been successfully wrapped in an envelope.",
                        "representations": [
                            {
                                "contentType": "application/xml"
                            }
                        ],
                        "headers": []
                    },
                    {
                        "statusCode": 500,
                        "description": "An error occurred trying to wrap the content in an Envelope and a Fault object has been returned",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n  \"fault\": {\r\n    \"faultActor\": \"WrapXmlEnvelope\",\r\n    \"faultCode\": \"500\",\r\n    \"faultReason\": \"Unknown error\",\r\n    \"faultCategory\": \"Error\",\r\n    \"faultMessage\": \"The supplied request body does not contain XML.\"\r\n  }\r\n}"
                            }
                        ],
                        "headers": []
                    }
                ]
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/decodebodycontent')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "displayName": "DecodeBodyContent",
                "description": "Decodes and returns the content from the root body part in the supplied envelope message.",
                "method": "POST",
                "urlTemplate": "/decodebodycontent",
                "templateParameters": [],
                "request": {
                    "queryParameters": [
                        {
                            "name": "clearCache",
                            "description": "If true, then any cached config is cleared, and config is retrieved from App Config again.",
                            "type": "bool",
                            "defaultValue": "false",
                            "values": [
                                "true",
								"false"
                            ]
                        },
                        {
                            "name": "enableTrace",
                            "description": "If true, then an APIM trace URL is returned as a response header.",
                            "type": "bool",
                            "defaultValue": "false",
                            "values": [
                                "true",
								"false"
                            ]
                        }
                    ],
                    "headers": [
                        {
                            "name": "Aim-Tracking-Id",
                            "description": "Tracking ID used to link disparate messages together by AIM.",
                            "type": "string",
                            "required": false,
                            "defaultValue": ""
                        }
                    ],
                    "representations": [
                        {
                            "contentType": "text/json",
                            "sample": "{\r\n    \"header\": {\r\n        \"properties\": {},\r\n        \"state\": {},\r\n        \"routing\": {},\r\n        \"routingSlip\": {\r\n            \"scenario\": \"\",\r\n            \"nextRoute\": 0,\r\n            \"routes\": []\r\n        }\r\n    },\r\n    \"body\": []\r\n}"
                        },
                        {
                            "contentType": "application/json",
                            "sample": "{\r\n    \"header\": {\r\n        \"properties\": {},\r\n        \"state\": {},\r\n        \"routing\": {},\r\n        \"routingSlip\": {\r\n            \"scenario\": \"\",\r\n            \"nextRoute\": 0,\r\n            \"routes\": []\r\n        }\r\n    },\r\n    \"body\": []\r\n}"
                        }
                    ]
                },
                "responses": [
                    {
                        "statusCode": 200,
                        "description": "Body content has been retrieved and returned.",
                        "representations": [
                            {
                                "contentType": "text/plain"
                            },
                            {
                                "contentType": "text/json"
                            },
                            {
                                "contentType": "text/xml"
                            },
                            {
                                "contentType": "text/csv"
                            },
                            {
                                "contentType": "application/json"
                            },
                            {
                                "contentType": "application/xml"
                            }
                        ],
                        "headers": []
                    },
                    {
                        "statusCode": 500,
                        "description": "An internal error has occurred, and a fault object has been returned.",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n  \"fault\": {\r\n    \"faultActor\": \"DecodeBodyContent\",\r\n    \"faultCode\": \"500\",\r\n    \"faultReason\": \"Unknown error\",\r\n    \"faultCategory\": \"Error\",\r\n    \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n  }\r\n}"
                            }
                        ],
                        "headers": []
                    }
                ]
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/getbodycontent')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "displayName": "GetBodyContent",
                "description": "Returns encoded content from the root body part in the supplied envelope message.",
                "method": "POST",
                "urlTemplate": "/getbodycontent",
                "templateParameters": [],
                "request": {
                    "queryParameters": [
                        {
                            "name": "clearCache",
                            "description": "If true, then any cached config is cleared, and config is retrieved from App Config again.",
                            "type": "bool",
                            "defaultValue": "false",
                            "values": [
                                "true",
								"false"
                            ]
                        },
                        {
                            "name": "enableTrace",
                            "description": "If true, then an APIM trace URL is returned as a response header.",
                            "type": "bool",
                            "defaultValue": "false",
                            "values": [
                                "true",
								"false"
                            ]
                        }
                    ],
                    "headers": [
                        {
                            "name": "Aim-Tracking-Id",
                            "description": "Tracking ID used to link disparate messages together by AIM.",
                            "type": "string",
                            "required": false,
                            "defaultValue": ""
                        }
                    ],
                    "representations": [
                        {
                            "contentType": "text/json",
                            "sample": "{\r\n    \"header\": {\r\n        \"properties\": {},\r\n        \"state\": {},\r\n        \"routing\": {},\r\n        \"routingSlip\": {\r\n            \"scenario\": \"\",\r\n            \"nextRoute\": 0,\r\n            \"routes\": []\r\n        }\r\n    },\r\n    \"body\": []\r\n}"
                        },
                        {
                            "contentType": "application/json",
                            "sample": "{\r\n    \"header\": {\r\n        \"properties\": {},\r\n        \"state\": {},\r\n        \"routing\": {},\r\n        \"routingSlip\": {\r\n            \"scenario\": \"\",\r\n            \"nextRoute\": 0,\r\n            \"routes\": []\r\n        }\r\n    },\r\n    \"body\": []\r\n}"
                        }
                    ]
                },
                "responses": [
                    {
                        "statusCode": 200,
                        "description": "Body content has been retrieved and returned.",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n    \"$contentType\": \"text/plain\",\r\n    \"$content\": \"SGVsbG8\"\r\n}"
                            }
                        ],
                        "headers": []
                    },
                    {
                        "statusCode": 500,
                        "description": "An internal error has occurred, and a fault object has been returned.",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n  \"fault\": {\r\n    \"faultActor\": \"GetBodyContent\",\r\n    \"faultCode\": \"500\",\r\n    \"faultReason\": \"Unknown error\",\r\n    \"faultCategory\": \"Error\",\r\n    \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n  }\r\n}"
                            }
                        ],
                        "headers": []
                    }
                ]
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/mergeproperties')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "displayName": "MergeProperties",
                "description": "Merges the contents of an array of property bags together and returns the result.",
                "method": "POST",
                "urlTemplate": "/mergeproperties",
                "templateParameters": [],
                "request": {
                    "queryParameters": [],
                    "headers": [
                        {
                            "name": "Aim-Tracking-Id",
                            "description": "Tracking ID used to link disparate messages together by AIM.",
                            "type": "string",
                            "required": false,
                            "defaultValue": ""
                        }
                    ],
                    "representations": [
                        {
                            "contentType": "text/json",
                            "sample": "[\r\n    {\r\n        \"properties\": \r\n        {\r\n            \"property1\": \"value1\",\r\n            \"property2\": \"value2\"\r\n        }\r\n    },\r\n    {\r\n        \"properties\": \r\n        {\r\n            \"property1\": \"value3\",\r\n            \"property4\": \"value4\"\r\n        }\r\n    }\r\n]\r\n"
                        },
                        {
                            "contentType": "application/json",
                            "sample": "[\r\n    {\r\n        \"properties\": \r\n        {\r\n            \"property1\": \"value1\",\r\n            \"property2\": \"value2\"\r\n        }\r\n    },\r\n    {\r\n        \"properties\": \r\n        {\r\n            \"property1\": \"value3\",\r\n            \"property4\": \"value4\"\r\n        }\r\n    }\r\n]\r\n"
                        }
                    ]
                },
                "responses": [
                    {
                        "statusCode": 200,
                        "description": "Property bags have been merged successfully.",
                        "representations": [
                            {
                                "contentType": "application/json"
                            }
                        ],
                        "headers": []
                    },
                    {
                        "statusCode": 500,
                        "description": "An internal error has occurred, and a fault object has been returned.",
                        "representations": [
                            {
                                "contentType": "application/json",
                                "sample": "{\r\n  \"fault\": {\r\n    \"faultActor\": \"MergeProperties\",\r\n    \"faultCode\": \"500\",\r\n    \"faultReason\": \"Unknown error\",\r\n    \"faultCategory\": \"Error\",\r\n    \"faultMessage\": \"The supplied request body contains an empty JSON array\"\r\n  }\r\n}"
                            }
                        ],
                        "headers": []
                    }
                ]
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations/policies",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/buildenvelope/policy')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'buildenvelope')]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
                "[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "value": "<policies>\r\n  <inbound>\r\n    <base />\r\n    <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimmessagingmanager\" />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <base />\r\n  </outbound>\r\n  <on-error>\r\n    <base />\r\n  </on-error>\r\n</policies>",
                "format": "xml"
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations/policies",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/convertjsontoxml/policy')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'convertjsontoxml')]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
                "[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "value": "<policies>\r\n  <inbound>\r\n    <base />\r\n    <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimmessagingmanager\" />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <base />\r\n  </outbound>\r\n  <on-error>\r\n    <base />\r\n  </on-error>\r\n</policies>",
                "format": "xml"
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations/policies",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/convertxmltojson/policy')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'convertxmltojson')]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
                "[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "value": "<policies>\r\n  <inbound>\r\n    <base />\r\n    <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimmessagingmanager\" />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <base />\r\n  </outbound>\r\n  <on-error>\r\n    <base />\r\n  </on-error>\r\n</policies>",
                "format": "xml"
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations/policies",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/wrapxmlenvelope/policy')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'wrapxmlenvelope')]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
                "[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "value": "<policies>\r\n  <inbound>\r\n    <base />\r\n    <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimmessagingmanager\" />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <base />\r\n  </outbound>\r\n  <on-error>\r\n    <base />\r\n  </on-error>\r\n</policies>",
                "format": "xml"
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations/policies",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/decodebodycontent/policy')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'decodebodycontent')]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
                "[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "value": "<policies>\r\n  <inbound>\r\n    <base />\r\n    <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimmessagingmanager\" />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <base />\r\n  </outbound>\r\n  <on-error>\r\n    <base />\r\n  </on-error>\r\n</policies>",
                "format": "xml"
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations/policies",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/getbodycontent/policy')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'getbodycontent')]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
                "[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "value": "<policies>\r\n  <inbound>\r\n    <base />\r\n    <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimmessagingmanager\" />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <base />\r\n  </outbound>\r\n  <on-error>\r\n    <base />\r\n  </on-error>\r\n</policies>",
                "format": "xml"
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/apis/operations/policies",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', parameters('apiName'), '/mergeproperties/policy')]",
            "dependsOn": [
                "[resourceId('Microsoft.ApiManagement/service/apis/operations', parameters('apimServiceName'), parameters('apiName'), 'mergeproperties')]",
                "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), parameters('apiName'))]",
                "[resourceId('Microsoft.ApiManagement/service/backends', parameters('apimServiceName'), parameters('apiName'))]"
            ],
            "properties": {
                "value": "<policies>\r\n  <inbound>\r\n    <base />\r\n    <set-backend-service id=\"apim-generated-policy\" backend-id=\"aimmessagingmanager\" />\r\n  </inbound>\r\n  <backend>\r\n    <base />\r\n  </backend>\r\n  <outbound>\r\n    <base />\r\n  </outbound>\r\n  <on-error>\r\n    <base />\r\n  </on-error>\r\n</policies>",
                "format": "xml"
            }
        },
        {
            "type": "Microsoft.ApiManagement/service/tags",
            "apiVersion": "2019-12-01",
            "name": "[concat(parameters('apimServiceName'), '/', variables('apiTagName'))]",
            "dependsOn": [
            ],
            "properties": {
                "displayName": "messagingmanager"
            }
        }
    ]
}
tools\templates\messagebus\messagingmanager\messagingmanager.apim.prod.parameters.json.liquid
 
tools\templates\messagebus\messagingmanager\messagingmanager.func.dev.parameters.json.liquid
 
tools\templates\messagebus\messagingmanager\messagingmanager.func.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "functionAppName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 60
        },
        "functionAppLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]"
        },
        "storageAccountName": {
            "type": "string",
            "minLength": 3,
            "maxLength": 24
        },
        "appInsightsName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 260
        },
        "appServicePlanName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
        },
        "apimServiceName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50
        },
        "enableOAuthForApim": {
            "type": "bool",
            "defaultValue": false
        },
        "enableOAuthForLogicApps": {
            "type": "bool",
            "defaultValue": false
        },
        "enableOAuthForManagementAPI": {
            "type": "bool",
            "defaultValue": false
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "storageAccountId": "[resourceId(resourceGroup().name, 'Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
    },
    "resources": [
        {
            "apiVersion": "2019-08-01",
            "type": "Microsoft.Web/sites",
            "name": "[parameters('functionAppName')]",
            "location": "[parameters('functionAppLocation')]",
            "tags": "[parameters('tags')]",
            "kind": "functionapp",
            "properties": {
                "serverFarmId": "[concat(resourceId(resourceGroup().name, 'Microsoft.Web/serverfarms', parameters('appServicePlanName')))]",
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "AzureWebJobsStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), '2019-06-01').keys[0].value)]"
                        },
                        {
                            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                            "value": "[reference(resourceId(resourceGroup().name, 'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"
                        },
                        {
                            "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), '2019-06-01').keys[0].value)]"
                        },
                        {
                            "name": "WEBSITE_CONTENTSHARE",
                            "value": "[toLower(parameters('functionAppName'))]"
                        },
                        {
                            "name": "FUNCTIONS_WORKER_RUNTIME",
                            "value": "dotnet"
                        },
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~3"
                        },
                        {
                            "name": "ApimSubscriptionKey",
                            "value": "[reference(resourceId('Microsoft.ApiManagement/service/subscriptions', parameters('apimServiceName'), 'master'), '2019-01-01').primaryKey]"
                        },
                        {
                            "name": "ApimInstanceName",
                            "value": "[parameters('apimServiceName')]"
                        },
                        {
                            "name": "EnableOAuthForApim",
                            "value": "[parameters('enableOAuthForApim')]"
                        },
                        {
                            "name": "EnableOAuthForLogicApps",
                            "value": "[parameters('enableOAuthForLogicApps')]"
                        },
                        {
                            "name": "EnableOAuthForManagementAPI",
                            "value": "[parameters('enableOAuthForManagementAPI')]"
                        }
                    ]
                }
            }
        },
        {
            "apiVersion": "2018-11-01",
            "type": "Microsoft.Web/sites/host/functionKeys",
            "name": "[concat(parameters('functionAppName'), '/default/apiManagement')]",
            "properties": {
                "name": "[parameters('apimServiceName')]"
            },
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('functionAppName'))]"
            ]
        }
    ]
}
tools\templates\messagebus\messagingmanager\messagingmanager.func.prod.parameters.json.liquid
 
tools\templates\messagebus\messagingmanager\Microsoft.AzureIntegrationMigration.FunctionApp.MessagingManager.zip
md5: C70A28150A4F8A81C56E189A770A6C80 | sha1: EBBFB0367D56ACACB0FD4BED8AA4189F2AE50744 | sha256: FC8BDA413A17B98F4E25F82E2602FC0A96EB7246142590BF8BBA406D72563024 | sha512: 43407B067FEA87F87034F1DD5A1543FC850CFAA19E3426BD48D6BC1E5289509E40184E6881B842F870857543278B38F6AC966450BA4239DD12A68EBBA07B66BC
tools\templates\messagebus\messagingmanager\New-MessagingManager-ApiManagement.ps1
<#
.SYNOPSIS
Creates an API resource in API Management for the messaging manager.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the API Management service is located.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER apimServiceName
The name of the API Management service.

.PARAMETER apiName
The name of the API being deployed.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-MessagingManager-ApiManagement.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -apimServiceName "apim-aimmsgbussvc-dev" -apiName "aimroutingmanager" -templateFile ".\routingmanager.apim.json" -templateParameterFile ".\routingmanager.apim.dev.parameters" -deploymentName "routingmanager.apim"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $apimServiceName,
    [parameter(Mandatory = $true)]
    [string] $apiName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

Write-Host "Deploying the API for the messaging manager`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"

Write-Host "Associating the API Management service $apimServiceName products to the API $apiName"

$products = az rest -m GET -u https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products?api-version=2018-01-01 | ConvertFrom-Json | Select-Object -ExpandProperty value

if ($products) {
    Write-Host "Found products for API Management service $apimServiceName"

    ForEach ($product in $products) {
        $productName = $product.name

        Write-Host "Associating product $productName with the messaging manager API"

        # PowerShell doesn't like variable expansion when a ? follows the variable
        $url = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products/$productName/apis/" + $apiName + "?api-version=2018-01-01"
		
        az rest -m PUT -u $url
    }
}
else {
    throw "Failed to get products for API Management service $apimServiceName"
}
tools\templates\messagebus\messagingmanager\New-MessagingManager-Function.ps1
<#
.SYNOPSIS
Creates a Function resource which implements the messaging manager operations.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER resourceName
Name of the Function App.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.PARAMETER zipFile
Name of the zip file containing the Function App.

.EXAMPLE
./New-MessagingManager-Function.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -templateFile ".\messagingmanager.func.json" -templateParameterFile ".\messagingmanager.func.dev.parameters" -deploymentName "messagingmanager.func"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName,
    [parameter(Mandatory = $true)]
    [string] $zipFile
)

Write-Host "Deploying the messaging manager function`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"

Write-Host "Uploading the messaging manager function zip package $zipFile"

if (!(Test-Path $zipFile)) {
    throw "Zip file $zipFile doesn't exist, unable to upload"
}

az functionapp deployment source config-zip --resource-group $resourceGroupName --name $resourceName --src $zipFile

Write-Host "Upload complete"
tools\templates\messagebus\messagingmanager\Remove-MessagingManager-ApiManagement.ps1
<#
.SYNOPSIS
Tears down the API resource in API Management for the messaging manager.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER serviceName
The name of the API Management service to find the resource.

.PARAMETER apiName
The name of the API resource in API Management to remove.

.EXAMPLE
./Remove-MessagingManager-ApiManagement.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -serviceName "apim-aimmsgbussvc-dev" -apiName "aimmessagingmanager"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $serviceName,
    [parameter(Mandatory = $true)]
    [string] $apiName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

if ($resourceExists) {
    Write-Host "Removing the API resource for service $serviceName : $apiName"

    az resource delete --resource-group $resourceGroupName --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

    Write-Host "Removed the API resource for service $serviceName : $apiName"
}
else {
    Write-Host "The API resource $apiName for service $serviceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\messagingmanager\Remove-MessagingManager-Function.ps1
<#
.SYNOPSIS
Tears down the Function resource.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-MessagingManager-Function.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -resourceName "func-aimmsgmgr-dev-001"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az functionapp show --name $resourceName --resource-group $resourceGroupName

if ($resourceExists) {
    Write-Host "Removing the messaging manager function resource: $resourceName"

    az functionapp delete --name $resourceName --resource-group $resourceGroupName

    Write-Host "Removed the messaging manager function resource: $resourceName"
}
else {
    Write-Host "The messaging manager function resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\messagingmanager\TearDown-50-MessagingManager-Function.ps1.liquid
 
tools\templates\messagebus\messagingmanager\TearDown-60-MessagingManager-ApiManagement.ps1.liquid
 
tools\templates\messagebus\routingmanager\Deploy-50-RoutingManager-Function.ps1.liquid
 
tools\templates\messagebus\routingmanager\Deploy-60-RoutingManager-ApiManagement.ps1.liquid
 
tools\templates\messagebus\routingmanager\Microsoft.AzureIntegrationMigration.FunctionApp.RoutingManager.zip
md5: C28CAAE7E279630BCC6E7F7E28766FF5 | sha1: 23103C5E5C1726DCDC9C2B594351ED32ED43DCD1 | sha256: D362D54DCFDDF5F94494BF01293DC008E5EA61071A4231ABD30B7F5AD072B73E | sha512: C7DE84EC51B2677D78276545C2B787D42B2D25A3191394CF60982D32FAFE14578E09C036A33575835986EC2C5DB1EAC9F8D9AE7BF16D937D233CD866DFF19B07
tools\templates\messagebus\routingmanager\New-RoutingManager-ApiManagement.ps1
<#
.SYNOPSIS
Creates an API resource in API Management for the routing manager.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the API Management service is located.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER apimServiceName
The name of the API Management service.

.PARAMETER apiName
The name of the API being deployed.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-RoutingManager-ApiManagement.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -apimServiceName "apim-aimmsgbussvc-dev" -apiName "aimroutingmanager" -templateFile ".\routingmanager.apim.json" -templateParameterFile ".\routingmanager.apim.dev.parameters" -deploymentName "routingmanager.apim"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $apimServiceName,
    [parameter(Mandatory = $true)]
    [string] $apiName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

Write-Host "Deploying the API for the routing manager`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"

Write-Host "Associating the API Management service $apimServiceName products to the API $apiName"

$products = az rest -m GET -u https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products?api-version=2018-01-01 | ConvertFrom-Json | Select-Object -ExpandProperty value

if ($products) {
    Write-Host "Found products for API Management service $apimServiceName"

    ForEach ($product in $products) {
        $productName = $product.name

        Write-Host "Associating product $productName with the routing manager API"

        # PowerShell doesn't like variable expansion when a ? follows the variable
        $url = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products/$productName/apis/" + $apiName + "?api-version=2018-01-01"
		
        az rest -m PUT -u $url
    }
}
else {
    throw "Failed to get products for API Management service $apimServiceName"
}
tools\templates\messagebus\routingmanager\New-RoutingManager-Function.ps1
<#
.SYNOPSIS
Creates a Function resource which implements the routing manager operations.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER resourceName
Name of the Function App.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.PARAMETER zipFile
Name of the zip file containing the Function App.

.EXAMPLE
./New-RoutingManager-Function.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -templateFile ".\routingmanager.func.json" -templateParameterFile ".\routingmanager.func.dev.parameters" -deploymentName "routingmanager.func"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName,
    [parameter(Mandatory = $true)]
    [string] $zipFile
)

Write-Host "Deploying the routing manager function`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"

Write-Host "Uploading the routing manager function zip package $zipFile"

if (!(Test-Path $zipFile)) {
    throw "Zip file $zipFile doesn't exist, unable to upload"
}

az functionapp deployment source config-zip --resource-group $resourceGroupName --name $resourceName --src $zipFile

Write-Host "Upload complete"
tools\templates\messagebus\routingmanager\Remove-RoutingManager-ApiManagement.ps1
<#
.SYNOPSIS
Tears down the API resource in API Management for the routing manager.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER serviceName
The name of the API Management service to find the resource.

.PARAMETER apiName
The name of the API resource in API Management to remove.

.EXAMPLE
./Remove-RoutingManager-ApiManagement.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -serviceName "apim-aimmsgbussvc-dev" -apiName "aimroutingmanager"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $serviceName,
    [parameter(Mandatory = $true)]
    [string] $apiName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

if ($resourceExists) {
    Write-Host "Removing the API resource for service $serviceName : $apiName"

    az resource delete --resource-group $resourceGroupName --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

    Write-Host "Removed the API resource for service $serviceName : $apiName"
}
else {
    Write-Host "The API resource $apiName for service $serviceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\routingmanager\Remove-RoutingManager-Function.ps1
<#
.SYNOPSIS
Tears down the Function resource.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-RoutingManager-Function.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -resourceName "func-aimroutemgr-dev-001"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az functionapp show --name $resourceName --resource-group $resourceGroupName

if ($resourceExists) {
    Write-Host "Removing the routing manager function resource: $resourceName"

    az functionapp delete --name $resourceName --resource-group $resourceGroupName

    Write-Host "Removed the routing manager function resource: $resourceName"
}
else {
    Write-Host "The routing manager function resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\routingmanager\routingmanager.apim.dev.parameters.json.liquid
 
tools\templates\messagebus\routingmanager\routingmanager.apim.json.liquid
 
tools\templates\messagebus\routingmanager\routingmanager.apim.prod.parameters.json.liquid
 
tools\templates\messagebus\routingmanager\routingmanager.func.dev.parameters.json.liquid
 
tools\templates\messagebus\routingmanager\routingmanager.func.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "functionAppName": {
            "type": "string",
            "minLength": 2,
            "maxLength": 60
        },
        "functionAppLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]"
        },
        "storageAccountName": {
            "type": "string",
            "minLength": 3,
            "maxLength": 24
        },
        "appInsightsName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 260
        },
        "appServicePlanName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 40
        },
        "apiManagementServiceName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 50
        },
        "enableOAuthForApim": {
            "type": "bool",
            "defaultValue": false
        },
        "enableOAuthForLogicApps": {
            "type": "bool",
            "defaultValue": false
        },
        "enableOAuthForManagementAPI": {
            "type": "bool",
            "defaultValue": false
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "storageAccountId": "[resourceId(resourceGroup().name, 'Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
    },
    "resources": [
        {
            "apiVersion": "2019-08-01",
            "type": "Microsoft.Web/sites",
            "name": "[parameters('functionAppName')]",
            "location": "[parameters('functionAppLocation')]",
            "tags": "[parameters('tags')]",
            "kind": "functionapp",
            "properties": {
                "serverFarmId": "[concat(resourceId(resourceGroup().name, 'Microsoft.Web/serverfarms', parameters('appServicePlanName')))]",
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "AzureWebJobsStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), '2019-06-01').keys[0].value)]"
                        },
                        {
                            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                            "value": "[reference(resourceId(resourceGroup().name, 'Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"
                        },
                        {
                            "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), '2019-06-01').keys[0].value)]"
                        },
                        {
                            "name": "WEBSITE_CONTENTSHARE",
                            "value": "[toLower(parameters('functionAppName'))]"
                        },
                        {
                            "name": "FUNCTIONS_WORKER_RUNTIME",
                            "value": "dotnet"
                        },
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~3"
                        },
                        {
                            "name": "ApimSubscriptionKey",
                            "value": "[reference(resourceId('Microsoft.ApiManagement/service/subscriptions', parameters('apiManagementServiceName'), 'master'), '2019-01-01').primaryKey]"
                        },
                        {
                            "name": "ApimInstanceName",
                            "value": "[parameters('apiManagementServiceName')]"
                        },
                        {
                            "name": "EnableOAuthForApim",
                            "value": "[parameters('enableOAuthForApim')]"
                        },
                        {
                            "name": "EnableOAuthForLogicApps",
                            "value": "[parameters('enableOAuthForLogicApps')]"
                        },
                        {
                            "name": "EnableOAuthForManagementAPI",
                            "value": "[parameters('enableOAuthForManagementAPI')]"
                        }
                    ]
                }
            }
        },
        {
            "apiVersion": "2018-11-01",
            "type": "Microsoft.Web/sites/host/functionKeys",
            "name": "[concat(parameters('functionAppName'), '/default/apiManagement')]",
            "properties": {
                "name": "[parameters('apiManagementServiceName')]"
            },
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('functionAppName'))]"
            ]
        }
    ]
}
tools\templates\messagebus\routingmanager\routingmanager.func.prod.parameters.json.liquid
 
tools\templates\messagebus\routingmanager\TearDown-50-RoutingManager-Function.ps1.liquid
 
tools\templates\messagebus\routingmanager\TearDown-60-RoutingManager-ApiManagement.ps1.liquid
 
tools\templates\messagebus\routingstore\Deploy-15-RoutingStore-KeyVault.ps1.liquid
 
tools\templates\messagebus\routingstore\Deploy-20-RoutingStore-AppConfig.ps1.liquid
 
tools\templates\messagebus\routingstore\Deploy-40-RoutingStore-ApiManagement.ps1.liquid
 
tools\templates\messagebus\routingstore\New-RoutingStore-ApiManagement.ps1
<#
.SYNOPSIS
Creates an API resource in API Management for the routing store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the API Management service is located.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER apimServiceName
The name of the API Management service.

.PARAMETER apiName
The name of the API being deployed.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-RoutingStore-ApiManagement.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -apimServiceName "apim-aimmsgbussvc-dev" -apiName "aimroutingstore" -templateFile ".\routingstore.apim.json" -templateParameterFile ".\routingstore.apim.dev.parameters" -deploymentName "routingstore.apim"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $apimServiceName,
    [parameter(Mandatory = $true)]
    [string] $apiName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

Write-Host "Deploying the API for the routing store`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"

Write-Host "Associating the API Management service $apimServiceName products to the API $apiName"

$products = az rest -m GET -u https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products?api-version=2018-01-01 | ConvertFrom-Json | Select-Object -ExpandProperty value

if ($products) {
    Write-Host "Found products for API Management service $apimServiceName"

    ForEach ($product in $products) {
        $productName = $product.name

        Write-Host "Associating product $productName with the routing store API"

        # PowerShell doesn't like variable expansion when a ? follows the variable
        $url = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.ApiManagement/service/$apimServiceName/products/$productName/apis/" + $apiName + "?api-version=2018-01-01"
		
        az rest -m PUT -u $url
    }
}
else {
    throw "Failed to get products for API Management service $apimServiceName"
}
tools\templates\messagebus\routingstore\New-RoutingStore-AppConfig.ps1
<#
.SYNOPSIS
Creates a App Config resource for the routing store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER subscriptionId
The Azure subscription ID where the Key Vault service is located.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER appConfigName
The name of the Azure App Configuration service.

.PARAMETER keyVaultName
The name of the Azure Key Vault service.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-RoutingStore-AppConfig.ps1 -subscriptionId "<azure-subs-id>" -resourceGroupName "rg-aimmsgbus-dev-uksouth" -appConfigName "appcfg-aimrstore-dev" -keyVaultName "kv-aimrstore-dev" -templateFile ".\routingstore.appcfg.json" -templateParameterFile ".\routingstore.appcfg.dev.parameters" -deploymentName "routingstore.appcfg"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [AllowNull()]
    [AllowEmptyString()]
    [string] $subscriptionId,
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $appConfigName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

if ($subscriptionId -eq "") {
    Write-Host "No Azure subscription ID specified, finding from current active subscription"

    $subscriptionId = az account show | ConvertFrom-Json | Select-Object -ExpandProperty id

    if ($subscriptionId) {
        Write-Host "Found subscription ID $subscriptionId"
    }
    else {
        throw "No subscription ID found, an active subscription may not have been set in the Azure CLI"
    }
}

Write-Host "Deploying the routing store`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"

Write-Host "Getting managed identity principal ID for App Configuration resource $appConfigName"

$principalId = az appconfig show --name $appConfigName --resource-group $resourceGroupName | ConvertFrom-Json | Select-Object -ExpandProperty identity | Select-Object -ExpandProperty principalId

if ($principalId) {
    Write-Host "Principal ID is $principalId"
}
else {
    throw "Unable to get managed identity principal ID for $appConfigName"
}

$role = "Key Vault Secrets User"

Write-Host "Adding role assignment for $principalId to role $role for Key Vault resource $keyVaultName"

az role assignment create --assignee $principalId --role "$role" --scope /subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.KeyVault/vaults/$keyVaultName

Write-Host "Assigned managed identity of App Configuration resource $appConfigName to $keyVaultName"
tools\templates\messagebus\routingstore\New-RoutingStore-KeyVault.ps1
<#
.SYNOPSIS
Creates a Key Vault resource for the routing store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER name
Name of the Key Vault that will be created.

.PARAMETER location
Location where the resource will be created.

.PARAMETER sku
The sku level for the Key Vault resource.

.PARAMETER tags
The tags to apply to the Key Vault resource.

.EXAMPLE
./New-RoutingStore-KeyVault.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -name "kv-aimrstore-dev" -location "UK South" -sku "Standard"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $name,
    [parameter(Mandatory = $true)]
    [string] $location,
    [parameter(Mandatory = $false)]
    [string] $sku = "Standard",
    [parameter(Mandatory = $false)]
    [string[]] $tags = ""
)

Write-Host "Deploying the routing store Key Vault $name"

az keyvault create --name $name --resource-group $resourceGroupName --location $location --sku $sku --no-self-perms false --enable-soft-delete false --enabled-for-template-deployment true --tags $tags

Write-Host "Deployment complete"
tools\templates\messagebus\routingstore\Remove-RoutingStore-ApiManagement.ps1
<#
.SYNOPSIS
Tears down the API resource in API Management for the routing store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER serviceName
The name of the API Management service to find the resource.

.PARAMETER apiName
The name of the API resource in API Management to remove.

.EXAMPLE
./Remove-RoutingStore-ApiManagement.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -serviceName "apim-aimmsgbussvc-dev" -apiName "aimroutingstore"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $serviceName,
    [parameter(Mandatory = $true)]
    [string] $apiName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

if ($resourceExists) {
    Write-Host "Removing the API resource for service $serviceName : $apiName"

    az resource delete --resource-group $resourceGroupName --name $apiName --namespace "Microsoft.ApiManagement" --parent "service/$serviceName" --resource-type "apis"

    Write-Host "Removed the API resource for service $serviceName : $apiName"
}
else {
    Write-Host "The API resource $apiName for service $serviceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\routingstore\Remove-RoutingStore-AppConfig.ps1
<#
.SYNOPSIS
Tears down the App Config resource for the routing store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-RoutingStore-AppConfig.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -resourceName "appcfg-aimrstore-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az appconfig show --name $resourceName --resource-group $resourceGroupName

if ($resourceExists) {
    Write-Host "Removing the app config resource: $resourceName"

    az appconfig delete --name $resourceName --resource-group $resourceGroupName --yes

    Write-Host "Removed the app config resource: $resourceName"
}
else {
    Write-Host "The app config resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\routingstore\Remove-RoutingStore-KeyVault.ps1
<#
.SYNOPSIS
Tears down the Key Vault resource for the routing store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
./Remove-RoutingStore-KeyVault.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -resourceName "kv-aimrstore-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az keyvault show --name $resourceName --resource-group $resourceGroupName

if ($resourceExists) {
    Write-Host "Removing the key vault resource: $resourceName"

    az keyvault delete --name $resourceName --resource-group $resourceGroupName

    Write-Host "Removed the key vault resource: $resourceName"
}
else {
    Write-Host "The key vault resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\routingstore\routingstore.apim.dev.parameters.json.liquid
 
tools\templates\messagebus\routingstore\routingstore.apim.json.liquid
 
tools\templates\messagebus\routingstore\routingstore.apim.prod.parameters.json.liquid
 
tools\templates\messagebus\routingstore\routingstore.appcfg.dev.parameters.json.liquid
 
tools\templates\messagebus\routingstore\routingstore.appcfg.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appConfigName": {
            "type": "string",
            "minLength": 5,
            "maxLength": 50
        },
        "appConfigLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]"
        },
        "tags": {
            "type": "object"
        },
        "sku": {
            "type": "string"
        }
    },
    "variables": {
    },
    "functions": [
    ],
    "resources": [
        {
            "name": "[parameters('appConfigName')]",
            "type": "Microsoft.AppConfiguration/configurationStores",
            "apiVersion": "2020-06-01",
            "location": "[parameters('appConfigLocation')]",
            "tags": "[parameters('tags')]",
            "identity": {
                "type": "SystemAssigned"
            },
            "sku": {
                "name": "[parameters('sku')]"
            },
            "resources": [
            ],
            "dependsOn": [
            ]
        }
    ],
    "outputs": {
    }
}
tools\templates\messagebus\routingstore\routingstore.appcfg.prod.parameters.json.liquid
 
tools\templates\messagebus\routingstore\routingstore.kv.dev.psparameters.json.liquid
 
tools\templates\messagebus\routingstore\routingstore.kv.prod.psparameters.json.liquid
 
tools\templates\messagebus\routingstore\TearDown-15-RoutingStore-KeyVault.ps1.liquid
 
tools\templates\messagebus\routingstore\TearDown-20-RoutingStore-AppConfig.ps1.liquid
 
tools\templates\messagebus\routingstore\TearDown-40-RoutingStore-ApiManagement.ps1.liquid
 
tools\templates\messagebus\standard\Deploy-80-MessageBusEventGrid-ApiConnection.ps1.liquid
 
tools\templates\messagebus\standard\Deploy-90-MessageBus-LogicApp.ps1.liquid
 
tools\templates\messagebus\standard\Deploy-95-AppConfigStore-RoleAssignment.ps1.liquid
 
tools\templates\messagebus\standard\Deploy-95-MessageBusEventGrid-ApiConnPolicy.ps1.liquid
 
tools\templates\messagebus\standard\messagebus.logic.dev.parameters.json.liquid
 
tools\templates\messagebus\standard\messagebus.logic.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"logicAppName": {
			"type": "string",
			"metadata": {
				"description": "The name of this Standard Logic App service (note that this differs from the name of the workflows contained within this Logic App)."
			}
		},
		"logicAppLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "The region that this Standard Logic App service should be deployed to."
			}
		},
		"appServicePlanName": {
			"type": "string",
			"metadata": {
				"description": "The name of the App Service Plan used by this Standard Logic App service."
			}
		},
		"storageAccountName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Storage Account used by this Standard Logic App service."
			}
		},
		"appConfigurationStoreName": {
			"type": "string",
			"metadata": {
				"description": "The name of the Azure App Configuration instance used to store configuration entries."
			}
		},
		"appInsightsName": {
			"type": "string",
			"metadata": {
				"description": "Name of the Application Insights instance used by this logic app."
			}
		},
		"apimServiceName": {
			"type": "string",
			"metadata": {
				"description": "Name of the APIM Service used for SystemApplication operations."
			}
		},
		"apimSubscriptionKey": {
			"type": "securestring",
			"metadata": {
				"description": "Subscription Key used to access APIM."
			}
		},
		"eventGridSubscribeApiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Name of the API Connection used to connect to Event Grid subscriptions."
			}
		},
		"tags": {
			"type": "object",
			"defaultValue": {
				"Environment": "dev"
			},
			"metadata": {
				"description": "Tags for this resource."
			}
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/sites",
			"apiVersion": "2021-01-15",
			"name": "[parameters('logicAppName')]",
			"location": "[parameters('logicAppLocation')]",
			"kind": "functionapp,workflowapp",
			"identity": {
				"type": "SystemAssigned"
			},
			"dependsOn": [],
			"tags": "[parameters('tags')]",
			"properties": {
				"enabled": true,
				"hostNameSslStates": [
					{
						"name": "[concat(parameters('logicAppName'), '.azurewebsites.net')]",
						"sslState": "Disabled",
						"hostType": "Standard"
					},
					{
						"name": "[concat(parameters('logicAppName'), '.scm.azurewebsites.net')]",
						"sslState": "Disabled",
						"hostType": "Repository"
					}
				],
				"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]",
				"reserved": false,
				"isXenon": false,
				"hyperV": false,
				"siteConfig": {
					"numberOfWorkers": 1,
					"acrUseManagedIdentityCreds": false,
					"alwaysOn": false,
					"http20Enabled": false,
					"functionAppScaleLimit": 0,
					"minimumElasticInstanceCount": 1
				},
				"scmSiteAlsoStopped": false,
				"clientAffinityEnabled": false,
				"clientCertEnabled": false,
				"clientCertMode": "Required",
				"hostNamesDisabled": false,
				"containerSize": 1536,
				"dailyMemoryTimeQuota": 0,
				"keyVaultReferenceIdentity": "SystemAssigned",
				"httpsOnly": false,
				"redundancyMode": "None",
				"storageAccountRequired": false,
				"siteConfig": {
					"appSettings": [
						{
							"name": "APP_KIND",
							"value": "workflowApp"
						},
						{
							"name": "AzureFunctionsJobHost__extensionBundle__id",
							"value": "Microsoft.Azure.Functions.ExtensionBundle.Workflows"
						},
						{
							"name": "AzureFunctionsJobHost__extensionBundle__version",
							"value": "[1.*, 2.0.0)"
						},
						{
							"name": "AzureWebJobsDashboard",
							"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
						},
						{
							"name": "AzureWebJobsStorage",
							"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
						},
						{
							"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
							"value": "[reference(resourceId('Microsoft.Insights/components', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"
						},
						{
							"name": "FUNCTIONS_EXTENSION_VERSION",
							"value": "~3"
						},
						{
							"name": "FUNCTIONS_V2_COMPATIBILITY_MODE",
							"value": "true"
						},
						{
							"name": "FUNCTIONS_WORKER_RUNTIME",
							"value": "node"
						},
						{
							"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
							"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
						},
						{
							"name": "WEBSITE_CONTENTSHARE",
							"value": "[parameters('logicAppName')]"
						},
						{
							"name": "WEBSITE_NODE_DEFAULT_VERSION",
							"value": "~12"
						},
						{
							"name": "apiConnectionSubscriptionId",
							"value": "[subscription().subscriptionId]"
						},
						{
							"name": "apiConnectionResourceGroupName",
							"value": "[resourceGroup().name]"
						},
						{
							"name": "apiConnectionLocation",
							"value": "[resourceGroup().location]"
						},
						{
							"name": "apimBaseUrl",
							"value": "[concat('https://', parameters('apimServiceName'), '.azure-api.net')]"
						},
						{
							"name": "apimSubscriptionKey",
							"value": "[parameters('apimSubscriptionKey')]"
						},
						{
							"name": "eventGridSubscribeConnectionName",
							"value": "[parameters('eventGridSubscribeApiConnectionName')]"
						},
						{
							"name": "eventGridSubscribeConnectionApiId",
							"value": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('logicAppLocation'), 'azureeventgrid')]"
						},
						{
							"name": "eventGridSubscribeConnectionResourceId",
							"value": "[resourceId('Microsoft.Web/connections', parameters('eventGridSubscribeApiConnectionName'))]"
						},
						{
							"name": "eventGridSubscribeConnectionRuntimeUrl",
							"value": "[reference(resourceId('Microsoft.Web/connections', parameters('eventGridSubscribeApiConnectionName')),'2016-06-01', 'full').properties.connectionRuntimeUrl]"
						},
						{
							"name": "appConfigurationStoreResourceId",
							"value": "[resourceId('Microsoft.AppConfiguration/configurationStores', parameters('appConfigurationStoreName'))]"
						}
					]
				},
				"redundancyMode": "None"
			}
		},
		{
			"type": "Microsoft.Web/sites/config",
			"apiVersion": "2021-01-15",
			"name": "[concat(parameters('logicAppName'), '/web')]",
			"location": "[parameters('logicAppLocation')]",
			"tags": "[parameters('tags')]",
			"dependsOn": [
				"[resourceId('Microsoft.Web/sites', parameters('logicAppName'))]"
			],
			"properties": {
				"numberOfWorkers": 1,
				"defaultDocuments": [
					"Default.htm",
					"Default.html",
					"Default.asp",
					"index.htm",
					"index.html",
					"iisstart.htm",
					"default.aspx",
					"index.php"
				],
				"netFrameworkVersion": "v4.0",
				"phpVersion": "5.6",
				"requestTracingEnabled": false,
				"remoteDebuggingEnabled": false,
				"httpLoggingEnabled": false,
				"acrUseManagedIdentityCreds": false,
				"logsDirectorySizeLimit": 35,
				"detailedErrorLoggingEnabled": false,
				"publishingUsername": "[concat('$', parameters('logicAppName'))]",
				"azureStorageAccounts": {},
				"scmType": "None",
				"use32BitWorkerProcess": true,
				"webSocketsEnabled": false,
				"alwaysOn": false,
				"managedPipelineMode": "Integrated",
				"virtualApplications": [
					{
						"virtualPath": "/",
						"physicalPath": "site\\wwwroot",
						"preloadEnabled": false
					}
				],
				"loadBalancing": "LeastRequests",
				"experiments": {
					"rampUpRules": []
				},
				"autoHealEnabled": false,
				"localMySqlEnabled": false,
				"ipSecurityRestrictions": [
					{
						"ipAddress": "Any",
						"action": "Allow",
						"priority": 1,
						"name": "Allow all",
						"description": "Allow all access"
					}
				],
				"scmIpSecurityRestrictions": [
					{
						"ipAddress": "Any",
						"action": "Allow",
						"priority": 1,
						"name": "Allow all",
						"description": "Allow all access"
					}
				],
				"scmIpSecurityRestrictionsUseMain": false,
				"http20Enabled": false,
				"minTlsVersion": "1.2",
				"scmMinTlsVersion": "1.0",
				"ftpsState": "AllAllowed",
				"preWarmedInstanceCount": 1,
				"functionAppScaleLimit": 0,
				"functionsRuntimeScaleMonitoringEnabled": false,
				"minimumElasticInstanceCount": 1
			}
		},
		{
			"type": "Microsoft.Web/sites/hostNameBindings",
			"apiVersion": "2021-01-15",
			"name": "[concat(parameters('logicAppName'), '/', parameters('logicAppName'), '.azurewebsites.net')]",
			"location": "[parameters('logicAppLocation')]",
			"tags": "[parameters('tags')]",
			"dependsOn": [
				"[resourceId('Microsoft.Web/sites', parameters('logicAppName'))]"
			],
			"properties": {
				"siteName": "[parameters('logicAppName')]",
				"hostNameType": "Verified"
			}
		}
	]
}
tools\templates\messagebus\standard\messagebus.logic.prod.parameters.json.liquid
 
tools\templates\messagebus\standard\messagebus.logic.workflows\.funcignore
 
tools\templates\messagebus\standard\messagebus.logic.workflows\.vscode\extensions.json
{
  "recommendations": [
    "ms-azuretools.vscode-azurefunctions"
  ]
}
tools\templates\messagebus\standard\messagebus.logic.workflows\.vscode\launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to .NET Functions",
      "type": "coreclr",
      "request": "attach",
      "processId": "${command:azureLogicAppsStandard.pickProcess}"
    }
  ]
}
tools\templates\messagebus\standard\messagebus.logic.workflows\.vscode\settings.json
{
  "azureLogicAppsStandard.deploySubpath": ".",
  "azureLogicAppsStandard.projectLanguage": "JavaScript",
  "azureLogicAppsStandard.projectRuntime": "~3",
  "debug.internalConsoleOptions": "neverOpen"
}
tools\templates\messagebus\standard\messagebus.logic.workflows\.vscode\tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "generateDebugSymbols",
      "command": "dotnet",
      "args": [
        "${input:getDebugSymbolDll}"
      ],
      "type": "process",
      "problemMatcher": "$msCompile"
    },
    {
      "type": "func",
      "command": "host start",
      "problemMatcher": "$func-watch",
      "isBackground": true
    }
  ],
  "inputs": [
    {
      "id": "getDebugSymbolDll",
      "type": "command",
      "command": "azureLogicAppsStandard.getDebugSymbolDll"
    }
  ]
}
tools\templates\messagebus\standard\messagebus.logic.workflows\configcacheupdater\workflow.json
{
	"definition": {
		"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
		"actions": {},
		"contentVersion": "1.0.0.0",
		"outputs": {},
		"triggers": {
			"When_a_resource_event_occurs": {
				"inputs": {
					"body": {
						"properties": {
							"destination": {
								"endpointType": "webhook",
								"properties": {
									"endpointUrl": "@{listCallbackUrl()}"
								}
							},
							"filter": {
								"includedEventTypes": [
									"Microsoft.AppConfiguration.KeyValueModified"
								]
							},
							"topic": "@appsetting('appConfigurationStoreResourceId')"
						}
					},
					"host": {
						"connection": {
							"referenceName": "eventGridSubscribe"
						}
					},
					"path": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/providers/Microsoft.AppConfiguration.ConfigurationStores/resource/eventSubscriptions",
					"queries": {
						"x-ms-api-version": "2017-09-15-preview"
					}
				},
				"splitOn": "@triggerBody()",
				"type": "ApiConnectionWebhook"
			}
		},
		"actions": {
			"Switch_on_Label": {
				"runAfter": {},
				"cases": {
					"ConfigurationEntry": {
						"case": "ConfigurationEntry",
						"actions": {
							"Clear_Configuration_Cache": {
								"runAfter": {},
								"type": "Http",
								"inputs": {
									"method": "GET",
									"uri": "@{appsetting('apimBaseUrl')}/aimconfigurationmanager/configuration/@{encodeURIComponent(triggerBody()?['data']?['key'])}",
									"queries": {
										"clearCache": "true"
									},
									"headers": {
										"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
										"Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
									},
									"retryPolicy": {
										"type": "none"
									}
								}
							}
						}
					},
					"RoutingProperties": {
						"case": "RoutingProperties",
						"actions": {
							"Clear_RoutingProperties_Cache": {
								"runAfter": {},
								"type": "Http",
								"inputs": {
									"method": "GET",
									"uri": "@{appsetting('apimBaseUrl')}/aimroutingstore/routingproperties/@{encodeURIComponent(triggerBody()?['data']?['key'])}",
									"queries": {
										"clearCache": "true"
									},
									"headers": {
										"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
										"Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
									},
									"retryPolicy": {
										"type": "none"
									}
								}
							}
						}
					},
					"RoutingSlip": {
						"case": "RoutingSlip",
						"actions": {
							"Clear_RoutingSlip_Cache": {
								"runAfter": {},
								"type": "Http",
								"inputs": {
									"method": "GET",
									"uri": "@{appsetting('apimBaseUrl')}/aimroutingstore/routingslip/@{encodeURIComponent(triggerBody()?['data']?['key'])}",
									"queries": {
										"clearCache": "true"
									},
									"headers": {
										"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
										"Ocp-Apim-Subscription-Key": "@appsetting('apimSubscriptionKey')"
									},
									"retryPolicy": {
										"type": "none"
									}
								}
							}
						}
					}
				},
				"default": {
					"actions": {}
				},
				"expression": "@triggerBody()?['data']?['label']",
				"type": "Switch"
			}
		}
	},
	"kind": "Stateful"
}
tools\templates\messagebus\standard\messagebus.logic.workflows\connections.json
{
	"serviceProviderConnections": {
	},
	"managedApiConnections": {
		"eventGridSubscribe": {
			"api": {
				"id": "@parameters('eventGridSubscribeConnectionApiId')"
			},
			"connection": {
				"id": "@parameters('eventGridSubscribeConnectionResourceId')"
			},
			"connectionRuntimeUrl": "@appsetting('eventGridSubscribeConnectionRuntimeUrl')",
			"authentication": "@parameters('eventGridSubscribeManagedApiAuthentication')"
		}
	}
}
tools\templates\messagebus\standard\messagebus.logic.workflows\host.json
{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": "[1.*, 2.0.0)"
  }
}
tools\templates\messagebus\standard\messagebus.logic.workflows\local.settings.json
{
	"IsEncrypted": false,
	"Values": {
		"AzureWebJobsStorage": "UseDevelopmentStorage=true",
		"FUNCTIONS_WORKER_RUNTIME": "node",
		"WORKFLOWS_TENANT_ID": "",
		"WORKFLOWS_SUBSCRIPTION_ID": "",
		"WORKFLOWS_RESOURCE_GROUP_NAME": "",
		"WORKFLOWS_LOCATION_NAME": "",
		"WORKFLOWS_MANAGEMENT_BASE_URI": "https://management.azure.com/",
		"apiConnectionSubscriptionId": "",
		"apiConnectionResourceGroupName": "",
		"apiConnectionLocation": "",
		"apimBaseUrl": "",
		"apimSubscriptionKey": "",
		"eventGridSubscribeConnectionName": "",
		"eventGridSubscribeConnectionApiId": "",
		"eventGridSubscribeConnectionResourceId": "",
		"eventGridSubscribeConnectionRuntimeUrl": "",
		"eventGridSubscribeConnectionKey": ""
	}
}
tools\templates\messagebus\standard\messagebus.logic.workflows\parameters.json
{
	"apimRetryPolicy": {
		"type": "Object",
		"value": {
			"count": 3,
			"interval": "PT5S",
			"type": "fixed"
		}
	},
	"eventGridSubscribeConnectionApiId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/providers/Microsoft.Web/locations/@appsetting('apiConnectionLocation')/managedApis/azureeventgrid"
	},
	"eventGridSubscribeConnectionResourceId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/resourceGroups/@appsetting('apiConnectionResourceGroupName')/providers/Microsoft.Web/connections/@appsetting('eventGridSubscribeConnectionName')"
	},
	"eventGridSubscribeManagedApiAuthentication": {
		"type": "Object",
		"value": {
			"type": "ManagedServiceIdentity"
		}
	},
	"clearCache": {
		"type": "Bool",
		"value": false,
		"description": "Flag indicating if the cache should be cleared when calling APIM."
	}
}
tools\templates\messagebus\standard\messagebus.logic.workflows\parameters.local.json
{
	"apimRetryPolicy": {
		"type": "Object",
		"value": {
			"count": 3,
			"interval": "PT5S",
			"type": "fixed"
		}
	},
	"eventGridSubscribeConnectionApiId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/providers/Microsoft.Web/locations/@appsetting('apiConnectionLocation')/managedApis/azureeventgrid"
	},
	"eventGridSubscribeConnectionResourceId": {
		"type": "String",
		"value": "/subscriptions/@appsetting('apiConnectionSubscriptionId')/resourceGroups/@appsetting('apiConnectionResourceGroupName')/providers/Microsoft.Web/connections/@appsetting('eventGridSubscribeConnectionName')"
	},
	"eventGridSubscribeManagedApiAuthentication": {
		"type": "Object",
		"value": {
			"type": "Raw",
			"scheme": "Key",
			"parameter": "@appsetting('eventGridSubscribeConnectionKey')"
		}
	},
	"clearCache": {
		"type": "Bool",
		"value": false,
		"description": "Flag indicating if the cache should be cleared when calling APIM."
	}
}
tools\templates\messagebus\standard\messagebus.logic.workflows\workflow-designtime\host.json
{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
    "version": "[1.*, 2.0.0)"
  },
  "extensions": {
    "workflow": {
      "settings": {
        "Runtime.WorkflowOperationDiscoveryHostMode": "true"
      }
    }
  }
}
tools\templates\messagebus\standard\messagebus.logic.workflows\workflow-designtime\local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsSecretStorageType": "Files",
    "FUNCTIONS_WORKER_RUNTIME": "node"
  }
}
tools\templates\messagebus\standard\messagebuseventgrid.apicaccesspolicy.dev.parameters.json.liquid
 
tools\templates\messagebus\standard\messagebuseventgrid.apicaccesspolicy.json
{
	"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
	"contentVersion": "1.0.0.0",
	"parameters": {
		"apiConnectionName": {
			"type": "string",
			"metadata": {
				"description": "Resource Name of the API Connection"
			}
		},
		"apiConnectionDisplayName": {
			"type": "string",
			"defaultValue": "[parameters('apiConnectionName')]",
			"metadata": {
				"description": "Display Name of the API Connection"
			}
		},
		"apiConnectionLocation": {
			"type": "string",
			"defaultValue": "[resourceGroup().location]",
			"metadata": {
				"description": "Location that we're deploying this resource to."
			}
		},
		"logicAppName": {
			"type": "String",
			"metadata": {
				"description": "Name of the LogicApp that we're creating a policy for."
			}
		},
		"tags": {
			"type": "object"
		}
	},
	"variables": {},
	"resources": [
		{
			"type": "Microsoft.Web/connections/accessPolicies",
			"apiVersion": "2016-06-01",
			"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
			"location": "[parameters('apiConnectionLocation')]",
			"dependsOn": [],
			"properties": {
				"principal": {
					"type": "ActiveDirectory",
					"identity": {
						"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
						"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
					}
				}
			}
		}
	],
	"outputs": {}
}
tools\templates\messagebus\standard\messagebuseventgrid.apicaccesspolicy.prod.parameters.json.liquid
 
tools\templates\messagebus\standard\messagebuseventgrid.apiconnection.dev.parameters.json.liquid
 
tools\templates\messagebus\standard\messagebuseventgrid.apiconnection.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "apiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Resource Name of the API Connection"
            }
        },
        "apiConnectionDisplayName": {
            "type": "string",
            "defaultValue": "[parameters('apiConnectionName')]",
            "metadata": {
                "description": "Display Name of the API Connection"
            }
        },
        "apiConnectionLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
			"metadata": {
                "description": "Location that we're deploying this resource to."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Web/connections",
            "apiVersion": "2016-06-01",
            "name": "[parameters('apiConnectionName')]",
            "location": "[parameters('apiConnectionLocation')]",
			"kind": "V2",
            "tags": "[parameters('tags')]",
            "properties": {
                "api": {
                    "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('apiConnectionLocation'), '/managedApis/', 'azureeventgrid')]"
                },
                "displayName": "[parameters('apiConnectionDisplayName')]",
                "parameterValueType": "Alternative"
            }
        }
    ],
    "outputs": {}
}
tools\templates\messagebus\standard\messagebuseventgrid.apiconnection.prod.parameters.json.liquid
 
tools\templates\messagebus\standard\New-AppConfigStore-RoleAssignment.ps1
<#
.SYNOPSIS
Assigns the Logic App to the given role for an App Config Store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER appConfigStoreName
Name of the app config store to assign permissions to.

.PARAMETER logicAppName
Name of the Logic App that will be granted permissions.

.PARAMETER roleName
Name of the Role that the the Logic App will be assigned.

.EXAMPLE
.\New-AppConfigStore-RoleAssignment.ps1 -appConfigStoreName "appcfg-aimrstore-dev-xxxxx" -logicAppName "logic-messagebus-dev-xxxxx" -roleName "Contributor"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $appConfigStoreName,
    [parameter(Mandatory = $true)]
    [string] $logicAppName,
	[parameter(Mandatory = $true)]
    [string] $roleName
)
Write-Host "Assigning the Logic App $logicAppName to the $roleName role for the App Config Store $appConfigStoreName"

Write-Host "Getting the ResourceId for the App Config Store $appConfigStoreName"
$appConfigStoreResourceId = az resource list --name $appConfigStoreName --query "[0].id" --output tsv
if (!$appConfigStoreResourceId) {
    throw "Unable to get the ResourceId for the App Config Store $appConfigStoreName"
}

Write-Host "Getting the ManagedIdentity ObjectId for the LogicApp $logicAppName"
$logicAppObjectId = az ad sp list --filter "displayName eq '$logicAppName' and servicePrincipalType eq 'ManagedIdentity'" --query "[0].objectId" --output tsv
if (!$logicAppObjectId) {
    throw "Unable to get the ObjectId for the Managed Identity for the Logic App $logicAppName"
}

Write-Host "Assigning the $roleName role to the Logic App $logicAppName for the App Config Store $appConfigStoreName"
az role assignment create --role $roleName --assignee $logicAppObjectId --scope $appConfigStoreResourceId

Write-Host "Finished assigning permissions"
tools\templates\messagebus\standard\New-MessageBus-LogicApp.ps1
<#
.SYNOPSIS
Creates the Message Bus Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER workflowFolder
Name of the folder containing the Logic App Workflows.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageBus-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -resourceName "logic-messagebus-dev-xxxxx" -templateFile "$PSScriptRoot\messagebus.logicapp.json" -templateParameterFile "$PSScriptRoot\messagebus.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -workflowFolder "$PSScriptRoot\messagebus.logic.workflows" -deploymentName "messagebus.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName,	
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
	[parameter(Mandatory = $true)]
    [string] $workflowFolder,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the Message Bus Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName 

Write-Host "Deployment complete"

Write-Host "Creating a ZIP file from the workflow folder"
# create the zip
$zipFile = "$workflowFolder.zip"
if(Test-path $zipFile) {Remove-item $zipFile}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($workflowFolder, $zipFile)

Write-Host "Zip File creation complete"

Write-Host "Uploading the message bus logic app zip package $zipFile"

if (!(Test-Path $zipFile)) {
    throw "Zip file $zipFile doesn't exist, unable to upload"
}

az logicapp deployment source config-zip --resource-group $resourceGroupName --name $resourceName --src "$zipFile"

Write-Host "Upload complete"
tools\templates\messagebus\standard\New-MessageBusEventGrid-ApiConnection.ps1
<#
.SYNOPSIS
Creates a message bus event grid api connection for the system application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageBusEventGrid-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\messagebuseventgrid.apiconnection.json" -templateParameterFile ".\messagebuseventgrid.apiconnection.dev.parameters.json" -deploymentName "messagebuseg.apiconnection.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a message bus event grid api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\messagebus\standard\New-MessageBusEventGrid-ApiConnPolicy.ps1
<#
.SYNOPSIS
Creates a message bus event grid api connection access policy for the system application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-MessageBusEventGrid-ApiConnPolicy.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\messagebuseventgrid.apicaccesspolicy.json" -templateParameterFile ".\messagebuseventgrid.apicaccesspolicy.dev.parameters.json" -deploymentName "messagebuseg.apicaccesspolicy.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying a message bus event grid api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\messagebus\standard\Remove-AppConfigStore-RoleAssignment.ps1
<#
.SYNOPSIS
Removes the Logic App from the given role for an App Config Store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER appConfigStoreName
Name of the app config store to remove permissions from.

.PARAMETER logicAppName
Name of the Logic App that permissions will be removed for.

.PARAMETER roleName
Name of the Role that the will have permissions removed.

.EXAMPLE
.\Remove-AppConfigStore-RoleAssignment.ps1 -appConfigStoreName "appcfg-aimrstore-dev-xxxxx" -logicAppName "logic-aimconfigcacheupdater-dev-xxxxx" -roleName "Contributor"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $appConfigStoreName,
    [parameter(Mandatory = $true)]
    [string] $logicAppName,
	[parameter(Mandatory = $true)]
    [string] $roleName
)
Write-Host "Removing the Logic App $logicAppName from the $roleName role for the App Config Store $appConfigStoreName"

Write-Host "Getting the ResourceId for the App Config Store $appConfigStoreName"
$appConfigStoreResourceId = az resource list --name $appConfigStoreName --query "[0].id" --output tsv
if (!$appConfigStoreResourceId) {
    throw "Unable to get the ResourceId for the App Config Store $appConfigStoreName"
}

Write-Host "Getting the ManagedIdentity ObjectId for the LogicApp $logicAppName"
$logicAppObjectId = az ad sp list --filter "displayName eq '$logicAppName' and servicePrincipalType eq 'ManagedIdentity'" --query "[0].objectId" --output tsv
if (!$logicAppObjectId) {
    throw "Unable to get the ObjectId for the Managed Identity for the Logic App $logicAppName"
}

Write-Host "Removing the Logic App $logicAppName from the $roleName role for the App Config Store $appConfigStoreName"
az role assignment delete --role $roleName --assignee $logicAppObjectId --scope $appConfigStoreResourceId

Write-Host "Finished removing permissions"
tools\templates\messagebus\standard\Remove-MessageBus-LogicApp.ps1
<#
.SYNOPSIS
Tears down the message bus Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER logicAppName
The name of the Logic App to find the resource.

.EXAMPLE
.\Remove-MessageBus-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -logicAppName "logic-messagebus-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $logicAppName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $logicAppName --resource-type "Microsoft.Web/sites"

if ($resourceExists) {
    Write-Host "Removing the Logic App $logicAppName"

    az resource delete --resource-group $resourceGroupName --name $logicAppName --resource-type "Microsoft.Web/sites"

    Write-Host "Removed the Logic App $logicAppName"
}
else {
    Write-Host "The Logic App $logicAppName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\standard\Remove-MessageBusEventGrid-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the message bus event grid api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-MessageBusEventGrid-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -resourceName "apic-messagebuseventgrid-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the message bus event grid api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the message bus event grid api connection resource: $resourceName"
}
else {
    Write-Host "The message bus event grid api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\standard\TearDown-80-MessageBusEventGrid-ApiConnection.ps1.liquid
 
tools\templates\messagebus\standard\TearDown-90-MessageBus-LogicApp.ps1.liquid
 
tools\templates\messagebus\standard\TearDown-95-AppConfigStore-RoleAssignment.ps1.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\configcacheupdater.logicapp.dev.parameters.json.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\configcacheupdater.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "defaultValue": "[resourceGroup().location]",
            "type": "string",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "configurationManagerAppConfigName": {
            "type": "string",
            "metadata": {
                "description": "Name of the Azure App Configuration store that holds config."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "type": "object",
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "eventGridSubscribeApiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Name of the API Connection used for EventGrid Subscribe operations."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId('Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "routingStoreApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimroutingstore')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
        "eventGridSubscribeApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('eventGridSubscribeApiConnectionName'))]",
        "configurationManagerResourceId": "[resourceId('Microsoft.AppConfiguration/configurationStores', parameters('configurationManagerAppConfigName'))]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
			"identity": {
                "type": "SystemAssigned"
            },
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "When_a_resource_event_occurs": {
                            "splitOn": "@triggerBody()",
                            "type": "ApiConnectionWebhook",
                            "inputs": {
                                "body": {
                                    "properties": {
                                        "destination": {
                                            "endpointType": "webhook",
                                            "properties": {
                                                "endpointUrl": "@{listCallbackUrl()}"
                                            }
                                        },
                                        "filter": {
                                            "includedEventTypes": [
                                                "Microsoft.AppConfiguration.KeyValueModified"
                                            ]
                                        },
                                        "topic": "[variables('configurationManagerResourceId')]"
                                    }
                                },
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['eventgridsubscribe']['connectionId']"
                                    }
                                },
                                "path": "[concat(subscription().id, '/providers/Microsoft.AppConfiguration.ConfigurationStores/resource/eventSubscriptions')]",
                                "queries": {
                                    "x-ms-api-version": "2017-06-15-preview"
                                }
                            }
                        }
                    },
                    "actions": {
                        "Switch_on_Label": {
                            "runAfter": {},
                            "cases": {
                                "ConfigurationEntry": {
                                    "case": "ConfigurationEntry",
                                    "actions": {
                                        "Clear_Configuration_Cache": {
                                            "runAfter": {},
                                            "type": "ApiManagement",
                                            "inputs": {
                                                "api": {
                                                    "id": "[variables('configurationManagerApiResourceId')]"
                                                },
                                                "method": "get",
                                                "pathTemplate": {
                                                    "parameters": {
                                                        "scenario": "@{encodeURIComponent(triggerBody()?['data']?['key'])}"
                                                    },
                                                    "template": "/aimconfigurationmanager/configuration/{scenario}"
                                                },
                                                "queries": {
                                                    "clearCache": "true"
                                                },
                                                "retryPolicy": "[parameters('apimRetryPolicy')]",
                                                "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                            }
                                        }
                                    }
                                },
                                "RoutingProperties": {
                                    "case": "RoutingProperties",
                                    "actions": {
                                        "Clear_RoutingProperties_Cache": {
                                            "runAfter": {},
                                            "type": "ApiManagement",
                                            "inputs": {
                                                "api": {
                                                    "id": "[variables('routingStoreApiResourceId')]"
                                                },
                                                "method": "get",
                                                "pathTemplate": {
                                                    "parameters": {
                                                        "scenario": "@{encodeURIComponent(triggerBody()?['data']?['key'])}"
                                                    },
                                                    "template": "/aimroutingstore/routingproperties/{scenario}"
                                                },
                                                "queries": {
                                                    "clearCache": "true"
                                                },
                                                "retryPolicy": "[parameters('apimRetryPolicy')]",
                                                "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                            }
                                        }
                                    }
                                },
                                "RoutingSlip": {
                                    "case": "RoutingSlip",
                                    "actions": {
                                        "Clear_RoutingSlip_Cache": {
                                            "runAfter": {},
                                            "type": "ApiManagement",
                                            "inputs": {
                                                "api": {
                                                    "id": "[variables('routingStoreApiResourceId')]"
                                                },
                                                "method": "get",
                                                "pathTemplate": {
                                                    "parameters": {
                                                        "scenario": "@{encodeURIComponent(triggerBody()?['data']?['key'])}"
                                                    },
                                                    "template": "/aimroutingstore/routingslip/{scenario}"
                                                },
                                                "queries": {
                                                    "clearCache": "true"
                                                },
                                                "retryPolicy": "[parameters('apimRetryPolicy')]",
                                                "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                            }
                                        }
                                    }
                                }
                            },
                            "default": {
                                "actions": {}
                            },
                            "expression": "@triggerBody()?['data']?['label']",
                            "type": "Switch"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
							"eventgridsubscribe": {
                                "connectionId": "[variables('eventGridSubscribeApiConnectionResourceId')]",
                                "connectionName": "[parameters('eventGridSubscribeApiConnectionName')]",
                                "connectionProperties": {
                                    "authentication": {
                                        "type": "ManagedServiceIdentity"
                                    }
                                },
                                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azureeventgrid')]"
                            }
                        }
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\messagebus\workflows\configcacheupdater\configcacheupdater.logicapp.prod.parameters.json.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\Deploy-100-AppConfigStore-RoleAssignment.ps1.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\Deploy-110-ConfigCacheUpdater-LogicApp-Enabled.ps1.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\Deploy-80-EventGridSubscribe-ApiConnection.ps1.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\Deploy-90-ConfigCacheUpdater-LogicApp-Disabled.ps1.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\eventgridsubscribe.apiconnection.dev.parameters.json.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\eventgridsubscribe.apiconnection.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "apiConnectionName": {
            "type": "string",
            "metadata": {
                "description": "Resource Name of the API Connection"
            }
        },
        "apiConnectionDisplayName": {
            "type": "string",
            "defaultValue": "[parameters('apiConnectionName')]",
            "metadata": {
                "description": "Display Name of the API Connection"
            }
        },
        "apiConnectionLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
			"metadata": {
                "description": "Location that we're deploying this resource to."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Web/connections",
            "apiVersion": "2016-06-01",
            "name": "[parameters('apiConnectionName')]",
            "location": "[parameters('apiConnectionLocation')]",
			"kind": "V1",
            "tags": "[parameters('tags')]",
            "properties": {
                "api": {
                    "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('apiConnectionLocation'), '/managedApis/', 'azureeventgrid')]"
                },
                "displayName": "[parameters('apiConnectionDisplayName')]",
                "parameterValueType": "Alternative"
            }
        }
    ],
    "outputs": {}
}
tools\templates\messagebus\workflows\configcacheupdater\eventgridsubscribe.apiconnection.prod.parameters.json.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\New-AppConfigStore-RoleAssignment.ps1
<#
.SYNOPSIS
Assigns the Logic App to the given role for an App Config Store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER appConfigStoreName
Name of the app config store to assign permissions to.

.PARAMETER logicAppName
Name of the Logic App that will be granted permissions.

.PARAMETER roleName
Name of the Role that the the Logic App will be assigned.

.EXAMPLE
.\New-AppConfigStore-RoleAssignment.ps1 -appConfigStoreName "appcfg-aimrstore-dev-xxxxx" -logicAppName "logic-messagebus-dev-xxxxx" -roleName "Contributor"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $appConfigStoreName,
    [parameter(Mandatory = $true)]
    [string] $logicAppName,
	[parameter(Mandatory = $true)]
    [string] $roleName
)
Write-Host "Assigning the Logic App $logicAppName to the $roleName role for the App Config Store $appConfigStoreName"

Write-Host "Getting the ResourceId for the App Config Store $appConfigStoreName"
$appConfigStoreResourceId = az resource list --name $appConfigStoreName --query "[0].id" --output tsv
if (!$appConfigStoreResourceId) {
    throw "Unable to get the ResourceId for the App Config Store $appConfigStoreName"
}

Write-Host "Getting the ManagedIdentity ObjectId for the LogicApp $logicAppName"
$logicAppObjectId = az ad sp list --filter "displayName eq '$logicAppName' and servicePrincipalType eq 'ManagedIdentity'" --query "[0].objectId" --output tsv
if (!$logicAppObjectId) {
    throw "Unable to get the ObjectId for the Managed Identity for the Logic App $logicAppName"
}

Write-Host "Assigning the $roleName role to the Logic App $logicAppName for the App Config Store $appConfigStoreName"
az role assignment create --role $roleName --assignee $logicAppObjectId --scope $appConfigStoreResourceId

Write-Host "Finished assigning permissions"
tools\templates\messagebus\workflows\configcacheupdater\New-ConfigCacheUpdater-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-ConfigCacheUpdater-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -templateFile ".\configcacheupdater.logicapp.json" -templateParameterFile ".\configcacheupdater.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -startupState "Enabled" -deploymentName "configcacheupdater.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
	[parameter(Mandatory = $true)]
    [string] $startupState,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the config cache updater Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters "$templateParameterFile" --parameters "apimSubscriptionKey=$apimSubscriptionKey" --parameters "logicAppStartupState=$startupState" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\messagebus\workflows\configcacheupdater\New-EventGridSubscribe-ApiConnection.ps1
<#
.SYNOPSIS
Creates an event grid subscribe api connection for the system application.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
.\New-EventGridSubscribe-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\eventgridsubscribe.apiconnection.json" -templateParameterFile ".\eventgridsubscribe.apiconnection.dev.parameters.json" -deploymentName "eventgridsubscribe.apiconnection.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Deploying an event grid subscribe api connection`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName

Write-Host "Deployment complete"
tools\templates\messagebus\workflows\configcacheupdater\Remove-AppConfigStore-RoleAssignment.ps1
<#
.SYNOPSIS
Removes the Logic App from the given role for an App Config Store.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER appConfigStoreName
Name of the app config store to remove permissions from.

.PARAMETER logicAppName
Name of the Logic App that permissions will be removed for.

.PARAMETER roleName
Name of the Role that the will have permissions removed.

.EXAMPLE
.\Remove-AppConfigStore-RoleAssignment.ps1 -appConfigStoreName "appcfg-aimrstore-dev-xxxxx" -logicAppName "logic-aimconfigcacheupdater-dev-xxxxx" -roleName "Contributor"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $appConfigStoreName,
    [parameter(Mandatory = $true)]
    [string] $logicAppName,
	[parameter(Mandatory = $true)]
    [string] $roleName
)
Write-Host "Removing the Logic App $logicAppName from the $roleName role for the App Config Store $appConfigStoreName"

Write-Host "Getting the ResourceId for the App Config Store $appConfigStoreName"
$appConfigStoreResourceId = az resource list --name $appConfigStoreName --query "[0].id" --output tsv
if (!$appConfigStoreResourceId) {
    throw "Unable to get the ResourceId for the App Config Store $appConfigStoreName"
}

Write-Host "Getting the ManagedIdentity ObjectId for the LogicApp $logicAppName"
$logicAppObjectId = az ad sp list --filter "displayName eq '$logicAppName' and servicePrincipalType eq 'ManagedIdentity'" --query "[0].objectId" --output tsv
if (!$logicAppObjectId) {
    throw "Unable to get the ObjectId for the Managed Identity for the Logic App $logicAppName"
}

Write-Host "Removing the Logic App $logicAppName from the $roleName role for the App Config Store $appConfigStoreName"
az role assignment delete --role $roleName --assignee $logicAppObjectId --scope $appConfigStoreResourceId

Write-Host "Finished removing permissions"
tools\templates\messagebus\workflows\configcacheupdater\Remove-ConfigCacheUpdater-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
./Remove-ConfigCacheUpdater-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth" -workflowName "logic-aimconfigcacheupdater-dev"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\workflows\configcacheupdater\Remove-EventGridSubscribe-ApiConnection.ps1
<#
.SYNOPSIS
Tears down the event grid subscribe api connection.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER resourceName
The name of the resource to remove.

.EXAMPLE
.\Remove-EventGridSubscribe-ApiConnection.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -resourceName "apic-eventgridsubscribe-dev-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $resourceName
)

$resourceExists = az resource show --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

if ($resourceExists) {
    Write-Host "Removing the event grid subscribe api connection resource: $resourceName"

    az resource delete --name $resourceName --resource-group $resourceGroupName --resource-type "connections" --namespace "Microsoft.Web"

    Write-Host "Removed the event grid subscribe api connection resource: $resourceName"
}
else {
    Write-Host "The event grid subscribe api connection resource $resourceName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\workflows\configcacheupdater\TearDown-100-AppConfigStore-RoleAssignment.ps1.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\TearDown-80-EventGridSubscribe-ApiConnection.ps1.liquid
 
tools\templates\messagebus\workflows\configcacheupdater\TearDown-90-ConfigCacheUpdater-LogicApp.ps1.liquid
 
tools\templates\messagebus\workflows\routingsliprouter\Deploy-80-RoutingSlipRouter-LogicApp.ps1.liquid
 
tools\templates\messagebus\workflows\routingsliprouter\New-RoutingSlipRouter-LogicApp.ps1
<#
.SYNOPSIS
Creates a Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.

.PARAMETER templateFile
Path to the ARM template that needs to be deployed.

.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.

.PARAMETER keyVaultName
The name of the key vault store.

.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.

.PARAMETER deploymentName
The name used to identify this instance of the deployment.

.EXAMPLE
./New-RoutingSlipRouter-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -templateFile ".\routingsliprouter.logicapp.json" -templateParameterFile ".\routingsliprouter.logicapp.dev.parameters" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -deploymentName "routingsliprouter.logicapp.uksouth.xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]    
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]    
    [string] $templateFile,
    [parameter(Mandatory = $true)]
    [string] $templateParameterFile,
    [string] $keyVaultName,
    [parameter(Mandatory = $true)]
    [string] $keyVaultApimSubscriptionSecretName,
    [parameter(Mandatory = $true)]
    [string] $deploymentName
)

Write-Host "Getting the subscription key from Key Vault for APIM"

$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
    throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}

Write-Host "Deploying the routing slip router Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"

az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName

Write-Host "Deployment complete"
tools\templates\messagebus\workflows\routingsliprouter\Remove-RoutingSlipRouter-LogicApp.ps1
<#
.SYNOPSIS
Tears down the Logic App.

.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.

.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.

.PARAMETER workflowName
The name of the Logic App to find the resource.

.EXAMPLE
./Remove-RoutingSlipRouter-LogicApp.ps1 -resourceGroupName "rg-aimmsgbus-dev-uksouth-xxxxx" -workflowName "AimRoutingSlipRouter-xxxxx"
#>

[CmdletBinding()]
Param(
    [parameter(Mandatory = $true)]
    [string] $resourceGroupName,
    [parameter(Mandatory = $true)]
    [string] $workflowName
)

$resourceExists = az resource show --resource-group $resourceGroupName  --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

if ($resourceExists) {
    Write-Host "Removing the Logic App $workflowName"

    az resource delete --resource-group $resourceGroupName --name $workflowName --namespace "Microsoft.Logic" --resource-type "workflows"

    Write-Host "Removed the Logic App $workflowName"
}
else {
    Write-Host "The Logic App $workflowName does not exist in resource group $resourceGroupName"
}
tools\templates\messagebus\workflows\routingsliprouter\routingsliprouter.logicapp.dev.parameters.json.liquid
 
tools\templates\messagebus\workflows\routingsliprouter\routingsliprouter.logicapp.json
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "logicAppName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "metadata": {
                "description": "Name of this LogicApp."
            }
        },
        "logicAppLocation": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
            }
        },
        "logicAppStartupState": {
            "type": "string",
            "defaultValue": "Enabled",
            "allowedValues": [ "Enabled", "Disabled" ],
            "metadata": {
                "description": "Initial state of the LogicApp after it is deployed."
            }
        },
        "messageBusResourceGroupName": {
            "type": "String",
            "defaultValue": "[resourceGroup().name]",
            "metadata": {
                "description": "Name of the ResourceGroup that APIM is deployed to (if different from the ResourceGroup that this LogicApp is deployed to)."
            }
        },
        "apimServiceName": {
            "type": "string",
            "metadata": {
                "description": "Name of the APIM Service used for MessageBus operations."
            }
        },
        "apimSubscriptionKey": {
            "type": "securestring",
            "metadata": {
                "description": "Subscription Key used to access APIM."
            }
        },
        "apimRetryPolicy": {
            "type": "object",
            "defaultValue": {
                "count": 3,
                "interval": "PT5S",
                "type": "fixed"
            },
            "metadata": {
                "description": "Retry Policy to use when calling APIM."
            }
        },
        "scenarioStep": {
            "defaultValue": "routingSlipRouter",
            "type": "string",
            "metadata": {
                "description": "The step within a Scenario that this LogicApp is running under e.g. routingSlipRouter."
            }
        },
        "tags": {
            "type": "object"
        }
    },
    "variables": {
        "apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
        "routingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimroutingmanager')]",
        "configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]"
    },
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('logicAppName')]",
            "location": "[parameters('logicAppLocation')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "state": "[parameters('logicAppStartupState')]",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "scenarioStep": {
                            "type": "String",
                            "description": "The step within a Scenario that this LogicApp is running under e.g. routingSlipRouter."
                        },
                        "apimSubscriptionKey": {
                            "type": "SecureString",
                            "description": "Subscription Key used to access APIM."
                        }
                    },
                    "triggers": {
                        "manual": {
                            "correlation": {
                                "clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
                            },
                            "type": "Request",
                            "kind": "Http",
                            "inputs": {
                                "schema": {}
                            }
                        }
                    },
                    "actions": {
                        "Initialize_StatusCode_variable": {
                            "runAfter": {},
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "StatusCode",
                                        "type": "integer",
                                        "value": 500
                                    }
                                ]
                            }
                        },
                        "Initialize_FaultMessage_variable": {
                            "runAfter": {
                                "Initialize_StatusCode_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "FaultMessage",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_ErrorMessage_variable": {
                            "runAfter": {
                                "Initialize_FaultMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ErrorMessage",
                                        "type": "string",
                                        "value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
                                    }
                                ]
                            }
                        },
                        "Initialize_ResponseMessage_variable": {
                            "runAfter": {
                                "Initialize_ErrorMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ResponseMessage",
                                        "type": "object",
                                        "value": null
                                    }
                                ]
                            }
                        },
                        "Initialize_Checkpoint_variable": {
                            "runAfter": {
                                "Initialize_ResponseMessage_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Checkpoint",
                                        "type": "string"
                                    }
                                ]
                            }
                        },
                        "Initialize_Envelope_variable": {
                            "runAfter": {
                                "Initialize_Checkpoint_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Envelope",
                                        "type": "object",
                                        "value": "@triggerBody()"
                                    }
                                ]
                            }
                        },
                        "Initialize_Configuration_variable": {
                            "runAfter": {
                                "Initialize_Envelope_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Configuration",
                                        "type": "object"
                                    }
                                ]
                            }
                        },
                        "Initialize_RouteIndex_variable": {
                            "runAfter": {
                                "Initialize_Configuration_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "RouteIndex",
                                        "type": "integer",
                                        "value": -1
                                    }
                                ]
                            }
                        },
                        "Set_RouteIndex_variable": {
                            "runAfter": {
                                "Initialize_RouteIndex_variable": [
                                    "Succeeded"
                                ]
                            },
                            "type": "SetVariable",
                            "inputs": {
                                "name": "RouteIndex",
                                "value": "@int(coalesce(triggerBody()?['header']?['routingSlip']?['nextRoute'], '-1'))"
                            }
                        },
                        "Initialize_Route_variable": {
                            "runAfter": {
                                "Set_RouteIndex_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "Route",
                                        "type": "object",
                                        "value": "@triggerBody()?['header']?['routingSlip']?['routes']?[variables('RouteIndex')]"
                                    }
                                ]
                            }
                        },
                        "Initialize_ChannelType_variable": {
                            "runAfter": {
                                "Initialize_Route_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "type": "InitializeVariable",
                            "inputs": {
                                "variables": [
                                    {
                                        "name": "ChannelType",
                                        "type": "string",
                                        "value": "@variables('Route')?['routingSteps']?['channelType']"
                                    }
                                ]
                            }
                        },
                        "MessageSender:_Were_we_successful": {
                            "actions": {
                                "Success:_Send_ACK_response": {
                                    "runAfter": {},
                                    "type": "Response",
                                    "kind": "Http",
                                    "inputs": {
                                        "body": "@variables('ResponseMessage')",
                                        "headers": {
                                            "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                            "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                            "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                            "Content-Type": "application/json"
                                        },
                                        "statusCode": 200
                                    }
                                }
                            },
                            "runAfter": {
                                "Step:_Process_Channel": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "else": {
                                "actions": {
                                    "Failure:_Build_NACK_message": {
                                        "runAfter": {},
                                        "type": "Compose",
                                        "inputs": {
                                            "body": [
                                                {
                                                    "$content": {
                                                        "code": "500",
                                                        "message": "@variables('ErrorMessage')",
                                                        "lastCheckpoint": "@variables('Checkpoint')",
                                                        "fault": "@variables('FaultMessage')"
                                                    },
                                                    "$contentType": "application/json",
                                                    "$part": 1,
                                                    "$partType": "http://schemas.microsoft.com/aim#nack"
                                                }
                                            ],
                                            "header": {
                                                "properties": {
                                                    "createDate": "@utcNow()",
                                                    "envelopeType": "nack",
                                                    "messageId": "@guid()",
                                                    "rootPart": 1,
                                                    "trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
                                                },
                                                "routing": {
                                                    "MessageType": "http://schemas.microsoft.com/aim#nack"
                                                },
                                                "routingSlip": {},
                                                "state": {}
                                            }
                                        }
                                    },
                                    "Failure:_Send_NACK_response": {
                                        "runAfter": {
                                            "Failure:_Build_NACK_message": [
                                                "Succeeded"
                                            ]
                                        },
                                        "type": "Response",
                                        "kind": "Http",
                                        "inputs": {
                                            "body": "@outputs('Failure:_Build_NACK_message')",
                                            "headers": {
                                                "Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                "Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
                                                "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                "Content-Type": "application/json"
                                            },
                                            "statusCode": 200
                                        }
                                    }
                                }
                            },
                            "expression": {
                                "or": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "NoMoreRoutes"
                                        ]
                                    },
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "ProcessChannel"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Get_Configuration": {
                            "actions": {
                                "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
                                    "runAfter": {},
                                    "type": "ApiManagement",
                                    "inputs": {
                                        "api": {
                                            "id": "[variables('configurationManagerApiResourceId')]"
                                        },
                                        "method": "get",
                                        "pathTemplate": {
                                            "parameters": {
                                                "scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
                                                "step": "@{encodeURIComponent(parameters('scenarioStep'))}"
                                            },
                                            "template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
                                        },
                                        "queries": {
                                            "clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
                                        },
                                        "retryPolicy": "[parameters('apimRetryPolicy')]",
                                        "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                    }
                                },
                                "GetConfiguration:_Check_Status_Code": {
                                    "runAfter": {
                                        "GetConfiguration:_Set_StatusCode_variable": [
                                            "Succeeded"
                                        ]
                                    },
                                    "cases": {
                                        "Success": {
                                            "case": 200,
                                            "actions": {
                                                "GetConfiguration:Success:_Set_Checkpoint_variable": {
                                                    "runAfter": {
                                                        "GetConfiguration:Success:_Set_Configuration_variable": [
                                                            "Succeeded"
                                                        ]
                                                    },
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Checkpoint",
                                                        "value": "GetConfiguration"
                                                    }
                                                },
                                                "GetConfiguration:Success:_Set_Configuration_variable": {
                                                    "runAfter": {},
                                                    "type": "SetVariable",
                                                    "inputs": {
                                                        "name": "Configuration",
                                                        "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "default": {
                                        "actions": {
                                            "GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
                                                "actions": {
                                                    "GetConfiguration:Fault:_Set_ErrorMessage_variable": {
                                                        "runAfter": {
                                                            "GetConfiguration:Fault:_Set_FaultMessage_variable": [
                                                                "Succeeded"
                                                            ]
                                                        },
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                        }
                                                    },
                                                    "GetConfiguration:Fault:_Set_FaultMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "FaultMessage",
                                                            "value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
                                                        }
                                                    }
                                                },
                                                "runAfter": {},
                                                "else": {
                                                    "actions": {
                                                        "GetConfiguration:NoFault:_Create_Fault_Message": {
                                                            "runAfter": {},
                                                            "type": "Compose",
                                                            "inputs": {
                                                                "fault": {
                                                                    "faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                    "faultCategory": "Error",
                                                                    "faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
                                                                    "faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
                                                                    "faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
                                                                }
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Set_FaultMessage_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "ErrorMessage",
                                                                "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
                                                            }
                                                        },
                                                        "GetConfiguration:NoFault:_Set_FaultMessage_variable": {
                                                            "runAfter": {
                                                                "GetConfiguration:NoFault:_Create_Fault_Message": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "FaultMessage",
                                                                "value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
                                                            }
                                                        }
                                                    }
                                                },
                                                "expression": {
                                                    "and": [
                                                        {
                                                            "not": {
                                                                "equals": [
                                                                    "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
                                                                    null
                                                                ]
                                                            }
                                                        }
                                                    ]
                                                },
                                                "type": "If"
                                            }
                                        }
                                    },
                                    "expression": "@variables('StatusCode')",
                                    "type": "Switch"
                                },
                                "GetConfiguration:_Set_StatusCode_variable": {
                                    "runAfter": {
                                        "GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
                                            "Succeeded",
                                            "Failed",
                                            "Skipped",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "StatusCode",
                                        "value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
                                    }
                                }
                            },
                            "runAfter": {
                                "Initialize_ChannelType_variable": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            ""
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Check_if_have_processed_all_routes": {
                            "actions": {
                                "Have_we_processed_all_routes": {
                                    "actions": {
                                        "NoMoreRoutes:_Build_ACK": {
                                            "runAfter": {},
                                            "type": "Compose",
                                            "inputs": {
                                                "body": [
                                                    {
                                                        "$content": "No more routes to process",
                                                        "$contentType": "text/plain",
                                                        "$part": 1,
                                                        "$partType": "http://schemas.microsoft.com/aim#ack"
                                                    }
                                                ],
                                                "header": {
                                                    "properties": {
                                                        "createDate": "@{utcNow()}",
                                                        "envelopeType": "ack",
                                                        "messageId": "@{guid()}",
                                                        "rootPart": 1,
                                                        "trackingId": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                        "correlationId": "@{triggerBody()?['header']?['properties']?['messageId']}"
                                                    },
                                                    "routing": {
                                                        "MessageType": "http://schemas.microsoft.com/aim#ack"
                                                    },
                                                    "routingSlip": {},
                                                    "state": {}
                                                }
                                            }
                                        },
                                        "NoMoreRoutes:_Set_ResponseMessage": {
                                            "runAfter": {
                                                "NoMoreRoutes:_Build_ACK": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "ResponseMessage",
                                                "value": "@outputs('NoMoreRoutes:_Build_ACK')"
                                            }
                                        },
                                        "NoMoreRoutes:_Set_Checkpoint_variable": {
                                            "runAfter": {
                                                "NoMoreRoutes:_Set_ResponseMessage": [
                                                    "Succeeded"
                                                ]
                                            },
                                            "type": "SetVariable",
                                            "inputs": {
                                                "name": "Checkpoint",
                                                "value": "NoMoreRoutes"
                                            }
                                        }
                                    },
                                    "runAfter": {},
                                    "else": {
                                        "actions": {
                                            "RoutesToProcess:_Set_Checkpoint_variable": {
                                                "runAfter": {},
                                                "type": "SetVariable",
                                                "inputs": {
                                                    "name": "Checkpoint",
                                                    "value": "RoutesToProcess"
                                                }
                                            }
                                        }
                                    },
                                    "expression": {
                                        "or": [
                                            {
                                                "greaterOrEquals": [
                                                    "@variables('RouteIndex')",
                                                    "@length(triggerBody()?['header']?['routingSlip']?['routes'])"
                                                ]
                                            },
                                            {
                                                "less": [
                                                    "@variables('RouteIndex')",
                                                    0
                                                ]
                                            }
                                        ]
                                    },
                                    "type": "If"
                                }
                            },
                            "runAfter": {
                                "Step:_Get_Configuration": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "GetConfiguration"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        },
                        "Step:_Process_Channel": {
                            "actions": {
                                "ProcessChannel:Failure:_Get_Failed_Items": {
                                    "runAfter": {
                                        "ProcessChannel:_Exception_Scope": [
                                            "Failed",
                                            "TimedOut"
                                        ]
                                    },
                                    "type": "Query",
                                    "inputs": {
                                        "from": "@result('ProcessChannel:_Exception_Scope')",
                                        "where": "@or(equals(item()['status'], 'Failed'), equals(item()['status'], 'TimedOut'))"
                                    }
                                },
                                "ProcessChannel:Failure:_Set_ErrorMessage_variable": {
                                    "runAfter": {
                                        "ProcessChannel:Failure:_Get_Failed_Items": [
                                            "Succeeded"
                                        ]
                                    },
                                    "type": "SetVariable",
                                    "inputs": {
                                        "name": "ErrorMessage",
                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) in an ExceptionScope. Error: Action: @{body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['name']}, StatusCode: @{body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['outputs']?['statusCode']}, Message: @{concat(body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['error']?['message'], body('ProcessChannel:Failure:_Get_Failed_Items')?[0]?['outputs']?['body']?['message'])}"
                                    }
                                },
                                "ProcessChannel:_Exception_Scope": {
                                    "actions": {
                                        "ProcessChannel:_Switch_on_ChannelType": {
                                            "runAfter": {},
                                            "cases": {
                                                "APIM": {
                                                    "case": "microsoft.channels.trigger.azure-apim",
                                                    "actions": {
                                                        "APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute": {
                                                            "runAfter": {},
                                                            "type": "ApiManagement",
                                                            "inputs": {
                                                                "api": {
                                                                    "id": "[variables('routingManagerApiResourceId')]"
                                                                },
                                                                "body": "@triggerBody()",
                                                                "headers": {
                                                                    "Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
                                                                    "Content-Transfer-Encoding": "none",
                                                                    "Content-Type": "application/json"
                                                                },
                                                                "method": "post",
                                                                "pathTemplate": {
                                                                    "parameters": {},
                                                                    "template": "/aimroutingmanager/sendtonextroute"
                                                                },
                                                                "queries": {
                                                                    "clearCache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
                                                                    "enableTrace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)"
                                                                },
                                                                "retryPolicy": "[parameters('apimRetryPolicy')]",
                                                                "subscriptionKey": "@{parameters('apimSubscriptionKey')}"
                                                            }
                                                        },
                                                        "APIMRouting:_Check_StatusCode": {
                                                            "runAfter": {
                                                                "APIMRouting:_Set_StatusCode_variable": [
                                                                    "Succeeded"
                                                                ]
                                                            },
                                                            "cases": {
                                                                "Success": {
                                                                    "case": 200,
                                                                    "actions": {
                                                                        "APIMRouting:Success:_Set_Checkpoint_variable": {
                                                                            "runAfter": {
                                                                                "APIMRouting:Success:_Set_ResponseMessage_variable": [
                                                                                    "Succeeded"
                                                                                ]
                                                                            },
                                                                            "type": "SetVariable",
                                                                            "inputs": {
                                                                                "name": "Checkpoint",
                                                                                "value": "ProcessChannel"
                                                                            }
                                                                        },
                                                                        "APIMRouting:Success:_Set_ResponseMessage_variable": {
                                                                            "runAfter": {},
                                                                            "type": "SetVariable",
                                                                            "inputs": {
                                                                                "name": "ResponseMessage",
                                                                                "value": "@body('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')"
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            },
                                                            "default": {
                                                                "actions": {
                                                                    "APIMRouting:Failure:_Do_we_have_a_Fault_Message": {
                                                                        "actions": {
                                                                            "APIMRouting:Fault:_Set_ErrorMessage_variable": {
                                                                                "runAfter": {
                                                                                    "APIMRouting:Fault:_Set_FaultMessage_variable": [
                                                                                        "Succeeded"
                                                                                    ]
                                                                                },
                                                                                "type": "SetVariable",
                                                                                "inputs": {
                                                                                    "name": "ErrorMessage",
                                                                                    "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager SendToNextRoute operation"
                                                                                }
                                                                            },
                                                                            "APIMRouting:Fault:_Set_FaultMessage_variable": {
                                                                                "runAfter": {},
                                                                                "type": "SetVariable",
                                                                                "inputs": {
                                                                                    "name": "FaultMessage",
                                                                                    "value": "@body('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')"
                                                                                }
                                                                            }
                                                                        },
                                                                        "runAfter": {},
                                                                        "else": {
                                                                            "actions": {
                                                                                "APIMRouting:NoFault:_Create_Fault_Message": {
                                                                                    "runAfter": {},
                                                                                    "type": "Compose",
                                                                                    "inputs": {
                                                                                        "fault": {
                                                                                            "faultActor": "@concat(workflow()?['name'], '.', actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['name'], ' (', workflow()?['run']?['name'], ')')",
                                                                                            "faultCategory": "Error",
                                                                                            "faultCode": "@{coalesce(outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['statusCode'], outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['body']?['statusCode'], actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['error']?['code'])}",
                                                                                            "faultMessage": "@{coalesce(outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['error']?['message'], outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['body']?['message'], actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['error']?['message'])}",
                                                                                            "faultReason": "@{actions('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['status']}"
                                                                                        }
                                                                                    }
                                                                                },
                                                                                "APIMRouting:NoFault:_Set_ErrorMessage_variable": {
                                                                                    "runAfter": {
                                                                                        "APIMRouting:NoFault:_Set_FaultMessage_variable": [
                                                                                            "Succeeded"
                                                                                        ]
                                                                                    },
                                                                                    "type": "SetVariable",
                                                                                    "inputs": {
                                                                                        "name": "ErrorMessage",
                                                                                        "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager SendToNextRoute operation"
                                                                                    }
                                                                                },
                                                                                "APIMRouting:NoFault:_Set_FaultMessage_variable": {
                                                                                    "runAfter": {
                                                                                        "APIMRouting:NoFault:_Create_Fault_Message": [
                                                                                            "Succeeded"
                                                                                        ]
                                                                                    },
                                                                                    "type": "SetVariable",
                                                                                    "inputs": {
                                                                                        "name": "FaultMessage",
                                                                                        "value": "@outputs('APIMRouting:NoFault:_Create_Fault_Message')"
                                                                                    }
                                                                                }
                                                                            }
                                                                        },
                                                                        "expression": {
                                                                            "and": [
                                                                                {
                                                                                    "not": {
                                                                                        "equals": [
                                                                                            "@body('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')?['fault']",
                                                                                            null
                                                                                        ]
                                                                                    }
                                                                                }
                                                                            ]
                                                                        },
                                                                        "type": "If"
                                                                    }
                                                                }
                                                            },
                                                            "expression": "@variables('StatusCode')",
                                                            "type": "Switch"
                                                        },
                                                        "APIMRouting:_Set_StatusCode_variable": {
                                                            "runAfter": {
                                                                "APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute": [
                                                                    "Succeeded",
                                                                    "Failed",
                                                                    "TimedOut",
                                                                    "Skipped"
                                                                ]
                                                            },
                                                            "type": "SetVariable",
                                                            "inputs": {
                                                                "name": "StatusCode",
                                                                "value": "@coalesce(outputs('APIMRouting:_Call_APIM_RoutingManager.SendToNextRoute')['statusCode'], 500)"
                                                            }
                                                        }
                                                    }
                                                }
                                            },
                                            "default": {
                                                "actions": {
                                                    "Unsupported_ChannelType:_Set_ErrorMessage_variable": {
                                                        "runAfter": {},
                                                        "type": "SetVariable",
                                                        "inputs": {
                                                            "name": "ErrorMessage",
                                                            "value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): Have an unsupported ChannelType value of @{coalesce(variables('ChannelType'), '(not supplied)')}"
                                                        }
                                                    }
                                                }
                                            },
                                            "expression": "@variables('ChannelType')",
                                            "type": "Switch"
                                        }
                                    },
                                    "runAfter": {},
                                    "type": "Scope"
                                }
                            },
                            "runAfter": {
                                "Step:_Check_if_have_processed_all_routes": [
                                    "Succeeded",
                                    "Failed",
                                    "Skipped",
                                    "TimedOut"
                                ]
                            },
                            "expression": {
                                "and": [
                                    {
                                        "equals": [
                                            "@variables('Checkpoint')",
                                            "RoutesToProcess"
                                        ]
                                    }
                                ]
                            },
                            "type": "If"
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "scenarioStep": {
                        "value": "[parameters('scenarioStep')]"
                    },
                    "apimSubscriptionKey": {
                        "value": "[parameters('apimSubscriptionKey')]"
                    }
                }
            }
        }
    ]
}
tools\templates\messagebus\workflows\routingsliprouter\routingsliprouter.logicapp.prod.parameters.json.liquid
 
tools\templates\messagebus\workflows\routingsliprouter\TearDown-80-RoutingSlipRouter-LogicApp.ps1.liquid
 
tools\templates\messages\schemas\Deploy-100-Schema.ps1.liquid
 
tools\templates\messages\schemas\New-Schema.ps1.liquid
 
tools\templates\messages\schemas\Remove-Schema.ps1.liquid
 
tools\templates\messages\schemas\requestbody.dev.json.liquid
 
tools\templates\messages\schemas\requestbody.prod.json.liquid
 
tools\templates\messages\schemas\TearDown-100-Schema.ps1.liquid
 
tools\templates\messages\transforms\Deploy-120-Map.ps1.liquid
 
tools\templates\messages\transforms\New-Map.ps1.liquid
 
tools\templates\messages\transforms\Remove-Map.ps1.liquid
 
tools\templates\messages\transforms\requestbody.dev.json.liquid
 
tools\templates\messages\transforms\requestbody.prod.json.liquid
 
tools\templates\messages\transforms\TearDown-120-Map.ps1.liquid
 
tools\VERIFICATION.txt
VERIFICATION
Verification is intended to assist Chocolatey moderators and the Chocolatey community
in verifying that this package's contents are trustworthy.

This package contains liquid template files, json files, powershell scripts, and a couple of zip files (containing Azure Functions).
This file lists their SHA256 checksums.

There is no other source for installation of these files, other than Chocolatey: 
The files are built and packaged and uploaded to Chocolatey; other than referenced files (e.g. .NET Core), they do not currently reside in any other public source.
Therefore, it is not possible to download an installer to compare checksums.

However, the checksums in here are generated as part of the build process,
and reflect the files that are packaged and submitted to Chocolatey.

It is still worthwhile comparing the checksums in this file to the ones for the files that have been installed by Chocolatey on your local system.

You can use one of the following methods to obtain the checksum from a local file:
  - Use powershell function 'Get-Filehash'
  - Use chocolatey utility 'checksum.exe'

File 'LICENSE.txt' is obtained from <https://github.com/Azure/aimazure/blob/main/LICENSE>

Checksums for the files in the package are:
LICENSE.txt [dist/choco-src/LICENSE.txt] -- 9906940f61b1f0b533fa7d99baf55178b2808fbe113ea51dfbfad8572ccd5f2b
VERIFICATION.txt [dist/choco-src/VERIFICATION.txt] -- 020024d8e6d4a211fedd69a2b3da6522757f35235d0c63eeadebc8cfee6be6a8
applicationgroup.dev.parameters.json.liquid [./templates/application/applicationgroup/applicationgroup.dev.parameters.json.liquid] -- 6ba6e48a5842d44f7624104ba252434de79d7c9a4e0997d7f7641d6dc65ddc07
applicationgroup.json.liquid [./templates/application/applicationgroup/applicationgroup.json.liquid] -- 1379def2deb0214bac849a52e56c1fc4e3f864c0aa9d1f6f35d88ec33a72d28a
applicationgroup.prod.parameters.json.liquid [./templates/application/applicationgroup/applicationgroup.prod.parameters.json.liquid] -- 6ba6e48a5842d44f7624104ba252434de79d7c9a4e0997d7f7641d6dc65ddc07
Deploy-10-ApplicationGroup.ps1.liquid [./templates/application/applicationgroup/Deploy-10-ApplicationGroup.ps1.liquid] -- 38a64e6dbfc1afe3c038004339295911839de5cd77c9b7c46378dc9bb7ed1b58
New-ApplicationGroup.ps1.liquid [./templates/application/applicationgroup/New-ApplicationGroup.ps1.liquid] -- 18278ab80fe1fbb2810d951d13ff1f3a0869fb7b87311f3b29afcee5e44b58a0
Remove-ApplicationGroup.ps1.liquid [./templates/application/applicationgroup/Remove-ApplicationGroup.ps1.liquid] -- e08e6d9105e2aa2a017304c62a88d4566c78fa39a92433342dbbc641cc6be4d1
TearDown-10-ApplicationGroup.ps1.liquid [./templates/application/applicationgroup/TearDown-10-ApplicationGroup.ps1.liquid] -- 7bdb8ae681b068a6bdf2ef92bba5ea6fc2c71275d25e7154f0138fbf1fe7444f
configurationentry.appcfg.dev.psparameters.json.liquid [./templates/application/config/configurationentries/configurationentry.appcfg.dev.psparameters.json.liquid] -- 55244ae3f0d639237acb05aa8bf87feff04e57ef8e56b35010cb25f8de767f22
configurationentry.appcfg.prod.psparameters.json.liquid [./templates/application/config/configurationentries/configurationentry.appcfg.prod.psparameters.json.liquid] -- 55244ae3f0d639237acb05aa8bf87feff04e57ef8e56b35010cb25f8de767f22
Deploy-105-ConfigurationEntry-AppConfig.ps1.liquid [./templates/application/config/configurationentries/Deploy-105-ConfigurationEntry-AppConfig.ps1.liquid] -- db5f17d8797979403933179a02792a9fa421ecabb6265656dc0e2367a30ba3b0
New-ConfigurationEntry-AppConfig.ps1 [./templates/application/config/configurationentries/New-ConfigurationEntry-AppConfig.ps1] -- ce1c6aaa40c860ce95a3a56147bb8794034b5a0e07d92538dec036bdac097505
Remove-ConfigurationEntry-AppConfig.ps1 [./templates/application/config/configurationentries/Remove-ConfigurationEntry-AppConfig.ps1] -- 090742f2b998993878017a7012cd525e8427a046dc3ad171dcdda959cccf4fff
TearDown-105-ConfigurationEntry-AppConfig.ps1.liquid [./templates/application/config/configurationentries/TearDown-105-ConfigurationEntry-AppConfig.ps1.liquid] -- c09495e03df5d1ad7bc7123480939add6dc1cdcce76af51010496ed62dda7bf8
Deploy-105-RoutingProperties-AppConfig.ps1.liquid [./templates/application/config/routingproperties/route/Deploy-105-RoutingProperties-AppConfig.ps1.liquid] -- 70f1e87eef0087350194ae7079bbc02a7defde7f9ae4266c0ffc1e07fb6b36ff
New-RoutingProperties-AppConfig.ps1 [./templates/application/config/routingproperties/route/New-RoutingProperties-AppConfig.ps1] -- 3c208dd9ee9ad4ab0e2ba30fbba9c36fef67778c4de848a5678baa97ff74ac9c
Remove-RoutingProperties-AppConfig.ps1 [./templates/application/config/routingproperties/route/Remove-RoutingProperties-AppConfig.ps1] -- 7638b0cdcd2b0f87f2006dc6678114b3e01d24d1f10ace22eb62e1416c306319
routingproperties.appcfg.dev.psparameters.json.liquid [./templates/application/config/routingproperties/route/routingproperties.appcfg.dev.psparameters.json.liquid] -- 26ebfde629aad0960be0dfddadb4736adaf8da7b56bc692e74b0f6719aa87bae
routingproperties.appcfg.prod.psparameters.json.liquid [./templates/application/config/routingproperties/route/routingproperties.appcfg.prod.psparameters.json.liquid] -- 26ebfde629aad0960be0dfddadb4736adaf8da7b56bc692e74b0f6719aa87bae
TearDown-105-RoutingProperties-AppConfig.ps1.liquid [./templates/application/config/routingproperties/route/TearDown-105-RoutingProperties-AppConfig.ps1.liquid] -- 94beb55cdb98375388a56a08126220c4329433478f25c0ec1199717e24878637
Deploy-105-RoutingProperties-AppConfig.ps1.liquid [./templates/application/config/routingproperties/schema/Deploy-105-RoutingProperties-AppConfig.ps1.liquid] -- b99687dd6c07fc107f9bca0cb161010527bb288f27894db1602c2259319ca4fc
New-RoutingProperties-AppConfig.ps1 [./templates/application/config/routingproperties/schema/New-RoutingProperties-AppConfig.ps1] -- dc4bf8882ae4c38d623ff4a5623995fa8366452e8d61560118adf6dda73ba8ff
Remove-RoutingProperties-AppConfig.ps1 [./templates/application/config/routingproperties/schema/Remove-RoutingProperties-AppConfig.ps1] -- 32bc3253cc3905c11515846867c8d521eee3fb1bb13d7a8df962101b8c7f4e05
routingproperties.appcfg.dev.psparameters.json.liquid [./templates/application/config/routingproperties/schema/routingproperties.appcfg.dev.psparameters.json.liquid] -- eaa23e13b518acf7608b0e036ca7388d1cbaaecfd503d2b822cce97c9a10c33f
routingproperties.appcfg.prod.psparameters.json.liquid [./templates/application/config/routingproperties/schema/routingproperties.appcfg.prod.psparameters.json.liquid] -- eaa23e13b518acf7608b0e036ca7388d1cbaaecfd503d2b822cce97c9a10c33f
TearDown-105-RoutingProperties-AppConfig.ps1.liquid [./templates/application/config/routingproperties/schema/TearDown-105-RoutingProperties-AppConfig.ps1.liquid] -- ba0929781bf69d07d11aa74b148d331e0ce4eace4c5b1354dc5b0a9a64e4f2cf
Deploy-105-RoutingSlip-AppConfig.ps1.liquid [./templates/application/config/routingslips/Deploy-105-RoutingSlip-AppConfig.ps1.liquid] -- bc894956a94c4200e3ba54d952f247a0f705b22e56e897434f50dfcb54a16fd1
New-RoutingSlip-AppConfig.ps1 [./templates/application/config/routingslips/New-RoutingSlip-AppConfig.ps1] -- 50a155243f876b72dcd5175e64443c1c1193d79a0a4628526790603af33755c8
Remove-RoutingSlip-AppConfig.ps1 [./templates/application/config/routingslips/Remove-RoutingSlip-AppConfig.ps1] -- ee93dfb266902090f82e4afd70ea0428f157563f2591814cb82f1a26b66acb81
routingslip.appcfg.dev.psparameters.json.liquid [./templates/application/config/routingslips/routingslip.appcfg.dev.psparameters.json.liquid] -- 580a0d41cee80cd41941d5bb875212ecc4f4019ae39cf7bccd18520873b2caf9
routingslip.appcfg.prod.psparameters.json.liquid [./templates/application/config/routingslips/routingslip.appcfg.prod.psparameters.json.liquid] -- 580a0d41cee80cd41941d5bb875212ecc4f4019ae39cf7bccd18520873b2caf9
TearDown-105-RoutingSlip-AppConfig.ps1.liquid [./templates/application/config/routingslips/TearDown-105-RoutingSlip-AppConfig.ps1.liquid] -- 530f0064d3cd16dd9853932c99e87f1d8d2dc1d288058a01ad08610a606d4dad
application.logic.dev.parameters.json.liquid [./templates/application/standard/application.logic.dev.parameters.json.liquid] -- 9387c0c6fbfecd525e678ede7a614fedc6eccae7ba4dce611f7c735cda0e842e
application.logic.prod.parameters.json.liquid [./templates/application/standard/application.logic.prod.parameters.json.liquid] -- 9387c0c6fbfecd525e678ede7a614fedc6eccae7ba4dce611f7c735cda0e842e
.funcignore [./templates/application/standard/application.logic.workflows/.funcignore] -- 96393bc26432421a0722a6d9f611083740cdbdce59205eb5de412df91669c8af
extensions.json [./templates/application/standard/application.logic.workflows/.vscode/extensions.json] -- dc808d40149bd12a4566c98e2e4cdd5f56c9ac11021805667b2749021b98f2a9
launch.json [./templates/application/standard/application.logic.workflows/.vscode/launch.json] -- de0269109118db95ac611b185f80bd5a78341a711e84a6a0bfede358e95ffe5a
settings.json [./templates/application/standard/application.logic.workflows/.vscode/settings.json] -- 3b5b7abc9971860ba37a6a8b1186a645ad1acdc0f7d995860a52fbbba76067a8
tasks.json [./templates/application/standard/application.logic.workflows/.vscode/tasks.json] -- dfcc0600c8cb6847bc2827b0ca59f869fe1ed0e05418f766595d5f949ed674dc
base.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/base.appsettings.local.json.liquid] -- 8f69f360a35de30ebb3343d766820eb5903510767cbbf60cc54177b5c8a68f18
base.connections.json.liquid [./templates/application/standard/application.logic.workflows/base.connections.json.liquid] -- e60b000055af7f4c0d426e04470848e121da0895f0280cab4c8320c6c619b74d
base.parameters.json.liquid [./templates/application/standard/application.logic.workflows/base.parameters.json.liquid] -- 5eaf5e3a4d0967c630216148d39466f82c1fa80017d4163093cf3451723937c7
base.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/base.parameters.local.json.liquid] -- 5eaf5e3a4d0967c630216148d39466f82c1fa80017d4163093cf3451723937c7
filereceiveadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/filereceiveadapter/filereceiveadapter.appsettings.json.liquid] -- 653047dc93ae6be7216a5d160903dabc8d92ed9d61d34899cc52a2a8835887ff
filereceiveadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/filereceiveadapter/filereceiveadapter.appsettings.local.json.liquid] -- b3b1b54df8b47802b6cd22841502c0998c6963e113f8d4adebbea977fb354e9c
filereceiveadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/filereceiveadapter/filereceiveadapter.connections.json.liquid] -- ab0db3efa8cb24bf3a12b8a2e82ea369c333b9b69b8ce5d78e2447f80a486e42
filereceiveadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/filereceiveadapter/filereceiveadapter.parameters.json.liquid] -- a78637e05f461e31dcce8085974d247f07102e681b535752cab6ac36ef5c2b7e
filereceiveadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/filereceiveadapter/filereceiveadapter.parameters.local.json.liquid] -- 34b3d3928ee5364ab59de25f8e7a0913b67c56e0cda1f879d989972b65b37d9f
workflow.json.liquid [./templates/application/standard/application.logic.workflows/filereceiveadapter/workflow.json.liquid] -- 189246491ea8cd00536fa152d387bf504d7b2455f586e8f4bf3f797327d4afe6
filesendadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/filesendadapter/filesendadapter.appsettings.json.liquid] -- cc7edfdb57f196f9406224770418df6e6b365c8ccc240a7d575281dfb159da23
filesendadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/filesendadapter/filesendadapter.appsettings.local.json.liquid] -- 448f15e0e6a0fa70034797709474ee2333c0608df805eedfc15190485ec7cf32
filesendadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/filesendadapter/filesendadapter.connections.json.liquid] -- 16afe519421ea3144e6d73dbe01a14aae3df038502d49b461d7a1a82ae305c3c
filesendadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/filesendadapter/filesendadapter.parameters.json.liquid] -- 5481f0b9dec7d442f7c3204d3cc3c70dc538809de512a6b67407dddfd51034e0
filesendadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/filesendadapter/filesendadapter.parameters.local.json.liquid] -- e03aec90fdc68fad5f600794e7abb4b8b159d0ad0fcae0a9d1421d63afc31f2e
workflow.json.liquid [./templates/application/standard/application.logic.workflows/filesendadapter/workflow.json.liquid] -- e60c0cb682f6d9c7f92ad0679f51c8f8564f8323ebc61122c5f4b4bb364aa0de
ftpreceiveadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/ftpreceiveadapter/ftpreceiveadapter.appsettings.json.liquid] -- 3e31d3e99ad91af9f00885fa1b96ecf7d6ba897837e6b71e683377683cb23e62
ftpreceiveadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/ftpreceiveadapter/ftpreceiveadapter.appsettings.local.json.liquid] -- 520a948d69708c54dec43a8488354894082882ad7a1932dd08165c4bdcb31ac3
ftpreceiveadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/ftpreceiveadapter/ftpreceiveadapter.connections.json.liquid] -- d7cb1e2cbe8a591ff872008b7fccca9612993cc5003a253cffa77524e439c7c2
ftpreceiveadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/ftpreceiveadapter/ftpreceiveadapter.parameters.json.liquid] -- 47852840fc17037cf620f64be4ff10216e90b0c91007c181978499203514f33c
ftpreceiveadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/ftpreceiveadapter/ftpreceiveadapter.parameters.local.json.liquid] -- 6952e58230f01af6fbecb1133e76c3a5d9836ac381421ec0c13262540eb9e4ff
workflow.json.liquid [./templates/application/standard/application.logic.workflows/ftpreceiveadapter/workflow.json.liquid] -- 0fbab7d6999a4740de68daef7161376a7a5128c7b97e8bdf34638fba32f31e1a
ftpsendadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/ftpsendadapter/ftpsendadapter.appsettings.json.liquid] -- 527d8c20e6382975d64650e0401ed45bd3828fec7c09f42245524337acb2a77d
ftpsendadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/ftpsendadapter/ftpsendadapter.appsettings.local.json.liquid] -- 5c278d0e01f7d65eceaceac2d7429367b1c463f748a5a1944b8b08d47d3b3282
ftpsendadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/ftpsendadapter/ftpsendadapter.connections.json.liquid] -- 3a9d57072c30bd02bcd39527b133428b5f66039e7b095ac4f06adc463733dae7
ftpsendadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/ftpsendadapter/ftpsendadapter.parameters.json.liquid] -- 8b6cd2fd5fa632543c7657bbfe8e9961b99443766c850ec87acd6b0fde41c4e9
ftpsendadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/ftpsendadapter/ftpsendadapter.parameters.local.json.liquid] -- c364dc85dd3d254e31822b24566ec60bf98b480cf425a44b69d94008ace01960
workflow.json.liquid [./templates/application/standard/application.logic.workflows/ftpsendadapter/workflow.json.liquid] -- dbdbbefcd52cfe5d7e6aafa28a389fe0d4609a3131f6345ca5dfe3b142cbd74b
host.json [./templates/application/standard/application.logic.workflows/host.json] -- 4c01b0f013d3e14d11c063affc7ddfa03ab59ef1557299e4d9594efee5487767
httpreceiveadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/httpreceiveadapter/httpreceiveadapter.appsettings.json.liquid] -- 5cada29124805d8e0454dc5b67225bbf87075cffd53418e9c56f674708220e2c
httpreceiveadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/httpreceiveadapter/httpreceiveadapter.appsettings.local.json.liquid] -- bac6a76645c48064f198e711301492ace386110831d381f33ba68a3db6847bd4
httpreceiveadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/httpreceiveadapter/httpreceiveadapter.connections.json.liquid] -- 85038539f84248f858746333cc4d27a7628d7bf182ccd4ac4c8c585337f30c8d
httpreceiveadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/httpreceiveadapter/httpreceiveadapter.parameters.json.liquid] -- 6008f4e2ab853e8786e8be021f981228ac37ca36da4957234d86010ab1a324e9
httpreceiveadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/httpreceiveadapter/httpreceiveadapter.parameters.local.json.liquid] -- 6008f4e2ab853e8786e8be021f981228ac37ca36da4957234d86010ab1a324e9
workflow.json.liquid [./templates/application/standard/application.logic.workflows/httpreceiveadapter/workflow.json.liquid] -- 7cf039fed6ae4ed85f25800e707de37f77eb0929615987c0feb9e9eb885251ed
httpsendadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/httpsendadapter/httpsendadapter.appsettings.json.liquid] -- bac6a76645c48064f198e711301492ace386110831d381f33ba68a3db6847bd4
httpsendadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/httpsendadapter/httpsendadapter.appsettings.local.json.liquid] -- bac6a76645c48064f198e711301492ace386110831d381f33ba68a3db6847bd4
httpsendadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/httpsendadapter/httpsendadapter.connections.json.liquid] -- 85038539f84248f858746333cc4d27a7628d7bf182ccd4ac4c8c585337f30c8d
httpsendadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/httpsendadapter/httpsendadapter.parameters.json.liquid] -- bac6a76645c48064f198e711301492ace386110831d381f33ba68a3db6847bd4
httpsendadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/httpsendadapter/httpsendadapter.parameters.local.json.liquid] -- bac6a76645c48064f198e711301492ace386110831d381f33ba68a3db6847bd4
workflow.json.liquid [./templates/application/standard/application.logic.workflows/httpsendadapter/workflow.json.liquid] -- f49f631a7a8fd26cb71ebaad72adc68b3453f4b366e309da1547c41865ddbe08
sftpreceiveadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/sftpreceiveadapter/sftpreceiveadapter.appsettings.json.liquid] -- fd801c017d8c9f02f7fc8c28f1992d4816b7af1f94487ffdafc443b9eda795bd
sftpreceiveadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/sftpreceiveadapter/sftpreceiveadapter.appsettings.local.json.liquid] -- 75607002a55ff7da4ec87db8bed90bf01e349d5a3273a4c52cb76ae579208dd8
sftpreceiveadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/sftpreceiveadapter/sftpreceiveadapter.connections.json.liquid] -- 67a64f76f40ae964bc6a96ec99f3ca3b5c014488df75d2b3c18bb1c06bef6605
sftpreceiveadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/sftpreceiveadapter/sftpreceiveadapter.parameters.json.liquid] -- 3f3b04d95f6d5d4cc29f26d10f78aab8aa0d05851c0dca0282eb0ea3a26ef1c8
sftpreceiveadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/sftpreceiveadapter/sftpreceiveadapter.parameters.local.json.liquid] -- eb6df9cea433f71efc902c6fe945960035519686e8f739514fa3278a647a9068
workflow.json.liquid [./templates/application/standard/application.logic.workflows/sftpreceiveadapter/workflow.json.liquid] -- 23d1d643f96755b97ef810d91aba1a68cead703c1b178cfe9ae4db8e240fdff2
sftpsendadapter.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/sftpsendadapter/sftpsendadapter.appsettings.json.liquid] -- 06587590c61af793611bb8dddff2d6ea49973e280576912e81d622825da8a336
sftpsendadapter.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/sftpsendadapter/sftpsendadapter.appsettings.local.json.liquid] -- 7e093e3e53fd312107a6f9ff2bb991261e7cd2dfffe811226c2048976f3d3185
sftpsendadapter.connections.json.liquid [./templates/application/standard/application.logic.workflows/sftpsendadapter/sftpsendadapter.connections.json.liquid] -- bdf34244438c1dac6a2c489a2bbe3ef50cd0ec7f16ae33756ace071120d3cb4c
sftpsendadapter.parameters.json.liquid [./templates/application/standard/application.logic.workflows/sftpsendadapter/sftpsendadapter.parameters.json.liquid] -- 78d42f8de63aa14c835d92087bbe55128df622aeb59f75a581298bb25f8c90ba
sftpsendadapter.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/sftpsendadapter/sftpsendadapter.parameters.local.json.liquid] -- 79dfedbda7a5f5083b60920cbf7d0d12ae539cbd76edd922fc18e768b7a8a17e
workflow.json.liquid [./templates/application/standard/application.logic.workflows/sftpsendadapter/workflow.json.liquid] -- dbdbbefcd52cfe5d7e6aafa28a389fe0d4609a3131f6345ca5dfe3b142cbd74b
topicsubscriber.appsettings.json.liquid [./templates/application/standard/application.logic.workflows/topicsubscriber/topicsubscriber.appsettings.json.liquid] -- 4f53cda18c2baa0c0354bb5f9a3ecbe5ed12ab4d8e11ba873c2f11161202b945
topicsubscriber.appsettings.local.json.liquid [./templates/application/standard/application.logic.workflows/topicsubscriber/topicsubscriber.appsettings.local.json.liquid] -- 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
topicsubscriber.connections.json.liquid [./templates/application/standard/application.logic.workflows/topicsubscriber/topicsubscriber.connections.json.liquid] -- 85038539f84248f858746333cc4d27a7628d7bf182ccd4ac4c8c585337f30c8d
topicsubscriber.parameters.json.liquid [./templates/application/standard/application.logic.workflows/topicsubscriber/topicsubscriber.parameters.json.liquid] -- 0e6a71b86a7208e7dacb7065f6abd47479931434316b3bc1acbd763a5dc6d85f
topicsubscriber.parameters.local.json.liquid [./templates/application/standard/application.logic.workflows/topicsubscriber/topicsubscriber.parameters.local.json.liquid] -- 0e6a71b86a7208e7dacb7065f6abd47479931434316b3bc1acbd763a5dc6d85f
workflow.json.liquid [./templates/application/standard/application.logic.workflows/topicsubscriber/workflow.json.liquid] -- 1d08ac5c58e228f2f98e63eb3a49b7820ba8769c22991e7d05bcb162a28ebf5b
host.json [./templates/application/standard/application.logic.workflows/workflow-designtime/host.json] -- bb8f058a2c5ce1ceefd5ed557ec0de961cfb2089a706bfc8f1904ced9a91a754
local.settings.json [./templates/application/standard/application.logic.workflows/workflow-designtime/local.settings.json] -- 24e0bdd57da3e30c789358ca8001020601accb31ec38b38abe88e261ed09cab7
base.application.logic.json.liquid [./templates/application/standard/base.application.logic.json.liquid] -- c1781c4de38c4dcc180ef189be7b35e43adb1e8c20b80ce0e5470e882d9148ac
Deploy-105-Application-LogicApp.ps1.liquid [./templates/application/standard/Deploy-105-Application-LogicApp.ps1.liquid] -- 01131d6724c90b4781c78b2ce188dae59cec9993bfa01cd7291a4c1141c2fd73
Deploy-110-Application-LogicApp-Configuration.ps1.liquid [./templates/application/standard/Deploy-110-Application-LogicApp-Configuration.ps1.liquid] -- 011cc1bf08741fc55f9ec8980ac31877bac5c50fdb97c0ca0310b45f8ce12052
Deploy-115-Application-LogicApp-Workflows.ps1.liquid [./templates/application/standard/Deploy-115-Application-LogicApp-Workflows.ps1.liquid] -- 73b45f1b3156f28b0453f69f37cebac862db1f0cb6dad1da884df488f7cddf3a
Deploy-120-Application-ClearUrlCache.ps1.liquid [./templates/application/standard/Deploy-120-Application-ClearUrlCache.ps1.liquid] -- b1a6287222f72b487857478429760e353cee5c58ac599e14f0370ce1794875e6
New-Application-ClearUrlCache.ps1 [./templates/application/standard/New-Application-ClearUrlCache.ps1] -- eeb5b4298d49ad53c6e29ba73f233a3b81fa8a55b03c2140806bd90c7abe70ab
New-Application-LogicApp-Configuration.ps1 [./templates/application/standard/New-Application-LogicApp-Configuration.ps1] -- 001930b32bf36ad34d4d9d49459e39ac86ee6de500d2314f4f52dfd0ebe8780c
New-Application-LogicApp-Workflows.ps1 [./templates/application/standard/New-Application-LogicApp-Workflows.ps1] -- 797bdf536c409442aa503393db145fc71fe6777d15fc867781c83521f01a6fde
New-Application-LogicApp.ps1 [./templates/application/standard/New-Application-LogicApp.ps1] -- 86720aea05fee9b2e98f3a1eacbef0a8c21bd6258a2a3d40febafd4f56b46d59
Remove-Application-LogicApp.ps1 [./templates/application/standard/Remove-Application-LogicApp.ps1] -- b1f1b8249563a1670652b6f7fd3c4246b6705d4bdafbb9c8e0b635bf1a76a54d
TearDown-100-Application-LogicApp.ps1.liquid [./templates/application/standard/TearDown-100-Application-LogicApp.ps1.liquid] -- ddbbfb6ba5b4be4a7e2d2c96c1f43aee9d7104acd715148d81654815a889117b
Deploy-80-MessageResponseHandlerServiceBus-ApiConnection.ps1.liquid [./templates/application/workflows/messageresponsehandler/Deploy-80-MessageResponseHandlerServiceBus-ApiConnection.ps1.liquid] -- bc06a254064a7f127dc7cb3e1f7e7af6a6d4e53222b2d4f208acd5fd13655249
Deploy-85-MessageResponseHandler-LogicApp.ps1.liquid [./templates/application/workflows/messageresponsehandler/Deploy-85-MessageResponseHandler-LogicApp.ps1.liquid] -- a55e2d110f94b644194c6ffddec2fc90fa359e896ee83948bcea10e917278c6b
Deploy-90-MessageResponseHandlerServiceBus-ApiConnPolicy.ps1.liquid [./templates/application/workflows/messageresponsehandler/Deploy-90-MessageResponseHandlerServiceBus-ApiConnPolicy.ps1.liquid] -- a28d203f95641714f5b6f5c63c6c48e36f271d90328611014a60274ce5b301b7
messageresponsehandler.logicapp.dev.parameters.json.liquid [./templates/application/workflows/messageresponsehandler/messageresponsehandler.logicapp.dev.parameters.json.liquid] -- b3a6c47c22f0f3f33894d53e38c7daea1041417255e439911d36cd150caeab67
messageresponsehandler.logicapp.json [./templates/application/workflows/messageresponsehandler/messageresponsehandler.logicapp.json] -- 814b04b87d759c27f17519836996b2447a0998462c8f2e15c971b61dc45b4804
messageresponsehandler.logicapp.prod.parameters.json.liquid [./templates/application/workflows/messageresponsehandler/messageresponsehandler.logicapp.prod.parameters.json.liquid] -- b3a6c47c22f0f3f33894d53e38c7daea1041417255e439911d36cd150caeab67
messageresponsehandlerservicebus.apiconnection.dev.parameters.json.liquid [./templates/application/workflows/messageresponsehandler/messageresponsehandlerservicebus.apiconnection.dev.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
messageresponsehandlerservicebus.apiconnection.json.liquid [./templates/application/workflows/messageresponsehandler/messageresponsehandlerservicebus.apiconnection.json.liquid] -- 4e4279c2066ebf0eed61b396bca8299fcf240c218076511d4059f3fd875776bc
messageresponsehandlerservicebus.apiconnection.prod.parameters.json.liquid [./templates/application/workflows/messageresponsehandler/messageresponsehandlerservicebus.apiconnection.prod.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
messageresponsehandlerservicebus.apiconnpolicy.dev.parameters.json.liquid [./templates/application/workflows/messageresponsehandler/messageresponsehandlerservicebus.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
messageresponsehandlerservicebus.apiconnpolicy.json [./templates/application/workflows/messageresponsehandler/messageresponsehandlerservicebus.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
messageresponsehandlerservicebus.apiconnpolicy.prod.parameters.json.liquid [./templates/application/workflows/messageresponsehandler/messageresponsehandlerservicebus.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
New-MessageResponseHandler-LogicApp.ps1 [./templates/application/workflows/messageresponsehandler/New-MessageResponseHandler-LogicApp.ps1] -- b88f98d9314e82c5a08d3753fb4db64db61cb0a2b107a43038a83f8bd6b69b8e
New-MessageResponseHandlerServiceBus-ApiConnection.ps1 [./templates/application/workflows/messageresponsehandler/New-MessageResponseHandlerServiceBus-ApiConnection.ps1] -- 3b99d6e1ab508e8a65b7962ace057ed0ec01ea86d300cc0b17539cc12b3c84d5
New-MessageResponseHandlerServiceBus-ApiConnPolicy.ps1 [./templates/application/workflows/messageresponsehandler/New-MessageResponseHandlerServiceBus-ApiConnPolicy.ps1] -- ab55b222ef896ca9b506eae322ee5553ca2c5c31008480f538a1c647647621a7
Remove-MessageResponseHandler-LogicApp.ps1 [./templates/application/workflows/messageresponsehandler/Remove-MessageResponseHandler-LogicApp.ps1] -- 61522bf8a3b55c1ab9ed2ab377ef223bd024f9b39bb59fc24f95826eb50bb9bf
Remove-MessageResponseHandlerServiceBus-ApiConnection.ps1 [./templates/application/workflows/messageresponsehandler/Remove-MessageResponseHandlerServiceBus-ApiConnection.ps1] -- 3dc4b47d16328cb5a73718a30cf3ebd2e37d339ba9c8f7901ac918cba65164e8
TearDown-80-MessageResponseHandlerServiceBus-ApiConnection.ps1.liquid [./templates/application/workflows/messageresponsehandler/TearDown-80-MessageResponseHandlerServiceBus-ApiConnection.ps1.liquid] -- 1db7ad5132c589a1a0803b634660159030c8e5a7ea4e260139b0bfa24a456a70
TearDown-85-MessageResponseHandler-LogicApp.ps1.liquid [./templates/application/workflows/messageresponsehandler/TearDown-85-MessageResponseHandler-LogicApp.ps1.liquid] -- bfba01d1f527ba27e86fb62ba145be51c204dc48259004c63e21ba235c6b5089
Deploy-80-MessageSuspendProcessorServiceBus-ApiConnection.ps1.liquid [./templates/application/workflows/messagesuspendprocessor/Deploy-80-MessageSuspendProcessorServiceBus-ApiConnection.ps1.liquid] -- 8a37a18756553c74b0ef4be8215259b9e7a5ca430c427271ddd317f81565e3c2
Deploy-85-MessageSuspendProcessor-LogicApp.ps1.liquid [./templates/application/workflows/messagesuspendprocessor/Deploy-85-MessageSuspendProcessor-LogicApp.ps1.liquid] -- 15e7641f8f4ce35a682ad702e8e568f4c7d58adac15e2b89ece4c1f1ec8695a1
messagesuspendprocessor.logicapp.dev.parameters.json.liquid [./templates/application/workflows/messagesuspendprocessor/messagesuspendprocessor.logicapp.dev.parameters.json.liquid] -- 10612d10af8555286b11799956524f282d3664a64607228ba64f924341bfbb85
messagesuspendprocessor.logicapp.json [./templates/application/workflows/messagesuspendprocessor/messagesuspendprocessor.logicapp.json] -- 4b90315256a5b84dcfab5539f26d837eb3bb4162bb1baa0be18fa8f6c1dd12e1
messagesuspendprocessor.logicapp.prod.parameters.json.liquid [./templates/application/workflows/messagesuspendprocessor/messagesuspendprocessor.logicapp.prod.parameters.json.liquid] -- 10612d10af8555286b11799956524f282d3664a64607228ba64f924341bfbb85
messagesuspendprocessorservicebus.apiconnection.dev.parameters.json.liquid [./templates/application/workflows/messagesuspendprocessor/messagesuspendprocessorservicebus.apiconnection.dev.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
messagesuspendprocessorservicebus.apiconnection.json.liquid [./templates/application/workflows/messagesuspendprocessor/messagesuspendprocessorservicebus.apiconnection.json.liquid] -- 4e4279c2066ebf0eed61b396bca8299fcf240c218076511d4059f3fd875776bc
messagesuspendprocessorservicebus.apiconnection.prod.parameters.json.liquid [./templates/application/workflows/messagesuspendprocessor/messagesuspendprocessorservicebus.apiconnection.prod.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
New-MessageSuspendProcessor-LogicApp.ps1 [./templates/application/workflows/messagesuspendprocessor/New-MessageSuspendProcessor-LogicApp.ps1] -- 879e1a943006e64c95ba5c21df490955154ea2a394ac2d3eb3331d345991b297
New-MessageSuspendProcessorServiceBus-ApiConnection.ps1 [./templates/application/workflows/messagesuspendprocessor/New-MessageSuspendProcessorServiceBus-ApiConnection.ps1] -- 4105bba1c47921fb6712b72eff5e2ad9fea9d75b7bb4546549e068e228540bad
Remove-MessageSuspendProcessor-LogicApp.ps1 [./templates/application/workflows/messagesuspendprocessor/Remove-MessageSuspendProcessor-LogicApp.ps1] -- 306396e958a9ca8607dd7b0ba90353b31d9691cdfc88406eb669eccbfadd3bb9
Remove-MessageSuspendProcessorServiceBus-ApiConnection.ps1 [./templates/application/workflows/messagesuspendprocessor/Remove-MessageSuspendProcessorServiceBus-ApiConnection.ps1] -- 3dd783a3da4e3227b68c16f8a2377d32ec8ae2f050dbaa2e566c9e60bf07f646
TearDown-80-MessageSuspendProcessorServiceBus-ApiConnection.ps1.liquid [./templates/application/workflows/messagesuspendprocessor/TearDown-80-MessageSuspendProcessorServiceBus-ApiConnection.ps1.liquid] -- 7ba8a7caf0b3659d0de6fe8b2dd95208e1c242569f5629fde4ed8debb219a638
TearDown-85-MessageSuspendProcessor-LogicApp.ps1.liquid [./templates/application/workflows/messagesuspendprocessor/TearDown-85-MessageSuspendProcessor-LogicApp.ps1.liquid] -- c06ca749596ad82b186dd714c585f30091f6a67bef8321fa16d9daa5122ec269
Deploy-20-TopicChannel-ServiceBus.ps1.liquid [./templates/channels/topicchannel/Deploy-20-TopicChannel-ServiceBus.ps1.liquid] -- 7fd57ec3c5ad58bfa63646dbe84c38a70f8212fdd5249d611af48467620e639c
Deploy-15-Namespace-ServiceBus.ps1.liquid [./templates/channels/topicchannel/namespace/Deploy-15-Namespace-ServiceBus.ps1.liquid] -- 01e5ad2733a5013d0804b9ef9019c4a6a69dd6d202011218129ae1a08d2bcba2
namespace.sb.dev.psparameters.json.liquid [./templates/channels/topicchannel/namespace/namespace.sb.dev.psparameters.json.liquid] -- 9342057e77000d25e44b267d10e738ccf10b903696b7f78fac05944048c7db08
namespace.sb.prod.psparameters.json.liquid [./templates/channels/topicchannel/namespace/namespace.sb.prod.psparameters.json.liquid] -- 9342057e77000d25e44b267d10e738ccf10b903696b7f78fac05944048c7db08
New-Namespace-ServiceBus.ps1 [./templates/channels/topicchannel/namespace/New-Namespace-ServiceBus.ps1] -- 0031cd8e3ce419580e427cb7447d1912200d16f696ad711473a2eb99f8a6fad4
Remove-Namespace-ServiceBus.ps1 [./templates/channels/topicchannel/namespace/Remove-Namespace-ServiceBus.ps1] -- 31a2699d718a9db34c29ddd19cdb4b3c355f9a422eb39e78cd3d448b61974ae8
TearDown-15-Namespace-ServiceBus.ps1.liquid [./templates/channels/topicchannel/namespace/TearDown-15-Namespace-ServiceBus.ps1.liquid] -- 5bb9d5d6e43de0b924fe8dbf51a34e61c2ec5c5474b4fffa8f9bc071375147a2
New-TopicChannel-ServiceBus.ps1 [./templates/channels/topicchannel/New-TopicChannel-ServiceBus.ps1] -- 303c04a2581e43d4b8e9f6aa77fc2bf74b73791cbc3fb21e743968cd085b3aeb
Remove-TopicChannel-ServiceBus.ps1 [./templates/channels/topicchannel/Remove-TopicChannel-ServiceBus.ps1] -- 8e95bfd8894f43ce19081a146b7dc6ced0d6344ab7b32cd2b8ee95d681d0b039
Deploy-30-TopicChannelSubscription-ServiceBus.ps1.liquid [./templates/channels/topicchannel/subscriptions/Deploy-30-TopicChannelSubscription-ServiceBus.ps1.liquid] -- 6490af3ab66d2558636fc10943ab29e4639ca624398a2c4c5cf7a1a60e3d3ae1
New-TopicChannelSubscription-ServiceBus.ps1 [./templates/channels/topicchannel/subscriptions/New-TopicChannelSubscription-ServiceBus.ps1] -- abcf54629e354518f78e102d049ce9d73b634f3d2e8efe18a0d365ad65ebcc9d
Remove-TopicChannelSubscription-ServiceBus.ps1 [./templates/channels/topicchannel/subscriptions/Remove-TopicChannelSubscription-ServiceBus.ps1] -- 574aa4dc4557f934e859f2ca54c3d1a140357d97a6d5bc73f7735a01d04e3ed0
TearDown-30-TopicChannelSubscription-ServiceBus.ps1.liquid [./templates/channels/topicchannel/subscriptions/TearDown-30-TopicChannelSubscription-ServiceBus.ps1.liquid] -- 8e5808d630f5115280bbf7e89205a0c14c9be89dc4f09035b5efe4c89e189d63
topicchannelsubscription.sbs.dev.psparameters.json.liquid [./templates/channels/topicchannel/subscriptions/topicchannelsubscription.sbs.dev.psparameters.json.liquid] -- deed6671cdc4cce4f93c9b4bb6859ff6395ee01f7f5113209d4b00b4404931c8
topicchannelsubscription.sbs.prod.psparameters.json.liquid [./templates/channels/topicchannel/subscriptions/topicchannelsubscription.sbs.prod.psparameters.json.liquid] -- deed6671cdc4cce4f93c9b4bb6859ff6395ee01f7f5113209d4b00b4404931c8
TearDown-20-TopicChannel-ServiceBus.ps1.liquid [./templates/channels/topicchannel/TearDown-20-TopicChannel-ServiceBus.ps1.liquid] -- 869b45a41c01297cdd6194d5bdc4b532cee98e1a8f72730417e95ac6b25ec05d
topicchannel.sb.dev.psparameters.json.liquid [./templates/channels/topicchannel/topicchannel.sb.dev.psparameters.json.liquid] -- a30e06dc1b13f0f008e917aa4ad2a80f64c52b24f23eb8346bdbb9af1ec016c8
topicchannel.sb.prod.psparameters.json.liquid [./templates/channels/topicchannel/topicchannel.sb.prod.psparameters.json.liquid] -- a30e06dc1b13f0f008e917aa4ad2a80f64c52b24f23eb8346bdbb9af1ec016c8
Deploy-All-Unattended.bat [./templates/deploy/consumption/Deploy-All-Unattended.bat] -- b5067adbf0d7991617f02af3c4999ca785cfaec18f5c2269c5ceeff3c53e2cbd
Deploy-All.bat [./templates/deploy/consumption/Deploy-All.bat] -- 99dbca6933ca1baa23ae33d196c8740346b820821aff5169cc71595c5cc448e8
Deploy-All.ps1.liquid [./templates/deploy/consumption/Deploy-All.ps1.liquid] -- c0d3898645892afb086db6a6e1cada0ab04dd94ee914a06151b0809b7a259fef
TearDown-All.bat [./templates/deploy/consumption/TearDown-All.bat] -- 7cdd9efb9db8ad2698dfedfc5f8b7f29d59000aa9693d4c9629b16144df7a35a
TearDown-All.ps1.liquid [./templates/deploy/consumption/TearDown-All.ps1.liquid] -- 4010d4c57b6a7306a47684a5287594fbc77737c312f84ef44f8cb2065a06caba
Deploy-All-Unattended.bat [./templates/deploy/consumptionlite/Deploy-All-Unattended.bat] -- b5067adbf0d7991617f02af3c4999ca785cfaec18f5c2269c5ceeff3c53e2cbd
Deploy-All.bat [./templates/deploy/consumptionlite/Deploy-All.bat] -- 99dbca6933ca1baa23ae33d196c8740346b820821aff5169cc71595c5cc448e8
Deploy-All.ps1.liquid [./templates/deploy/consumptionlite/Deploy-All.ps1.liquid] -- 825fccd0c792e966c7ac2cd2af3dadba2aba9fb4c1796d490f37bb8da61944f8
TearDown-All.bat [./templates/deploy/consumptionlite/TearDown-All.bat] -- 7cdd9efb9db8ad2698dfedfc5f8b7f29d59000aa9693d4c9629b16144df7a35a
TearDown-All.ps1.liquid [./templates/deploy/consumptionlite/TearDown-All.ps1.liquid] -- 4010d4c57b6a7306a47684a5287594fbc77737c312f84ef44f8cb2065a06caba
Deploy-All-Unattended.bat [./templates/deploy/standard/Deploy-All-Unattended.bat] -- b5067adbf0d7991617f02af3c4999ca785cfaec18f5c2269c5ceeff3c53e2cbd
Deploy-All.bat [./templates/deploy/standard/Deploy-All.bat] -- f75fa7850a079ef705ee494328230b1dd80158e36834f21682896c703a507ad5
Deploy-All.ps1.liquid [./templates/deploy/standard/Deploy-All.ps1.liquid] -- d7c25278c5fcf7d27593a9f11a772df0c143c5057c235793f261d81d1d9c6804
TearDown-All.bat [./templates/deploy/standard/TearDown-All.bat] -- 7cdd9efb9db8ad2698dfedfc5f8b7f29d59000aa9693d4c9629b16144df7a35a
TearDown-All.ps1.liquid [./templates/deploy/standard/TearDown-All.ps1.liquid] -- 4010d4c57b6a7306a47684a5287594fbc77737c312f84ef44f8cb2065a06caba
Deploy-All-Unattended.bat [./templates/deploy/standardlite/Deploy-All-Unattended.bat] -- b5067adbf0d7991617f02af3c4999ca785cfaec18f5c2269c5ceeff3c53e2cbd
Deploy-All.bat [./templates/deploy/standardlite/Deploy-All.bat] -- f75fa7850a079ef705ee494328230b1dd80158e36834f21682896c703a507ad5
Deploy-All.ps1.liquid [./templates/deploy/standardlite/Deploy-All.ps1.liquid] -- 5aa50ba78fdde513890e170496d6c3ce5d228d29910da73c9ed29b778c5eed53
TearDown-All.bat [./templates/deploy/standardlite/TearDown-All.bat] -- 7cdd9efb9db8ad2698dfedfc5f8b7f29d59000aa9693d4c9629b16144df7a35a
TearDown-All.ps1.liquid [./templates/deploy/standardlite/TearDown-All.ps1.liquid] -- 4010d4c57b6a7306a47684a5287594fbc77737c312f84ef44f8cb2065a06caba
datagateway.onpremisedatagateway.dev.parameters.json.liquid [./templates/endpoints/file/datagateway/datagateway.onpremisedatagateway.dev.parameters.json.liquid] -- 5086934803f19eec9c024164d8026bd3988c64159bb54e62daa5ffb903270332
datagateway.onpremisedatagateway.dev.psparameters.json.liquid [./templates/endpoints/file/datagateway/datagateway.onpremisedatagateway.dev.psparameters.json.liquid] -- d8b667f85eeabe30711d98c39037233ad9a3a76e558cecff059a8a68a8a93c1c
datagateway.onpremisedatagateway.json [./templates/endpoints/file/datagateway/datagateway.onpremisedatagateway.json] -- fa268ba59d97fe9b25cf2099da5d7794ca6578ab8710abf1718506ec2d01985b
datagateway.onpremisedatagateway.prod.parameters.json.liquid [./templates/endpoints/file/datagateway/datagateway.onpremisedatagateway.prod.parameters.json.liquid] -- 5086934803f19eec9c024164d8026bd3988c64159bb54e62daa5ffb903270332
datagateway.onpremisedatagateway.prod.psparameters.json.liquid [./templates/endpoints/file/datagateway/datagateway.onpremisedatagateway.prod.psparameters.json.liquid] -- d8b667f85eeabe30711d98c39037233ad9a3a76e558cecff059a8a68a8a93c1c
Deploy-30-DataGateway.ps1.liquid [./templates/endpoints/file/datagateway/Deploy-30-DataGateway.ps1.liquid] -- d53d2366bda3408a05039c9bdadeb57604d75fe844d4ca73ec3eeb1ea4330894
New-DataGateway.ps1 [./templates/endpoints/file/datagateway/New-DataGateway.ps1] -- dd6e54b85444fa6a23ec207d1ddc832f93f94c48d613897286a58091d5e1297a
Remove-DataGateway.ps1 [./templates/endpoints/file/datagateway/Remove-DataGateway.ps1] -- f2cdea8575927d19e272f7603ffb0b86c3261c9383cde2e18bbb2c36a6bbafca
TearDown-30-DataGateway.ps1.liquid [./templates/endpoints/file/datagateway/TearDown-30-DataGateway.ps1.liquid] -- 92a94287c3e1fcada7ad22494aa3ce10cb652429c33eb1d0d662e8790367aa70
Deploy-100-FileReceiveAdapterFileSystem-ApiConnection.ps1.liquid [./templates/endpoints/file/receive/Deploy-100-FileReceiveAdapterFileSystem-ApiConnection.ps1.liquid] -- c3c9d58cdb647793d1be5bf4851cb07dd0c9e4fef9d8398813253c7df6d441c0
Deploy-100-FileReceiveAdapterServiceBus-ApiConnection.ps1.liquid [./templates/endpoints/file/receive/Deploy-100-FileReceiveAdapterServiceBus-ApiConnection.ps1.liquid] -- 811907578afaa6bf5e20ca8cef4d909cead2d23084908465aa471ef22329d66b
Deploy-105-FileReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/file/receive/Deploy-105-FileReceiveAdapter-LogicApp.ps1.liquid] -- e5a957ec7ea84037e5bc9b80c96f9a4525aa570e3a38e2e34a216ed819ed95d5
Deploy-110-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1.liquid [./templates/endpoints/file/receive/Deploy-110-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1.liquid] -- 6fc7255adab47bb49af745e88ec326869b117f44a980958f72cda92dd86e705e
Deploy-110-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid [./templates/endpoints/file/receive/Deploy-110-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid] -- d2ce18fc9d0c47d0719a0dd755266cbb10fb48aabfcf4e7043973d17b4ceae28
filereceiveadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapter.logicapp.dev.parameters.json.liquid] -- d16081e9e8f55408a52d82f0dcfef30d03edc4dc1fe391ae49b54a22081f10cf
filereceiveadapter.logicapp.json [./templates/endpoints/file/receive/filereceiveadapter.logicapp.json] -- 6937170ed941f223bc16fedf87b3ebe723a23f18963eafcfd9106e9f14475d2a
filereceiveadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapter.logicapp.prod.parameters.json.liquid] -- c93a63830219ee279fa73ac18cc864e97c5e6d0007b8130abbe447df572e88b9
filereceiveadapterfilesystem.apiconnection.dev.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterfilesystem.apiconnection.dev.parameters.json.liquid] -- 6e0238fa3f9caa7bffb8158d256137fa31285efc6cd4d731254a8723361b0b0e
filereceiveadapterfilesystem.apiconnection.json.liquid [./templates/endpoints/file/receive/filereceiveadapterfilesystem.apiconnection.json.liquid] -- 26a21514d67b1dc6746b78c06c8d1c6b49c377c53e1c1ac5ac394d517e40689c
filereceiveadapterfilesystem.apiconnection.prod.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterfilesystem.apiconnection.prod.parameters.json.liquid] -- 6e0238fa3f9caa7bffb8158d256137fa31285efc6cd4d731254a8723361b0b0e
filereceiveadapterfilesystem.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterfilesystem.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
filereceiveadapterfilesystem.apiconnpolicy.json [./templates/endpoints/file/receive/filereceiveadapterfilesystem.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
filereceiveadapterfilesystem.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterfilesystem.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
filereceiveadapterservicebus.apiconnection.dev.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterservicebus.apiconnection.dev.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
filereceiveadapterservicebus.apiconnection.json.liquid [./templates/endpoints/file/receive/filereceiveadapterservicebus.apiconnection.json.liquid] -- 4e4279c2066ebf0eed61b396bca8299fcf240c218076511d4059f3fd875776bc
filereceiveadapterservicebus.apiconnection.prod.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterservicebus.apiconnection.prod.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
filereceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
filereceiveadapterservicebus.apiconnpolicy.json [./templates/endpoints/file/receive/filereceiveadapterservicebus.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
filereceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/file/receive/filereceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
New-FileReceiveAdapter-LogicApp.ps1 [./templates/endpoints/file/receive/New-FileReceiveAdapter-LogicApp.ps1] -- 2e26fcca4f793889d670e5e6718d4d73933d43953c33e9ba38f9bd183645a557
New-FileReceiveAdapterFileSystem-ApiConnection.ps1 [./templates/endpoints/file/receive/New-FileReceiveAdapterFileSystem-ApiConnection.ps1] -- ad7761b721ba72bffcfd3f6bd591a39ab900c2e0cc9ba9314f024e0982ff843d
New-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1 [./templates/endpoints/file/receive/New-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1] -- 7151d12041c9dbf9c17460c318cbdcfe8801082f1b921f2ff52c269380e19539
New-FileReceiveAdapterServiceBus-ApiConnection.ps1 [./templates/endpoints/file/receive/New-FileReceiveAdapterServiceBus-ApiConnection.ps1] -- d18b23f9b24691cfc13cc4d11d24574e68ba4e8d909f7244556727b148a261cb
New-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1 [./templates/endpoints/file/receive/New-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1] -- 98e3652d2998bfa5e6b8f144afdf9562baed8ac4fb5ec4e048cc0c5c64e368f0
Remove-FileReceiveAdapter-LogicApp.ps1 [./templates/endpoints/file/receive/Remove-FileReceiveAdapter-LogicApp.ps1] -- efe6fae39f19afbc3d30ee6261737d5cb0484460849363c3e03e7f87b6e046b8
Remove-FileReceiveAdapterFileSystem-ApiConnection.ps1 [./templates/endpoints/file/receive/Remove-FileReceiveAdapterFileSystem-ApiConnection.ps1] -- 7468a9c3871a6f7681c0709f1357dbe15d89b846ccb841f3182880183c922526
Remove-FileReceiveAdapterServiceBus-ApiConnection.ps1 [./templates/endpoints/file/receive/Remove-FileReceiveAdapterServiceBus-ApiConnection.ps1] -- af9746e5b0accdb4b2178942657870722239d93c4d0f6d08b4bc155b1ec165ae
TearDown-100-FileReceiveAdapterFileSystem-ApiConnection.ps1.liquid [./templates/endpoints/file/receive/TearDown-100-FileReceiveAdapterFileSystem-ApiConnection.ps1.liquid] -- 007272f20f99b7005e74686fa99622a8fefb9022d60bc3d5be2de9dc276e3be1
TearDown-100-FileReceiveAdapterServiceBus-ApiConnection.ps1.liquid [./templates/endpoints/file/receive/TearDown-100-FileReceiveAdapterServiceBus-ApiConnection.ps1.liquid] -- 80f190f612def0643c8c17b23beea8f6148030eafe36a1cd5bb678d7ef56882e
TearDown-105-FileReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/file/receive/TearDown-105-FileReceiveAdapter-LogicApp.ps1.liquid] -- 4a28148435f4a6ad02c9aca3635770694405be4bb277a821af56ef67fff05281
Deploy-100-FileSendAdapter-ApiConnection.ps1.liquid [./templates/endpoints/file/send/Deploy-100-FileSendAdapter-ApiConnection.ps1.liquid] -- 9031329d58ccc0698ee3eeb39f74b9b22e63c47718c98daf013c92d3e5ded6b8
Deploy-105-FileSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/file/send/Deploy-105-FileSendAdapter-LogicApp.ps1.liquid] -- 35d50e494bd70104b27d348c187d4af9368d8f2e1a6eb55224c8c26a49c334ea
Deploy-110-FileSendAdapter-ApiConnPolicy.ps1.liquid [./templates/endpoints/file/send/Deploy-110-FileSendAdapter-ApiConnPolicy.ps1.liquid] -- c0a3c13c36e84afb019ddc536c799160c4148876084f500b7a1c17bd1852104b
filesendadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/file/send/filesendadapter.logicapp.dev.parameters.json.liquid] -- 4c3cd33d39a3e44c6156914b981f3c74a5aacaa7982fb9647fabfda962c0d47c
filesendadapter.logicapp.json [./templates/endpoints/file/send/filesendadapter.logicapp.json] -- f518ae587c2b0588e48e30000e0ef87330f183f40a9e2de42e3ae8940930e349
filesendadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/file/send/filesendadapter.logicapp.prod.parameters.json.liquid] -- 4c3cd33d39a3e44c6156914b981f3c74a5aacaa7982fb9647fabfda962c0d47c
filesystemsendadapter.apiconnection.dev.parameters.json.liquid [./templates/endpoints/file/send/filesystemsendadapter.apiconnection.dev.parameters.json.liquid] -- 6e0238fa3f9caa7bffb8158d256137fa31285efc6cd4d731254a8723361b0b0e
filesystemsendadapter.apiconnection.json.liquid [./templates/endpoints/file/send/filesystemsendadapter.apiconnection.json.liquid] -- 2ff0c4e9dbf050c750b107934b69e8d965f18d64d7c38a280af2f68068c0829a
filesystemsendadapter.apiconnection.prod.parameters.json.liquid [./templates/endpoints/file/send/filesystemsendadapter.apiconnection.prod.parameters.json.liquid] -- 6e0238fa3f9caa7bffb8158d256137fa31285efc6cd4d731254a8723361b0b0e
filesystemsendadapter.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/file/send/filesystemsendadapter.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
filesystemsendadapter.apiconnpolicy.json [./templates/endpoints/file/send/filesystemsendadapter.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
filesystemsendadapter.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/file/send/filesystemsendadapter.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
New-FileSendAdapter-ApiConnection.ps1 [./templates/endpoints/file/send/New-FileSendAdapter-ApiConnection.ps1] -- dca0db2f90099c6c03572fe9dd153c7a02a5f6d316621ccdc8cad1b0a2eac64a
New-FileSendAdapter-ApiConnPolicy.ps1 [./templates/endpoints/file/send/New-FileSendAdapter-ApiConnPolicy.ps1] -- cd68cd7a37568629e4959572d5ac6cc58d8446101866c5007932cfa0b437dea6
New-FileSendAdapter-LogicApp.ps1 [./templates/endpoints/file/send/New-FileSendAdapter-LogicApp.ps1] -- a3d596e7de988fc56db4187f0afadc64268fde6eb7962a7b0dba6fc111d13f18
Remove-FileSendAdapter-ApiConnection.ps1 [./templates/endpoints/file/send/Remove-FileSendAdapter-ApiConnection.ps1] -- 7467420b16ce7fa86dd3200a62dc2be3d0aeb1ad159a1fcc83dccdbc2273e2fa
Remove-FileSendAdapter-LogicApp.ps1 [./templates/endpoints/file/send/Remove-FileSendAdapter-LogicApp.ps1] -- a53ca42bd0c219fea00342cca5be250870b00e39c14a29cbf437c8b465dbba9a
TearDown-100-FileSendAdapter-ApiConnection.ps1.liquid [./templates/endpoints/file/send/TearDown-100-FileSendAdapter-ApiConnection.ps1.liquid] -- 9f717aa8a0569d0acdd1f700224c7da56e25a48f9e9b80cfd4ef1b3aa0d05aa9
TearDown-105-FileSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/file/send/TearDown-105-FileSendAdapter-LogicApp.ps1.liquid] -- 5296e147bcfae68e62c57477c0bc70efd125b3635a4281d77821e4c3312ba2cc
Deploy-100-FtpReceiveAdapterFtp-ApiConnection.ps1.liquid [./templates/endpoints/ftp/receive/Deploy-100-FtpReceiveAdapterFtp-ApiConnection.ps1.liquid] -- 17235c73a0ad91be3544714c17bd8b91e5554564972ba41dd8ece20055bc1847
Deploy-100-FtpReceiveAdapterServiceBus-ApiConnection.ps1.liquid [./templates/endpoints/ftp/receive/Deploy-100-FtpReceiveAdapterServiceBus-ApiConnection.ps1.liquid] -- 35b52b4f5b7c40f6a0af23d6c7fecfc24e302eae6253dcf1162a618f4e5197b8
Deploy-105-FtpReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/ftp/receive/Deploy-105-FtpReceiveAdapter-LogicApp.ps1.liquid] -- 0f9f20934ead3e9b88d1341f343101aae755aeb598a7b15ce831a9e815643881
Deploy-110-FtpReceiveAdapterFtp-ApiConnPolicy.ps1.liquid [./templates/endpoints/ftp/receive/Deploy-110-FtpReceiveAdapterFtp-ApiConnPolicy.ps1.liquid] -- b392310b826d51bf872b9f37c2e4f74df47f79a6cc3269f2177cb04774eab8a3
Deploy-110-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid [./templates/endpoints/ftp/receive/Deploy-110-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid] -- 4e1ee84ce0c6ad837e0619d2f79bdb51704dea0d50680b1190b41363fa3ea94a
ftpreceiveadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapter.logicapp.dev.parameters.json.liquid] -- 1120d57213771ee73ae1daadd90880c1a7bef2afbb1fa9cc1a48a98b649e88fc
ftpreceiveadapter.logicapp.json [./templates/endpoints/ftp/receive/ftpreceiveadapter.logicapp.json] -- 80ef8211f49c68eea1a7d0f40e8ee9c9a640c62d035259a10b4f21839f1af018
ftpreceiveadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapter.logicapp.prod.parameters.json.liquid] -- 1120d57213771ee73ae1daadd90880c1a7bef2afbb1fa9cc1a48a98b649e88fc
ftpreceiveadapterftp.apiconnection.dev.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterftp.apiconnection.dev.parameters.json.liquid] -- 96f1fbeeb99a9f0eeeb702a45793790fb15c812384c7c2fe3707cb34cecefc85
ftpreceiveadapterftp.apiconnection.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterftp.apiconnection.json.liquid] -- e91578c974fc758fb11dd60c2c054f2a2c36b76ca889ccb6f09bc8ed4139aaaf
ftpreceiveadapterftp.apiconnection.prod.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterftp.apiconnection.prod.parameters.json.liquid] -- 96f1fbeeb99a9f0eeeb702a45793790fb15c812384c7c2fe3707cb34cecefc85
ftpreceiveadapterftp.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterftp.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
ftpreceiveadapterftp.apiconnpolicy.json [./templates/endpoints/ftp/receive/ftpreceiveadapterftp.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
ftpreceiveadapterftp.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterftp.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
ftpreceiveadapterservicebus.apiconnection.dev.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterservicebus.apiconnection.dev.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
ftpreceiveadapterservicebus.apiconnection.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterservicebus.apiconnection.json.liquid] -- 4e4279c2066ebf0eed61b396bca8299fcf240c218076511d4059f3fd875776bc
ftpreceiveadapterservicebus.apiconnection.prod.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterservicebus.apiconnection.prod.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
ftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
ftpreceiveadapterservicebus.apiconnpolicy.json [./templates/endpoints/ftp/receive/ftpreceiveadapterservicebus.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
ftpreceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/ftp/receive/ftpreceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
New-FtpReceiveAdapter-LogicApp.ps1 [./templates/endpoints/ftp/receive/New-FtpReceiveAdapter-LogicApp.ps1] -- cfc3917207653b63ce8732798bd96a7e490ab2def2c9b41ce15a2f391a62de0c
New-FtpReceiveAdapterFtp-ApiConnection.ps1 [./templates/endpoints/ftp/receive/New-FtpReceiveAdapterFtp-ApiConnection.ps1] -- 5d5df73f3dc022c2577a75f4d1f10223711e9c2221fdbfc6807c99a9dee788fe
New-FtpReceiveAdapterFtp-ApiConnPolicy.ps1 [./templates/endpoints/ftp/receive/New-FtpReceiveAdapterFtp-ApiConnPolicy.ps1] -- 320e4f70ad71188d143ce24eeac96e31a27ff980b3f4d011de939f462ba13946
New-FtpReceiveAdapterServiceBus-ApiConnection.ps1 [./templates/endpoints/ftp/receive/New-FtpReceiveAdapterServiceBus-ApiConnection.ps1] -- 6d035531df970e208ddf6c5360cae2bdbcd0485280705e9baa57c609f1596f74
New-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1 [./templates/endpoints/ftp/receive/New-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1] -- 9f53ecfd97d437354d6ea36c703524a1eaa46af3b24b705646cd97e9b96af08d
Remove-FtpReceiveAdapter-LogicApp.ps1 [./templates/endpoints/ftp/receive/Remove-FtpReceiveAdapter-LogicApp.ps1] -- 29645f6a0be48dbe4a8c52506fab309d66c6570e93de0c2e3addec902162a8ef
Remove-FtpReceiveAdapterFtp-ApiConnection.ps1 [./templates/endpoints/ftp/receive/Remove-FtpReceiveAdapterFtp-ApiConnection.ps1] -- 890cb240e55816c2cbebfcfe64e1f42d5d86905eeec1cd12828176ed5a3f948f
Remove-FtpReceiveAdapterServiceBus-ApiConnection.ps1 [./templates/endpoints/ftp/receive/Remove-FtpReceiveAdapterServiceBus-ApiConnection.ps1] -- 26c4fda97937a9fcc673d9f43bfbbf0cd4a4f779b85462aac199456d6cf1e7a0
TearDown-100-FtpReceiveAdapterFtp-ApiConnection.ps1.liquid [./templates/endpoints/ftp/receive/TearDown-100-FtpReceiveAdapterFtp-ApiConnection.ps1.liquid] -- fc5d4a111059cbfe16f3eafbc7dc092ce41a5324a5600fb83919ea16a49b77b7
TearDown-100-FtpReceiveAdapterServiceBus-ApiConnection.ps1.liquid [./templates/endpoints/ftp/receive/TearDown-100-FtpReceiveAdapterServiceBus-ApiConnection.ps1.liquid] -- c3718f68c2686ea9752bf4a92ebe6efdf6421b4608445752f1cc6a60fd174cb0
TearDown-105-FtpReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/ftp/receive/TearDown-105-FtpReceiveAdapter-LogicApp.ps1.liquid] -- a826c1bbb0a39a72cd6b7792c6062a79edddc5ab72928208ea52f31d92b99883
Deploy-100-FtpSendAdapter-ApiConnection.ps1.liquid [./templates/endpoints/ftp/send/Deploy-100-FtpSendAdapter-ApiConnection.ps1.liquid] -- 1708f960787cce4bc2c5fdf8deb55c7294780658ea9e5f58b1cb2a939d46078e
Deploy-105-FtpSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/ftp/send/Deploy-105-FtpSendAdapter-LogicApp.ps1.liquid] -- 062ef890613236c3ddd308210e49434b5668710e82f1326c2092403c1d82370a
Deploy-110-FtpSendAdapter-ApiConnPolicy.ps1.liquid [./templates/endpoints/ftp/send/Deploy-110-FtpSendAdapter-ApiConnPolicy.ps1.liquid] -- 1e1ee0ccbd02143f56f0527993344c681c5fb4537939eccc3c7db88753d3a4db
ftpsendadapter.apiconnection.dev.parameters.json.liquid [./templates/endpoints/ftp/send/ftpsendadapter.apiconnection.dev.parameters.json.liquid] -- 96f1fbeeb99a9f0eeeb702a45793790fb15c812384c7c2fe3707cb34cecefc85
ftpsendadapter.apiconnection.json.liquid [./templates/endpoints/ftp/send/ftpsendadapter.apiconnection.json.liquid] -- 3db7311d7ff06d5e683e0ee4e12e9893847d98ebbabd9c6920246859ea15129a
ftpsendadapter.apiconnection.prod.parameters.json.liquid [./templates/endpoints/ftp/send/ftpsendadapter.apiconnection.prod.parameters.json.liquid] -- 96f1fbeeb99a9f0eeeb702a45793790fb15c812384c7c2fe3707cb34cecefc85
ftpsendadapter.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/ftp/send/ftpsendadapter.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
ftpsendadapter.apiconnpolicy.json [./templates/endpoints/ftp/send/ftpsendadapter.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
ftpsendadapter.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/ftp/send/ftpsendadapter.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
ftpsendadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/ftp/send/ftpsendadapter.logicapp.dev.parameters.json.liquid] -- 6b4c3f76953ac5c842f30b6c79661b4e68844ea8b48cf37466a0c42b6570bcce
ftpsendadapter.logicapp.json [./templates/endpoints/ftp/send/ftpsendadapter.logicapp.json] -- 5aa84e7102e3582fee07be168ebaa990b527250a96126860466eb28d91f25c07
ftpsendadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/ftp/send/ftpsendadapter.logicapp.prod.parameters.json.liquid] -- 6b4c3f76953ac5c842f30b6c79661b4e68844ea8b48cf37466a0c42b6570bcce
New-FtpSendAdapter-ApiConnection.ps1 [./templates/endpoints/ftp/send/New-FtpSendAdapter-ApiConnection.ps1] -- 311570ec0a96986b79004cdbefea0c5d5a7e7507d322c8e0ab9407eb78573ee9
New-FtpSendAdapter-ApiConnPolicy.ps1 [./templates/endpoints/ftp/send/New-FtpSendAdapter-ApiConnPolicy.ps1] -- aaf82a7116529331dbfc8d57e801e2316bd0eccbd632777869a13d499c3acfdc
New-FtpSendAdapter-LogicApp.ps1 [./templates/endpoints/ftp/send/New-FtpSendAdapter-LogicApp.ps1] -- d53227dce1e20167710170c19b926d860087f442a080b8985603a67a94104143
Remove-FtpSendAdapter-ApiConnection.ps1 [./templates/endpoints/ftp/send/Remove-FtpSendAdapter-ApiConnection.ps1] -- 60e96a688ef5be6b0f041f34eb45c3b9d1394a3a664a71399faf8856e66e06d8
Remove-FtpSendAdapter-LogicApp.ps1 [./templates/endpoints/ftp/send/Remove-FtpSendAdapter-LogicApp.ps1] -- 1e1531e0f61748368af2c49512589b8f9a33fca3b53262633de9fc71873d59d9
TearDown-100-FtpSendAdapter-ApiConnection.ps1.liquid [./templates/endpoints/ftp/send/TearDown-100-FtpSendAdapter-ApiConnection.ps1.liquid] -- 10eb53d527110de379de4528495d6991cf4a5393415ad964581c6330d93dd424
TearDown-105-FtpSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/ftp/send/TearDown-105-FtpSendAdapter-LogicApp.ps1.liquid] -- 30c8ca74fd0bf559267297b175069fbcb91020778a12a5d8b63be90683d6eb85
Deploy-105-HttpReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/http/receive/Deploy-105-HttpReceiveAdapter-LogicApp.ps1.liquid] -- 2cc6356b95e46b426d74a6c0368bbc51e17e5519353c1c7feebf20038a3ee6b6
httpreceiveadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/http/receive/httpreceiveadapter.logicapp.dev.parameters.json.liquid] -- 7bf37f7ccb4f2e3c3df6f7e7201aa4b9d84fda5deff7387c5bea3cd0c8e248a0
httpreceiveadapter.logicapp.json [./templates/endpoints/http/receive/httpreceiveadapter.logicapp.json] -- d918c4e5761bc34257f360747c5c931fbb21f30cb4e7da0dc75a400934047953
httpreceiveadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/http/receive/httpreceiveadapter.logicapp.prod.parameters.json.liquid] -- 7bf37f7ccb4f2e3c3df6f7e7201aa4b9d84fda5deff7387c5bea3cd0c8e248a0
New-HttpReceiveAdapter-LogicApp.ps1 [./templates/endpoints/http/receive/New-HttpReceiveAdapter-LogicApp.ps1] -- 50c991d539f81259266df5c304cc89f469e0522859aed73775590811dfc3ce66
Remove-HttpReceiveAdapter-LogicApp.ps1 [./templates/endpoints/http/receive/Remove-HttpReceiveAdapter-LogicApp.ps1] -- cda3141db65b80ceb35ac8605cc3d20b2c1fafe41bc8d4ef91729fbe718e5467
TearDown-105-HttpReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/http/receive/TearDown-105-HttpReceiveAdapter-LogicApp.ps1.liquid] -- f2def6f65736f7618fe542269256d5cb8fc58eb5a8e58f5ca503a5c81370bf95
Deploy-105-HttpSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/http/send/Deploy-105-HttpSendAdapter-LogicApp.ps1.liquid] -- e498adc2d0be0519d2c1d299507df225eea7ed0cefecbc615aec6793076b1d97
httpsendadapter.logicapp.json [./templates/endpoints/http/send/httpsendadapter.logicapp.json] -- f0248c06c50f49afe69083dfc3e6cbbade3be995983e25e63d35257395611ca9
httpsendadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/http/send/httpsendadapter.logicapp.prod.parameters.json.liquid] -- 6e0238fa3f9caa7bffb8158d256137fa31285efc6cd4d731254a8723361b0b0e
httpsnedadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/http/send/httpsnedadapter.logicapp.dev.parameters.json.liquid] -- 252cd3360c89d2a0a69c164a0de9c408b7a75011dadf262de738167e5d059580
New-HttpSendAdapter-LogicApp.ps1 [./templates/endpoints/http/send/New-HttpSendAdapter-LogicApp.ps1] -- e5e00b6db5b9a6ee35c8762e19f708bae30ff1e733d3387759626108fcad423e
Remove-HttpSendAdapter-LogicApp.ps1 [./templates/endpoints/http/send/Remove-HttpSendAdapter-LogicApp.ps1] -- 69727adaf6a0e358415bcb1a134e7d443a4ced61f36dfbcf0fdae17ff0b56db0
TearDown-105-HttpSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/http/send/TearDown-105-HttpSendAdapter-LogicApp.ps1.liquid] -- 8160d6679d557b3f74803a37954a3fb6415678263a62ef73acc451fca0b7f9a7
Deploy-85-MessageConstructor-LogicApp.ps1.liquid [./templates/endpoints/messageconstructor/Deploy-85-MessageConstructor-LogicApp.ps1.liquid] -- 70a62e5568fcb833356c4a3536a640fd3861c0647192a1a168413f36ea27d47f
messageconstructor.logicapp.dev.parameters.json.liquid [./templates/endpoints/messageconstructor/messageconstructor.logicapp.dev.parameters.json.liquid] -- 71686710eec7758d2e7a9002b04cd27afe3755f6437d5ad9a54d5a509d35c3f3
messageconstructor.logicapp.json [./templates/endpoints/messageconstructor/messageconstructor.logicapp.json] -- abe74f4d840e892155bda641ba2ad184c91b0ed789640f6a6fb350d8882994b3
messageconstructor.logicapp.prod.parameters.json.liquid [./templates/endpoints/messageconstructor/messageconstructor.logicapp.prod.parameters.json.liquid] -- 71686710eec7758d2e7a9002b04cd27afe3755f6437d5ad9a54d5a509d35c3f3
New-MessageConstructor-LogicApp.ps1 [./templates/endpoints/messageconstructor/New-MessageConstructor-LogicApp.ps1] -- c0e352ec2c7b9daf8172593f493a993bddca4469af877ca1fed2009942e37d32
Remove-MessageConstructor-LogicApp.ps1 [./templates/endpoints/messageconstructor/Remove-MessageConstructor-LogicApp.ps1] -- 998bf9a66e9a4492b6aefe873b19ff9f8692e583d736e199091fda6e1611d90f
TearDown-85-MessageConstructor-LogicApp.ps1.liquid [./templates/endpoints/messageconstructor/TearDown-85-MessageConstructor-LogicApp.ps1.liquid] -- 4540571d1e15f3d0af262b7c01ddc606929ec73aafafe64bf9e65a3ecb549c09
Deploy-100-SftpReceiveAdapterServiceBus-ApiConnection.ps1.liquid [./templates/endpoints/sftp/receive/Deploy-100-SftpReceiveAdapterServiceBus-ApiConnection.ps1.liquid] -- 8a585a35b2a58da3663ccf6e4e5cd9615aa147b55bdfa434495a4355fd14a4cb
Deploy-100-SftpReceiveAdapterSftp-ApiConnection.ps1.liquid [./templates/endpoints/sftp/receive/Deploy-100-SftpReceiveAdapterSftp-ApiConnection.ps1.liquid] -- 21ad59c97c937e82a45c534f543332b0a7a622a7c1d87c808d80234d14fb2b7d
Deploy-105-SftpReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/sftp/receive/Deploy-105-SftpReceiveAdapter-LogicApp.ps1.liquid] -- c4423a91f5f28889f9e4c54ba7b04e7f379e5f53ce733ebac5eb3047f7545650
Deploy-110-SftpReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid [./templates/endpoints/sftp/receive/Deploy-110-SftpReceiveAdapterServiceBus-ApiConnPolicy.ps1.liquid] -- 288035eba51197cf9767aa9febdfa3a1be42d47e5ba0274810bb157006fff46b
Deploy-110-SftpReceiveAdapterSftp-ApiConnPolicy.ps1.liquid [./templates/endpoints/sftp/receive/Deploy-110-SftpReceiveAdapterSftp-ApiConnPolicy.ps1.liquid] -- c7b8e7a81543073b6b296c20ef3d3a2eeef37f666b8a0b69ea73037af20db490
New-SftpReceiveAdapter-LogicApp.ps1 [./templates/endpoints/sftp/receive/New-SftpReceiveAdapter-LogicApp.ps1] -- 6246b158555ee5e8f790f2578a4fb5743c035e0c22c120b4a180a58caaed7fa8
New-SftpReceiveAdapterServiceBus-ApiConnection.ps1 [./templates/endpoints/sftp/receive/New-SftpReceiveAdapterServiceBus-ApiConnection.ps1] -- 46aee44d2977ea7c585afcdeeb8bbc9c4c2d05a1676766f653cb682b1f560a51
New-SftpReceiveAdapterServiceBus-ApiConnPolicy.ps1 [./templates/endpoints/sftp/receive/New-SftpReceiveAdapterServiceBus-ApiConnPolicy.ps1] -- 53e130bf7a70faee991a604a245f8dfa2cf76b27799f5ae6de4bff2f18b0b57b
New-SftpReceiveAdapterSftp-ApiConnection.ps1 [./templates/endpoints/sftp/receive/New-SftpReceiveAdapterSftp-ApiConnection.ps1] -- 6ef5639d5e835514b0c21432bbff1031da31dd6b4ec8a832c91cc92a188162fd
New-SftpReceiveAdapterSftp-ApiConnPolicy.ps1 [./templates/endpoints/sftp/receive/New-SftpReceiveAdapterSftp-ApiConnPolicy.ps1] -- 8f296341e688091c0d1195723a06cff4fce0fe9a3135e440ea0ea06691cc8a72
Remove-SftpReceiveAdapter-LogicApp.ps1 [./templates/endpoints/sftp/receive/Remove-SftpReceiveAdapter-LogicApp.ps1] -- 4819ba703a42a8a4510f9bb968710f5527cc3a92c3170ae1a5b1e02618459f0e
Remove-SftpReceiveAdapterServiceBus-ApiConnection.ps1 [./templates/endpoints/sftp/receive/Remove-SftpReceiveAdapterServiceBus-ApiConnection.ps1] -- 3b547ab75538f7b61bfc03515bbb475c4afa6fc61a996ba80f7dedd960ffc0ab
Remove-SftpReceiveAdapterSftp-ApiConnection.ps1 [./templates/endpoints/sftp/receive/Remove-SftpReceiveAdapterSftp-ApiConnection.ps1] -- 1de340051dbf61df75ddf73e29cff7167c7e447e61d305dbcddc77d0c3d10413
sftpreceiveadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadapter.logicapp.dev.parameters.json.liquid] -- 4e4ec89272b1b8f959a1b0903ba860f9f73d0723495d82f323189439624fad18
sftpreceiveadapter.logicapp.json [./templates/endpoints/sftp/receive/sftpreceiveadapter.logicapp.json] -- 910baf2ef2ab9e2d27d0973eb70a42f34a7f649649b720f61730f792bd805022
sftpreceiveadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadapter.logicapp.prod.parameters.json.liquid] -- 4e4ec89272b1b8f959a1b0903ba860f9f73d0723495d82f323189439624fad18
sftpreceiveadapterservicebus.apiconnection.dev.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadapterservicebus.apiconnection.dev.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
sftpreceiveadapterservicebus.apiconnection.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadapterservicebus.apiconnection.json.liquid] -- b164ececb99085bae937c55360bd9ada82ce72ef7f5f7005011789f1db93e2b5
sftpreceiveadapterservicebus.apiconnection.prod.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadapterservicebus.apiconnection.prod.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
sftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
sftpreceiveadapterservicebus.apiconnpolicy.json [./templates/endpoints/sftp/receive/sftpreceiveadapterservicebus.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
sftpreceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadapterservicebus.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
sftpreceiveadaptersftp.apiconnection.dev.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadaptersftp.apiconnection.dev.parameters.json.liquid] -- bd4d38ecd9ef1defcb98929df738d6b1365503859fd8e01bb2e993e51b555f1c
sftpreceiveadaptersftp.apiconnection.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadaptersftp.apiconnection.json.liquid] -- a74c45d16fb383d6bfd36ad8acece90cff485458d3f5be38c95668dd7a85a8cf
sftpreceiveadaptersftp.apiconnection.prod.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadaptersftp.apiconnection.prod.parameters.json.liquid] -- bd4d38ecd9ef1defcb98929df738d6b1365503859fd8e01bb2e993e51b555f1c
sftpreceiveadaptersftp.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadaptersftp.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
sftpreceiveadaptersftp.apiconnpolicy.json [./templates/endpoints/sftp/receive/sftpreceiveadaptersftp.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
sftpreceiveadaptersftp.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/sftp/receive/sftpreceiveadaptersftp.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
TearDown-100-SftpReceiveAdapterServiceBus-ApiConnection.ps1.liquid [./templates/endpoints/sftp/receive/TearDown-100-SftpReceiveAdapterServiceBus-ApiConnection.ps1.liquid] -- 7620960f2ac1c1b1b5bb48dc10100b77598ca7bc3ad2f0a793e8e66a2a5a836a
TearDown-100-SftpReceiveAdapterSftp-ApiConnection.ps1.liquid [./templates/endpoints/sftp/receive/TearDown-100-SftpReceiveAdapterSftp-ApiConnection.ps1.liquid] -- e551a18374daa74513043a22f9c6542d75650f4c5262d6da2e2aa6ec1147e04c
TearDown-105-SftpReceiveAdapter-LogicApp.ps1.liquid [./templates/endpoints/sftp/receive/TearDown-105-SftpReceiveAdapter-LogicApp.ps1.liquid] -- eca0bd9fd943da16c0219795b132e7f37313b05cbdd737b3b7f330b27a42ee9f
Deploy-100-SftpSendAdapter-ApiConnection.ps1.liquid [./templates/endpoints/sftp/send/Deploy-100-SftpSendAdapter-ApiConnection.ps1.liquid] -- a7d0d5de99fddf3942cfadb0ebcffce320a84af6c358e4fbe7918fab69b642cf
Deploy-105-SftpSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/sftp/send/Deploy-105-SftpSendAdapter-LogicApp.ps1.liquid] -- a69d55c90d1b25243c6311c08828f8792a9afcca51bb42c3418902abaa58042d
Deploy-110-SftpSendAdapter-ApiConnPolicy.ps1.liquid [./templates/endpoints/sftp/send/Deploy-110-SftpSendAdapter-ApiConnPolicy.ps1.liquid] -- fe09f1d3046c1a344e4af89096bf1f3a118faf128d7caaa94ef64e4ed37466a4
New-SftpSendAdapter-ApiConnection.ps1 [./templates/endpoints/sftp/send/New-SftpSendAdapter-ApiConnection.ps1] -- cb7bbd7b03d5a99b7d90dbbf1588e404b0ae8882ed652c964821aaed24e4b49c
New-SftpSendAdapter-ApiConnPolicy.ps1 [./templates/endpoints/sftp/send/New-SftpSendAdapter-ApiConnPolicy.ps1] -- 3b4abcaa9e90ad270e562a46163592c53da4b42c2fcf4c97dea6828775fbfdb0
New-SftpSendAdapter-LogicApp.ps1 [./templates/endpoints/sftp/send/New-SftpSendAdapter-LogicApp.ps1] -- fe7002f0ea6931a630950e8d26f62a64c33ce5a712d14eefdf1b789e1217f615
Remove-SftpSendAdapter-ApiConnection.ps1 [./templates/endpoints/sftp/send/Remove-SftpSendAdapter-ApiConnection.ps1] -- 05d02cbab0b7e02738a9540a6be0281657396b80b33bfdffe1532e2cd71e0aee
Remove-SftpSendAdapter-LogicApp.ps1 [./templates/endpoints/sftp/send/Remove-SftpSendAdapter-LogicApp.ps1] -- 90321d95015186773859ad26e165611266e8f32c445d6f378a9915ce04b1a73e
sftpsendadapter.apiconnection.dev.parameters.json.liquid [./templates/endpoints/sftp/send/sftpsendadapter.apiconnection.dev.parameters.json.liquid] -- 07ed032e1df69dd423f24bba19b566de2d9e5374bfa8292abe0deb7f75190b62
sftpsendadapter.apiconnection.json.liquid [./templates/endpoints/sftp/send/sftpsendadapter.apiconnection.json.liquid] -- a74c45d16fb383d6bfd36ad8acece90cff485458d3f5be38c95668dd7a85a8cf
sftpsendadapter.apiconnection.prod.parameters.json.liquid [./templates/endpoints/sftp/send/sftpsendadapter.apiconnection.prod.parameters.json.liquid] -- 07ed032e1df69dd423f24bba19b566de2d9e5374bfa8292abe0deb7f75190b62
sftpsendadapter.apiconnpolicy.dev.parameters.json.liquid [./templates/endpoints/sftp/send/sftpsendadapter.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
sftpsendadapter.apiconnpolicy.json [./templates/endpoints/sftp/send/sftpsendadapter.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
sftpsendadapter.apiconnpolicy.prod.parameters.json.liquid [./templates/endpoints/sftp/send/sftpsendadapter.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
sftpsendadapter.logicapp.dev.parameters.json.liquid [./templates/endpoints/sftp/send/sftpsendadapter.logicapp.dev.parameters.json.liquid] -- 712f9d7484e9c31722b2701ab3af7b0b6d99c1d0b86f66e844a15f733d3920a4
sftpsendadapter.logicapp.json [./templates/endpoints/sftp/send/sftpsendadapter.logicapp.json] -- b1fee531300f03d128d18c825a282c6a2e30a309fdf6d1003cf5ab05fb0639ad
sftpsendadapter.logicapp.prod.parameters.json.liquid [./templates/endpoints/sftp/send/sftpsendadapter.logicapp.prod.parameters.json.liquid] -- 712f9d7484e9c31722b2701ab3af7b0b6d99c1d0b86f66e844a15f733d3920a4
TearDown-100-SftpSendAdapter-ApiConnection.ps1.liquid [./templates/endpoints/sftp/send/TearDown-100-SftpSendAdapter-ApiConnection.ps1.liquid] -- 7190fec362d9de4dee26240d5b6c393a83cce26dff358ec40d93dc07d1cf0f0c
TearDown-105-SftpSendAdapter-LogicApp.ps1.liquid [./templates/endpoints/sftp/send/TearDown-105-SftpSendAdapter-LogicApp.ps1.liquid] -- 82da2c8f1c342063433f7cdb119a51ce8217c070b060c751720fb920dd4db953
contentdemoter.logicapp.dev.parameters.json.liquid [./templates/intermediaries/contentdemoter/contentdemoter.logicapp.dev.parameters.json.liquid] -- f540120dda57a97d9b8dc9c791e722b9c2c96a6343e020060d533196f680d682
contentdemoter.logicapp.json [./templates/intermediaries/contentdemoter/contentdemoter.logicapp.json] -- eb5c6e34846b77daf9bc2ceb04a61c7efb3f10db9556e7bf6106f53143098075
contentdemoter.logicapp.prod.parameters.json.liquid [./templates/intermediaries/contentdemoter/contentdemoter.logicapp.prod.parameters.json.liquid] -- 97bf5d22fb4f129fd977770cfabf2dc5bf43dc5c9a0c172c55567449e4e6891c
Deploy-90-ContentDemoter-LogicApp.ps1.liquid [./templates/intermediaries/contentdemoter/Deploy-90-ContentDemoter-LogicApp.ps1.liquid] -- 1f9a8e405553544ab534bd2b043536d3314ba00a35922a3dfa7125e7f2d8e497
New-ContentDemoter-LogicApp.ps1 [./templates/intermediaries/contentdemoter/New-ContentDemoter-LogicApp.ps1] -- b297071858d6765be77f20d98f7de782bea7d0e98525a3b1e31cc48314886d53
Remove-ContentDemoter-LogicApp.ps1 [./templates/intermediaries/contentdemoter/Remove-ContentDemoter-LogicApp.ps1] -- 5e32ce59d67ddf00af09bf9b7a4d1ced77a1a62ae5bc79d10b95093e04cf526f
TearDown-90-ContentDemoter-LogicApp.ps1.liquid [./templates/intermediaries/contentdemoter/TearDown-90-ContentDemoter-LogicApp.ps1.liquid] -- 476fafc8d5a2d5c88867cbd905ff125e4d763f187f7ddf5c92ba2bb4e73aecb9
contentpromoter.logicapp.dev.parameters.json.liquid [./templates/intermediaries/contentpromoter/contentpromoter.logicapp.dev.parameters.json.liquid] -- f540120dda57a97d9b8dc9c791e722b9c2c96a6343e020060d533196f680d682
contentpromoter.logicapp.json [./templates/intermediaries/contentpromoter/contentpromoter.logicapp.json] -- 8911bf31321286f4275451cc51036aefa2aed18641977358f1aa072e5c3499c3
contentpromoter.logicapp.prod.parameters.json.liquid [./templates/intermediaries/contentpromoter/contentpromoter.logicapp.prod.parameters.json.liquid] -- f540120dda57a97d9b8dc9c791e722b9c2c96a6343e020060d533196f680d682
Deploy-90-ContentPromoter-LogicApp.ps1.liquid [./templates/intermediaries/contentpromoter/Deploy-90-ContentPromoter-LogicApp.ps1.liquid] -- 2b3b763b7708f53f3e49355f4f4d1393584ee90c01a5360335d3d7c04410ca00
New-ContentPromoter-LogicApp.ps1 [./templates/intermediaries/contentpromoter/New-ContentPromoter-LogicApp.ps1] -- d75588c9e190b344e5c099d3c6119854e928f7b8b92bdd203d3a306c2510d761
Remove-ContentPromoter-LogicApp.ps1 [./templates/intermediaries/contentpromoter/Remove-ContentPromoter-LogicApp.ps1] -- 839cf95c993a0bec3bca055400311810be48f88260bb9d3e1ca0c43e61b68cc7
TearDown-90-ContentPromoter-LogicApp.ps1.liquid [./templates/intermediaries/contentpromoter/TearDown-90-ContentPromoter-LogicApp.ps1.liquid] -- 69d867fb62695b276faa7837bfd1003d2e2c2f76f468c98b94a378b94d2d0d89
Deploy-90-FlatFileMessageProcessor-LogicApp.ps1.liquid [./templates/intermediaries/flatfilemessageprocessor/Deploy-90-FlatFileMessageProcessor-LogicApp.ps1.liquid] -- 00fee6402dccb16a77fa7f293ba3c48e1fe16838ddd197e3baf2fa612eb89bed
flatfilemessageprocessor.logicapp.dev.parameters.json.liquid [./templates/intermediaries/flatfilemessageprocessor/flatfilemessageprocessor.logicapp.dev.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
flatfilemessageprocessor.logicapp.json [./templates/intermediaries/flatfilemessageprocessor/flatfilemessageprocessor.logicapp.json] -- 59638b8cca899c9584aa3bdb1c1dde8f77d742bd585fd45cbf510094d494786c
flatfilemessageprocessor.logicapp.prod.parameters.json.liquid [./templates/intermediaries/flatfilemessageprocessor/flatfilemessageprocessor.logicapp.prod.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
New-FlatFileMessageProcessor-LogicApp.ps1 [./templates/intermediaries/flatfilemessageprocessor/New-FlatFileMessageProcessor-LogicApp.ps1] -- 9c66a3bdf404bab70fd58b4d439adb0429bc44760a135d1af35a29b6d109e7c1
Remove-FlatFileMessageProcessor-LogicApp.ps1 [./templates/intermediaries/flatfilemessageprocessor/Remove-FlatFileMessageProcessor-LogicApp.ps1] -- dc3abd859454dacd1eb67619d1b679ef586b88e64439e147fe2cc07e42df9c60
TearDown-90-FlatFileMessageProcessor-LogicApp.ps1.liquid [./templates/intermediaries/flatfilemessageprocessor/TearDown-90-FlatFileMessageProcessor-LogicApp.ps1.liquid] -- e625e848d94e026aba4b7b3f4cdeff70533948ad731b399df7f2927289842877
Deploy-90-JsonDecoder-LogicApp.ps1.liquid [./templates/intermediaries/jsondecoder/Deploy-90-JsonDecoder-LogicApp.ps1.liquid] -- 14f9dfa0b0663f308c1d99ef44b6bb09c111621f356ffe028ccff568b5fa26e4
jsondecoder.logicapp.dev.parameters.json.liquid [./templates/intermediaries/jsondecoder/jsondecoder.logicapp.dev.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
jsondecoder.logicapp.json [./templates/intermediaries/jsondecoder/jsondecoder.logicapp.json] -- 1f0805875dccf714eba66a951c06fec31d174c5b7e7158e70d3e94da73d26773
jsondecoder.logicapp.prod.parameters.json.liquid [./templates/intermediaries/jsondecoder/jsondecoder.logicapp.prod.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
New-JsonDecoder-LogicApp.ps1 [./templates/intermediaries/jsondecoder/New-JsonDecoder-LogicApp.ps1] -- 39864efe545528844ff7224e796d7cf949246d90737aed2097cc9403be42ebc4
Remove-JsonDecoder-LogicApp.ps1 [./templates/intermediaries/jsondecoder/Remove-JsonDecoder-LogicApp.ps1] -- b2577c0f14bac2d93a8b0de51ccaa6e081061857381e8657cbc21cb978838357
TearDown-90-JsonDecoder-LogicApp.ps1.liquid [./templates/intermediaries/jsondecoder/TearDown-90-JsonDecoder-LogicApp.ps1.liquid] -- fdc40eadf2096fc105462f935ab28dcd286aeb4a5331ebf9b7212955f0a972ae
Deploy-90-JsonEncoder-LogicApp.ps1.liquid [./templates/intermediaries/jsonencoder/Deploy-90-JsonEncoder-LogicApp.ps1.liquid] -- ba7eccbf4db7195717b0a9ee3ca8b443104093827302521d6388d717f45162ff
jsonencoder.logicapp.dev.parameters.json.liquid [./templates/intermediaries/jsonencoder/jsonencoder.logicapp.dev.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
jsonencoder.logicapp.json [./templates/intermediaries/jsonencoder/jsonencoder.logicapp.json] -- 51df214c86d9443aa88e553a733ece19abf50c44937fb6962b6a131c22e8c028
jsonencoder.logicapp.prod.parameters.json.liquid [./templates/intermediaries/jsonencoder/jsonencoder.logicapp.prod.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
New-JsonEncoder-LogicApp.ps1 [./templates/intermediaries/jsonencoder/New-JsonEncoder-LogicApp.ps1] -- aeb9f3dda18fd141b29f27a476a2e210511c20b08ca4f61739fc87c759f4b727
Remove-JsonEncoder-LogicApp.ps1 [./templates/intermediaries/jsonencoder/Remove-JsonEncoder-LogicApp.ps1] -- 51ff147a3b9554b62b947ea8399e4cf95df2bfb50255ddbc3364ca1e4b3ee501
TearDown-90-JsonEncoder-LogicApp.ps1.liquid [./templates/intermediaries/jsonencoder/TearDown-90-JsonEncoder-LogicApp.ps1.liquid] -- eab3151b7dcae349c1791f1aadd747f4932947637870cfb44e3ccc33201ba463
Deploy-100-ProcessManagerServiceBus-ApiConnection.ps1.liquid [./templates/intermediaries/procmgr/Deploy-100-ProcessManagerServiceBus-ApiConnection.ps1.liquid] -- d398fc11306bae16ba0681dd1017519a7fcf753262f876cfb0bee744919e2b07
Deploy-105-ProcessManager-LogicApp.ps1.liquid [./templates/intermediaries/procmgr/Deploy-105-ProcessManager-LogicApp.ps1.liquid] -- 66d9770f31a1c8d6de5cf7b55ee7dd7236c486139d75abf25d7a158eff715f33
New-ProcessManager-LogicApp.ps1 [./templates/intermediaries/procmgr/New-ProcessManager-LogicApp.ps1] -- ecc7d15de3515a7f6e93642d07a26e66cafdc708a95690cd3fff433aa28cbda7
New-ProcessManagerServiceBus-ApiConnection.ps1 [./templates/intermediaries/procmgr/New-ProcessManagerServiceBus-ApiConnection.ps1] -- 46f2657c306a32d644213cb01b85244095c479a2e8bd0739b75ec9dd58f9dce7
processmanagerservicebus.apiconnection.dev.parameters.json.liquid [./templates/intermediaries/procmgr/processmanagerservicebus.apiconnection.dev.parameters.json.liquid] -- bf0ae3785ace38014b2f048d1b9c9a67c3695eff89b37d085b87e224be179bcc
processmanagerservicebus.apiconnection.json.liquid [./templates/intermediaries/procmgr/processmanagerservicebus.apiconnection.json.liquid] -- 4d6235e59086e8577caa7788981073bc71b738039d6a21915014440e17f517ff
processmanagerservicebus.apiconnection.prod.parameters.json.liquid [./templates/intermediaries/procmgr/processmanagerservicebus.apiconnection.prod.parameters.json.liquid] -- bf0ae3785ace38014b2f048d1b9c9a67c3695eff89b37d085b87e224be179bcc
Remove-ProcessManager-LogicApp.ps1 [./templates/intermediaries/procmgr/Remove-ProcessManager-LogicApp.ps1] -- 7596858640f39059d85035544ee3878961904defd0149e2e542ed08a8fc52575
Remove-ProcessManagerServiceBus-ApiConnection.ps1 [./templates/intermediaries/procmgr/Remove-ProcessManagerServiceBus-ApiConnection.ps1] -- 3adac5da46a1ca7b6d1608c2c66ae6d9ae6e4081e17c7a3a1a4134ea2f254ec5
processmanager.activitycontainer.workflow.sbmsg.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/act/processmanager.activitycontainer.workflow.sbmsg.snippet.json.liquid] -- 2ac4c8c43c89cd1c067b9299fbab59a5ad7528e60486f8bff2b36985b5c6ec35
processmanager.activitycontainer.workflow.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/act/processmanager.activitycontainer.workflow.snippet.json.liquid] -- 1079621cd4514980789fda18007c76b23a82ee27af0530baf3c189c083f76e05
processmanager.channel.trigger.servicebustopic.snippet.json [./templates/intermediaries/procmgr/snippets/cons/act/processmanager.channel.trigger.servicebustopic.snippet.json] -- f22b907b0e035393317a20abe080c6a3bb703fcd45a0c43c8957bbcd8962a10d
processmanager.parametersdefinition.snippet.json [./templates/intermediaries/procmgr/snippets/cons/act/processmanager.parametersdefinition.snippet.json] -- 0a97ef9b16d31ab31b5ed643ac798d6a9e0a42ceb290c403c32007403fec43c6
processmanager.workflowdefinition.snippet.json [./templates/intermediaries/procmgr/snippets/cons/act/processmanager.workflowdefinition.snippet.json] -- e6a7eb42cb2cb97b02adba0e8f9be246ab20dc608e394d2895886ab2ebd64df0
processmanager.activity.codeexpression.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activity.codeexpression.snippet.json.liquid] -- a5b0754c13aa05df58ed36b72bf6fb25a39bc84047fc3e4522f24cb944ca2ec2
processmanager.activity.invokeworkflow.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activity.invokeworkflow.snippet.json.liquid] -- 212bbcaccb8ecc898acc0d99ccae2d2f2ffe01243dd193abb6cdb72082b336dc
processmanager.activity.messageconstruction.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activity.messageconstruction.snippet.json.liquid] -- 89abebca1659f537f2d192f2cb3a1de985a17d4ecdf7b887f0da2bed05d06b97
processmanager.activity.messagetransform.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activity.messagetransform.snippet.json.liquid] -- 6441c1cd0b716637274c78240bb6e2092d8f38d1d37e8c7f550f7cb608868e7d
processmanager.activity.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activity.placeholder.snippet.json.liquid] -- 96e593596e1495dd852ee4b49a6106e5aaa6bde67d7c9a23bbdf4692b3b07c7f
processmanager.activitycontainer.decision.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activitycontainer.decision.snippet.json.liquid] -- be2d20ee9bbc6b49171b69a4e07c6ce30aad10e2bc82df96b056f346535d0f03
processmanager.activitycontainer.decisionbranch.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activitycontainer.decisionbranch.snippet.json.liquid] -- 8eca32f99eb915e8aff8ce1739b9b099d8a489c25334f1e4183d2d26196f584c
processmanager.activitycontainer.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activitycontainer.placeholder.snippet.json.liquid] -- e7456fc90a5b3ae21c14c5d323b31c58252a19e4018a8222369866c9a7450720
processmanager.activitycontainer.task.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activitycontainer.task.snippet.json.liquid] -- 7085eef1450931ef0c218fb34bb63aaa09d36e5a795ea3caa0e6a77079f85b92
processmanager.activitycontainer.workflow.getconfig.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.activitycontainer.workflow.getconfig.snippet.json] -- e872873700228a55ed35d54f232f860b940600840595a4badf21c2273db27880
processmanager.channel.receive.servicebustopic.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.channel.receive.servicebustopic.snippet.json.liquid] -- 31de91fec7b0d7abc25a1ac8b5691e33cdf6715360d23e0927a679069f86f868
processmanager.channel.send.servicebustopic.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.channel.send.servicebustopic.snippet.json.liquid] -- 773078fb471d73a31ad2d3fc6c6f52294ba8238fff194a88566acfaa7529cbb3
processmanager.message.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.message.placeholder.snippet.json.liquid] -- 682ec137cb48addc1cbd8aba1e8ff0d3ede211259ccd0cf195d04dfcc45648ca
processmanager.parameter.apimretrypolicy.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.apimretrypolicy.snippet.json] -- e363679a612038927693668b71c52bdb12669a0ddd3fc7f8bac0e4eb782a9783
processmanager.parameter.apimservice.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.apimservice.snippet.json] -- 76face1f7a8d20278ab7d159c91d65d79ec90b7e998450fd7f180a6233d99a30
processmanager.parameter.apimsubscriptionkey.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.apimsubscriptionkey.snippet.json] -- de4620f712d2ed954efe5b3d0fa4dd21142ac3fbf0d999cc14fe540919ec6789
processmanager.parameter.integrationaccount.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.integrationaccount.snippet.json] -- f8f609c1edf3c3bf8031c728091a80a214f5c331b607eb3efc8b003d14cb62f2
processmanager.parameter.messagebusresourcegroup.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.messagebusresourcegroup.snippet.json] -- 8ddfb2a87d4db58c9e444effc34ed3260dbfcc9bdb8ffe4da4460b29f34da429
processmanager.parameter.messagesuspendprocessorlogicapp.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.messagesuspendprocessorlogicapp.snippet.json] -- b3c3e4fa8b6d9fa02bf831d12dbdbf6e4d47b441c8121e0c348fb05240110eb9
processmanager.parameter.routingsliprouterlogicapp.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.routingsliprouterlogicapp.snippet.json] -- 854fb60d51959b7d8b4162e22e26fdef2c25822b4e32bc0aeeff980dc55acd9a
processmanager.parameter.routingsliprouterretrypolicy.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.routingsliprouterretrypolicy.snippet.json] -- c261c3a66800b61b469549f4ec449c3a633b7737a0f36511f398bc405f4a2aee
processmanager.parameter.sbtopicpublishapiconnection.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.sbtopicpublishapiconnection.snippet.json] -- 279199fb81b6bace3d36e98a62a83d68fa03c6b6bcce95c4fd64bd83df8932ff
processmanager.parameter.sbtopicsubscribeapiconnection.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.sbtopicsubscribeapiconnection.snippet.json] -- 2c4dad4ca48203e493088b15315fa7aba8c8aebedb75771f130b9f5c88a731d3
processmanager.parameter.scenario.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.scenario.snippet.json] -- 39e1d93762d4ca9a241288c2ed0b0740678dbd12e18d8bd68bccb6e9aaf83219
processmanager.parameter.scenariostep.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.scenariostep.snippet.json] -- e0fe20a6dfe9f3af65f4552305a38f5d11fd836aa415e8f61465046845087b20
processmanager.parameter.servicebusrecurrencefrequency.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.servicebusrecurrencefrequency.snippet.json] -- d6a60c95ab639ef9a15615e6f4bbf498998466d8ca173a04cc05619fe44f061c
processmanager.parameter.servicebusrecurrenceinterval.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.servicebusrecurrenceinterval.snippet.json.liquid] -- 0f49a10c758a84e03252bc81951abc17e4acacc3935ff551fc212efdfda60b17
processmanager.parameter.servicebustopic.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.servicebustopic.snippet.json] -- bd891e80e375c5d71e6a5b880b84c4ade0f7cd0fda0ddb046efdd0f8e50f47c3
processmanager.parameter.servicebustopicsubscription.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.servicebustopicsubscription.snippet.json] -- 77e2449dcfd631a2f79af5503b1b97bc61f3fc1967c17acaa35b93ee101af0c1
processmanager.parameter.suspendqueuetopic.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.suspendqueuetopic.snippet.json] -- 80ec2912c6256148f445cb87f78cb2a0234e862b45a4585364db643089dc2c76
processmanager.parameter.systemapplicationresourcegroup.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.systemapplicationresourcegroup.snippet.json] -- c8898f826ab5712dcb414adc220d8afd818933c60d90607875353d3876009a6c
processmanager.parameter.tags.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.parameter.tags.snippet.json.liquid] -- f5794595f09d924c7c6a70311717a18497e8567877ddc64462f6bd11951adf47
processmanager.property.integrationaccount.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.property.integrationaccount.snippet.json] -- 7b8eb5a43a544649368bb1db1e49ac4564c9fdbd2a7d3a8dc3efdfc47346290b
processmanager.property.tags.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.property.tags.snippet.json] -- 4fe113668b885c7ba559037589cd62b6f8e9b79d5e61912b64297fc38f9a0868
processmanager.variable.apimservice.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.apimservice.snippet.json] -- e1aab84bef302c16e8d801f9b99ed67930fdc124b67b72a1e86eb1d666e9b2a5
processmanager.variable.configurationmanager.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.configurationmanager.snippet.json] -- d9cb15d1d8cc8563ddc3d8e47a6da34ae7c433c73230dedcce840b7594279b4b
processmanager.variable.initialize.configuration.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.initialize.configuration.snippet.json] -- f75d7cd2c9191cf02d8577e5ec03df2b228f6ec48ae1ec3ed92593be25745347
processmanager.variable.initialize.errormessage.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.initialize.errormessage.snippet.json] -- 4c7dc9eb0d7e471320dd2bf8f087211435c1fb39eb6ca6d60d496c64fd501864
processmanager.variable.initialize.faultmessage.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.initialize.faultmessage.snippet.json] -- b99bdf578d5e339bda43614354fc4c91e2505ae2b306effb514e7a1547565c70
processmanager.variable.initialize.messagetype.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.initialize.messagetype.snippet.json] -- 4ef9804c72bdee15b7fb2a6f06b5d584daa8589ec954582b96404492bd4daf3a
processmanager.variable.initialize.statuscode.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.initialize.statuscode.snippet.json] -- 01a686eefc7f7ea8e873dc309cd1bbb7d219a5009808ed7baf530d1f591dcceb
processmanager.variable.integrationaccount.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.integrationaccount.snippet.json] -- 59c6dda8de94e00804482f9ee78498eae4ae72f84618a53c04fe15a6f13e210f
processmanager.variable.messagesuspendprocessorlogicapp.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.messagesuspendprocessorlogicapp.snippet.json] -- 202fbacc7018fd46e9634b502b79adb1a5d495143521671e4ca2b23b3d39c20c
processmanager.variable.messagingmanager.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.messagingmanager.snippet.json] -- 192bfa84ba5419c7efc4c5e9979ded8591b39e39a131e649101c564497f3418c
processmanager.variable.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.placeholder.snippet.json.liquid] -- 3296e2059b1e873229c909f5a02d686d1868f511ecd3697ec8dbd4f5a88e9b2f
processmanager.variable.routingmanager.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.routingmanager.snippet.json] -- 7be6cadda4b9b31d95b3a3854479d21cfd2db7342639f11b3ec09b260ffbb504
processmanager.variable.routingsliprouterlogicapp.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.routingsliprouterlogicapp.snippet.json] -- e27231f4295c0a5f7c8dfcf52f053ad6d7815881b14be484cac38649af4e82f6
processmanager.variable.sbtopicpublishapiconnection.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.sbtopicpublishapiconnection.snippet.json] -- 841164891c23318b1ce0d1762e27cc87de45e2aec7d648a97a2ea9a29da1e953
processmanager.variable.sbtopicsubscribeapiconnection.snippet.json [./templates/intermediaries/procmgr/snippets/cons/com/processmanager.variable.sbtopicsubscribeapiconnection.snippet.json] -- 71e730a53bfbc5428babd36f3da0bf2e70b63456cb54d722410b6c75ef6833cc
processmanager.channel.trigger.http.snippet.json [./templates/intermediaries/procmgr/snippets/cons/inv/processmanager.channel.trigger.http.snippet.json] -- a9de6bf5e64fa38de69bfb9584c65861d6ffdacfdc6ec166cfd2176b385f89c2
processmanager.parametersdefinition.snippet.json [./templates/intermediaries/procmgr/snippets/cons/inv/processmanager.parametersdefinition.snippet.json] -- 0a97ef9b16d31ab31b5ed643ac798d6a9e0a42ceb290c403c32007403fec43c6
processmanager.workflowdefinition.snippet.json [./templates/intermediaries/procmgr/snippets/cons/inv/processmanager.workflowdefinition.snippet.json] -- e6a7eb42cb2cb97b02adba0e8f9be246ab20dc608e394d2895886ab2ebd64df0
processmanager.activitycontainer.workflow.sbmsg.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.activitycontainer.workflow.sbmsg.snippet.json.liquid] -- 41a91dd65c0e9b8d485fe97f52dbd551152348f3eb02919a08656667c21ccb5b
processmanager.activitycontainer.workflow.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.activitycontainer.workflow.snippet.json.liquid] -- 3adc63384b4de054bb61b2bff70418387b28e62687eea61364baabee62c9c0f1
processmanager.appsettings.local.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.appsettings.local.snippet.json.liquid] -- 3ac044e271ae20e966615b74a88955bbf2e5fe190dea39114bcaafe305ba2eec
processmanager.appsettings.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.appsettings.snippet.json.liquid] -- d50b66060ef4bc2af5383a6e45dca17992d1b957e7bf9ce9120c9f6941b0106c
processmanager.channel.trigger.servicebustopic.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.channel.trigger.servicebustopic.snippet.json.liquid] -- f0d8389141ca5ab47d05cffd26437d4e12d1cbd821a26f296f78c61b43155a70
processmanager.connections.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.connections.snippet.json.liquid] -- 85038539f84248f858746333cc4d27a7628d7bf182ccd4ac4c8c585337f30c8d
processmanager.parameters.local.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.parameters.local.snippet.json.liquid] -- 105aa0ad2a7251f3a83f164061be9b885d74d27050af9057365a184d8a23aa2a
processmanager.parameters.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/act/processmanager.parameters.snippet.json.liquid] -- 56c6a910281d7a442a9ad02331553f9512e34b35d95531ea477bb148021f4dbc
processmanager.workflowdefinition.snippet.json [./templates/intermediaries/procmgr/snippets/std/act/processmanager.workflowdefinition.snippet.json] -- 9891e1a775691b10a3391a18891da9b5afac3f7b57504c6b29a324721913d7f6
processmanager.activity.codeexpression.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activity.codeexpression.snippet.json.liquid] -- a5b0754c13aa05df58ed36b72bf6fb25a39bc84047fc3e4522f24cb944ca2ec2
processmanager.activity.invokeworkflow.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activity.invokeworkflow.snippet.json.liquid] -- 308d5967fdbcb99571807f3fa12ff3c3cd2a1d428eb491244e64d207d61aa9d7
processmanager.activity.messageconstruction.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activity.messageconstruction.snippet.json.liquid] -- 89abebca1659f537f2d192f2cb3a1de985a17d4ecdf7b887f0da2bed05d06b97
processmanager.activity.messagetransform.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activity.messagetransform.snippet.json.liquid] -- a2749c913731b1635325fab351655920bb2706b11f2f16fb9248d960b84d5672
processmanager.activity.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activity.placeholder.snippet.json.liquid] -- 96e593596e1495dd852ee4b49a6106e5aaa6bde67d7c9a23bbdf4692b3b07c7f
processmanager.activitycontainer.decision.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activitycontainer.decision.snippet.json.liquid] -- be2d20ee9bbc6b49171b69a4e07c6ce30aad10e2bc82df96b056f346535d0f03
processmanager.activitycontainer.decisionbranch.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activitycontainer.decisionbranch.snippet.json.liquid] -- 8eca32f99eb915e8aff8ce1739b9b099d8a489c25334f1e4183d2d26196f584c
processmanager.activitycontainer.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activitycontainer.placeholder.snippet.json.liquid] -- e7456fc90a5b3ae21c14c5d323b31c58252a19e4018a8222369866c9a7450720
processmanager.activitycontainer.task.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activitycontainer.task.snippet.json.liquid] -- 7085eef1450931ef0c218fb34bb63aaa09d36e5a795ea3caa0e6a77079f85b92
processmanager.activitycontainer.workflow.getconfig.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.activitycontainer.workflow.getconfig.snippet.json.liquid] -- 838f1206af893db63c20b0aa7e71d87120fd2a45908add8dc1e28f526ad4ee5d
processmanager.channel.receive.servicebustopic.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.channel.receive.servicebustopic.snippet.json.liquid] -- 31de91fec7b0d7abc25a1ac8b5691e33cdf6715360d23e0927a679069f86f868
processmanager.channel.send.servicebustopic.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.channel.send.servicebustopic.snippet.json.liquid] -- 874ac5135e0747923b01ce112dfcd5365d3cf58761ca9401e88cb57153f04c45
processmanager.message.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.message.placeholder.snippet.json.liquid] -- 682ec137cb48addc1cbd8aba1e8ff0d3ede211259ccd0cf195d04dfcc45648ca
processmanager.parameter.scenario.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.parameter.scenario.snippet.json] -- 85b42a8efe9defe733319e044523d3236b55d51e4769842fb986298d8851c91d
processmanager.parameter.scenariostep.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.parameter.scenariostep.snippet.json] -- 76a4907ba1f116c0c82cc98ce46604f1125a664489207a15dd704e12e55160df
processmanager.parameter.servicebustopic.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.parameter.servicebustopic.snippet.json] -- dc54701d0bd75e1d7efcf9338fa2bf56533cf3200be8b8feb59701725be9d9dd
processmanager.parameter.servicebustopicsubscription.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.parameter.servicebustopicsubscription.snippet.json] -- d04a5c53ee9a4db5beb83fbeac7e982119ab7a611d93fe87602b1c6d8677a443
processmanager.variable.initialize.configuration.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.variable.initialize.configuration.snippet.json] -- f75d7cd2c9191cf02d8577e5ec03df2b228f6ec48ae1ec3ed92593be25745347
processmanager.variable.initialize.errormessage.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.variable.initialize.errormessage.snippet.json] -- ee5da30b9086d8b1893eb86d76983a0e51752eda07a0747e4d64b6a6332383dc
processmanager.variable.initialize.faultmessage.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.variable.initialize.faultmessage.snippet.json] -- b99bdf578d5e339bda43614354fc4c91e2505ae2b306effb514e7a1547565c70
processmanager.variable.initialize.messagetype.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.variable.initialize.messagetype.snippet.json] -- 4ef9804c72bdee15b7fb2a6f06b5d584daa8589ec954582b96404492bd4daf3a
processmanager.variable.initialize.statuscode.snippet.json [./templates/intermediaries/procmgr/snippets/std/com/processmanager.variable.initialize.statuscode.snippet.json] -- 01a686eefc7f7ea8e873dc309cd1bbb7d219a5009808ed7baf530d1f591dcceb
processmanager.variable.placeholder.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/com/processmanager.variable.placeholder.snippet.json.liquid] -- 3296e2059b1e873229c909f5a02d686d1868f511ecd3697ec8dbd4f5a88e9b2f
processmanager.appsettings.local.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/inv/processmanager.appsettings.local.snippet.json.liquid] -- 3ac044e271ae20e966615b74a88955bbf2e5fe190dea39114bcaafe305ba2eec
processmanager.appsettings.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/inv/processmanager.appsettings.snippet.json.liquid] -- d50b66060ef4bc2af5383a6e45dca17992d1b957e7bf9ce9120c9f6941b0106c
processmanager.channel.trigger.http.snippet.json [./templates/intermediaries/procmgr/snippets/std/inv/processmanager.channel.trigger.http.snippet.json] -- a9de6bf5e64fa38de69bfb9584c65861d6ffdacfdc6ec166cfd2176b385f89c2
processmanager.connections.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/inv/processmanager.connections.snippet.json.liquid] -- 85038539f84248f858746333cc4d27a7628d7bf182ccd4ac4c8c585337f30c8d
processmanager.parameters.local.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/inv/processmanager.parameters.local.snippet.json.liquid] -- bb343bd6e96730a671614c0eae7e11b010654f3067f4073a67911814f986198b
processmanager.parameters.snippet.json.liquid [./templates/intermediaries/procmgr/snippets/std/inv/processmanager.parameters.snippet.json.liquid] -- bb343bd6e96730a671614c0eae7e11b010654f3067f4073a67911814f986198b
processmanager.workflowdefinition.snippet.json [./templates/intermediaries/procmgr/snippets/std/inv/processmanager.workflowdefinition.snippet.json] -- 9891e1a775691b10a3391a18891da9b5afac3f7b57504c6b29a324721913d7f6
TearDown-100-ProcessManagerServiceBus-ApiConnection.ps1.liquid [./templates/intermediaries/procmgr/TearDown-100-ProcessManagerServiceBus-ApiConnection.ps1.liquid] -- 70f2b3da35b7e47136f69fcbd7785dc2ac3d65228063f94f1bf44a2f6a31ca09
TearDown-105-ProcessManager-LogicApp.ps1.liquid [./templates/intermediaries/procmgr/TearDown-105-ProcessManager-LogicApp.ps1.liquid] -- e813736bf86430462badf124245017e7397199ab5641e33b675b631ba957d3e4
Deploy-120-SystemApplication-ClearUrlCache.ps1.liquid [./templates/intermediaries/standard/Deploy-120-SystemApplication-ClearUrlCache.ps1.liquid] -- 88bcbee6df8b289408be79181cd5b106e4a04c58499c41bf98e3faff52144d6b
Deploy-80-SystemApplicationServiceBus-ApiConnection.ps1.liquid [./templates/intermediaries/standard/Deploy-80-SystemApplicationServiceBus-ApiConnection.ps1.liquid] -- 3a212465c515e905ea2fe2c6afac668a1a92ec6b64f98eee8f7969074cf9932f
Deploy-90-SystemApplication-LogicApp.ps1.liquid [./templates/intermediaries/standard/Deploy-90-SystemApplication-LogicApp.ps1.liquid] -- 2d7358ca4a50a150666ac7cd532b6233deb9f9218f97e5d297306f3a75aae166
Deploy-95-SystemApplicationServiceBus-ApiConnPolicy.ps1.liquid [./templates/intermediaries/standard/Deploy-95-SystemApplicationServiceBus-ApiConnPolicy.ps1.liquid] -- 03f0ce0281349c03241853c9e5b1ce1a3ee9c6dd15d72b35137a41089518a644
New-SystemApplication-ClearUrlCache.ps1 [./templates/intermediaries/standard/New-SystemApplication-ClearUrlCache.ps1] -- 2feabcbdbd14036de39870d058192470aba782290332bccd644182be1c345590
New-SystemApplication-LogicApp.ps1 [./templates/intermediaries/standard/New-SystemApplication-LogicApp.ps1] -- 3eec98fa4aceea246ed3268df744d9c1cb68e4c73d04706d3ef12507f8a4f03f
New-SystemApplicationServiceBus-ApiConnection.ps1 [./templates/intermediaries/standard/New-SystemApplicationServiceBus-ApiConnection.ps1] -- 3257eb9b6c4c454e02bd8e5b6e3c6e50cdd5fdf6b69e4fbdaab20256dacd8188
New-SystemApplicationServiceBus-ApiConnPolicy.ps1 [./templates/intermediaries/standard/New-SystemApplicationServiceBus-ApiConnPolicy.ps1] -- 5e489cf21a3687e445023802e4a5eabacdd1ff299c5050d2cd6306d69590c1af
Remove-SystemApplication-LogicApp.ps1 [./templates/intermediaries/standard/Remove-SystemApplication-LogicApp.ps1] -- 1da6bfb2550ab00b40290d3b517beeb86ed4b0798aed357bfc83b145a353b794
Remove-SystemApplicationServiceBus-ApiConnection.ps1 [./templates/intermediaries/standard/Remove-SystemApplicationServiceBus-ApiConnection.ps1] -- 0ca7940515b3f15e34dab0b74c1307ee92f1afeb51610163e73783a1c8dc9d0c
systemapplication.logic.dev.parameters.json.liquid [./templates/intermediaries/standard/systemapplication.logic.dev.parameters.json.liquid] -- 7532b96397fe6a575956eb8dd2a53d9e5c82064091c80095f4867834f2e0e644
systemapplication.logic.json [./templates/intermediaries/standard/systemapplication.logic.json] -- 6bb77c285c26a71b31081cc2c9fee13b6ddb6f6b57c4f9b4e1e3aa0d824f7db2
systemapplication.logic.prod.parameters.json.liquid [./templates/intermediaries/standard/systemapplication.logic.prod.parameters.json.liquid] -- 2beeca603963cc0b576b438ad851a3092284d2bb1165de48fed19aef413edb7c
.funcignore [./templates/intermediaries/standard/systemapplication.logic.workflows/.funcignore] -- 96393bc26432421a0722a6d9f611083740cdbdce59205eb5de412df91669c8af
extensions.json [./templates/intermediaries/standard/systemapplication.logic.workflows/.vscode/extensions.json] -- dc808d40149bd12a4566c98e2e4cdd5f56c9ac11021805667b2749021b98f2a9
launch.json [./templates/intermediaries/standard/systemapplication.logic.workflows/.vscode/launch.json] -- de0269109118db95ac611b185f80bd5a78341a711e84a6a0bfede358e95ffe5a
settings.json [./templates/intermediaries/standard/systemapplication.logic.workflows/.vscode/settings.json] -- 3b5b7abc9971860ba37a6a8b1186a645ad1acdc0f7d995860a52fbbba76067a8
tasks.json [./templates/intermediaries/standard/systemapplication.logic.workflows/.vscode/tasks.json] -- dfcc0600c8cb6847bc2827b0ca59f869fe1ed0e05418f766595d5f949ed674dc
connections.json [./templates/intermediaries/standard/systemapplication.logic.workflows/connections.json] -- ef10fb8df6865045662705c39c41bd560b409873f52ad935787c11f1d719b9ec
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/contentdemoter/workflow.json] -- 6a5efefa0774153881114bac518b91b1934f84cc3cb0ec7919cfd0fe7e791077
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/contentpromoter/workflow.json] -- f09aa7bdf4788e71fb15af61194ea2b3e032d3047debac97e29770b2b5aeb6eb
host.json [./templates/intermediaries/standard/systemapplication.logic.workflows/host.json] -- 4c01b0f013d3e14d11c063affc7ddfa03ab59ef1557299e4d9594efee5487767
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/jsondecoder/workflow.json] -- 1fede1f046fc3dc90a7d1d47a71f09d1a0cd52a90e87cf03c05b033dc3b02826
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/jsonencoder/workflow.json] -- d30c6395fefd3b4ba0a212af402266fd9dd11ef0b33f04f746b06e65e0720035
local.settings.json [./templates/intermediaries/standard/systemapplication.logic.workflows/local.settings.json] -- fd2de4762220aba0d99469e90949d70b6bbed16a53016c9dd352e953828ee7ba
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/messageconstructor/workflow.json] -- 4c3b4cdcdad7ed5545e16b8790d525d1dc80950be8257815cb1384ff07e19e2a
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/messageresponsehandler/workflow.json] -- 96c4330cef949735d258246f4e85e7f53cee0e051f141059c4d2844541958d55
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/messagesuspendprocessor/workflow.json] -- 73537ed6a5e22a1ede410ac1829dac2dd887d160689c9befc95fdcab9e033c70
parameters.json [./templates/intermediaries/standard/systemapplication.logic.workflows/parameters.json] -- 8ed442e930dda563f2b9b571f3e96f679e9fa37fad866a5cb0f107c6b5156651
parameters.local.json [./templates/intermediaries/standard/systemapplication.logic.workflows/parameters.local.json] -- c3a72c2d768ff8a1f8917627bce23077f524bcaba716f54ed5a655a917fcf068
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/routingsliprouter/workflow.json] -- cadef238a844e9c5b93bfa4f0a4d594f071b233098528373fa6133862829bfe7
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/topicpublisher/workflow.json] -- 7412d21ba255ac1b889bb93b4eae0bcb9c6ae221144dad440ba40f7deef57568
host.json [./templates/intermediaries/standard/systemapplication.logic.workflows/workflow-designtime/host.json] -- bb8f058a2c5ce1ceefd5ed557ec0de961cfb2089a706bfc8f1904ced9a91a754
local.settings.json [./templates/intermediaries/standard/systemapplication.logic.workflows/workflow-designtime/local.settings.json] -- 24e0bdd57da3e30c789358ca8001020601accb31ec38b38abe88e261ed09cab7
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/xmlenvelopewrapper/workflow.json] -- 7e6db87633bad8d7cb2290093619e6909cf765344a7c7aa4d16770dbcc798a72
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/xmlmessageprocessor/workflow.json] -- 572f09faaaa00726bc64409de1cc65a43650e1cc4c63a0637b24cb698f245e1d
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/xmlmessagetranslator/workflow.json] -- cbb35c6330559ae1ff3089a117f18f7e8e52b69e61b803d308d5cd1d207c3289
workflow.json [./templates/intermediaries/standard/systemapplication.logic.workflows/xmlmessagevalidator/workflow.json] -- c49b32ad9e38ff82d79e19b8a78acd2cf3020c1e1d246170ef52874b24290e0e
systemapplicationservicebus.apicaccesspolicy.dev.parameters.json.liquid [./templates/intermediaries/standard/systemapplicationservicebus.apicaccesspolicy.dev.parameters.json.liquid] -- 461b68d1a4a3e388df022195a60fe9765e65396f9fc78f4317dd90b750dec8e1
systemapplicationservicebus.apicaccesspolicy.json [./templates/intermediaries/standard/systemapplicationservicebus.apicaccesspolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
systemapplicationservicebus.apicaccesspolicy.prod.parameters.json.liquid [./templates/intermediaries/standard/systemapplicationservicebus.apicaccesspolicy.prod.parameters.json.liquid] -- 461b68d1a4a3e388df022195a60fe9765e65396f9fc78f4317dd90b750dec8e1
systemapplicationservicebus.apiconnection.dev.parameters.json.liquid [./templates/intermediaries/standard/systemapplicationservicebus.apiconnection.dev.parameters.json.liquid] -- f1a2bfcc1e7ca3c620ad6c87f48ef61230c83a457db56a212437417adfbd63da
systemapplicationservicebus.apiconnection.json [./templates/intermediaries/standard/systemapplicationservicebus.apiconnection.json] -- 31d877d777d85f6b053c679d2b6631dbab4acf2c0ef98fd5f1b2b704429c33b1
systemapplicationservicebus.apiconnection.prod.parameters.json.liquid [./templates/intermediaries/standard/systemapplicationservicebus.apiconnection.prod.parameters.json.liquid] -- f1a2bfcc1e7ca3c620ad6c87f48ef61230c83a457db56a212437417adfbd63da
TearDown-80-SystemApplicationServiceBus-ApiConnection.ps1.liquid [./templates/intermediaries/standard/TearDown-80-SystemApplicationServiceBus-ApiConnection.ps1.liquid] -- 0fbbaf780602b204336b7be49f679fa23828fe6b1e1f4733949a357733efe352
TearDown-90-SystemApplication-LogicApp.ps1.liquid [./templates/intermediaries/standard/TearDown-90-SystemApplication-LogicApp.ps1.liquid] -- 1f43f0e21ba69ab1fdeeaf013e9f6c3681837c7119eebec02f8337c70cf23f17
Deploy-90-TopicPublisher-ApiConnection.ps1.liquid [./templates/intermediaries/topicpublisher/Deploy-90-TopicPublisher-ApiConnection.ps1.liquid] -- 47ea2c52cc73bfdff88937aae717e2aca09541d2814f3f7105d3bf492e21590f
Deploy-95-TopicPublisher-LogicApp.ps1.liquid [./templates/intermediaries/topicpublisher/Deploy-95-TopicPublisher-LogicApp.ps1.liquid] -- 1791cb020479a922f1ff1db78289e1acfb9f568d21465ebee57e6b24e4b582de
New-TopicPublisher-ApiConnection.ps1 [./templates/intermediaries/topicpublisher/New-TopicPublisher-ApiConnection.ps1] -- a5a732e1fb51b039a07116dfc3df86f44a2c09d1eb9eec8127b33068db189287
New-TopicPublisher-LogicApp.ps1 [./templates/intermediaries/topicpublisher/New-TopicPublisher-LogicApp.ps1] -- 11758c5460d791619ed33090ed110659e48d76189afd77563b6f59cfe7f5ee52
Remove-TopicPublisher-ApiConnection.ps1 [./templates/intermediaries/topicpublisher/Remove-TopicPublisher-ApiConnection.ps1] -- 4ab8d52ab4ea97358fdf28cab76145d3f2ffdea2a83426cfe60ac9b767a37045
Remove-TopicPublisher-LogicApp.ps1 [./templates/intermediaries/topicpublisher/Remove-TopicPublisher-LogicApp.ps1] -- 5a96362920e790d3c15e5635cf73cba36c4668a8da2ffd70ffb94741728d1515
TearDown-90-TopicPublisher-ApiConnection.ps1.liquid [./templates/intermediaries/topicpublisher/TearDown-90-TopicPublisher-ApiConnection.ps1.liquid] -- 28b91cee22469ca826184991af6e5652d8c7a13af88802936be6bc38e03c3e0d
TearDown-95-TopicPublisher-LogicApp.ps1.liquid [./templates/intermediaries/topicpublisher/TearDown-95-TopicPublisher-LogicApp.ps1.liquid] -- fba06d7127da0e70b6064e63d74280798275c82bcb127873afd8b50dc4c48f56
topicpublisher.apiconnection.dev.parameters.json.liquid [./templates/intermediaries/topicpublisher/topicpublisher.apiconnection.dev.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
topicpublisher.apiconnection.json.liquid [./templates/intermediaries/topicpublisher/topicpublisher.apiconnection.json.liquid] -- 4e4279c2066ebf0eed61b396bca8299fcf240c218076511d4059f3fd875776bc
topicpublisher.apiconnection.prod.parameters.json.liquid [./templates/intermediaries/topicpublisher/topicpublisher.apiconnection.prod.parameters.json.liquid] -- b38ea4cf09e002638379439e7386e55b30c1e06a2cc63d979359c5063594841c
topicpublisher.logicapp.dev.parameters.json.liquid [./templates/intermediaries/topicpublisher/topicpublisher.logicapp.dev.parameters.json.liquid] -- a4ee37e07e3b17f4ed56fd78706e631bb8b8ce787121493eb109e5c67669d8c0
topicpublisher.logicapp.json [./templates/intermediaries/topicpublisher/topicpublisher.logicapp.json] -- 1e5b832b1b300df933f40c2c1cef4d438a5724eb9a9049fb7b43df7439bbec89
topicpublisher.logicapp.prod.parameters.json.liquid [./templates/intermediaries/topicpublisher/topicpublisher.logicapp.prod.parameters.json.liquid] -- a4ee37e07e3b17f4ed56fd78706e631bb8b8ce787121493eb109e5c67669d8c0
Deploy-100-TopicSubscriber-ApiConnection.ps1.liquid [./templates/intermediaries/topicsubscriber/Deploy-100-TopicSubscriber-ApiConnection.ps1.liquid] -- 26e8e95fcb4e27b59de697331e1059635d93634381470035700fca9a1bf34a05
Deploy-105-TopicSubscriber-LogicApp.ps1.liquid [./templates/intermediaries/topicsubscriber/Deploy-105-TopicSubscriber-LogicApp.ps1.liquid] -- 821e8f6de5591e49ba8eeda0fddd9545404d2f6c396954d2984e6ce2ae3f419c
Deploy-110-TopicSubscriber-ApiConnPolicy.ps1.liquid [./templates/intermediaries/topicsubscriber/Deploy-110-TopicSubscriber-ApiConnPolicy.ps1.liquid] -- 546e8dd153c044de335842d48e5fc58e03b7490b9445ff98b261a4d9d0bf8b93
New-TopicSubscriber-ApiConnection.ps1 [./templates/intermediaries/topicsubscriber/New-TopicSubscriber-ApiConnection.ps1] -- 60e622d3fe31bb572efd35175898b7fd2d591d0827583eb341f82c2440ad6452
New-TopicSubscriber-ApiConnPolicy.ps1 [./templates/intermediaries/topicsubscriber/New-TopicSubscriber-ApiConnPolicy.ps1] -- 1239d307747119ae8945e6e9e4396951d22d480aba904e4ee48194862ba27b05
New-TopicSubscriber-LogicApp.ps1 [./templates/intermediaries/topicsubscriber/New-TopicSubscriber-LogicApp.ps1] -- ce5f5cffa955723985a54ad0a8b3358d10213380111480b0320822d50587d08f
Remove-TopicSubscriber-ApiConnection.ps1 [./templates/intermediaries/topicsubscriber/Remove-TopicSubscriber-ApiConnection.ps1] -- 466e0683784b8346397c26223fc179b9065edfe1e8497fe6aa9a45c607539284
Remove-TopicSubscriber-LogicApp.ps1 [./templates/intermediaries/topicsubscriber/Remove-TopicSubscriber-LogicApp.ps1] -- 03c6aa6d118b4b5214bd5d1ad2762e58a0ddb88e701ec4e9981be1776be03fbe
TearDown-100-TopicSubscriber-ApiConnection.ps1.liquid [./templates/intermediaries/topicsubscriber/TearDown-100-TopicSubscriber-ApiConnection.ps1.liquid] -- d7d545d7ca304a60b59b7b42cd839d5f60821de80f2ace3dccf747b3b7cf3941
TearDown-105-TopicSubscriber-LogicApp.ps1.liquid [./templates/intermediaries/topicsubscriber/TearDown-105-TopicSubscriber-LogicApp.ps1.liquid] -- 8d53121a6ed95c4c073f7a05f5c37fcd122a899fae11c689d0fc123783e9e58d
topicsubscriber.apiconnection.dev.parameters.json.liquid [./templates/intermediaries/topicsubscriber/topicsubscriber.apiconnection.dev.parameters.json.liquid] -- bf0ae3785ace38014b2f048d1b9c9a67c3695eff89b37d085b87e224be179bcc
topicsubscriber.apiconnection.json.liquid [./templates/intermediaries/topicsubscriber/topicsubscriber.apiconnection.json.liquid] -- 4d6235e59086e8577caa7788981073bc71b738039d6a21915014440e17f517ff
topicsubscriber.apiconnection.prod.parameters.json.liquid [./templates/intermediaries/topicsubscriber/topicsubscriber.apiconnection.prod.parameters.json.liquid] -- bf0ae3785ace38014b2f048d1b9c9a67c3695eff89b37d085b87e224be179bcc
topicsubscriber.apiconnpolicy.dev.parameters.json.liquid [./templates/intermediaries/topicsubscriber/topicsubscriber.apiconnpolicy.dev.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
topicsubscriber.apiconnpolicy.json [./templates/intermediaries/topicsubscriber/topicsubscriber.apiconnpolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
topicsubscriber.apiconnpolicy.prod.parameters.json.liquid [./templates/intermediaries/topicsubscriber/topicsubscriber.apiconnpolicy.prod.parameters.json.liquid] -- 84276200a95ff1e14175d1edc7ba6d19c4ddd0564009d9186e7f08dfcafb0ec0
topicsubscriber.logicapp.dev.parameters.json.liquid [./templates/intermediaries/topicsubscriber/topicsubscriber.logicapp.dev.parameters.json.liquid] -- 8882f4883b465550fd368b12d511f4c2e65815c498b12ee407bde932b6ba2376
topicsubscriber.logicapp.json [./templates/intermediaries/topicsubscriber/topicsubscriber.logicapp.json] -- f6e117667377c602fa9a155cfb08092a90ca51416b49018c751ba29442cade8f
topicsubscriber.logicapp.prod.parameters.json.liquid [./templates/intermediaries/topicsubscriber/topicsubscriber.logicapp.prod.parameters.json.liquid] -- 8882f4883b465550fd368b12d511f4c2e65815c498b12ee407bde932b6ba2376
Deploy-85-XmlEnvelopeWrapper-LogicApp.ps1.liquid [./templates/intermediaries/xmlenvelopewrapper/Deploy-85-XmlEnvelopeWrapper-LogicApp.ps1.liquid] -- ce14c803ae926257ce58b5397f050d21cd91135ec58f8555d082ead818067a5c
New-XmlEnvelopeWrapper-LogicApp.ps1 [./templates/intermediaries/xmlenvelopewrapper/New-XmlEnvelopeWrapper-LogicApp.ps1] -- 65ea1018296b75618c836a049cb20e565e95d99430bd0c242da64474fd404cbc
Remove-XmlEnvelopeWrapper-LogicApp.ps1 [./templates/intermediaries/xmlenvelopewrapper/Remove-XmlEnvelopeWrapper-LogicApp.ps1] -- 331e59323a75b0efee30db1de320ff61c4c333ef7c3b049d367e3cf5cac4dbee
TearDown-85-XmlEnvelopeWrapper-LogicApp.ps1.liquid [./templates/intermediaries/xmlenvelopewrapper/TearDown-85-XmlEnvelopeWrapper-LogicApp.ps1.liquid] -- 53e6619b655360ad60d78b8815c2d8337754147a7ee896c2d00d109e5e8da14a
xmlenvelopewrapper.logicapp.dev.parameters.json.liquid [./templates/intermediaries/xmlenvelopewrapper/xmlenvelopewrapper.logicapp.dev.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
xmlenvelopewrapper.logicapp.json [./templates/intermediaries/xmlenvelopewrapper/xmlenvelopewrapper.logicapp.json] -- 6462cd42b68da4518722de0d15dca55e303e202d7326ac4510a7395260db7115
xmlenvelopewrapper.logicapp.prod.parameters.json.liquid [./templates/intermediaries/xmlenvelopewrapper/xmlenvelopewrapper.logicapp.prod.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
Deploy-85-XmlMessageProcessor-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessageprocessor/Deploy-85-XmlMessageProcessor-LogicApp.ps1.liquid] -- a5aabe67c9cfbb273a19febe919294f6cca92cf4863bc5d64023a57aeb674a56
New-XmlMessageProcessor-LogicApp.ps1 [./templates/intermediaries/xmlmessageprocessor/New-XmlMessageProcessor-LogicApp.ps1] -- 5a430843e159341f37c414dbb4caeec3fa3c2cc9245feb1a6ed1774f9490d73b
Remove-XmlMessageProcessor-LogicApp.ps1 [./templates/intermediaries/xmlmessageprocessor/Remove-XmlMessageProcessor-LogicApp.ps1] -- 2f024ef295489e61a0442b99d98ff95e4d3f7245ad651b7c846e64dc36365b2c
TearDown-85-XmlMessageProcessor-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessageprocessor/TearDown-85-XmlMessageProcessor-LogicApp.ps1.liquid] -- dff01fcf53c8b50111bf4f7e08ebef8c8af38612f055c096435133bdb43d4b51
xmlmessageprocessor.logicapp.dev.parameters.json.liquid [./templates/intermediaries/xmlmessageprocessor/xmlmessageprocessor.logicapp.dev.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
xmlmessageprocessor.logicapp.json [./templates/intermediaries/xmlmessageprocessor/xmlmessageprocessor.logicapp.json] -- 10bb8f1d81004c7efa84fc1bb45378d85839af9001a25ee4d7ee6724f8b92a49
xmlmessageprocessor.logicapp.prod.parameters.json.liquid [./templates/intermediaries/xmlmessageprocessor/xmlmessageprocessor.logicapp.prod.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
Deploy-85-XmlMessageTranslator-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessagetranslator/Deploy-85-XmlMessageTranslator-LogicApp.ps1.liquid] -- 0446ca973f05d81649a642b69e3f8d1bcb0511369926669575859108c21917ff
New-XmlMessageTranslator-LogicApp.ps1 [./templates/intermediaries/xmlmessagetranslator/New-XmlMessageTranslator-LogicApp.ps1] -- dae6949354a5337bc964318da9397dbdb4031bbc9ebbbf3ca93da12bd405f049
Remove-XmlMessageTranslator-LogicApp.ps1 [./templates/intermediaries/xmlmessagetranslator/Remove-XmlMessageTranslator-LogicApp.ps1] -- fbaffd43f838163f2fd602a8ec53def4a8ec9d656f9707cd166a4b28d34be33f
TearDown-85-XmlMessageTranslator-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessagetranslator/TearDown-85-XmlMessageTranslator-LogicApp.ps1.liquid] -- 24e3b65171db1356d36b256e3855057a41de50d0fce11fc5558a6aba89e68ddc
xmlmessagetranslator.logicapp.dev.parameters.json.liquid [./templates/intermediaries/xmlmessagetranslator/xmlmessagetranslator.logicapp.dev.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
xmlmessagetranslator.logicapp.json [./templates/intermediaries/xmlmessagetranslator/xmlmessagetranslator.logicapp.json] -- 55f43ade702c209fcfdd197cd8fe08524333234ff44d3301f589b89613aa808c
xmlmessagetranslator.logicapp.prod.parameters.json.liquid [./templates/intermediaries/xmlmessagetranslator/xmlmessagetranslator.logicapp.prod.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
Deploy-85-XmlMessageTranslatorLite-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessagetranslatorlite/Deploy-85-XmlMessageTranslatorLite-LogicApp.ps1.liquid] -- 33db086a956e2003074ea2a1ab9f56de41db7c6515f5c86be887ee6c4a7a9f5c
New-XmlMessageTranslatorLite-LogicApp.ps1 [./templates/intermediaries/xmlmessagetranslatorlite/New-XmlMessageTranslatorLite-LogicApp.ps1] -- e2819c910be4cbd795220cc5120efa8083abcf04fedf54f1d51aeb591148d1e9
Remove-XmlMessageTranslatorLite-LogicApp.ps1 [./templates/intermediaries/xmlmessagetranslatorlite/Remove-XmlMessageTranslatorLite-LogicApp.ps1] -- cd6fe42df66334e17822b14dc590d03726cdaca0bddb9b73fc42219ea46c666f
TearDown-85-XmlMessageTranslatorLite-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessagetranslatorlite/TearDown-85-XmlMessageTranslatorLite-LogicApp.ps1.liquid] -- 86705ef01ed9a6e950919ed6728ef4b7a7c091de6285a7fbef43c28383d518a9
xmlmessagetranslatorlite.logicapp.dev.parameters.json.liquid [./templates/intermediaries/xmlmessagetranslatorlite/xmlmessagetranslatorlite.logicapp.dev.parameters.json.liquid] -- ed2131ccde09ef99debc5e27a786f416a0062575458d2c91fffb0278c48c7eaa
xmlmessagetranslatorlite.logicapp.json [./templates/intermediaries/xmlmessagetranslatorlite/xmlmessagetranslatorlite.logicapp.json] -- 93f7c9db2d9fdaf13709e2b969dfad5c3216453487cec2b9141483ecd0975901
xmlmessagetranslatorlite.logicapp.prod.parameters.json.liquid [./templates/intermediaries/xmlmessagetranslatorlite/xmlmessagetranslatorlite.logicapp.prod.parameters.json.liquid] -- ed2131ccde09ef99debc5e27a786f416a0062575458d2c91fffb0278c48c7eaa
Deploy-85-XmlMessageValidator-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessagevalidator/Deploy-85-XmlMessageValidator-LogicApp.ps1.liquid] -- f2ca2e4911fa303bf33f04c2fb96ff0bc0606bbe420868211d423fb330ff56ae
New-XmlMessageValidator-LogicApp.ps1 [./templates/intermediaries/xmlmessagevalidator/New-XmlMessageValidator-LogicApp.ps1] -- a5d346bea94865ed237ccd48be7613949df74712331181d680b9b0ef2e772c33
Remove-XmlMessageValidator-LogicApp.ps1 [./templates/intermediaries/xmlmessagevalidator/Remove-XmlMessageValidator-LogicApp.ps1] -- 861d51c494317ac4297124dd06bd25bfa9490b1f5244a0c7672857e4917822fc
TearDown-85-XmlMessageValidator-LogicApp.ps1.liquid [./templates/intermediaries/xmlmessagevalidator/TearDown-85-XmlMessageValidator-LogicApp.ps1.liquid] -- 4651e1ed36069181d47c5db887a87236bbbcb8bc1d7ad736eb81b2a492112e5b
xmlmessagevalidator.logicapp.dev.parameters.json.liquid [./templates/intermediaries/xmlmessagevalidator/xmlmessagevalidator.logicapp.dev.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
xmlmessagevalidator.logicapp.json [./templates/intermediaries/xmlmessagevalidator/xmlmessagevalidator.logicapp.json] -- bac5d6e0664ba66e24cf3fdfdba6f841cdee8cce182e0b0f7b41dc996845448b
xmlmessagevalidator.logicapp.prod.parameters.json.liquid [./templates/intermediaries/xmlmessagevalidator/xmlmessagevalidator.logicapp.prod.parameters.json.liquid] -- 95408c6a325af587f58e5392cc4f720439b394edd891fd572ecf1415e90ee348
artifactstore.dev.parameters.json.liquid [./templates/messagebus/artifactstore/artifactstore.dev.parameters.json.liquid] -- 35cd587b0ee9ec18e146d4fa38e7745dc8bb10aab312dd2f9e464bbce0e98213
artifactstore.json.liquid [./templates/messagebus/artifactstore/artifactstore.json.liquid] -- 2e58a183f7466ff107cdfb52afeed70ccb69025e201ce4e2093063b7c9fea132
artifactstore.prod.parameters.json.liquid [./templates/messagebus/artifactstore/artifactstore.prod.parameters.json.liquid] -- 35cd587b0ee9ec18e146d4fa38e7745dc8bb10aab312dd2f9e464bbce0e98213
Deploy-20-ArtifactStore.ps1.liquid [./templates/messagebus/artifactstore/Deploy-20-ArtifactStore.ps1.liquid] -- 0bb19643fd6434d198e8dc10cf933e19564d2df598f86a9281863b91d763c45e
New-ArtifactStore.ps1.liquid [./templates/messagebus/artifactstore/New-ArtifactStore.ps1.liquid] -- 9334c8c0f5b5d4223b79f76b22f027ff493c16a2f9d1e065057ce077448947f0
Remove-ArtifactStore.ps1.liquid [./templates/messagebus/artifactstore/Remove-ArtifactStore.ps1.liquid] -- 1a24f3032b6e5a2b94acfb94afaba823b9532a9c2d3ce999abd9bab80657d182
TearDown-20-ArtifactStore.ps1.liquid [./templates/messagebus/artifactstore/TearDown-20-ArtifactStore.ps1.liquid] -- 89c92a27afbe71c9d7314af6c998939724ec0dbed932dc940b67841b1b57b646
configmanager.apim.dev.parameters.json.liquid [./templates/messagebus/configmanager/configmanager.apim.dev.parameters.json.liquid] -- 077d18eac1b6c430743d04bf4eb810fb49f6fab491a6f32d71d4ae43df07b25b
configmanager.apim.json.liquid [./templates/messagebus/configmanager/configmanager.apim.json.liquid] -- 0201791ac3453d7235c28f6d248dfd38f456cec9b0da57d7fb89aa2d48bc52b0
configmanager.apim.prod.parameters.json.liquid [./templates/messagebus/configmanager/configmanager.apim.prod.parameters.json.liquid] -- 077d18eac1b6c430743d04bf4eb810fb49f6fab491a6f32d71d4ae43df07b25b
Deploy-40-ConfigManager-ApiManagement.ps1.liquid [./templates/messagebus/configmanager/Deploy-40-ConfigManager-ApiManagement.ps1.liquid] -- 898710f334d2f059f375265c79a72bb1040659b9c72dad4f271f3fc28a479a0b
New-ConfigManager-ApiManagement.ps1 [./templates/messagebus/configmanager/New-ConfigManager-ApiManagement.ps1] -- 5a8fc3894ff0de15cedfad494553856674b8437ba7e65f5be4227a91504ae3ad
Remove-ConfigManager-ApiManagement.ps1 [./templates/messagebus/configmanager/Remove-ConfigManager-ApiManagement.ps1] -- a121b5d5e7046fe5e2ea4f5ae8d13496cf9b31908cac60c553da6d9ea8d07c2f
TearDown-40-ConfigManager-ApiManagement.ps1.liquid [./templates/messagebus/configmanager/TearDown-40-ConfigManager-ApiManagement.ps1.liquid] -- 7ed8a2c260cb62b8a729d64e97b7a48f9131ad2d0e190dc276bd104081b83b44
Deploy-10-MessageBusGroup.ps1.liquid [./templates/messagebus/messagebusgroup/Deploy-10-MessageBusGroup.ps1.liquid] -- f4dbb41932d47baff45dcbee6b82c487219f558f093b0f233ac4882466dd9b72
messagebusgroup.dev.parameters.json.liquid [./templates/messagebus/messagebusgroup/messagebusgroup.dev.parameters.json.liquid] -- 6ba6e48a5842d44f7624104ba252434de79d7c9a4e0997d7f7641d6dc65ddc07
messagebusgroup.json.liquid [./templates/messagebus/messagebusgroup/messagebusgroup.json.liquid] -- 1379def2deb0214bac849a52e56c1fc4e3f864c0aa9d1f6f35d88ec33a72d28a
messagebusgroup.prod.parameters.json.liquid [./templates/messagebus/messagebusgroup/messagebusgroup.prod.parameters.json.liquid] -- 6ba6e48a5842d44f7624104ba252434de79d7c9a4e0997d7f7641d6dc65ddc07
New-MessageBusGroup.ps1.liquid [./templates/messagebus/messagebusgroup/New-MessageBusGroup.ps1.liquid] -- d19020a0d994e233d96b6975d566a32324d41030c6ad082925a7439a4535865c
Remove-MessageBusGroup.ps1.liquid [./templates/messagebus/messagebusgroup/Remove-MessageBusGroup.ps1.liquid] -- c718a6d3bb349619b7cc8d7e09ca261d98f7e731e392544d9600cd042f5fcf82
TearDown-10-MessageBusGroup.ps1.liquid [./templates/messagebus/messagebusgroup/TearDown-10-MessageBusGroup.ps1.liquid] -- ad733cb74d0dccb9425e29974a2048e5d95859aa3a81e5d7a03a9ca68e2bed76
Deploy-20-MessageBusOps-AppInsights.ps1.liquid [./templates/messagebus/messagebusops/Deploy-20-MessageBusOps-AppInsights.ps1.liquid] -- 30766fea2892a637018defa3e0ceab786793af75559ac018579f90b37c6f0402
messagebusops.appi.dev.psparameters.json.liquid [./templates/messagebus/messagebusops/messagebusops.appi.dev.psparameters.json.liquid] -- ffe4e0cf73caedcf408c26c66b2f6db65e6471b211252dcd5c66c7407626e01f
messagebusops.appi.prod.psparameters.json.liquid [./templates/messagebus/messagebusops/messagebusops.appi.prod.psparameters.json.liquid] -- ffe4e0cf73caedcf408c26c66b2f6db65e6471b211252dcd5c66c7407626e01f
New-MessageBusOps-AppInsights.ps1.liquid [./templates/messagebus/messagebusops/New-MessageBusOps-AppInsights.ps1.liquid] -- 0842d52c2359c69497325def146f5c1a613cf6e30d08135b760278bb4e9a29fe
Remove-MessageBusOps-AppInsights.ps1.liquid [./templates/messagebus/messagebusops/Remove-MessageBusOps-AppInsights.ps1.liquid] -- 4a341fe7e0ad6a695b0f8e9a3058a22f4c48558366637b17731216be0e822dcb
TearDown-20-MessageBusOps-AppInsights.ps1.liquid [./templates/messagebus/messagebusops/TearDown-20-MessageBusOps-AppInsights.ps1.liquid] -- dd7a0e1fbf575f1fef472292fdaade6c690f61efaaf2180e9016ffc874d11d93
Deploy-20-MessageBusService-StorageAccount.ps1.liquid [./templates/messagebus/messagebusservice/Deploy-20-MessageBusService-StorageAccount.ps1.liquid] -- a9453413cbc7684beb8437e74278772cd1faf196ab032af4f8e81356cbb858a3
Deploy-30-MessageBusService-ApiManagement.ps1.liquid [./templates/messagebus/messagebusservice/Deploy-30-MessageBusService-ApiManagement.ps1.liquid] -- 6821d59107868052eea10f44a2bdeb6ab57ad86e1caacc648046a68493265bab
Deploy-30-MessageBusService-AppService.ps1.liquid [./templates/messagebus/messagebusservice/Deploy-30-MessageBusService-AppService.ps1.liquid] -- 2b623e22dff7adb8819b9beedccebe7bdd52dd9c0d3ef96357a4d14c76937449
Deploy-30-MessageBusService-LogicAppPlan.ps1.liquid [./templates/messagebus/messagebusservice/Deploy-30-MessageBusService-LogicAppPlan.ps1.liquid] -- b3b1041121049708d5a55a62c14920fe16521f06652ce043fccbbfd3eb9b0c91
Deploy-35-MessageBusService-ApiManagement-RoleAssignment.ps1.liquid [./templates/messagebus/messagebusservice/Deploy-35-MessageBusService-ApiManagement-RoleAssignment.ps1.liquid] -- 2ddddbf1005bf987da9561a6ad3368712d8ae501c5006be3389dd394326b0660
Deploy-5-MessageBusService-Role.ps1.liquid [./templates/messagebus/messagebusservice/Deploy-5-MessageBusService-Role.ps1.liquid] -- 392f1255bb11b0eafc11cc1f16ef6236a4c776a50a3f774a6d8ee6094ce8bcd0
messagebusservice.apim.dev.psparameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.apim.dev.psparameters.json.liquid] -- 0091ce19678fa4499d9fa9d3b57c54dab81ddce0485f467feb6dabef1b42bf8a
messagebusservice.apim.prod.psparameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.apim.prod.psparameters.json.liquid] -- 0091ce19678fa4499d9fa9d3b57c54dab81ddce0485f467feb6dabef1b42bf8a
messagebusservice.logicapp.plan.dev.parameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.logicapp.plan.dev.parameters.json.liquid] -- 3f0a7848a255cfe979bc91da33d0d88a6536228ec38941c9e1eb1542e14924c4
messagebusservice.logicapp.plan.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.logicapp.plan.json.liquid] -- 0df36ed8d9f7ee1b52e4b04a32574fcd4fdd19cf6e98b44e163c23796a293073
messagebusservice.logicapp.plan.prod.parameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.logicapp.plan.prod.parameters.json.liquid] -- 3f0a7848a255cfe979bc91da33d0d88a6536228ec38941c9e1eb1542e14924c4
messagebusservice.logicappsrole.json [./templates/messagebus/messagebusservice/messagebusservice.logicappsrole.json] -- 4147460f3b94bd94dde555dd1ad8026f49cf57e28d3c1143a7db88e9afb4a8a7
messagebusservice.plan.dev.parameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.plan.dev.parameters.json.liquid] -- 157013252e1124422e4a82f73b03b44fc7e839a0e707dab6956d7f70fbd58413
messagebusservice.plan.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.plan.json.liquid] -- e3a6e0c0a19f134518e85aaf14200df87af0db8ccac5217a3f81c023add3039b
messagebusservice.plan.prod.parameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.plan.prod.parameters.json.liquid] -- 157013252e1124422e4a82f73b03b44fc7e839a0e707dab6956d7f70fbd58413
messagebusservice.st.dev.psparameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.st.dev.psparameters.json.liquid] -- 0f64edeb8bbc0d3ade84dd7a51424a43e230cf0cf65b2a76af05fbbb66f95f09
messagebusservice.st.prod.psparameters.json.liquid [./templates/messagebus/messagebusservice/messagebusservice.st.prod.psparameters.json.liquid] -- 0f64edeb8bbc0d3ade84dd7a51424a43e230cf0cf65b2a76af05fbbb66f95f09
New-MessageBusService-ApiManagement-RoleAssignment.ps1 [./templates/messagebus/messagebusservice/New-MessageBusService-ApiManagement-RoleAssignment.ps1] -- ef81c4481ef9c5144d2f5c771e6b0d3ed60da37b3c2d4ad7da6192b8a1da282f
New-MessageBusService-ApiManagement.ps1 [./templates/messagebus/messagebusservice/New-MessageBusService-ApiManagement.ps1] -- 650b249d946b251969899745d18e70c5e24bc2f00f0497cbf1885cb3c3ba83f3
New-MessageBusService-AppService.ps1.liquid [./templates/messagebus/messagebusservice/New-MessageBusService-AppService.ps1.liquid] -- e83f48fe815b0cbca67a87a34de0f0737b48bd103e505983a4980d9bcc70b56b
New-MessageBusService-LogicAppPlan.ps1 [./templates/messagebus/messagebusservice/New-MessageBusService-LogicAppPlan.ps1] -- 8a13e64eddddb231c0344b2ab65acfe3277f939fd486f3f4aa26f76c9ab6e796
New-MessageBusService-Role.ps1 [./templates/messagebus/messagebusservice/New-MessageBusService-Role.ps1] -- d0b54a67457f56b00378fb00c5dc324158ee37d35fdb567fdece22ceeda7e07e
New-MessageBusService-StorageAccount.ps1.liquid [./templates/messagebus/messagebusservice/New-MessageBusService-StorageAccount.ps1.liquid] -- 6527b7af11efc4712fa6ed2d30ea69bf6fb72c62d0f7ff1ba3638c6f10bdaddf
Remove-MessageBusService-ApiManagement-RoleAssignment.ps1 [./templates/messagebus/messagebusservice/Remove-MessageBusService-ApiManagement-RoleAssignment.ps1] -- 7f0d49e8f3b37647be7561e799bb414435c58e1ee1572e1610984676374128ab
Remove-MessageBusService-ApiManagement.ps1 [./templates/messagebus/messagebusservice/Remove-MessageBusService-ApiManagement.ps1] -- b720c6d2f8c674831cf3770a8c0ff2199e6e5f275d4f4c24178b7461eb1cb499
Remove-MessageBusService-AppService.ps1.liquid [./templates/messagebus/messagebusservice/Remove-MessageBusService-AppService.ps1.liquid] -- d417b486ab4f7c33a909ce10171d2e163feb100ca5138bce246da54808e36336
Remove-MessageBusService-LogicAppPlan.ps1 [./templates/messagebus/messagebusservice/Remove-MessageBusService-LogicAppPlan.ps1] -- e7523c9f697a36ed51ee981b21a13ede96e5ca430686477d16f04a2fa71b4a4b
Remove-MessageBusService-Role.ps1 [./templates/messagebus/messagebusservice/Remove-MessageBusService-Role.ps1] -- 5a73ab6c8b993b9dca00049660f4998977ed536c36651b620d3ac5535001c457
Remove-MessageBusService-StorageAccount.ps1.liquid [./templates/messagebus/messagebusservice/Remove-MessageBusService-StorageAccount.ps1.liquid] -- fafef5bd4ef77f71da1157213fcb22d563c8060080b8ab83e5dbc1f2ab3e0e05
TearDown-20-MessageBusService-StorageAccount.ps1.liquid [./templates/messagebus/messagebusservice/TearDown-20-MessageBusService-StorageAccount.ps1.liquid] -- 824a027d8e9944539bdc470821a8e88b9531764ed0218efef646e44d1bd5e762
TearDown-30-MessageBusService-ApiManagement.ps1.liquid [./templates/messagebus/messagebusservice/TearDown-30-MessageBusService-ApiManagement.ps1.liquid] -- 45e93de9779d30e01e65e6082d68081c6181d1683d6273dd4187da0fb7f59be9
TearDown-30-MessageBusService-AppService.ps1.liquid [./templates/messagebus/messagebusservice/TearDown-30-MessageBusService-AppService.ps1.liquid] -- 5dd383abd7ee4d1b0a5e7db220f54c7031ab6521461831f6640b8daaf6b669ac
TearDown-30-MessageBusService-LogicAppPlan.ps1.liquid [./templates/messagebus/messagebusservice/TearDown-30-MessageBusService-LogicAppPlan.ps1.liquid] -- 752b45929ba042b7cf80833111567050f9eab31b89f7f3b839586ebfe4026490
TearDown-35-MessageBusService-ApiManagement-RoleAssignment.ps1.liquid [./templates/messagebus/messagebusservice/TearDown-35-MessageBusService-ApiManagement-RoleAssignment.ps1.liquid] -- ce6e674cfa99bf8b777fd86b7c0a6c4dfb108bcda8c2ae47fa25b4f68ba38bdd
TearDown-5-MessageBusService-Role.ps1.liquid [./templates/messagebus/messagebusservice/TearDown-5-MessageBusService-Role.ps1.liquid] -- e8be369d83fd16615e8c19a1bec89ca2715cb0e061b4d70278f24b98c24b3d02
Deploy-50-MessagingManager-Function.ps1.liquid [./templates/messagebus/messagingmanager/Deploy-50-MessagingManager-Function.ps1.liquid] -- 2bbdc496b90438093ca0283853134c9feecfc70155dc2460741bdd7ac895a884
Deploy-60-MessagingManager-ApiManagement.ps1.liquid [./templates/messagebus/messagingmanager/Deploy-60-MessagingManager-ApiManagement.ps1.liquid] -- ea0d32caf8a4e829b07d8c692bdcdc3ef2faaf81c19fab16c652a80080cb4bf3
messagingmanager.apim.dev.parameters.json.liquid [./templates/messagebus/messagingmanager/messagingmanager.apim.dev.parameters.json.liquid] -- 44e4516e34d474a6e5f79d935a870a833a64dcae038532d9ca90f9b0558b32f4
messagingmanager.apim.json [./templates/messagebus/messagingmanager/messagingmanager.apim.json] -- 7c225eeab251b4f4301456ec62581e46f73a8920327e93413e0da69a2bb8b73b
messagingmanager.apim.prod.parameters.json.liquid [./templates/messagebus/messagingmanager/messagingmanager.apim.prod.parameters.json.liquid] -- 44e4516e34d474a6e5f79d935a870a833a64dcae038532d9ca90f9b0558b32f4
messagingmanager.func.dev.parameters.json.liquid [./templates/messagebus/messagingmanager/messagingmanager.func.dev.parameters.json.liquid] -- 6e9ac995a315bb020bcb8f706d349c1c0b7588b8270468a5fa050816b336580f
messagingmanager.func.json [./templates/messagebus/messagingmanager/messagingmanager.func.json] -- 364bde499571dc5aefba1e002cfa594acd6abaf630c4734261e9993f463d51e2
messagingmanager.func.prod.parameters.json.liquid [./templates/messagebus/messagingmanager/messagingmanager.func.prod.parameters.json.liquid] -- 6e9ac995a315bb020bcb8f706d349c1c0b7588b8270468a5fa050816b336580f
Microsoft.AzureIntegrationMigration.FunctionApp.MessagingManager.zip [./templates/messagebus/messagingmanager/Microsoft.AzureIntegrationMigration.FunctionApp.MessagingManager.zip] -- fc8bda413a17b98f4e25f82e2602fc0a96eb7246142590bf8bba406d72563024
New-MessagingManager-ApiManagement.ps1 [./templates/messagebus/messagingmanager/New-MessagingManager-ApiManagement.ps1] -- ff9eba06127882165afdfe3316cbee37f5c0de418f61d8c1ce862bb8490600f9
New-MessagingManager-Function.ps1 [./templates/messagebus/messagingmanager/New-MessagingManager-Function.ps1] -- 7b81048c123d7e3af78462f9549928658d554afbcdaa9f4ca34238abdc612e4e
Remove-MessagingManager-ApiManagement.ps1 [./templates/messagebus/messagingmanager/Remove-MessagingManager-ApiManagement.ps1] -- f7c8ab9c53f9df4f643b1a317e6af245b63fc3eeff6256812110280b2381b35b
Remove-MessagingManager-Function.ps1 [./templates/messagebus/messagingmanager/Remove-MessagingManager-Function.ps1] -- b3dc1a264749b0fd40db8a896f7e48c854906db3b43600afc88e7827600ee7f6
TearDown-50-MessagingManager-Function.ps1.liquid [./templates/messagebus/messagingmanager/TearDown-50-MessagingManager-Function.ps1.liquid] -- ee6021f7aedf82f7051964ccf0e87e8a1f39524837ce80129d7dabae84652cc7
TearDown-60-MessagingManager-ApiManagement.ps1.liquid [./templates/messagebus/messagingmanager/TearDown-60-MessagingManager-ApiManagement.ps1.liquid] -- 3ed543e55327b6884202c2434a96dcca870527fea57770583b26216d1527fccc
Deploy-50-RoutingManager-Function.ps1.liquid [./templates/messagebus/routingmanager/Deploy-50-RoutingManager-Function.ps1.liquid] -- a1e155f6ce28d8d27e3cf2ec6efdb8c5a28a5a3804d05083b744d29daa34ce9f
Deploy-60-RoutingManager-ApiManagement.ps1.liquid [./templates/messagebus/routingmanager/Deploy-60-RoutingManager-ApiManagement.ps1.liquid] -- e24f429ba11fd0e057d7bfaff53092590cb33a74c8d0cca8ca5f032227e83bfa
Microsoft.AzureIntegrationMigration.FunctionApp.RoutingManager.zip [./templates/messagebus/routingmanager/Microsoft.AzureIntegrationMigration.FunctionApp.RoutingManager.zip] -- d362d54dcfddf5f94494bf01293dc008e5ea61071a4231abd30b7f5ad072b73e
New-RoutingManager-ApiManagement.ps1 [./templates/messagebus/routingmanager/New-RoutingManager-ApiManagement.ps1] -- 3c5411e30c835e7449cff123529c330fe7b43dc17ea2c64dde1afdef64940fb8
New-RoutingManager-Function.ps1 [./templates/messagebus/routingmanager/New-RoutingManager-Function.ps1] -- ee5e823d3829ad1ad7aa82ef52518f3340a51be1c05ac4f81452c4ae7ee0d059
Remove-RoutingManager-ApiManagement.ps1 [./templates/messagebus/routingmanager/Remove-RoutingManager-ApiManagement.ps1] -- 1151fac496efcd772ae1f0fcd04ded2884bd3d753312bc028b118cc1987f55aa
Remove-RoutingManager-Function.ps1 [./templates/messagebus/routingmanager/Remove-RoutingManager-Function.ps1] -- f9e68c425eebc93fd0b83a171f3c507ebe56fd890abbd0ab369ba6811e205d29
routingmanager.apim.dev.parameters.json.liquid [./templates/messagebus/routingmanager/routingmanager.apim.dev.parameters.json.liquid] -- 1c26280f082575a8697e27172b1a9547a5727316af85d32780c01822bd0666c0
routingmanager.apim.json.liquid [./templates/messagebus/routingmanager/routingmanager.apim.json.liquid] -- 750fee290b589ebb3ca4554298d4e2e269a7b1b99dd645fb1c91348dd3c34dc3
routingmanager.apim.prod.parameters.json.liquid [./templates/messagebus/routingmanager/routingmanager.apim.prod.parameters.json.liquid] -- 1c26280f082575a8697e27172b1a9547a5727316af85d32780c01822bd0666c0
routingmanager.func.dev.parameters.json.liquid [./templates/messagebus/routingmanager/routingmanager.func.dev.parameters.json.liquid] -- 5319131796fea7859e86d5e39b1af2d7cf426b3ece5117a2d0a478de0337c7e7
routingmanager.func.json [./templates/messagebus/routingmanager/routingmanager.func.json] -- 9ed7c38658e830707c559d8c1368f5038c7387eb070a903286f728e39db068c6
routingmanager.func.prod.parameters.json.liquid [./templates/messagebus/routingmanager/routingmanager.func.prod.parameters.json.liquid] -- 5319131796fea7859e86d5e39b1af2d7cf426b3ece5117a2d0a478de0337c7e7
TearDown-50-RoutingManager-Function.ps1.liquid [./templates/messagebus/routingmanager/TearDown-50-RoutingManager-Function.ps1.liquid] -- 2169ca4d1d5828eb48b6faed62933905d889dc25e9572b26d601e945589b2b89
TearDown-60-RoutingManager-ApiManagement.ps1.liquid [./templates/messagebus/routingmanager/TearDown-60-RoutingManager-ApiManagement.ps1.liquid] -- fe94cdeb4aa9866fb2d3130fa66c3665892257736d89879e3a740d86ec80ccdd
Deploy-15-RoutingStore-KeyVault.ps1.liquid [./templates/messagebus/routingstore/Deploy-15-RoutingStore-KeyVault.ps1.liquid] -- e31ba286a638a322404eda8269bb04a71d84ac20e3118d03539b004dff7fb2f7
Deploy-20-RoutingStore-AppConfig.ps1.liquid [./templates/messagebus/routingstore/Deploy-20-RoutingStore-AppConfig.ps1.liquid] -- d49d9219459e9ba2492e8156876027ca9fb929d4423d8f4ed30d70873e5acb2f
Deploy-40-RoutingStore-ApiManagement.ps1.liquid [./templates/messagebus/routingstore/Deploy-40-RoutingStore-ApiManagement.ps1.liquid] -- 7dcb485fc9d08b53832e54ac6db04eb1b15cb40c1a767fefa46887224446e58a
New-RoutingStore-ApiManagement.ps1 [./templates/messagebus/routingstore/New-RoutingStore-ApiManagement.ps1] -- 744577a102212338b9a6bc44932dbc56442795ae7cabf70699ab180d36338e71
New-RoutingStore-AppConfig.ps1 [./templates/messagebus/routingstore/New-RoutingStore-AppConfig.ps1] -- be8766b7893990e04b662d99a1fe5860875cd80b2df7bd152bdff60df1e71f39
New-RoutingStore-KeyVault.ps1 [./templates/messagebus/routingstore/New-RoutingStore-KeyVault.ps1] -- 21919ed410d9210d80c9f51a248c2feb6337ee8ba4def47c6b23a738992a531c
Remove-RoutingStore-ApiManagement.ps1 [./templates/messagebus/routingstore/Remove-RoutingStore-ApiManagement.ps1] -- 1e7bc7a2db8b45663aa5c3d9576dbd8910d2feb909d7c5b8f897e1e48773067b
Remove-RoutingStore-AppConfig.ps1 [./templates/messagebus/routingstore/Remove-RoutingStore-AppConfig.ps1] -- 6a6305831bd944acbfa4186ede8787fb831a6461493468d76291d0fff339cf5c
Remove-RoutingStore-KeyVault.ps1 [./templates/messagebus/routingstore/Remove-RoutingStore-KeyVault.ps1] -- 1e502b716e519ae4444d30aaf7ea51591e320dab05ef8e611969b72aed26aece
routingstore.apim.dev.parameters.json.liquid [./templates/messagebus/routingstore/routingstore.apim.dev.parameters.json.liquid] -- 55cfded99de69cbe8ce698ccbef4d8e2d5e882ec1130cc14e7c648821b4e66a7
routingstore.apim.json.liquid [./templates/messagebus/routingstore/routingstore.apim.json.liquid] -- b4b6a8a0c33e1383fc15c104fea595801c67bd37950fc069cd8cb8b95049f654
routingstore.apim.prod.parameters.json.liquid [./templates/messagebus/routingstore/routingstore.apim.prod.parameters.json.liquid] -- 55cfded99de69cbe8ce698ccbef4d8e2d5e882ec1130cc14e7c648821b4e66a7
routingstore.appcfg.dev.parameters.json.liquid [./templates/messagebus/routingstore/routingstore.appcfg.dev.parameters.json.liquid] -- c8a04f75e54a5e7a3ba266aa4bfda708c15b701fa244bb89e1a1786ea3b239ea
routingstore.appcfg.json [./templates/messagebus/routingstore/routingstore.appcfg.json] -- 82190287a265a6caa8df629389fa5e747d5bdc966732fce284d37839db73ae47
routingstore.appcfg.prod.parameters.json.liquid [./templates/messagebus/routingstore/routingstore.appcfg.prod.parameters.json.liquid] -- c8971d22a3d7afc05fae0d8772cf36f1dcc23b4480c44396bb7b60a6b77905cd
routingstore.kv.dev.psparameters.json.liquid [./templates/messagebus/routingstore/routingstore.kv.dev.psparameters.json.liquid] -- 803401d34c1025de7702bcca794517b2f3194308c2b0ec5fbe833b2679c18b83
routingstore.kv.prod.psparameters.json.liquid [./templates/messagebus/routingstore/routingstore.kv.prod.psparameters.json.liquid] -- 803401d34c1025de7702bcca794517b2f3194308c2b0ec5fbe833b2679c18b83
TearDown-15-RoutingStore-KeyVault.ps1.liquid [./templates/messagebus/routingstore/TearDown-15-RoutingStore-KeyVault.ps1.liquid] -- d0fb6c64934a2e91a64f5c5876f6906c0b0ea0f09d7596d1ea21e2bf55a90330
TearDown-20-RoutingStore-AppConfig.ps1.liquid [./templates/messagebus/routingstore/TearDown-20-RoutingStore-AppConfig.ps1.liquid] -- 2238d909356f619ac8ca300f302bef9d46bb6648468ae5ba008475f7f619efd6
TearDown-40-RoutingStore-ApiManagement.ps1.liquid [./templates/messagebus/routingstore/TearDown-40-RoutingStore-ApiManagement.ps1.liquid] -- 6b494aa8e45ce2ce35808b926129700fdb3b6fd7415a07bdc65f51034e2ded59
Deploy-80-MessageBusEventGrid-ApiConnection.ps1.liquid [./templates/messagebus/standard/Deploy-80-MessageBusEventGrid-ApiConnection.ps1.liquid] -- f87c73ecf2c78991298888d9999a0ba48fec1596c2fda377626b5ab6ef3d86cf
Deploy-90-MessageBus-LogicApp.ps1.liquid [./templates/messagebus/standard/Deploy-90-MessageBus-LogicApp.ps1.liquid] -- 5687624b6a821385c9b3d2fcd3c29bc28aa252d48dbee8a33e9e24c06da919a3
Deploy-95-AppConfigStore-RoleAssignment.ps1.liquid [./templates/messagebus/standard/Deploy-95-AppConfigStore-RoleAssignment.ps1.liquid] -- 1effd624e9327e3227c4a2f4e0ec35d875d05c3ca5fb4f832fbb44d26d6295c4
Deploy-95-MessageBusEventGrid-ApiConnPolicy.ps1.liquid [./templates/messagebus/standard/Deploy-95-MessageBusEventGrid-ApiConnPolicy.ps1.liquid] -- 0064caf6633f929e8425d1efc01cbe7d1c36020f8dd81e2fd8ee91aefa57ae20
messagebus.logic.dev.parameters.json.liquid [./templates/messagebus/standard/messagebus.logic.dev.parameters.json.liquid] -- 5800cb8007b98f3907ca92d6d8b4693749e37a2a4f18a8c2458b682936c72f7e
messagebus.logic.json [./templates/messagebus/standard/messagebus.logic.json] -- fbc269c01c0fdb4dca6da4498c5801d12bfb55987906d29c5935da41e6920e13
messagebus.logic.prod.parameters.json.liquid [./templates/messagebus/standard/messagebus.logic.prod.parameters.json.liquid] -- 5800cb8007b98f3907ca92d6d8b4693749e37a2a4f18a8c2458b682936c72f7e
.funcignore [./templates/messagebus/standard/messagebus.logic.workflows/.funcignore] -- 96393bc26432421a0722a6d9f611083740cdbdce59205eb5de412df91669c8af
extensions.json [./templates/messagebus/standard/messagebus.logic.workflows/.vscode/extensions.json] -- dc808d40149bd12a4566c98e2e4cdd5f56c9ac11021805667b2749021b98f2a9
launch.json [./templates/messagebus/standard/messagebus.logic.workflows/.vscode/launch.json] -- de0269109118db95ac611b185f80bd5a78341a711e84a6a0bfede358e95ffe5a
settings.json [./templates/messagebus/standard/messagebus.logic.workflows/.vscode/settings.json] -- 3b5b7abc9971860ba37a6a8b1186a645ad1acdc0f7d995860a52fbbba76067a8
tasks.json [./templates/messagebus/standard/messagebus.logic.workflows/.vscode/tasks.json] -- dfcc0600c8cb6847bc2827b0ca59f869fe1ed0e05418f766595d5f949ed674dc
workflow.json [./templates/messagebus/standard/messagebus.logic.workflows/configcacheupdater/workflow.json] -- 5744160636888cc6a6c2251c470e3e828d9f4510b6497335582f4f0bf7d7c65e
connections.json [./templates/messagebus/standard/messagebus.logic.workflows/connections.json] -- 5faf1594594124e7fd024f85e7530727e0d7cec076ba85d11928bc2213ed0d53
host.json [./templates/messagebus/standard/messagebus.logic.workflows/host.json] -- 4c01b0f013d3e14d11c063affc7ddfa03ab59ef1557299e4d9594efee5487767
local.settings.json [./templates/messagebus/standard/messagebus.logic.workflows/local.settings.json] -- 71e2302df3ab6198624b4cff30672316162ea8735668b666b4ecdf38597ec61b
parameters.json [./templates/messagebus/standard/messagebus.logic.workflows/parameters.json] -- 9d47f258fb46e01f249d157578cf17ccb69bc29713ce69c031e46e8cb87ae163
parameters.local.json [./templates/messagebus/standard/messagebus.logic.workflows/parameters.local.json] -- 2ebb0abdd33469e949f18390c0eed0c6fa7d4fa916fd162e7484a55432a73329
host.json [./templates/messagebus/standard/messagebus.logic.workflows/workflow-designtime/host.json] -- bb8f058a2c5ce1ceefd5ed557ec0de961cfb2089a706bfc8f1904ced9a91a754
local.settings.json [./templates/messagebus/standard/messagebus.logic.workflows/workflow-designtime/local.settings.json] -- 24e0bdd57da3e30c789358ca8001020601accb31ec38b38abe88e261ed09cab7
messagebuseventgrid.apicaccesspolicy.dev.parameters.json.liquid [./templates/messagebus/standard/messagebuseventgrid.apicaccesspolicy.dev.parameters.json.liquid] -- f62ccfae0367f44199b5b50b07cce85b836076a21dff0b30ebcebe5632d281d1
messagebuseventgrid.apicaccesspolicy.json [./templates/messagebus/standard/messagebuseventgrid.apicaccesspolicy.json] -- 144a8eb06cc03220273a51924f1ca1a450aa2e77fef1168916cc67b878db7945
messagebuseventgrid.apicaccesspolicy.prod.parameters.json.liquid [./templates/messagebus/standard/messagebuseventgrid.apicaccesspolicy.prod.parameters.json.liquid] -- f62ccfae0367f44199b5b50b07cce85b836076a21dff0b30ebcebe5632d281d1
messagebuseventgrid.apiconnection.dev.parameters.json.liquid [./templates/messagebus/standard/messagebuseventgrid.apiconnection.dev.parameters.json.liquid] -- 6b6e8ac85940f48ea6c341878a06b6a241ad99205f2d99d417895af9a7fc9b07
messagebuseventgrid.apiconnection.json [./templates/messagebus/standard/messagebuseventgrid.apiconnection.json] -- 397265e8bf665a08caf507d4c86137ef72362c24b820ff5c54df1ea0289ff71d
messagebuseventgrid.apiconnection.prod.parameters.json.liquid [./templates/messagebus/standard/messagebuseventgrid.apiconnection.prod.parameters.json.liquid] -- 6b6e8ac85940f48ea6c341878a06b6a241ad99205f2d99d417895af9a7fc9b07
New-AppConfigStore-RoleAssignment.ps1 [./templates/messagebus/standard/New-AppConfigStore-RoleAssignment.ps1] -- d782ab3f5f97800903cec562b1f7577c297fe108d0ce989e708a8d98bdb4ce1a
New-MessageBus-LogicApp.ps1 [./templates/messagebus/standard/New-MessageBus-LogicApp.ps1] -- 1820732f893a9578323995ec65608b0adc8e1fc8dea4c12201096267e21856e6
New-MessageBusEventGrid-ApiConnection.ps1 [./templates/messagebus/standard/New-MessageBusEventGrid-ApiConnection.ps1] -- e56866baee4945b0432e8a78a24f1d7f53baba6d9caa9ff536d6144d758dd902
New-MessageBusEventGrid-ApiConnPolicy.ps1 [./templates/messagebus/standard/New-MessageBusEventGrid-ApiConnPolicy.ps1] -- 4776835b5393b22b09d40e5b238a99edcd3ca0fda8c530cc757078659c629056
Remove-AppConfigStore-RoleAssignment.ps1 [./templates/messagebus/standard/Remove-AppConfigStore-RoleAssignment.ps1] -- 1c3d7b31609c04a0a7f7dbd7d298c0a818e5fc6faf647662809f770e87738927
Remove-MessageBus-LogicApp.ps1 [./templates/messagebus/standard/Remove-MessageBus-LogicApp.ps1] -- a0da2cebcdc5ad78ed28df18754c4852126d502b298ea63fb122a883fe002261
Remove-MessageBusEventGrid-ApiConnection.ps1 [./templates/messagebus/standard/Remove-MessageBusEventGrid-ApiConnection.ps1] -- 120ccb956fb98f774dd84593120c4a1245ff7765944d8724f6c1ff51cc0cdbc4
TearDown-80-MessageBusEventGrid-ApiConnection.ps1.liquid [./templates/messagebus/standard/TearDown-80-MessageBusEventGrid-ApiConnection.ps1.liquid] -- 3697338e517c1ea117a3060d35d4254575fc8bdb2ee8a796ef599793bf8a6229
TearDown-90-MessageBus-LogicApp.ps1.liquid [./templates/messagebus/standard/TearDown-90-MessageBus-LogicApp.ps1.liquid] -- 433e2480dbdf720e11ac32093d05b1d6005a894e7ba8cefc84dfcbcd686412f5
TearDown-95-AppConfigStore-RoleAssignment.ps1.liquid [./templates/messagebus/standard/TearDown-95-AppConfigStore-RoleAssignment.ps1.liquid] -- df8b12a231fe2b0cc2f015abf0f5d9838d3602840372cc86157a5f66e32d6f58
configcacheupdater.logicapp.dev.parameters.json.liquid [./templates/messagebus/workflows/configcacheupdater/configcacheupdater.logicapp.dev.parameters.json.liquid] -- 6929d360ffde2705a644fdda0eeb78b9446639d3bd6121526497a6609e53f75e
configcacheupdater.logicapp.json [./templates/messagebus/workflows/configcacheupdater/configcacheupdater.logicapp.json] -- 25837936a2b81cffaa0621aa69447e4a346d0b0a1f8c4365bf8b1625ca696aef
configcacheupdater.logicapp.prod.parameters.json.liquid [./templates/messagebus/workflows/configcacheupdater/configcacheupdater.logicapp.prod.parameters.json.liquid] -- 6929d360ffde2705a644fdda0eeb78b9446639d3bd6121526497a6609e53f75e
Deploy-100-AppConfigStore-RoleAssignment.ps1.liquid [./templates/messagebus/workflows/configcacheupdater/Deploy-100-AppConfigStore-RoleAssignment.ps1.liquid] -- 276ccef41cce3149e5c2f773b5552eb2cfb658b130cc588ddd571ec221a7df97
Deploy-110-ConfigCacheUpdater-LogicApp-Enabled.ps1.liquid [./templates/messagebus/workflows/configcacheupdater/Deploy-110-ConfigCacheUpdater-LogicApp-Enabled.ps1.liquid] -- 589337b6c3d2eb8c5f24492a5dfcaf92684fb259afe439809853dbb221403aea
Deploy-80-EventGridSubscribe-ApiConnection.ps1.liquid [./templates/messagebus/workflows/configcacheupdater/Deploy-80-EventGridSubscribe-ApiConnection.ps1.liquid] -- d07daf10a3b686f22e0296bd6f0543fcfba646577c0db58e526b48658ce0a191
Deploy-90-ConfigCacheUpdater-LogicApp-Disabled.ps1.liquid [./templates/messagebus/workflows/configcacheupdater/Deploy-90-ConfigCacheUpdater-LogicApp-Disabled.ps1.liquid] -- 53ae843376fdf54fbbca5b812b88866fcf73ae2f9181b6dedb331a101f3af75b
eventgridsubscribe.apiconnection.dev.parameters.json.liquid [./templates/messagebus/workflows/configcacheupdater/eventgridsubscribe.apiconnection.dev.parameters.json.liquid] -- 6b6e8ac85940f48ea6c341878a06b6a241ad99205f2d99d417895af9a7fc9b07
eventgridsubscribe.apiconnection.json [./templates/messagebus/workflows/configcacheupdater/eventgridsubscribe.apiconnection.json] -- 007828d320852b198bc42fda6c862992236c126dd39aeb56514fa39120c07cb1
eventgridsubscribe.apiconnection.prod.parameters.json.liquid [./templates/messagebus/workflows/configcacheupdater/eventgridsubscribe.apiconnection.prod.parameters.json.liquid] -- 6b6e8ac85940f48ea6c341878a06b6a241ad99205f2d99d417895af9a7fc9b07
New-AppConfigStore-RoleAssignment.ps1 [./templates/messagebus/workflows/configcacheupdater/New-AppConfigStore-RoleAssignment.ps1] -- d782ab3f5f97800903cec562b1f7577c297fe108d0ce989e708a8d98bdb4ce1a
New-ConfigCacheUpdater-LogicApp.ps1 [./templates/messagebus/workflows/configcacheupdater/New-ConfigCacheUpdater-LogicApp.ps1] -- fca231cb22f9523d180ae2eb740c19eb762eb3e3a272cd66b6a1e2918522f337
New-EventGridSubscribe-ApiConnection.ps1 [./templates/messagebus/workflows/configcacheupdater/New-EventGridSubscribe-ApiConnection.ps1] -- d4b7b80b805c707984bb0c588c353e0e4795e54b75bd799f30fe8208aef4531b
Remove-AppConfigStore-RoleAssignment.ps1 [./templates/messagebus/workflows/configcacheupdater/Remove-AppConfigStore-RoleAssignment.ps1] -- 1c3d7b31609c04a0a7f7dbd7d298c0a818e5fc6faf647662809f770e87738927
Remove-ConfigCacheUpdater-LogicApp.ps1 [./templates/messagebus/workflows/configcacheupdater/Remove-ConfigCacheUpdater-LogicApp.ps1] -- 373a9668356cec5cf3c1c3aa7e53abede8bee09279d4fb4b7f8db40d4485a666
Remove-EventGridSubscribe-ApiConnection.ps1 [./templates/messagebus/workflows/configcacheupdater/Remove-EventGridSubscribe-ApiConnection.ps1] -- 07597a023687d6a1e8e8dbc34883454badbb417ec781997db9e3f4fec183605a
TearDown-100-AppConfigStore-RoleAssignment.ps1.liquid [./templates/messagebus/workflows/configcacheupdater/TearDown-100-AppConfigStore-RoleAssignment.ps1.liquid] -- b6a7809a4b6940bd5c7d7a5ad1469d1d1169ca62346731e9d7de6af90f8bdce8
TearDown-80-EventGridSubscribe-ApiConnection.ps1.liquid [./templates/messagebus/workflows/configcacheupdater/TearDown-80-EventGridSubscribe-ApiConnection.ps1.liquid] -- 95ac3eb3921bd6b42faf6d56bc0a18cd04668453089f77528bf4387bc04e0831
TearDown-90-ConfigCacheUpdater-LogicApp.ps1.liquid [./templates/messagebus/workflows/configcacheupdater/TearDown-90-ConfigCacheUpdater-LogicApp.ps1.liquid] -- 775770dfeb47754b0f109bea428a653d7924cadb8e326e3e8b74496246a2b7cd
Deploy-80-RoutingSlipRouter-LogicApp.ps1.liquid [./templates/messagebus/workflows/routingsliprouter/Deploy-80-RoutingSlipRouter-LogicApp.ps1.liquid] -- 20193da7dc841a50ae298d1f6a87bfde85ea1ec481f12167835f786c914aad58
New-RoutingSlipRouter-LogicApp.ps1 [./templates/messagebus/workflows/routingsliprouter/New-RoutingSlipRouter-LogicApp.ps1] -- 0c382d01ebd96b92014b6b6f8a15e2883a66fc59cb68ee3c330a3015b5f2f075
Remove-RoutingSlipRouter-LogicApp.ps1 [./templates/messagebus/workflows/routingsliprouter/Remove-RoutingSlipRouter-LogicApp.ps1] -- 0d721563965144081ac803a907f2ede01aea802dd3e443abd4153d8b2504bc27
routingsliprouter.logicapp.dev.parameters.json.liquid [./templates/messagebus/workflows/routingsliprouter/routingsliprouter.logicapp.dev.parameters.json.liquid] -- a751838194f326a34f797ce4aab3876629d1e0c1fb71344826881242a9f1839e
routingsliprouter.logicapp.json [./templates/messagebus/workflows/routingsliprouter/routingsliprouter.logicapp.json] -- 8c27dd625c138b2989090d58fa709dfda2ab265d6e8ad876bba6be17f092ad6e
routingsliprouter.logicapp.prod.parameters.json.liquid [./templates/messagebus/workflows/routingsliprouter/routingsliprouter.logicapp.prod.parameters.json.liquid] -- a751838194f326a34f797ce4aab3876629d1e0c1fb71344826881242a9f1839e
TearDown-80-RoutingSlipRouter-LogicApp.ps1.liquid [./templates/messagebus/workflows/routingsliprouter/TearDown-80-RoutingSlipRouter-LogicApp.ps1.liquid] -- 995d44b3f2f95e144c917646d05415ecefcaa897b3e1536df67878bfca689444
Deploy-100-Schema.ps1.liquid [./templates/messages/schemas/Deploy-100-Schema.ps1.liquid] -- 13b7de4b359e0867fc968fe59fcd01612205b9b46c0c4e91431dc83a855ff33d
New-Schema.ps1.liquid [./templates/messages/schemas/New-Schema.ps1.liquid] -- 36071f1009e271ab43d00ab94ee71ce575a3a45b064cab5c3a311f2a23298e5b
Remove-Schema.ps1.liquid [./templates/messages/schemas/Remove-Schema.ps1.liquid] -- 9d4634bd51b3c7e86ae8b081088ad7e8faf5c11ea4ac212bc63c3c88596e5210
requestbody.dev.json.liquid [./templates/messages/schemas/requestbody.dev.json.liquid] -- 2f0994f50441847af70aa8013317a54acb8b3dce37c577878e276415433fd7a6
requestbody.prod.json.liquid [./templates/messages/schemas/requestbody.prod.json.liquid] -- 2f0994f50441847af70aa8013317a54acb8b3dce37c577878e276415433fd7a6
TearDown-100-Schema.ps1.liquid [./templates/messages/schemas/TearDown-100-Schema.ps1.liquid] -- e33845f89c51e10e474adea67bf9a7883b9276c0222f56b2e912bc09b226cd6d
Deploy-120-Map.ps1.liquid [./templates/messages/transforms/Deploy-120-Map.ps1.liquid] -- 5187b9bcfd85f59ab8d93b04e9428eea2fa36608f5cb03947b6063f04ca8b3fa
New-Map.ps1.liquid [./templates/messages/transforms/New-Map.ps1.liquid] -- 9e3df239e6f2a4fcf7a97f62064842dcbac79931b997f9582ba0cb456c418f80
Remove-Map.ps1.liquid [./templates/messages/transforms/Remove-Map.ps1.liquid] -- 92c1768e28c516b5fdb8842a995a6b6e0f7fe96e31b70238a94ba583f22c32d0
requestbody.dev.json.liquid [./templates/messages/transforms/requestbody.dev.json.liquid] -- fc5a81426ab0ad0be1eb1e1cac1afb2015989516a8837b47c02e252cfd3c38a0
requestbody.prod.json.liquid [./templates/messages/transforms/requestbody.prod.json.liquid] -- fc5a81426ab0ad0be1eb1e1cac1afb2015989516a8837b47c02e252cfd3c38a0
TearDown-120-Map.ps1.liquid [./templates/messages/transforms/TearDown-120-Map.ps1.liquid] -- 7c817667c244d7de3b3c2af4ec067d672eb03a0de94b08e6c6a9ef5096fc7088

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Add to Builder Version Downloads Last Updated Status
BizTalk Migrator Dependency - Azure Templates 0.5.1-beta-2020102943006 247 Thursday, October 29, 2020 Exempted
BizTalk Migrator Dependency - Azure Templates 0.5.1-beta-2020102860442 99 Wednesday, October 28, 2020 Exempted
BizTalk to Azure Integration Services Migration - Azure templates 0.5.1-beta-2020102776889 57 Tuesday, October 27, 2020 Exempted
BizTalk to Azure Integration Services Migration - Azure templates 0.5.1-beta-2020102752953 66 Tuesday, October 27, 2020 Exempted
BizTalk to Azure Integration Services Migration - Azure templates 0.5.0-beta-2020102741772 73 Tuesday, October 27, 2020 Exempted
BizTalk to Azure Integration Services Migration - Azure templates 0.5.0-beta-2020102659679 69 Monday, October 26, 2020 Exempted
BizTalk to Azure Integration Services Migration - Azure templates 0.5.0-beta-2020102624119 79 Monday, October 26, 2020 Exempted

This package has no dependencies.

Discussion for the BizTalk Migrator Dependency - Azure Templates Package

Ground Rules:

  • This discussion is only about BizTalk Migrator Dependency - Azure Templates and the BizTalk Migrator Dependency - Azure Templates package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or BizTalk Migrator Dependency - Azure Templates, or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus