Downloads:
1,383
Downloads of v 0.5.0-beta-2020102741772:
73
Last Update:
27 Oct 2020
Package Maintainer(s):
Software Author(s):
- Microsoft
Tags:
biztalkmigrator-azure biztalk azure ais cli- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
BizTalk to Azure Integration Services Migration - Azure templates
This is a prerelease version of BizTalk to Azure Integration Services Migration - Azure templates.
- 1
- 2
- 3
0.5.0-beta-2020102741772 | Updated: 27 Oct 2020
- Software Specific:
- Software Site
- Software License
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
1,383
Downloads of v 0.5.0-beta-2020102741772:
73
Maintainer(s):
Software Author(s):
- Microsoft
BizTalk to Azure Integration Services Migration - Azure templates 0.5.0-beta-2020102741772
This is a prerelease version of BizTalk to Azure Integration Services Migration - Azure templates.
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
Some Checks Have Failed or Are Not Yet Complete
Not All Tests Have Passed
Deployment Method: Individual Install, Upgrade, & Uninstall
To install BizTalk to Azure Integration Services Migration - Azure templates, run the following command from the command line or from PowerShell:
To upgrade BizTalk to Azure Integration Services Migration - Azure templates, run the following command from the command line or from PowerShell:
To uninstall BizTalk to Azure Integration Services Migration - Azure templates, run the following command from the command line or from PowerShell:
Deployment Method:
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
Option 1: Cached Package (Unreliable, Requires Internet - Same As Community)-
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
-
Open Source
-
Download the package:
Download - Follow manual internalization instructions
-
-
Package Internalizer (C4B)
-
Run: (additional options)
choco download biztalkmigrator-azure --internalize --version=0.5.0-beta-2020102741772 --pre --source=https://community.chocolatey.org/api/v2/
-
For package and dependencies run:
choco push --source="'INTERNAL REPO URL'"
- Automate package internalization
-
Run: (additional options)
3. Copy Your Script
choco upgrade biztalkmigrator-azure -y --source="'INTERNAL REPO URL'" --version="'0.5.0-beta-2020102741772'" --prerelease [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'" --version="'0.5.0-beta-2020102741772'" --prerelease
$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: '0.5.0-beta-2020102741772'
source: INTERNAL REPO URL
state: present
allow_prerelease: yes
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 '0.5.0-beta-2020102741772'
options '--prerelease'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
cChocoPackageInstaller biztalkmigrator-azure
{
Name = "biztalkmigrator-azure"
Version = "0.5.0-beta-2020102741772"
Source = "INTERNAL REPO URL"
chocoParams = "--prerelease"
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'biztalkmigrator-azure':
ensure => '0.5.0-beta-2020102741772',
install_options => ['--prerelease'],
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.
This package is exempt from moderation. While it is likely safe for you, there is more risk involved.
Azure templates to migrate BizTalk applications to Microsoft Azure Integration Services.
<#
.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"
<#
.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"
<#
.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"
<#
.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"
<#
.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"
<#
.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"
<#
.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"
<#
.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"
<#
.SYNOPSIS
Creates an 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 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 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" -location "uksouth" -namespace "sb-aimmsgbox-dev-uksouth" -sku "Standard" -topic "messagebox"
#>
[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 = $true)]
[string] $topic,
[parameter(Mandatory = $true)]
[bool] $enablePartitioning,
[parameter(Mandatory = $false)]
[string[]] $tags = ""
)
Write-Host "Deploying the topic channel"
# Create the namespace
Write-Host "Deploying the namespace: $namespace"
az servicebus namespace create --resource-group $resourceGroupName --name $namespace --location $location --sku $sku --tags $tags
# Create the service bus topic
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"
<#
.SYNOPSIS
Removes the topic channel resource.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.EXAMPLE
.\Remove-TopicChannel-ServiceBus.ps1 --$resourceName "sb-aimmsgbox-dev-uksouth" --resourceGroupName "rg-aimapp-systemapplication-dev-uksouth"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $resourceName
)
$resourceExists = az servicebus namespace list --resource-group $resourceGroupName --query "[?name=='$resourceName'].{name:name}" -o tsv
if ($resourceExists) {
Write-Host "Removing the topic channel resource: $resourceName"
az servicebus namespace delete --name $resourceName --resource-group $resourceGroupName
Write-Host "Removed the topic channel resource: $resourceName"
}
else {
Write-Host "The topic channel resource $resourceName does not exist in resource group $resourceGroupName"
}
<#
.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"
<#
.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"
}
{
"$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')]"
},
"servicebuspublish": {
"connectionId": "[variables('serviceBusTopicPublishApiConnectionResourceId')]",
"connectionName": "[parameters('serviceBusTopicPublishApiConnectionName')]",
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
}
}
},
"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')]"
}
}
}
}
]
}
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-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]"
},
"rootFolder": {
"type": "string",
"metadata": {
"description": "Root folder to use with the Filesystem connector"
}
},
"authType": {
"defaultValue": "windows",
"type": "string",
"metadata": {
"description": "Authentication type to use with the Filesystem connector"
}
},
"userName": {
"type": "string",
"metadata": {
"description": "User Name for the Filesystem connector"
}
},
"password": {
"type": "securestring",
"metadata": {
"description": "Password for the Filesystem connector"
}
},
"gatewayResourceGroupName": {
"type": "string",
"metadata": {
"description": "Name of the ResourceGroup the On-Premises Data Gateway is located in"
}
},
"gatewayName": {
"type": "string",
"metadata": {
"description": "Name of the On-Premises Data Gateway to use"
}
},
"tags": {
"type": "object"
}
},
"variables": {
"gatewayResourceId": "[resourceId(parameters('gatewayResourceGroupName'), 'Microsoft.Web/connectionGateways', parameters('gatewayName'))]"
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('apiConnectionName')]",
"location": "[parameters('apiConnectionLocation')]",
"tags": "[parameters('tags')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('apiConnectionLocation'), '/managedApis/', 'filesystem')]"
},
"displayName": "[parameters('apiConnectionDisplayName')]",
"parameterValues": {
"rootfolder": "[parameters('rootfolder')]",
"authType": "[parameters('authType')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"gateway": {
"id": "[variables('gatewayResourceId')]"
}
}
}
}
],
"outputs": {}
}
<#
.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"
<#
.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"
}
<#
.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"
}
{
"$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": {
}
}
<#
.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"
<#
.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"
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-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]"
},
"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')]",
"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": {}
}
<#
.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"
<#
.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"
<#
.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"
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-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]"
},
"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')]",
"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": {}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-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]"
},
"rootFolder": {
"type": "string",
"metadata": {
"description": "Root folder to use with the Filesystem connector"
}
},
"authType": {
"defaultValue": "windows",
"type": "string",
"metadata": {
"description": "Authentication type to use with the Filesystem connector"
}
},
"userName": {
"type": "string",
"metadata": {
"description": "User Name for the Filesystem connector"
}
},
"password": {
"type": "securestring",
"metadata": {
"description": "Password for the Filesystem connector"
}
},
"gatewayResourceGroupName": {
"type": "string",
"metadata": {
"description": "Name of the ResourceGroup the On-Premises Data Gateway is located in"
}
},
"gatewayName": {
"type": "string",
"metadata": {
"description": "Name of the On-Premises Data Gateway to use"
}
},
"tags": {
"type": "object"
}
},
"variables": {
"gatewayResourceId": "[resourceId(parameters('gatewayResourceGroupName'), 'Microsoft.Web/connectionGateways', parameters('gatewayName'))]"
},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('apiConnectionName')]",
"location": "[parameters('apiConnectionLocation')]",
"tags": "[parameters('tags')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('apiConnectionLocation'), '/managedApis/', 'filesystem')]"
},
"displayName": "[parameters('apiConnectionDisplayName')]",
"parameterValues": {
"rootfolder": "[parameters('rootfolder')]",
"authType": "[parameters('authType')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"gateway": {
"id": "[variables('gatewayResourceId')]"
}
}
}
}
],
"outputs": {}
}
<#
.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"
<#
.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"
<#
.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"
<#
.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"
}
<#
.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"
}
{
"$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')]"
},
"servicebuspublish": {
"connectionId": "[variables('serviceBusTopicPublishApiConnectionResourceId')]",
"connectionName": "[parameters('serviceBusTopicPublishApiConnectionName')]",
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/servicebus')]"
}
}
},
"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')]"
}
}
}
}
]
}
{
"$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')]"
}
}
}
}
]
}
<#
.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"
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectorName": {
"type": "string",
"metadata": {
"description": "FTP Server Name"
}
},
"apiConnectorLocation": {
"defaultValue": "[resourceGroup().location]",
"type": "string",
"metadata": {
"description": "Location (region) or ISE that this connection is to be deployed to. Defaults to the ResourceGroup location."
}
},
"serverAddress": {
"type": "string",
"metadata": {
"description": "FTP Server Address"
}
},
"userName": {
"type": "string",
"metadata": {
"description": "User Name for the FTP Server"
}
},
"password": {
"type": "securestring",
"metadata": {
"description": "Password for the FTP Server"
}
},
"isBinaryTransport": {
"type": "bool",
"metadata": {
"description": "Indicates if Binary or ASCII mode should be used"
}
},
"serverPort": {
"type": "int",
"defaultValue": 21,
"metadata": {
"description": "FTP Port Number (example: 21)"
}
},
"isSSL": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Indicates if SSL needs to be enabled (i.e. FTPS)"
}
},
"disableCertificateValidation": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Indicates if Certificate Validation needs to be disabled"
}
},
"closeConnectionAfterRequestCompletion": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Indicates if the session should be closed every time after request completes. Enable if you hit Max Connections limit."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('apiConnectorName')]",
"location": "[parameters('apiConnectorLocation')]",
"tags": "[parameters('tags')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'ftp')]"
},
"displayName": "Ftp-Send-Connector",
"parameterValues": {
"serverAddress": "[parameters('serverAddress')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"serverPort": "[parameters('serverPort')]",
"isSSL": "[parameters('isSSL')]",
"isBinaryTransport": "[parameters('isBinaryTransport')]",
"disableCertificateValidation": "[parameters('disableCertificateValidation')]",
"closeConnectionAfterRequestCompletion": "[parameters('closeConnectionAfterRequestCompletion')]"
}
}
}
],
"outputs": {}
}
<#
.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"
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
<#
.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"
<#
.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"
}
<#
.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"
<#
.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"
}
<#
.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"
<#
.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"
}
<#
.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"
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectorName": {
"type": "string",
"metadata": {
"description": "FTP Server Name"
}
},
"apiConnectorLocation": {
"defaultValue": "[resourceGroup().location]",
"type": "string",
"metadata": {
"description": "Location (region) or ISE that this connection is to be deployed to. Defaults to the ResourceGroup location."
}
},
"serverAddress": {
"type": "string",
"metadata": {
"description": "FTP Server Address"
}
},
"userName": {
"type": "string",
"metadata": {
"description": "User Name for the FTP Server"
}
},
"password": {
"type": "securestring",
"metadata": {
"description": "Password for the FTP Server"
}
},
"isBinaryTransport": {
"type": "bool",
"metadata": {
"description": "Indicates if Binary or ASCII mode should be used"
}
},
"serverPort": {
"type": "int",
"defaultValue": 21,
"metadata": {
"description": "FTP Port Number (example: 21)"
}
},
"isSSL": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Indicates if SSL needs to be enabled (i.e. FTPS)"
}
},
"disableCertificateValidation": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Indicates if Certificate Validation needs to be disabled"
}
},
"closeConnectionAfterRequestCompletion": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Indicates if the session should be closed every time after request completes. Enable if you hit Max Connections limit."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('apiConnectorName')]",
"location": "[parameters('apiConnectorLocation')]",
"tags": "[parameters('tags')]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'ftp')]"
},
"displayName": "Ftp-Receive-Connector",
"parameterValues": {
"serverAddress": "[parameters('serverAddress')]",
"userName": "[parameters('userName')]",
"password": "[parameters('password')]",
"serverPort": "[parameters('serverPort')]",
"isSSL": "[parameters('isSSL')]",
"isBinaryTransport": "[parameters('isBinaryTransport')]",
"disableCertificateValidation": "[parameters('disableCertificateValidation')]",
"closeConnectionAfterRequestCompletion": "[parameters('closeConnectionAfterRequestCompletion')]"
}
}
}
],
"outputs": {}
}
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
<#
.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"
<#
.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"
}
<#
.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"
<#
.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"
}
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
<#
.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"
<#
.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"
}
<#
.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"
<#
.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"
}
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
<#
.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"
<#
.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"
}
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
{
"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')}"
}
}
}
}
{
"armTemplateParameter": {
"apimRetryPolicy": {
"type": "object",
"defaultValue": {
"count": 3,
"interval": "PT5S",
"type": "fixed"
},
"metadata": {
"description": "Retry Policy to use when calling APIM."
}
}
}
}
{
"armParameter": {
"apimServiceName": {
"value": "{{ resource_template.parameters.apim_service_name }}"
}
},
"armTemplateParameter": {
"apimServiceName": {
"type": "string",
"metadata": {
"description": "Name of the APIM Service used for MessageBus operations."
}
}
}
}
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
{
"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."
}
}
}
}
{
"armTemplateParameter": {
"routerRetryPolicy": {
"type": "object",
"defaultValue": {
"count": 3,
"interval": "PT5S",
"type": "fixed"
},
"metadata": {
"description": "Retry Policy to use when calling RoutingSlipRouter."
}
}
}
}
<#
.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"
<#
.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"
<#
.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"
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-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]"
},
"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')]",
"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": {}
}
<#
.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"
}
<#
.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"
}
{
"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"
}
}
}
{
"$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 }}"
}
}
}
{
"$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": {}
}
}
]
}
<#
.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"
}
{
"armParameter": {
"integrationAccountName": {
"value": "{{ resource_template.parameters.azure_integration_account_name }}"
}
},
"armTemplateParameter": {
"integrationAccountName": {
"type": "String",
"metadata": {
"description": "Name of the integration account for the MessageBus."
}
}
}
}
{
"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."
}
}
}
{
"armTemplateVariable": {
"routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
}
}
{
"armTemplateVariable": {
"serviceBusTopicPublishApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicPublishApiConnectionName'))]"
}
}
{
"armTemplateVariable": {
"serviceBusTopicSubscribeApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicSubscribeApiConnectionName'))]"
}
}
{
"workflowTrigger": {
"manual": {
"correlation": {
"clientTrackingId": "triggerBody()?['header']?['properties']?['trackingId']"
},
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {}
}
}
}
}
{
"$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 }}"
}
}
}
{
"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."
}
}
}
{
"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."
}
}
}
{
"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."
}
}
}
{
"workflowDefinitionVariable": {
"Initialize_Configuration_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Configuration",
"type": "object"
}
]
}
}
}
}
{
"workflowDefinitionVariable": {
"Initialize_StatusCode_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "StatusCode",
"type": "integer",
"value": 500
}
]
}
}
}
}
{
"armTemplateVariable": {
"integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]"
}
}
{
"armTemplateVariable": {
"messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]"
}
}
{
"armTemplateVariable": {
"routingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimroutingmanager')]"
}
}
{
"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."
}
}
}
{
"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"
}
}
}
{
"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"
}
}
}
{
"$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": {}
}
}
]
}
{
"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."
}
}
}
{
"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."
}
}
}
{
"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."
}
}
}
}
{
"workflowProperty": {
"integrationAccount": {
"id": "[variables('integrationAccountResourceId')]"
}
}
}
{
"armTemplateVariable": {
"apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]"
}
}
{
"armTemplateVariable": {
"configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]"
}
}
<#
.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"
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-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]"
},
"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')]",
"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": {}
}
<#
.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"
<#
.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"
<#
.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"
<#
.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"
}
<#
.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"
}
<#
.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"
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-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]"
},
"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')]",
"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": {}
}
{
"$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": "template",
"type": "string",
"metadata": {
"description": "The step within a Scenario that this LogicApp is running under e.g. template."
}
},
"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')]"
}
}
}
}
]
}
<#
.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"
<#
.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"
}
<#
.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"
}
{
"$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": "triggerBody()?['header']?['properties']?['trackingId']"
},
"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')]"
}
}
}
}
]
}
<#
.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"
}
<#
.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"
}
{
"$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'))]"
]
}
]
}
{
"$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'))]"
]
}
]
}
{
"$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": [
"false",
"true"
]
},
{
"name": "enableTrace",
"description": "If true, then an APIM trace URL is returned as a response header.",
"type": "bool",
"defaultValue": "false",
"values": [
"false",
"true"
]
},
{
"name": "encodeBody",
"description": "If true, then body content is always encoded using Bse64.",
"type": "bool",
"defaultValue": "true",
"values": [
"false",
"true"
]
}
],
"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": [
"false"
]
},
{
"name": "enableTrace",
"description": "If true, then an APIM trace URL is returned as a response header.",
"type": "bool",
"defaultValue": "false",
"values": [
"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": [
"false"
]
},
{
"name": "enableTrace",
"description": "If true, then an APIM trace URL is returned as a response header.",
"type": "bool",
"defaultValue": "false",
"values": [
"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"
}
}
]
}
md5: 76D30DC317C67C126F8CA27F1EC663B0 | sha1: AADFAD76C24A3B0F9C7F73981E6D9BF19E787216 | sha256: AD69B9BE6307BF32A16082A2642C4C761719D36A9FD4738D36AAE7A142103B18 | sha512: 39EA2FDFEB45F04E226DEA72E769B26D5E4E0CC2DFBB38B198AA9BCD007FC9D87D54EF9F38E0BFDDD160837E28742852D80C1FFD4B440695647E6663EEB35375
<#
.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"
}
<#
.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"
<#
.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"
}
<#
.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"
}
<#
.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"
}
<#
.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 (preview)"
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"
md5: B728AE1ACD624FAAF4AAF6BE97C7D0BA | sha1: A5CABD46C48A8D5C6C697F72549BE4EDD2E01FF8 | sha256: 8CA5B2917B9986829EB15BBD3175929DFB8A0AD4CBF157C391EE99AC23CAD460 | sha512: 18352EBE8F0DF2E89666E3F658E0166F13938A97DC98BCE184C0C5130369548A8C0A8D77851BEE770037556312F1A53A0DA71D83B2230BDA2E97DF5EF23C61FD
<#
.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"
}
<#
.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"
<#
.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"
}
<#
.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"
}
{
"$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": {
}
}
<#
.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"
<#
.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"
}
{
"$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')]"
}
}
}
}
]
}
<#
.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"
<#
.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"
}
<#
.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"
}
<#
.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"
}
Log in or click on link to see number of positives.
- Microsoft.AzureIntegrationMigration.FunctionApp.MessagingManager.zip (8ca5b2917b99) - ## / 63
- Microsoft.AzureIntegrationMigration.FunctionApp.RoutingManager.zip (ad69b9be6307) - ## / 66
- biztalkmigrator-azure.0.5.0-beta-2020102741772.nupkg (56e1f9d141bf) - ## / 63
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.
This package has no dependencies.
Ground Rules:
- This discussion is only about BizTalk to Azure Integration Services Migration - Azure templates and the BizTalk to Azure Integration Services Migration - 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 to Azure Integration Services Migration - 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.