Downloads:
1,338
Downloads of v 1.0.0:
627
Last Update:
28 Sep 2021
Package Maintainer(s):
Software Author(s):
- Microsoft
Tags:
biztalkmigrator-azure biztalk azure integration aim ais cli- Software Specific:
- Software Site
- Software Source
- Software License
- Software Docs
- Software Issues
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
BizTalk Migrator Dependency - Azure Templates
- 1
- 2
- 3
1.0.0 | Updated: 28 Sep 2021
- Software Specific:
- Software Site
- Software Source
- Software License
- Software Docs
- Software Issues
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
1,338
Downloads of v 1.0.0:
627
Maintainer(s):
Software Author(s):
- Microsoft
BizTalk Migrator Dependency - Azure Templates 1.0.0
Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Microsoft. The inclusion of Microsoft trademark(s), if any, upon this webpage is solely to identify Microsoft goods or services and not for commercial purposes.
- 1
- 2
- 3
All Checks are Passing
3 Passing Tests
Deployment Method: Individual Install, Upgrade, & Uninstall
To install BizTalk Migrator Dependency - Azure Templates, run the following command from the command line or from PowerShell:
To upgrade BizTalk Migrator Dependency - Azure Templates, run the following command from the command line or from PowerShell:
To uninstall BizTalk Migrator Dependency - Azure Templates, run the following command from the command line or from PowerShell:
Deployment Method:
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 --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'" [other options]
See options you can pass to upgrade.
See best practices for scripting.
Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.
If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:
choco upgrade biztalkmigrator-azure -y --source="'INTERNAL REPO URL'"
$exitCode = $LASTEXITCODE
Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
- name: Install biztalkmigrator-azure
win_chocolatey:
name: biztalkmigrator-azure
version: '1.0.0'
source: INTERNAL REPO URL
state: present
See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.
chocolatey_package 'biztalkmigrator-azure' do
action :install
source 'INTERNAL REPO URL'
version '1.0.0'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
cChocoPackageInstaller biztalkmigrator-azure
{
Name = "biztalkmigrator-azure"
Version = "1.0.0"
Source = "INTERNAL REPO URL"
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'biztalkmigrator-azure':
ensure => '1.0.0',
provider => 'chocolatey',
source => 'INTERNAL REPO URL',
}
Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.
4. If applicable - Chocolatey configuration/installation
See infrastructure management matrix for Chocolatey configuration elements and examples.
This package was approved by moderator TheCakeIsNaOH on 28 Sep 2021.
Azure templates to migrate BizTalk applications to Microsoft Azure Integration Services.
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
<#
.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
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
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"
{
"recommendations": [
"ms-azuretools.vscode-azurefunctions"
]
}
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureLogicAppsStandard.pickProcess}"
}
]
}
{
"azureLogicAppsStandard.deploySubpath": ".",
"azureLogicAppsStandard.projectLanguage": "JavaScript",
"azureLogicAppsStandard.projectRuntime": "~3",
"debug.internalConsoleOptions": "neverOpen"
}
{
"version": "2.0.0",
"tasks": [
{
"label": "generateDebugSymbols",
"command": "dotnet",
"args": [
"${input:getDebugSymbolDll}"
],
"type": "process",
"problemMatcher": "$msCompile"
},
{
"type": "func",
"command": "host start",
"problemMatcher": "$func-watch",
"isBackground": true
}
],
"inputs": [
{
"id": "getDebugSymbolDll",
"type": "command",
"command": "azureLogicAppsStandard.getDebugSymbolDll"
}
]
}
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
"version": "[1.*, 2.0.0)"
}
}
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle.Workflows",
"version": "[1.*, 2.0.0)"
},
"extensions": {
"workflow": {
"settings": {
"Runtime.WorkflowOperationDiscoveryHostMode": "true"
}
}
}
}
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsSecretStorageType": "Files",
"FUNCTIONS_WORKER_RUNTIME": "node"
}
}
<#
.SYNOPSIS
Clears the Url Cache for a given Workflow in this Logic App.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the Logic App is located.
.PARAMETER resourceName
Name of the Logic App.
.PARAMETER workflowName
Name of the Workflow.
.PARAMETER apimInstanceName
Name of the APIM instance used to clear the cache.
.PARAMETER keyVaultName
The name of the key vault store.
.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.
.EXAMPLE
.\New-Application-ClearUrlCache.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -workflowName "workflowname" -apimInstanceName "apim-aimmsgbussvc-dev-xxxxx" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $resourceName,
[parameter(Mandatory = $true)]
[string] $workflowName,
[parameter(Mandatory = $true)]
[string] $apimInstanceName,
[parameter(Mandatory = $true)]
[string] $keyVaultName,
[parameter(Mandatory = $true)]
[string] $keyVaultApimSubscriptionSecretName
)
Write-Host "Getting the subscription from Key Vault for APIM"
$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}
$apimBaseUrl = "https://$apimInstanceName.azure-api.net/aimroutingmanager/standardlogicappcallbackurl/$resourceGroupName/$resourceName"
Write-Host "Using base url: $apimBaseUrl"
Write-Host "Clearing cache for Workflow"
Write-Host "$workflowName"
az rest --method get --url "$apimBaseUrl/$workflowName?clearCache=true" --headers "Ocp-Apim-Subscription-Key=$apimSubscriptionKey" --skip-authorization-header --output none
Write-Host "Cache Clearing complete"
<#
.SYNOPSIS
Creates the Application Logic App Configuration.
This script will merge the individual workflow config files into single files,
prior to the workflows app being uploaded to the Logic App in Azure.
Note that if you want to open this Logic App project in VS Code,
you need to run this script first.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER workflowFolder
Location of the folder containing the Logic App Workflows.
.EXAMPLE
.\New-Application-LogicApp-Configuration.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -workflowFolder "$PSScriptRoot\application.logic.workflows"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $resourceName,
[parameter(Mandatory = $true)]
[string] $workflowFolder
)
Write-Host "Merging Parameters Files"
# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\parameters.json" -PathType Leaf))
{
# We're using PowerShell Hashtables to merge the Json files.
# We're not using Newtonsoft's Json.NET JObject.Merge() option here
# as we can't guarantee the version of PowerShell being used has access to Json.NET.
$mergedParameters = [ordered]@{}
Get-ChildItem "$workflowFolder\*.parameters.json" -Recurse |
Foreach-Object {
$parameterFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
# Remove any duplicate property names - have to do this or the merge will fail
# as we'll be generating invalid Json
foreach ($jsonPropertyName in $parameterFile.Keys) {
if ($mergedParameters.Contains($jsonPropertyName)) {
$mergedParameters.Remove($jsonPropertyName);
}
}
# Union the two hashtables together
$mergedParameters = $mergedParameters + $parameterFile;
# Delete this file
Remove-Item -Path $_.FullName
}
# Output a new merged parameters file
ConvertTo-Json $mergedParameters -Depth 10 | Set-Content "$workflowFolder\parameters.json"
}
else
{
Write-Host "Parameters File has already been merged - no work to do"
}
Write-Host "Parameters File Merging Complete"
Write-Host "Merging Local Parameters Files"
# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\parameters.local.json" -PathType Leaf))
{
# We're using PowerShell Hashtables to merge the Json files.
# We're not using Newtonsoft's Json.NET JObject.Merge() option here
# as we can't guarantee the version of PowerShell being used has access to Json.NET.
$mergedLocalParameters = [ordered]@{}
Get-ChildItem "$workflowFolder\*.parameters.local.json" -Recurse |
Foreach-Object {
$localParameterFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
# Remove any duplicate property names - have to do this or the merge will fail
# as we'll be generating invalid Json
foreach ($jsonPropertyName in $localParameterFile.Keys) {
if ($mergedLocalParameters.Contains($jsonPropertyName)) {
$mergedLocalParameters.Remove($jsonPropertyName);
}
}
# Union the two hashtables together
$mergedLocalParameters = $mergedLocalParameters + $localParameterFile;
# Delete this file
Remove-Item -Path $_.FullName
}
# Output a new merged local parameters file
ConvertTo-Json $mergedLocalParameters -Depth 10 | Set-Content "$workflowFolder\parameters.local.json"
}
else
{
Write-Host "Local Parameters File has already been merged - no work to do"
}
Write-Host "Local Parameters File Merging Complete"
Write-Host "Merging Connections Files"
# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\connections.json" -PathType Leaf))
{
# We're using PowerShell Hashtables to merge the Json files.
# We're not using Newtonsoft's Json.NET JObject.Merge() option here
# as we can't guarantee the version of PowerShell being used has access to Json.NET.
$serviceProviderConnections = [ordered]@{}
$managedApiConnections = [ordered]@{}
Get-ChildItem "$PSScriptRoot\*.connections.json" -Recurse |
Foreach-Object {
$connectionsFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
if ($connectionsFile.Contains("serviceProviderConnections"))
{
$tempServiceProviderConnections = $connectionsFile["serviceProviderConnections"]
foreach ($serviceProviderConnectionKey in $tempServiceProviderConnections.Keys) {
if (-Not $serviceProviderConnections.Contains($serviceProviderConnectionKey))
{
$serviceProviderConnections[$serviceProviderConnectionKey] = $tempServiceProviderConnections[$serviceProviderConnectionKey]
}
}
}
if ($connectionsFile.Contains("managedApiConnections"))
{
$tempManagedApiConnections = $connectionsFile["managedApiConnections"]
foreach ($managedApiConnectionKey in $tempManagedApiConnections.Keys) {
if (-Not $managedApiConnections.Contains($managedApiConnectionKey))
{
$managedApiConnections[$managedApiConnectionKey] = $tempManagedApiConnections[$managedApiConnectionKey]
}
}
}
# Delete this file
Remove-Item -Path $_.FullName
}
$connections = [ordered]@{}
$connections["serviceProviderConnections"] = $serviceProviderConnections
$connections["managedApiConnections"] = $managedApiConnections
ConvertTo-Json $connections -Depth 10 | Set-Content "$workflowFolder\connections.json"
}
else
{
Write-Host "Connections File has already been merged - no work to do"
}
Write-Host "Connections File Merging Complete"
Write-Host "Merging Local AppSettings Files"
# Check if we've already done a merge
if (!(Test-Path -Path "$workflowFolder\local.settings.json" -PathType Leaf))
{
# We're using PowerShell Hashtables to merge the Json files.
# We're not using Newtonsoft's Json.NET JObject.Merge() option here
# as we can't guarantee the version of PowerShell being used has access to Json.NET.
$mergedLocalAppSettings = [ordered]@{}
Get-ChildItem "$workflowFolder\*.appsettings.local.json" -Recurse |
Foreach-Object {
$localAppSettingsFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
# Remove any duplicate property names - have to do this or the merge will fail
# as we'll be generating invalid Json
foreach ($jsonPropertyName in $localAppSettingsFile.Keys) {
if ($mergedLocalAppSettings.Contains($jsonPropertyName)) {
$mergedLocalAppSettings.Remove($jsonPropertyName);
}
}
# Union the two hashtables together
$mergedLocalAppSettings = $mergedLocalAppSettings + $localAppSettingsFile;
# Delete this file
Remove-Item -Path $_.FullName
}
# Create Local App Settings format
$localAppSettings = [ordered]@{}
$localAppSettings["IsEncrypted"] = $false
$localAppSettings["Values"] = $mergedLocalAppSettings
# Output a new merged local appsettings file
ConvertTo-Json $localAppSettings -Depth 10 | Set-Content "$workflowFolder\local.settings.json"
}
else
{
Write-Host "Local App Settings File has already been merged - no work to do"
}
Write-Host "Local AppSettings File Merging Complete"
<#
.SYNOPSIS
Creates the Application Logic App Workflows.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER workflowFolder
Location of the folder containing the Logic App Workflows.
.EXAMPLE
.\New-Application-LogicApp-Workflows.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -workflowFolder "$PSScriptRoot\application.logic.workflows"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $resourceName,
[parameter(Mandatory = $true)]
[string] $workflowFolder
)
Write-Host "Creating a ZIP file from the workflow folder"
# create the zip
$zipFile = "$workflowFolder.zip"
if(Test-path $zipFile) {Remove-item $zipFile}
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($workflowFolder, $zipFile)
Write-Host "Zip File creation complete"
Write-Host "Uploading the application logic app zip package $zipFile"
if (!(Test-Path $zipFile)) {
throw "Zip file $zipFile doesn't exist, unable to upload"
}
az logicapp deployment source config-zip --resource-group $resourceGroupName --name $resourceName --src "$zipFile"
Write-Host "Upload complete"
<#
.SYNOPSIS
Creates the Application Logic App.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER templateFile
Path to the ARM template that needs to be deployed.
.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.
.PARAMETER keyVaultName
The name of the key vault store.
.PARAMETER keyVaultApimSubscriptionSecretName
The name of secret in key vault which stores the apim subscription.
.PARAMETER workflowFolder
Location of the folder containing the Logic App Workflows.
.PARAMETER deploymentName
The name used to identify this instance of the deployment.
.EXAMPLE
.\New-Application-LogicApp.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -resourceName "logic-application-dev-xxxxx" -templateFile "$PSScriptRoot\application.logic.json" -templateParameterFile "$PSScriptRoot\application.logicapp.dev.parameters.json" -keyVaultName "kv-aimrstore-dev-xxxxx" -keyVaultApimSubscriptionSecretName "aim-apim-subscriptionkey-unlimited" -workflowFolder "$PSScriptRoot\application.logic.workflows" -deploymentName "application.logicapp.uksouth.xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $resourceName,
[parameter(Mandatory = $true)]
[string] $templateFile,
[parameter(Mandatory = $true)]
[string] $templateParameterFile,
[parameter(Mandatory = $true)]
[string] $keyVaultName,
[parameter(Mandatory = $true)]
[string] $keyVaultApimSubscriptionSecretName,
[parameter(Mandatory = $true)]
[string] $workflowFolder,
[parameter(Mandatory = $true)]
[string] $deploymentName
)
Write-Host "Getting the subscription from Key Vault for APIM"
$apimSubscriptionKey = az keyvault secret show --name $keyVaultApimSubscriptionSecretName --vault-name $keyVaultName --query value
if (!$apimSubscriptionKey) {
throw "Unable to get a secret from the vault $keyVaultName with the name $keyVaultApimSubscriptionSecretName"
}
Write-Host "Merging AppSetting Files"
# We're using PowerShell Arrays to merge the Json AppSettings files.
# We're not using Newtonsoft's Json.NET JObject.Merge() option here
# as we can't guarantee the version of PowerShell being used has access to Json.NET.
$mergedAppSettings = @()
Get-ChildItem "$workflowFolder\*.appsettings.json" -Recurse |
Foreach-Object {
$appSettingsFile = Get-Content $_.FullName -Raw | ConvertFrom-Json -AsHashtable
# Union the two arrays together
$mergedAppSettings += $appSettingsFile;
# Delete this file
Remove-Item -Path $_.FullName
}
$templatePath = Split-Path -Path $templateFile
$templateFileName = Split-Path -Path $templateFile -Leaf
$baseTemplateFile = "$templatePath\base.$templateFileName"
# Load in the original template, and add in the updated AppSettings
if (Test-Path -Path $baseTemplateFile -PathType Leaf) {
$applicationTemplate = Get-Content $baseTemplateFile -Raw | ConvertFrom-Json
# Look for the web site resource
foreach ($resource in $applicationTemplate.resources) {
if ($resource.type -eq "Microsoft.Web/sites") {
$resource.properties.siteConfig.appSettings += $mergedAppSettings
}
}
# Write out a new template
ConvertTo-Json $applicationTemplate -Depth 10 | Set-Content $templateFile
# Delete the base template file
Remove-Item -Path $baseTemplateFile
}
Write-Host "Finished AppSetting File Merge"
Write-Host "Deploying the Application Logic App`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"
az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --parameters "apimSubscriptionKey=$apimSubscriptionKey" --name $deploymentName
Write-Host "Deployment complete"
<#
.SYNOPSIS
Tears down the Application Logic App.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroup
The name of the resource group containing the resources to remove.
.PARAMETER logicAppName
The name of the Logic App to find the resource.
.EXAMPLE
.\Remove-Application-LogicApp.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -logicAppName "logic-application-dev-xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $logicAppName
)
$resourceExists = az resource show --resource-group $resourceGroupName --name $logicAppName --resource-type "Microsoft.Web/sites"
if ($resourceExists) {
Write-Host "Removing the Logic App $logicAppName"
az resource delete --resource-group $resourceGroupName --name $logicAppName --resource-type "Microsoft.Web/sites"
Write-Host "Removed the Logic App $logicAppName"
}
else {
Write-Host "The Logic App $logicAppName does not exist in resource group $resourceGroupName"
}
<#
.SYNOPSIS
Creates a Service Bus Namespace resource for use by various AIM components.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER location
The location to create the service bus in.
.PARAMETER namespace
Namespace to create the service bus with.
.PARAMETER sku
The SKU level for the namespace.
.PARAMETER tags
The tags to apply to the namespace.
.EXAMPLE
.\New-Namespace-ServiceBus.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth" -location "uksouth" -namespace "sb-aimmsgbox-dev-uksouth" -sku "Standard"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $location,
[parameter(Mandatory = $true)]
[string] $namespace,
[parameter(Mandatory = $false)]
[string] $sku = "Basic",
[parameter(Mandatory = $false)]
[string[]] $tags = ""
)
Write-Host "Deploying the namespace: $namespace"
az servicebus namespace create --resource-group $resourceGroupName --name $namespace --location $location --sku $sku --tags $tags
Write-Host "Deployment Complete"
<#
.SYNOPSIS
Removes the namespace resource.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
The resource group the namespace is in.
.PARAMETER namespace.
The name of the namespace.
.EXAMPLE
.\Remove-Namespace-ServiceBus.ps1 -namespace "sb-aimmsgbox-dev-uksouth" -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $namespace
)
$resourceExists = az servicebus namespace list --resource-group $resourceGroupName --query "[?name=='$namespace'].{name:name}" -o tsv
if ($resourceExists) {
Write-Host "Removing the namespace resource: $namespace"
az servicebus namespace delete --name $namespace --resource-group $resourceGroupName
Write-Host "Removed the namespace resource: $namespace"
}
else {
Write-Host "The namespace resource $namespace does not exist in resource group $resourceGroupName"
}
<#
.SYNOPSIS
Creates a Topic Channel resource for use by various AIM components.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER namespace
Namespace to create the topic on.
.PARAMETER topic
Topic name to create in the namespace.
.PARAMETER enablePartitioning
Defines if partitioning should be enabled (true) or not on the topic.
.PARAMETER tags
The tags to apply to the namespace.
.EXAMPLE
.\New-TopicChannel-ServiceBus.ps1 -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth" -namespace "sb-aimmsgbox-dev-uksouth" -topic "messagebox"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $namespace,
[parameter(Mandatory = $true)]
[string] $topic,
[parameter(Mandatory = $true)]
[bool] $enablePartitioning,
[parameter(Mandatory = $false)]
[string[]] $tags = ""
)
Write-Host "Deploying the topic: $topic"
az servicebus topic create --resource-group $resourceGroupName --namespace-name $namespace --name $topic --enable-partitioning $enablePartitioning
Write-Host "Deployment Complete"
<#
.SYNOPSIS
Removes the topic channel resource.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
The resource group name.
.PARAMETER namespace
The name of the namespace the topic is on.
.PARAMETER topic.
The topic to remove.
.EXAMPLE
.\Remove-TopicChannel-ServiceBus.ps1 -$resourceName "sb-aimmsgbox-dev-uksouth" -resourceGroupName "rg-aimapp-systemapplication-dev-uksouth" -topic "messagebox"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $namespace,
[parameter(Mandatory = $true)]
[string] $topic
)
$namespaceResourceExists = az servicebus namespace list --resource-group $resourceGroupName --query "[?name=='$namespace'].{name:name}" -o tsv
if ($namespaceResourceExists) {
$topicResourceExists = az servicebus topic list --resource-group $resourceGroupName --namespace-name $namespace --query "[?name=='$topic'].{name:name}" -o tsv
if ($topicResourceExists) {
Write-Host "Removing the topic resource: $topic"
az servicebus topic delete --resource-group $resourceGroupName --namespace-name $namespace --name $topic
Write-Host "Removed the topic resource: $topic"
}
else {
Write-Host "The topic resource $topic does not exist in resource group $resourceGroupName with the namespace $namespace"
}
}
else {
Write-Host "The namespace $namespace does not exist in resource group $resourceGroupName when attempting to remove the topic $topic"
}
<#
.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"
}
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="
REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellCoreInstalled=Y"
)
REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellInstalled=Y"
)
REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
ECHO PowerShell Core is installed - using this to execute script.
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
)
REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled
ECHO PowerShell is installed. Checking what version is installed.
REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i
FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i
REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion
REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF
:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
pause
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="
REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellCoreInstalled=Y"
)
REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellInstalled=Y"
)
REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
ECHO PowerShell Core is installed - using this to execute script.
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
)
REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled
ECHO PowerShell is installed. Checking what version is installed.
REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i
FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i
REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion
REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF
:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
pause
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="
REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellCoreInstalled=Y"
)
REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellInstalled=Y"
)
REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
ECHO PowerShell Core is installed - using this to execute script.
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
)
REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled
ECHO PowerShell is installed. Checking what version is installed.
REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i
FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i
REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion
REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF
:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="
REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellCoreInstalled=Y"
)
REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellInstalled=Y"
)
REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
ECHO PowerShell Core is installed - using this to execute script.
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
PAUSE
GOTO:EOF
)
REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled
ECHO PowerShell is installed. Checking what version is installed.
REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i
FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i
REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion
REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
PAUSE
GOTO:EOF
:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF
:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="
REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellCoreInstalled=Y"
)
REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellInstalled=Y"
)
REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
ECHO PowerShell Core is installed - using this to execute script.
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
)
REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled
ECHO PowerShell is installed. Checking what version is installed.
REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i
FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i
REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion
REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1' -runUnattended 1"
PAUSE
GOTO:EOF
:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF
:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF
@ECHO OFF
SETLOCAL
SET "PowerShellCoreInstalled="
SET "PowerShellInstalled="
REM Check if PowerShell Core is installed
WHERE pwsh >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellCoreInstalled=Y"
)
REM Check if PowerShell is installed
WHERE PowerShell >nul 2>nul
IF %ERRORLEVEL% EQU 0 (
SET "PowerShellInstalled=Y"
)
REM If PowerShell Core installed, use that
IF DEFINED PowerShellCoreInstalled (
ECHO PowerShell Core is installed - using this to execute script.
pwsh -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
PAUSE
GOTO:EOF
)
REM Check if PowerShell is installed
IF NOT DEFINED PowerShellInstalled GOTO PowerShellNotInstalled
ECHO PowerShell is installed. Checking what version is installed.
REM Get the version of PowerShell installed - this doesn't include PowerShell Core
FOR /f %%i IN ('PowerShell -command "[int]([System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor))"') DO SET PowerShellVersion=%%i
FOR /f %%i IN ('PowerShell -command "[System.String]::Concat((Get-Variable PSVersionTable -ValueOnly).PSVersion.Major, '.', (Get-Variable PSVersionTable -ValueOnly).PSVersion.Minor)"') DO SET PowerShellVersionText=%%i
REM Check the version of PowerShell installed
IF %PowerShellVersion% LEQ 62 GOTO PowerShellOldVersion
REM Use PowerShell to execute script
ECHO PowerShell v6.2+ is installed - using this to execute script.
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './Deploy-All.ps1'"
PAUSE
GOTO:EOF
:PowerShellNotInstalled
ECHO Neither PowerShell nor PowerShell Core is installed on this system.
ECHO In order to run this script, you need either PowerShell v6.2+ or PowerShell Core (v7.x+).
PAUSE
GOTO:EOF
:PowerShellOldVersion
ECHO An older version of PowerShell is installed.
ECHO In order to run this script, you need at least PowerShell v6.2+.
ECHO You currently have v%PowerShellVersionText% installed.
PAUSE
GOTO:EOF
@ECHO OFF
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& './TearDown-All.ps1'"
pause
{
"$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": {
"logicAppName": {
"type": "string",
"metadata": {
"description": "Name of this LogicApp."
}
},
"logicAppLocation": {
"defaultValue": "[resourceGroup().location]",
"type": "string",
"metadata": {
"description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
}
},
"logicApStartupState": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [ "Enabled", "Disabled" ],
"metadata": {
"description": "Initial state of the LogicApp after it is deployed."
}
},
"messageBusResourceGroupName": {
"type": "string",
"metadata": {
"description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
}
},
"systemApplicationResourceGroupName": {
"type": "string",
"metadata": {
"description": "Name of the ResourceGroup that SystemApplication artifacts are deployed to (e.g. ServiceBus or MessageConstructor LogicApp)."
}
},
"integrationAccountName": {
"type": "string",
"metadata": {
"description": "Name of the IntegrationAccount connected to this LogicApp."
}
},
"messageConstructorLogicAppName": {
"type": "string",
"metadata": {
"description": "Name of the LogicApp to call to handle File Message Construction and Sending."
}
},
"messageSuspendProcessorLogicAppName": {
"type": "string",
"metadata": {
"description": "Name of the LogicApp to call to handle suspending of messages."
}
},
"suspendQueueTopicName": {
"type": "string",
"metadata": {
"description": "Name of the ServiceBus Topic that suspended messages are sent to."
}
},
"apimServiceName": {
"type": "string",
"metadata": {
"description": "Name of the APIM Service used for MessageBus operations."
}
},
"apimSubscriptionKey": {
"type": "securestring",
"metadata": {
"description": "Subscription Key used to access APIM."
}
},
"apimRetryPolicy": {
"type": "object",
"defaultValue": {
"count": 3,
"interval": "PT5S",
"type": "fixed"
},
"metadata": {
"description": "Retry Policy to use when calling APIM."
}
},
"fileSystemReceiveApiConnectionName": {
"type": "string",
"metadata": {
"description": "Name of the API Connection used for Filesystem Receive operations."
}
},
"fileReceiveFolder": {
"type": "string",
"metadata": {
"description": "The path where the File connector looks for new/updated files."
}
},
"fileMaxFileCount": {
"defaultValue": 10,
"type": "int",
"metadata": {
"description": "The max number of files the File Connector will retrieve per polling interval."
}
},
"fileRecurrenceFrequency": {
"type": "string",
"allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
"metadata": {
"description": "The frequency with which to check for new files on the File server."
}
},
"fileRecurrenceInterval": {
"type": "int",
"metadata": {
"description": "The interval with which to check for new files on the File server."
}
},
"serviceBusTopicPublishApiConnectionName": {
"type": "string",
"metadata": {
"description": "Name of the API Connection used for ServiceBus SuspendQueue Publish operations."
}
},
"scenario": {
"type": "string",
"metadata": {
"description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
}
},
"scenarioStep": {
"defaultValue": "fileReceiveAdapter",
"type": "string",
"metadata": {
"description": "The step within a Scenario that this LogicApp is running under e.g. fileReceiveAdapter."
}
},
"tags": {
"type": "object"
}
},
"variables": {
"apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
"configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
"messageConstructorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageConstructorLogicAppName'))]",
"messageSuspendProcessorLogicAppResourceId": "[resourceId(parameters('systemApplicationResourceGroupName'), 'Microsoft.Logic/workflows', parameters('messageSuspendProcessorLogicAppName'))]",
"fileSystemApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('fileSystemReceiveApiConnectionName'))]",
"integrationAccountResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/integrationAccounts', parameters('integrationAccountName'))]",
"serviceBusTopicPublishApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('serviceBusTopicPublishApiConnectionName'))]"
},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('logicAppName')]",
"location": "[parameters('logicAppLocation')]",
"tags": "[parameters('tags')]",
"properties": {
"state": "[parameters('logicApStartupState')]",
"integrationAccount": {
"id": "[variables('integrationAccountResourceId')]"
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
},
"fileReceiveFolder": {
"type": "String",
"description": "The path where the File connector looks for new/updated files."
},
"fileMaxFileCount": {
"type": "Int",
"description": "The max number of files the File Connector will retrieve per polling interval."
},
"fileRecurrenceFrequency": {
"type": "string",
"allowedValues": [ "Second", "Minute", "Hour", "Day", "Month", "Year" ],
"description": "The frequency with which to check for new files on the File server."
},
"fileRecurrenceInterval": {
"type": "int",
"description": "The interval with which to check for new files on the File server."
},
"apimSubscriptionKey": {
"type": "SecureString",
"description": "Subscription Key used to access APIM."
},
"scenario": {
"type": "String",
"description": "The name of the Scenario that this LogicApp is running under e.g. ApplicationName + ReceivePort/Location Name."
},
"scenarioStep": {
"type": "String",
"description": "The step within a Scenario that this LogicApp is running under e.g. FileReceiveAdapter."
},
"clearCache": {
"defaultValue": true,
"type": "Bool",
"description": "Indicates if we should clear APIM cache before retrieved config items e.g. configurationEntries or routingSlips."
},
"suspendQueueTopicName": {
"type": "String",
"description": "Name of the ServiceBus Topic that suspended messages are sent to."
}
},
"triggers": {
"When_a_file_is_added_or_modified_(properties_only)": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['filesystemreceive']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/triggers/batch/onupdatedfile",
"queries": {
"folderId": "@{parameters('fileReceiveFolder')}",
"maxFileCount": "@parameters('fileMaxFileCount')"
}
},
"recurrence": {
"frequency": "@parameters('fileRecurrenceFrequency')",
"interval": "@parameters('fileRecurrenceInterval')"
},
"splitOn": "@triggerBody()",
"type": "ApiConnection"
}
},
"actions": {
"Initialize_StatusCode_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "StatusCode",
"type": "integer",
"value": 500
}
]
}
},
"Initialize_FaultMessage_variable": {
"runAfter": {
"Initialize_StatusCode_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "FaultMessage",
"type": "object"
}
]
}
},
"Initialize_ErrorMessage_variable": {
"runAfter": {
"Initialize_FaultMessage_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ErrorMessage",
"type": "string",
"value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
}
]
}
},
"Initialize_ResponseMessage_variable": {
"runAfter": {
"Initialize_ErrorMessage_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ResponseMessage",
"type": "object",
"value": null
}
]
}
},
"Initialize_Checkpoint_variable": {
"runAfter": {
"Initialize_ResponseMessage_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Checkpoint",
"type": "string"
}
]
}
},
"Initialize_Configuration_variable": {
"runAfter": {
"Initialize_Checkpoint_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Configuration",
"type": "object"
}
]
}
},
"Compose_FileNameMask": {
"runAfter": {
"Initialize_Configuration_variable": [
"Succeeded"
]
},
"type": "Compose",
"inputs": "@{coalesce(variables('Configuration')?['scenarioStep']?['fileNameMask'], '*.*')}"
},
"Respond:_Were_we_successful": {
"actions": {
"Terminate_with_ACK": {
"runAfter": {},
"type": "Terminate",
"inputs": {
"runStatus": "Succeeded"
}
}
},
"runAfter": {
"Step:_Construct_Message": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"else": {
"actions": {
"Failure:_Do_we_have_a_NACK": {
"actions": {},
"runAfter": {},
"else": {
"actions": {
"Failure:_Build_NACK_message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"body": [
{
"$content": {
"code": "500",
"message": "@variables('ErrorMessage')",
"lastCheckpoint": "@variables('Checkpoint')",
"fault": "@variables('FaultMessage')"
},
"$contentType": "application/json",
"$part": 1,
"$partType": "http://schemas.microsoft.com/aim#nack"
}
],
"header": {
"properties": {
"createDate": "@utcNow()",
"envelopeType": "nack",
"messageId": "@guid()",
"rootPart": 1,
"trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
},
"routing": {
"MessageType": "http://schemas.microsoft.com/aim#nack"
},
"routingSlip": {},
"state": {}
}
}
},
"Failure:_Set_ResponseMessage_variable": {
"runAfter": {
"Failure:_Build_NACK_message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ResponseMessage",
"value": "@outputs('Failure:_Build_NACK_message')"
}
}
}
},
"expression": {
"and": [
{
"equals": [
"@{coalesce(variables('ResponseMessage')?['header']?['properties']?['envelopeType'], '(unknown)')}",
"nack"
]
}
]
},
"type": "If"
},
"Failure:_Send_NACK_to_SuspendQueue": {
"runAfter": {
"Failure:_Do_we_have_a_NACK": [
"Succeeded"
]
},
"type": "Workflow",
"inputs": {
"body": {
"nackMessage": "@variables('ResponseMessage')",
"originalMessage": "@triggerBody()",
"suspendQueueTopicName": "@{parameters('suspendQueueTopicName')}",
"failedMessageRouting": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['failedMessageRouting'], false)",
"scenario": "@{parameters('scenario')}"
},
"headers": {
"Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
"Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
},
"host": {
"triggerName": "manual",
"workflow": {
"id": "[variables('messageSuspendProcessorLogicAppResourceId')]"
}
}
}
},
"Terminate_with_NACK": {
"runAfter": {
"Failure:_Send_NACK_to_SuspendQueue": [
"Succeeded",
"Failed",
"TimedOut"
]
},
"type": "Terminate",
"inputs": {
"runError": {
"code": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['code'], '500')}",
"message": "@{coalesce(variables('ResponseMessage')?['body']?[0]?['$content']?['message'], '(unknown error)')}"
},
"runStatus": "Failed"
}
}
}
},
"expression": {
"or": [
{
"equals": [
"@variables('Checkpoint')",
"IgnoreFile"
]
},
{
"equals": [
"@variables('Checkpoint')",
"ConstructMessageACK"
]
}
]
},
"type": "If"
},
"Step:_Get_Configuration": {
"actions": {
"GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
"runAfter": {},
"type": "ApiManagement",
"inputs": {
"api": {
"id": "[variables('configurationManagerApiResourceId')]"
},
"method": "get",
"pathTemplate": {
"parameters": {
"scenario": "@{encodeURIComponent(parameters('scenario'))}",
"step": "@{encodeURIComponent(parameters('scenarioStep'))}"
},
"template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
},
"queries": {
"clearCache": "@parameters('clearCache')"
},
"retryPolicy": "[parameters('apimRetryPolicy')]",
"subscriptionKey": "@{parameters('apimSubscriptionKey')}"
}
},
"GetConfiguration:_Check_Status_Code": {
"runAfter": {
"GetConfiguration:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"GetConfiguration:Success:_Set_Checkpoint_variable": {
"runAfter": {
"GetConfiguration:Success:_Set_Configuration_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "GetConfiguration"
}
},
"GetConfiguration:Success:_Set_Configuration_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Configuration",
"value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
}
}
}
}
},
"default": {
"actions": {
"GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
"actions": {
"GetConfiguration:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetConfiguration:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
}
},
"GetConfiguration:Fault:_Set_FaultMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"GetConfiguration:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
"faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
}
}
},
"GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetConfiguration:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
}
},
"GetConfiguration:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"GetConfiguration:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
null
]
}
}
]
},
"type": "If"
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"GetConfiguration:_Set_StatusCode_variable": {
"runAfter": {
"GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Compose_FileNameMask": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
""
]
}
]
},
"type": "If"
},
"Step:_Validate_Configuration": {
"actions": {
"ValidateConfiguration:_Have_Valid_Properties": {
"actions": {
"ValidateConfiguration:Success:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "ValidateConfiguration"
}
}
},
"runAfter": {},
"else": {
"actions": {
"ValidateConfiguration:Failure:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}): property btsReceivePortName is not set in configuration"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '')",
""
]
}
}
]
},
"type": "If"
}
},
"runAfter": {
"Step:_Get_Configuration": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"GetConfiguration"
]
}
]
},
"type": "If"
},
"Step:_Should_we_process_file": {
"actions": {
"ShouldWeProcessFile:_Check_FileMask": {
"inputs": {
"code": "var escapedFileMask = workflowContext.actions.Compose_FileNameMask.outputs;\r\nvar fileMaskRegex = \"^\" + escapedFileMask.replace(\".\", \"[.]\").replace(\"*\", \".*\").replace(\"?\", \".\") + \"$\";\r\nreturn workflowContext.trigger.outputs.body.Name.match(fileMaskRegex) !== null;"
},
"runAfter": {},
"type": "JavaScriptCode"
},
"ShouldWeProcessFile:Failure:_Set_StatusCode_variable": {
"runAfter": {
"ShouldWeProcessFile:_Check_FileMask": [
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": 500
}
},
"ShouldWeProcessFile:Success:_Set_StatusCode_variable": {
"runAfter": {
"ShouldWeProcessFile:_Check_FileMask": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": 200
}
},
"ShouldWeProcessFile:_Check_StatusCode": {
"runAfter": {
"ShouldWeProcessFile:Failure:_Set_StatusCode_variable": [
"Succeeded",
"Skipped"
],
"ShouldWeProcessFile:Success:_Set_StatusCode_variable": [
"Succeeded",
"Skipped"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"ShouldWeProcessFile:Success:_Does_FileMask_match": {
"actions": {
"ShouldWeProcessFile:Process:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "ProcessFile"
}
}
},
"runAfter": {},
"else": {
"actions": {
"ShouldWeProcessFile:Ignore:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "IgnoreFile"
}
}
}
},
"expression": {
"and": [
{
"equals": [
"@outputs('ShouldWeProcessFile:_Check_FileMask')?['body']",
true
]
}
]
},
"type": "If"
}
}
}
},
"default": {
"actions": {
"ShouldWeProcessFile:Failure:_Create_Fault_message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('ShouldWeProcessFile:_Check_FileMask')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['statusCode'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['statusCode'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'], outputs('ShouldWeProcessFile:_Check_FileMask')?['body']?['message'], actions('ShouldWeProcessFile:_Check_FileMask')?['error']?['message'])}",
"faultReason": "@{actions('ShouldWeProcessFile:_Check_FileMask')?['status']}"
}
}
},
"ShouldWeProcessFile:Failure:_Set_ErrorMessage_variable": {
"runAfter": {
"ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to execute the FileMask Javascript"
}
},
"ShouldWeProcessFile:Failure:_Set_FaultMessage_variable": {
"runAfter": {
"ShouldWeProcessFile:Failure:_Create_Fault_message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('ShouldWeProcessFile:Failure:_Create_Fault_message')"
}
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
}
},
"runAfter": {
"Step:_Validate_Configuration": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"ValidateConfiguration"
]
}
]
},
"type": "If"
},
"Step:_Construct_Message": {
"actions": {
"ConstructMessage:_Call_MessageConstructor": {
"runAfter": {
"ConstructMessage:_Get_file_content": [
"Succeeded"
]
},
"type": "Workflow",
"inputs": {
"body": {
"$content": "@{body('ConstructMessage:_Get_file_content')}",
"$contentTransferEncoding": "none",
"$contentType": "@triggerBody()?['MediaType']",
"properties": {
"receivedFileName": "@{triggerBody()?['Name']}",
"scenario": "@{parameters('scenario')}",
"btsReceivePortName": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortName'], '(unknownReceivePortName)')}",
"btsReceivePortId": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['btsReceivePortId'], '(unknownReceivePortId)')}"
}
},
"headers": {
"Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
"Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
},
"host": {
"triggerName": "manual",
"workflow": {
"id": "[variables('messageConstructorLogicAppResourceId')]"
}
}
}
},
"ConstructMessage:_Check_StatusCode": {
"runAfter": {
"ConstructMessage:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"ConstructMessage:Success:_Check_EnvelopeType": {
"runAfter": {},
"cases": {
"ACK": {
"case": "ack",
"actions": {
"ACK:_Set_ResponseMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "ResponseMessage",
"value": "@body('ConstructMessage:_Call_MessageConstructor')"
}
},
"ACK:_Set_Checkpoint_variable": {
"runAfter": {
"ACK:_Set_ResponseMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "ConstructMessageACK"
}
}
}
},
"NACK": {
"case": "nack",
"actions": {
"NACK:_Set_ResponseMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "ResponseMessage",
"value": "@body('ConstructMessage:_Call_MessageConstructor')"
}
},
"NACK:_Set_Checkpoint_variable": {
"runAfter": {
"NACK:_Set_ResponseMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "ConstructMessageNACK"
}
}
}
}
},
"default": {
"actions": {
"ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"body": [
{
"$content": {
"code": "500",
"message": "@concat('Body returned by action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' is not an ACK or NACK. Envelope type is: ', coalesce(body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType'], '(unknown)'))"
},
"$contentType": "application/json",
"$part": 1,
"$partType": "http://schemas.microsoft.com/aim#nack"
}
],
"header": {
"properties": {
"createDate": "@utcNow()",
"envelopeType": "nack",
"messageId": "@guid()",
"rootPart": 1,
"trackingId": ""
},
"routing": {
"MessageType": "http://schemas.microsoft.com/aim#nack"
},
"routingSlip": {},
"state": {}
}
}
},
"ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": {
"runAfter": {
"ConstructMessage:UnknownEnvelope:_Compose_NACK_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ResponseMessage",
"value": "@outputs('ConstructMessage:UnknownEnvelope:_Compose_NACK_Message')"
}
},
"ConstructMessage:UnknownEnvelope:_Set_Checkpoint_variable": {
"runAfter": {
"ConstructMessage:UnknownEnvelope:_Set_ResponseMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "ConstructMessageNACK"
}
}
}
},
"expression": "@body('ConstructMessage:_Call_MessageConstructor')?['header']?['properties']?['envelopeType']",
"type": "Switch"
}
}
}
},
"default": {
"actions": {
"ConstructMessage:Failure:_Create_NACK_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"body": [
{
"$content": {
"code": "500",
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['statusCode'])}",
"faultMessage": "@{coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['error']?['message'], outputs('ConstructMessage:_Call_MessageConstructor')?['body']?['message'])}",
"faultReason": ""
},
"message": "@concat('Action ', actions('ConstructMessage:_Call_MessageConstructor')?['name'], ' resulted in an error response.')"
},
"$contentType": "application/json",
"$part": 1,
"$partType": "http://schemas.microsoft.com/aim#nack"
}
],
"header": {
"properties": {
"createDate": "@utcNow()",
"envelopeType": "nack",
"messageId": "@guid()",
"rootPart": 1,
"trackingId": ""
},
"routing": {
"MessageType": "http://schemas.microsoft.com/aim#nack"
},
"routingSlip": {},
"state": {}
}
}
},
"ConstructMessage:Failure:_Set_ResponseMessage_variable": {
"runAfter": {
"ConstructMessage:Failure:_Create_NACK_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ResponseMessage",
"value": "@outputs('ConstructMessage:Failure:_Create_NACK_Message')"
}
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"ConstructMessage:_Get_file_content": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['filesystemreceive']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(triggerBody()?['Id']))}/content",
"queries": {
"inferContentType": true
}
}
},
"ConstructMessage:_Set_StatusCode_variable": {
"runAfter": {
"ConstructMessage:_Call_MessageConstructor": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('ConstructMessage:_Call_MessageConstructor')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Step:_Should_we_process_file": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"ProcessFile"
]
}
]
},
"type": "If"
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"filesystemreceive": {
"connectionId": "[variables('fileSystemApiConnectionResourceId')]",
"connectionName": "[parameters('fileSystemReceiveApiConnectionName')]",
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/filesystem')]"
}
}
},
"fileReceiveFolder": {
"value": "[parameters('fileReceiveFolder')]"
},
"fileMaxFileCount": {
"value": "[parameters('fileMaxFileCount')]"
},
"fileRecurrenceFrequency": {
"value": "[parameters('fileRecurrenceFrequency')]"
},
"fileRecurrenceInterval": {
"value": "[parameters('fileRecurrenceInterval')]"
},
"apimSubscriptionKey": {
"value": "[parameters('apimSubscriptionKey')]"
},
"scenario": {
"value": "[parameters('scenario')]"
},
"scenarioStep": {
"value": "[parameters('scenarioStep')]"
},
"suspendQueueTopicName": {
"value": "[parameters('suspendQueueTopicName')]"
}
}
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectionName": {
"type": "string",
"metadata": {
"description": "Resource Name of the API Connection"
}
},
"apiConnectionDisplayName": {
"type": "string",
"defaultValue": "[parameters('apiConnectionName')]",
"metadata": {
"description": "Display Name of the API Connection"
}
},
"apiConnectionLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location that we're deploying this resource to."
}
},
"logicAppName": {
"type": "String",
"metadata": {
"description": "Name of the LogicApp that we're creating a policy for."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections/accessPolicies",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
"location": "[parameters('apiConnectionLocation')]",
"dependsOn": [],
"properties": {
"principal": {
"type": "ActiveDirectory",
"identity": {
"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
}
}
}
}
],
"outputs": {}
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectionName": {
"type": "string",
"metadata": {
"description": "Resource Name of the API Connection"
}
},
"apiConnectionDisplayName": {
"type": "string",
"defaultValue": "[parameters('apiConnectionName')]",
"metadata": {
"description": "Display Name of the API Connection"
}
},
"apiConnectionLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location that we're deploying this resource to."
}
},
"logicAppName": {
"type": "String",
"metadata": {
"description": "Name of the LogicApp that we're creating a policy for."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections/accessPolicies",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
"location": "[parameters('apiConnectionLocation')]",
"dependsOn": [],
"properties": {
"principal": {
"type": "ActiveDirectory",
"identity": {
"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
}
}
}
}
],
"outputs": {}
}
<#
.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
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 file receive api connection access policy.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER templateFile
Path to the ARM template that needs to be deployed.
.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.
.PARAMETER deploymentName
The name used to identify this instance of the deployment.
.EXAMPLE
.\New-FileReceiveAdapterFileSystem-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\filereceiveadapterfilesystem.apiconnpolicy.json" -templateParameterFile ".\filereceiveadapterfilesystem.apiconnpolicy.dev.parameters.json" -deploymentName "filereceiveadapterfile.apicaccesspolicy.xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $templateFile,
[parameter(Mandatory = $true)]
[string] $templateParameterFile,
[parameter(Mandatory = $true)]
[string] $deploymentName
)
Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"
az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName
Write-Host "Deployment complete"
<#
.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
Creates a file receive service bus api connection access policy.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER templateFile
Path to the ARM template that needs to be deployed.
.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.
.PARAMETER deploymentName
The name used to identify this instance of the deployment.
.EXAMPLE
.\New-FileReceiveAdapterServiceBus-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\filereceiveadapterservicebus.apiconnpolicy.json" -templateParameterFile ".\filereceiveadapterservicebus.apiconnpolicy.dev.parameters.json" -deploymentName "filereceiveadapterservicebus.apicaccesspolicy.xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $templateFile,
[parameter(Mandatory = $true)]
[string] $templateParameterFile,
[parameter(Mandatory = $true)]
[string] $deploymentName
)
Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"
az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName
Write-Host "Deployment complete"
<#
.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"
}
<#
.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": {
"logicAppName": {
"type": "string",
"metadata": {
"description": "Name of this LogicApp."
}
},
"logicAppLocation": {
"defaultValue": "[resourceGroup().location]",
"type": "string",
"metadata": {
"description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
}
},
"logicAppStartupState": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [ "Enabled", "Disabled" ],
"metadata": {
"description": "Initial state of the LogicApp after it is deployed."
}
},
"messageBusResourceGroupName": {
"type": "String",
"metadata": {
"description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
}
},
"routingSlipRouterLogicAppName": {
"type": "string",
"metadata": {
"description": "Name of the LogicApp to call to route via the RoutingSlip."
}
},
"routerRetryPolicy": {
"defaultValue": {
"count": 3,
"interval": "PT5S",
"type": "fixed"
},
"type": "object",
"metadata": {
"description": "Retry Policy to use when calling RoutingSlipRouter."
}
},
"apimServiceName": {
"type": "string",
"metadata": {
"description": "Name of the APIM Service used for MessageBus operations."
}
},
"apimSubscriptionKey": {
"type": "securestring",
"metadata": {
"description": "Subscription Key used to access APIM."
}
},
"apimRetryPolicy": {
"defaultValue": {
"count": 3,
"interval": "PT5S",
"type": "fixed"
},
"type": "object",
"metadata": {
"description": "Retry Policy to use when calling APIM."
}
},
"fileSystemSendApiConnectionName": {
"type": "string",
"metadata": {
"description": "Name of the API Connection used for File Send operations."
}
},
"scenarioStep": {
"defaultValue": "fileSendAdapter",
"type": "string",
"metadata": {
"description": "The step within a Scenario that this LogicApp is running under e.g. fileSendAdapter."
}
},
"tags": {
"type": "object"
}
},
"variables": {
"apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
"configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
"messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
"fileSendApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('fileSystemSendApiConnectionName'))]",
"routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('logicAppName')]",
"location": "[parameters('logicAppLocation')]",
"tags": "[parameters('tags')]",
"properties": {
"state": "[parameters('logicAppStartupState')]",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
},
"scenarioStep": {
"type": "String",
"description": "The step within a Scenario that this LogicApp is running under e.g. fileSendAdapter."
},
"apimSubscriptionKey": {
"type": "SecureString",
"description": "Subscription Key used to access APIM."
}
},
"triggers": {
"manual": {
"correlation": {
"clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
},
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {}
}
}
},
"actions": {
"Initialize_StatusCode_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "StatusCode",
"type": "integer",
"value": 500
}
]
}
},
"Initialize_FaultMessage_variable": {
"runAfter": {
"Initialize_StatusCode_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "FaultMessage",
"type": "object"
}
]
}
},
"Initialize_ErrorMessage_variable": {
"runAfter": {
"Initialize_FaultMessage_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ErrorMessage",
"type": "string",
"value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
}
]
}
},
"Initialize_Checkpoint_variable": {
"runAfter": {
"Initialize_ErrorMessage_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Checkpoint",
"type": "string"
}
]
}
},
"Initialize_Envelope_variable": {
"runAfter": {
"Initialize_Checkpoint_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Envelope",
"type": "object",
"value": "@triggerBody()"
}
]
}
},
"Initialize_Configuration_variable": {
"runAfter": {
"Initialize_Envelope_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Configuration",
"type": "object"
}
]
}
},
"Initialize_BodyContent_variable": {
"runAfter": {
"Initialize_Configuration_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "BodyContent",
"type": "string"
}
]
}
},
"Initialize_SendFileName_variable": {
"runAfter": {
"Initialize_BodyContent_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "SendFileName",
"type": "string"
}
]
}
},
"Initialize_CopyMode_variable": {
"runAfter": {
"Initialize_SendFileName_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "CopyMode",
"type": "string",
"value": "Create"
}
]
}
},
"MessageSender:_Were_we_Successful": {
"actions": {
"Routing:_Call_RoutingSlipRouter": {
"runAfter": {},
"type": "Workflow",
"inputs": {
"body": "@variables('Envelope')",
"headers": {
"Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
"Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"host": {
"triggerName": "manual",
"workflow": {
"id": "[variables('routingSlipRouterLogicAppResourceId')]"
}
},
"retryPolicy": "[parameters('routerRetryPolicy')]"
}
},
"Routing:_Check_StatusCode": {
"runAfter": {
"Routing:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"Routing:Success:_Send_ACK-Content_response": {
"runAfter": {},
"type": "Response",
"kind": "Http",
"inputs": {
"body": "@body('Routing:_Call_RoutingSlipRouter')",
"headers": {
"Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
"Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"statusCode": 200
}
}
}
}
},
"default": {
"actions": {
"Routing:Error:_Build_NACK_message": {
"runAfter": {
"Routing:Error:_Do_we_have_a_Fault_Message": [
"Succeeded"
]
},
"type": "Compose",
"inputs": {
"body": [
{
"$content": {
"code": "500",
"message": "@variables('ErrorMessage')",
"lastCheckpoint": "@variables('Checkpoint')",
"fault": "@variables('FaultMessage')"
},
"$contentType": "application/json",
"$part": 1,
"$partType": "http://schemas.microsoft.com/aim#nack"
}
],
"header": {
"properties": {
"createDate": "@utcNow()",
"envelopeType": "nack",
"messageId": "@guid()",
"rootPart": 1,
"trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
},
"routing": {
"MessageType": "http://schemas.microsoft.com/aim#nack"
},
"routingSlip": {},
"state": {}
}
}
},
"Routing:Error:_Do_we_have_a_Fault_Message": {
"actions": {
"Routing:Error:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"Routing:Error:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
}
},
"Routing:Error:Fault:_Set_FaultMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('Routing:_Call_RoutingSlipRouter')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"Routing:Error:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
"faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
}
}
},
"Routing:Error:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"Routing:Error:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
}
},
"Routing:Error:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"Routing:Error:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('Routing:_Call_RoutingSlipRouter')?['fault']",
null
]
}
}
]
},
"type": "If"
},
"Routing:Error:_Send_NACK_response": {
"runAfter": {
"Routing:Error:_Build_NACK_message": [
"Succeeded"
]
},
"type": "Response",
"kind": "Http",
"inputs": {
"body": "@outputs('Routing:Error:_Build_NACK_message')",
"headers": {
"Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
"Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"statusCode": 200
}
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"Routing:_Set_StatusCode_variable": {
"runAfter": {
"Routing:_Call_RoutingSlipRouter": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Step:_SendToFile": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"else": {
"actions": {
"Failure:_Build_NACK_message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"body": [
{
"$content": {
"code": "500",
"message": "@variables('ErrorMessage')",
"lastCheckpoint": "@variables('Checkpoint')",
"fault": "@variables('FaultMessage')"
},
"$contentType": "application/json",
"$part": 1,
"$partType": "http://schemas.microsoft.com/aim#nack"
}
],
"header": {
"properties": {
"createDate": "@utcNow()",
"envelopeType": "nack",
"messageId": "@guid()",
"rootPart": 1,
"trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
},
"routing": {
"MessageType": "http://schemas.microsoft.com/aim#nack"
},
"routingSlip": {},
"state": {}
}
}
},
"Failure:_Send_NACK_response": {
"runAfter": {
"Failure:_Build_NACK_message": [
"Succeeded"
]
},
"type": "Response",
"kind": "Http",
"inputs": {
"body": "@outputs('Failure:_Build_NACK_message')",
"headers": {
"Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
"Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"statusCode": 200
}
}
}
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"SendToFile"
]
}
]
},
"type": "If"
},
"Step:_Get_Configuration": {
"actions": {
"GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
"runAfter": {},
"type": "ApiManagement",
"inputs": {
"api": {
"id": "[variables('configurationManagerApiResourceId')]"
},
"method": "get",
"pathTemplate": {
"parameters": {
"scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
"step": "@{encodeURIComponent(parameters('scenarioStep'))}"
},
"template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
},
"queries": {
"clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
},
"retryPolicy": "[parameters('apimRetryPolicy')]",
"subscriptionKey": "@{parameters('apimSubscriptionKey')}"
}
},
"GetConfiguration:_Check_Status_Code": {
"runAfter": {
"GetConfiguration:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"GetConfiguration:Success:_Set_Checkpoint_variable": {
"runAfter": {
"GetConfiguration:Success:_Set_Configuration_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "GetConfiguration"
}
},
"GetConfiguration:Success:_Set_Configuration_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Configuration",
"value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
}
}
}
}
},
"default": {
"actions": {
"GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
"actions": {
"GetConfiguration:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetConfiguration:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
}
},
"GetConfiguration:Fault:_Set_FaultMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"GetConfiguration:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
"faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
}
}
},
"GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetConfiguration:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
}
},
"GetConfiguration:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"GetConfiguration:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
null
]
}
}
]
},
"type": "If"
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"GetConfiguration:_Set_StatusCode_variable": {
"runAfter": {
"GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Initialize_CopyMode_variable": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
""
]
}
]
},
"type": "If"
},
"Step:_Check_BodyContent": {
"actions": {
"CheckBodyContent:_Body_Content_is_missing": {
"actions": {
"CheckBodyContent:Missing:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "NoBodyContent"
}
}
},
"runAfter": {
"CheckBodyContent:_Select_Root_Part": [
"Succeeded"
]
},
"else": {
"actions": {
"CheckBodyContent:Success:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "CheckBodyContent"
}
}
}
},
"expression": {
"and": [
{
"equals": [
"@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
""
]
}
]
},
"type": "If"
},
"CheckBodyContent:_Select_Root_Part": {
"runAfter": {},
"type": "Query",
"inputs": {
"from": "@variables('Envelope')?['body']",
"where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
}
}
},
"runAfter": {
"Step:_Get_Configuration": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"GetConfiguration"
]
}
]
},
"type": "If"
},
"Step:_Get_BodyContent": {
"actions": {
"GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
"runAfter": {},
"type": "ApiManagement",
"inputs": {
"api": {
"id": "[variables('messagingManagerApiResourceId')]"
},
"body": "@variables('Envelope')",
"headers": {
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"method": "post",
"pathTemplate": {
"parameters": {},
"template": "/aimmessagingmanager/getbodycontent"
},
"queries": {
"clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
"enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
},
"retryPolicy": "[parameters('apimRetryPolicy')]",
"subscriptionKey": "@{parameters('apimSubscriptionKey')}"
}
},
"GetBodyContent:_Check_Status_Code": {
"runAfter": {
"GetBodyContent:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"GetBodyContent:Success:_Set_Checkpoint_variable": {
"runAfter": {
"GetBodyContent:Success:_Set_BodyContent_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "GetBodyContent"
}
},
"GetBodyContent:Success:_Set_BodyContent_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "BodyContent",
"value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
}
}
}
}
},
"default": {
"actions": {
"GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
"actions": {
"GetBodyContent:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetBodyContent:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
}
},
"GetBodyContent:Fault:_Set_FaultMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"GetBodyContent:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
"faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
}
}
},
"GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetBodyContent:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
}
},
"GetBodyContent:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"GetBodyContent:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
null
]
}
}
]
},
"type": "If"
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"GetBodyContent:_Set_StatusCode_variable": {
"runAfter": {
"GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
}
}
},
"runAfter": {
"Step:_Check_BodyContent": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"CheckBodyContent"
]
}
]
},
"type": "If"
},
"Step:_GetSendFileName": {
"actions": {
"GetSendFileName:_Set_SendFileName_variable": {
"description": "A full list of supported FileName macros can be found here: https://social.technet.microsoft.com/wiki/contents/articles/8823.biztalk-server-list-of-macros.aspx. At this time we are not supporting the Party macros.",
"type": "SetVariable",
"runAfter": {},
"inputs": {
"name": "SendFileName",
"value": "@{replace(replace(replace(replace(replace(replace(replace(coalesce(variables('Configuration')?[parameters('scenarioStep')]?['fileName'], '%MessageID%.xml'), '%MessageID%', coalesce(triggerBody()?['header']?['properties']?['messageId'], guid())), '%SourceFileName%', coalesce(triggerBody()?['header']?['properties']?['receivedFileName'], 'myfile.txt')), '%datetime%', utcNow('yyyy-MM-ddThhmmss')), '%datetime_bts2000%', utcNow('yyyyMMddhhmmsss')), '%datetime.tz%', utcNow('yyyy-MM-ddThhmmssK')), '%time%', utcNow('hhmmss')), '%time.tz%', utcNow('hhmmssK'))}"
}
},
"SendToFile:_Set_Checkpoint_variable": {
"runAfter": {
"GetSendFileName:_Set_SendFileName_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "GetSendFileName"
}
}
},
"runAfter": {
"Step:_Get_BodyContent": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"or": [
{
"equals": [
"@variables('Checkpoint')",
"GetBodyContent"
]
},
{
"equals": [
"@variables('Checkpoint')",
"NoBodyContent"
]
}
]
},
"type": "If"
},
"Step:_SendToFile": {
"actions": {
"SendToFile:_Check_Status_Code": {
"runAfter": {
"SendToFile:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"SendToFile:Success:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "SendToFile"
}
}
}
}
},
"default": {
"actions": {
"SendToFile:Failure:_Do_we_have_a_Fault_Message": {
"actions": {
"SendToFile:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"SendToFile:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FileSystem connector"
}
},
"SendToFile:Fault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('SendToFile:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('SendToFile:_Create_File')?['statusCode'], outputs('SendToFile:_Create_File')?['body']?['statusCode'], actions('SendToFile:_Create_File')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('SendToFile:_Create_File')?['error']?['message'], outputs('SendToFile:_Create_File')?['body']?['message'], actions('SendToFile:_Create_File')?['error']?['message'])}",
"faultReason": "@{actions('SendToFile:_Create_File')?['status']}"
}
}
},
"SendToFile:Fault:_Set_FaultMessage_variable": {
"runAfter": {
"SendToFile:Fault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('SendToFile:Fault:_Create_Fault_Message')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"SendToFile:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('SendToFile:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('SendToFile:_Create_File')?['statusCode'], outputs('SendToFile:_Create_File')?['body']?['statusCode'])}",
"faultMessage": "@{coalesce(outputs('SendToFile:_Create_File')?['error']?['message'], outputs('SendToFile:_Create_File')?['body']?['message'])}",
"faultReason": "@actions('SendToFile:_Create_File')?['inputs']?['path']"
}
}
},
"SendToFile:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"SendToFile:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FileSystem connector"
}
},
"SendToFile:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"SendToFile:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('SendToFile:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('SendToFile:_Create_File')?['fault']",
null
]
}
}
]
},
"type": "If"
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"SendToFile:_Set_CopyMode_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "CopyMode",
"value": "@{coalesce(variables('Configuration')?[parameters('scenarioStep')]?['copyMode'], 'Create')}"
}
},
"SendToFile:_Create_File": {
"inputs": {
"body": "@variables('BodyContent')",
"host": {
"connection": {
"name": "@parameters('$connections')['filesystemsend']['connectionId']"
}
},
"method": "@{if(equals(variables('CopyMode'), 'Create'), 'post', if(equals(variables('CopyMode'), 'Append'), 'patch', if(equals(variables('CopyMode'), 'Update'), 'put', 'undefined')))}",
"path": "/datasets/default/files@{if(contains(createArray('Append', 'Update'), variables('CopyMode')), concat(coalesce(variables('Configuration')?[parameters('scenarioStep')]?['destinationFolder'], '(undefined)'), '\\', variables('SendFileName')), '')}",
"queries": {
"folderPath": "@coalesce(variables('Configuration')?[parameters('scenarioStep')]?['destinationFolder'], '(undefined)')",
"name": "@variables('SendFileName')",
"queryParametersSingleEncoded": true
}
},
"runAfter": {
"SendToFile:_Set_CopyMode_variable": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"SendToFile:_Set_StatusCode_variable": {
"runAfter": {
"SendToFile:_Create_File": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('SendToFile:_Create_File')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Step:_GetSendFileName": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"GetSendFileName"
]
}
]
},
"type": "If"
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"filesystemsend": {
"connectionId": "[variables('fileSendApiConnectionResourceId')]",
"connectionName": "[parameters('fileSystemSendApiConnectionName')]",
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/filesystem')]"
}
}
},
"scenarioStep": {
"value": "[parameters('scenarioStep')]"
},
"apimSubscriptionKey": {
"value": "[parameters('apimSubscriptionKey')]"
}
}
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectionName": {
"type": "string",
"metadata": {
"description": "Resource Name of the API Connection"
}
},
"apiConnectionDisplayName": {
"type": "string",
"defaultValue": "[parameters('apiConnectionName')]",
"metadata": {
"description": "Display Name of the API Connection"
}
},
"apiConnectionLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location that we're deploying this resource to."
}
},
"logicAppName": {
"type": "String",
"metadata": {
"description": "Name of the LogicApp that we're creating a policy for."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections/accessPolicies",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
"location": "[parameters('apiConnectionLocation')]",
"dependsOn": [],
"properties": {
"principal": {
"type": "ActiveDirectory",
"identity": {
"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
}
}
}
}
],
"outputs": {}
}
<#
.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 api connection access policy.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER templateFile
Path to the ARM template that needs to be deployed.
.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.
.PARAMETER deploymentName
The name used to identify this instance of the deployment.
.EXAMPLE
.\New-FileSendAdapter-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\filesystemsendadapter.apiconnpolicy.json" -templateParameterFile ".\filesystemsendadapter.apiconnpolicy.dev.parameters.json" -deploymentName "filesystemsendadapter.apicaccesspolicy.xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $templateFile,
[parameter(Mandatory = $true)]
[string] $templateParameterFile,
[parameter(Mandatory = $true)]
[string] $deploymentName
)
Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"
az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName
Write-Host "Deployment complete"
<#
.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')]"
}
}
},
"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/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectionName": {
"type": "string",
"metadata": {
"description": "Resource Name of the API Connection"
}
},
"apiConnectionDisplayName": {
"type": "string",
"defaultValue": "[parameters('apiConnectionName')]",
"metadata": {
"description": "Display Name of the API Connection"
}
},
"apiConnectionLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location that we're deploying this resource to."
}
},
"logicAppName": {
"type": "String",
"metadata": {
"description": "Name of the LogicApp that we're creating a policy for."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections/accessPolicies",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
"location": "[parameters('apiConnectionLocation')]",
"dependsOn": [],
"properties": {
"principal": {
"type": "ActiveDirectory",
"identity": {
"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
}
}
}
}
],
"outputs": {}
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectionName": {
"type": "string",
"metadata": {
"description": "Resource Name of the API Connection"
}
},
"apiConnectionDisplayName": {
"type": "string",
"defaultValue": "[parameters('apiConnectionName')]",
"metadata": {
"description": "Display Name of the API Connection"
}
},
"apiConnectionLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location that we're deploying this resource to."
}
},
"logicAppName": {
"type": "String",
"metadata": {
"description": "Name of the LogicApp that we're creating a policy for."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections/accessPolicies",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
"location": "[parameters('apiConnectionLocation')]",
"dependsOn": [],
"properties": {
"principal": {
"type": "ActiveDirectory",
"identity": {
"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
}
}
}
}
],
"outputs": {}
}
<#
.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 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"
<#
.SYNOPSIS
Creates an ftp receive api connection access policy.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER templateFile
Path to the ARM template that needs to be deployed.
.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.
.PARAMETER deploymentName
The name used to identify this instance of the deployment.
.EXAMPLE
.\New-FtpReceiveAdapterFtp-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\ftpreceiveadapterftp.apiconnpolicy.json" -templateParameterFile ".\ftpreceiveadapterftp.apiconnpolicy.dev.parameters.json" -deploymentName "ftpreceiveadapterftp.apicaccesspolicy.xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $templateFile,
[parameter(Mandatory = $true)]
[string] $templateParameterFile,
[parameter(Mandatory = $true)]
[string] $deploymentName
)
Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"
az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName
Write-Host "Deployment complete"
<#
.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
Creates an ftp receive service bus api connection access policy.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER templateFile
Path to the ARM template that needs to be deployed.
.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.
.PARAMETER deploymentName
The name used to identify this instance of the deployment.
.EXAMPLE
.\New-FtpReceiveAdapterServiceBus-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\ftpreceiveadapterservicebus.apiconnpolicy.json" -templateParameterFile ".\ftpreceiveadapterservicebus.apiconnpolicy.dev.parameters.json" -deploymentName "ftpreceiveadapterservicebus.apicaccesspolicy.xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $templateFile,
[parameter(Mandatory = $true)]
[string] $templateParameterFile,
[parameter(Mandatory = $true)]
[string] $deploymentName
)
Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"
az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName
Write-Host "Deployment complete"
<#
.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
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
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/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiConnectionName": {
"type": "string",
"metadata": {
"description": "Resource Name of the API Connection"
}
},
"apiConnectionDisplayName": {
"type": "string",
"defaultValue": "[parameters('apiConnectionName')]",
"metadata": {
"description": "Display Name of the API Connection"
}
},
"apiConnectionLocation": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location that we're deploying this resource to."
}
},
"logicAppName": {
"type": "String",
"metadata": {
"description": "Name of the LogicApp that we're creating a policy for."
}
},
"tags": {
"type": "object"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections/accessPolicies",
"apiVersion": "2016-06-01",
"name": "[concat(parameters('apiConnectionName'),'/', parameters('logicAppName'))]",
"location": "[parameters('apiConnectionLocation')]",
"dependsOn": [],
"properties": {
"principal": {
"type": "ActiveDirectory",
"identity": {
"tenantId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.tenantId]",
"objectId": "[reference(resourceId('Microsoft.Web/sites', parameters('logicAppName')),'2021-01-15', 'full').identity.principalId]"
}
}
}
}
],
"outputs": {}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"logicAppName": {
"type": "string",
"metadata": {
"description": "Name of this LogicApp."
}
},
"logicAppLocation": {
"defaultValue": "[resourceGroup().location]",
"type": "string",
"metadata": {
"description": "Location (region) or ISE that this LogicApp is to be deployed to. Defaults to the ResourceGroup location."
}
},
"logicAppStartupState": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [ "Enabled", "Disabled" ],
"metadata": {
"description": "Initial state of the LogicApp after it is deployed."
}
},
"messageBusResourceGroupName": {
"type": "String",
"metadata": {
"description": "Name of the ResourceGroup that MessageBus artifacts are deployed to (e.g. APIM or RoutingSlipRouter LogicApp)."
}
},
"routingSlipRouterLogicAppName": {
"type": "string",
"metadata": {
"description": "Name of the LogicApp to call to route via the RoutingSlip."
}
},
"routerRetryPolicy": {
"defaultValue": {
"count": 3,
"interval": "PT5S",
"type": "fixed"
},
"type": "object",
"metadata": {
"description": "Retry Policy to use when calling RoutingSlipRouter."
}
},
"apimServiceName": {
"type": "string",
"metadata": {
"description": "Name of the APIM Service used for MessageBus operations."
}
},
"apimSubscriptionKey": {
"type": "securestring",
"metadata": {
"description": "Subscription Key used to access APIM."
}
},
"apimRetryPolicy": {
"defaultValue": {
"count": 3,
"interval": "PT5S",
"type": "fixed"
},
"type": "object",
"metadata": {
"description": "Retry Policy to use when calling APIM."
}
},
"ftpSendApiConnectionName": {
"type": "string",
"metadata": {
"description": "Name of the API Connection used for FTP Send operations."
}
},
"ftpSendFolder": {
"defaultValue": "/",
"type": "string",
"metadata": {
"description": "The path where the FTP connector send files."
}
},
"ftpSendFileName": {
"defaultValue": "%MessageID%-%SourceFileName%",
"type": "string",
"metadata": {
"description": "The name of the file to send (can include macro values e.g. %MessageID% or %SourceFileName%)."
}
},
"scenarioStep": {
"defaultValue": "ftpSendAdapter",
"type": "string",
"metadata": {
"description": "The step within a Scenario that this LogicApp is running under e.g. ftpSendAdapter."
}
},
"tags": {
"type": "object"
}
},
"variables": {
"apimServiceResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.ApiManagement/service', parameters('apimServiceName'))]",
"configurationManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimconfigurationmanager')]",
"messagingManagerApiResourceId": "[concat(variables('apimServiceResourceId'), '/apis/aimmessagingmanager')]",
"ftpSendApiConnectionResourceId": "[resourceId('Microsoft.Web/connections', parameters('ftpSendApiConnectionName'))]",
"routingSlipRouterLogicAppResourceId": "[resourceId(parameters('messageBusResourceGroupName'), 'Microsoft.Logic/workflows', parameters('routingSlipRouterLogicAppName'))]"
},
"resources": [
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('logicAppName')]",
"location": "[parameters('logicAppLocation')]",
"tags": "[parameters('tags')]",
"properties": {
"state": "[parameters('logicAppStartupState')]",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
},
"ftpSendFolder": {
"type": "String",
"description": "The path where the FTP connector send files."
},
"ftpSendFileName": {
"type": "String",
"description": "The name of the file to send (can include macro values e.g. %MessageID% or %SourceFileName%))."
},
"scenarioStep": {
"type": "String",
"description": "The step within a Scenario that this LogicApp is running under e.g. ftpSendAdapter."
},
"apimSubscriptionKey": {
"type": "SecureString",
"description": "Subscription Key used to access APIM."
}
},
"triggers": {
"manual": {
"correlation": {
"clientTrackingId": "@coalesce(triggerBody()?['header']?['properties']?['trackingId'], guid())"
},
"type": "Request",
"kind": "Http",
"inputs": {
"schema": {}
}
}
},
"actions": {
"Initialize_StatusCode_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "StatusCode",
"type": "integer",
"value": 500
}
]
}
},
"Initialize_FaultMessage_variable": {
"runAfter": {
"Initialize_StatusCode_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "FaultMessage",
"type": "object"
}
]
}
},
"Initialize_ErrorMessage_variable": {
"runAfter": {
"Initialize_FaultMessage_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "ErrorMessage",
"type": "string",
"value": "An error occurred in the @{workflow()?['name']} (@{workflow()?['run']?['name']}) LogicApp"
}
]
}
},
"Initialize_Checkpoint_variable": {
"runAfter": {
"Initialize_ErrorMessage_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Checkpoint",
"type": "string"
}
]
}
},
"Initialize_Envelope_variable": {
"runAfter": {
"Initialize_Checkpoint_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Envelope",
"type": "object",
"value": "@triggerBody()"
}
]
}
},
"Initialize_Configuration_variable": {
"runAfter": {
"Initialize_Envelope_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Configuration",
"type": "object"
}
]
}
},
"Initialize_BodyContent_variable": {
"runAfter": {
"Initialize_Configuration_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "BodyContent",
"type": "string"
}
]
}
},
"Initialize_SendFileName_variable": {
"runAfter": {
"Initialize_BodyContent_variable": [
"Succeeded"
]
},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "SendFileName",
"type": "string"
}
]
}
},
"MessageSender:_Were_we_Successful": {
"actions": {
"Routing:_Call_RoutingSlipRouter": {
"runAfter": {},
"type": "Workflow",
"inputs": {
"body": "@variables('Envelope')",
"headers": {
"Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
"Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"host": {
"triggerName": "manual",
"workflow": {
"id": "[variables('routingSlipRouterLogicAppResourceId')]"
}
},
"retryPolicy": "[parameters('routerRetryPolicy')]"
}
},
"Routing:_Check_StatusCode": {
"runAfter": {
"Routing:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"Routing:Success:_Send_ACK-Content_response": {
"runAfter": {},
"type": "Response",
"kind": "Http",
"inputs": {
"body": "@body('Routing:_Call_RoutingSlipRouter')",
"headers": {
"Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
"Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"statusCode": 200
}
}
}
}
},
"default": {
"actions": {
"Routing:Error:_Build_NACK_message": {
"runAfter": {
"Routing:Error:_Do_we_have_a_Fault_Message": [
"Succeeded"
]
},
"type": "Compose",
"inputs": {
"body": [
{
"$content": {
"code": "500",
"message": "@variables('ErrorMessage')",
"lastCheckpoint": "@variables('Checkpoint')",
"fault": "@variables('FaultMessage')"
},
"$contentType": "application/json",
"$part": 1,
"$partType": "http://schemas.microsoft.com/aim#nack"
}
],
"header": {
"properties": {
"createDate": "@utcNow()",
"envelopeType": "nack",
"messageId": "@guid()",
"rootPart": 1,
"trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
},
"routing": {
"MessageType": "http://schemas.microsoft.com/aim#nack"
},
"routingSlip": {},
"state": {}
}
}
},
"Routing:Error:_Do_we_have_a_Fault_Message": {
"actions": {
"Routing:Error:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"Routing:Error:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
}
},
"Routing:Error:Fault:_Set_FaultMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('Routing:_Call_RoutingSlipRouter')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"Routing:Error:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('Routing:_Call_RoutingSlipRouter')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['statusCode'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['error']?['message'], outputs('Routing:_Call_RoutingSlipRouter')?['body']?['message'], actions('Routing:_Call_RoutingSlipRouter')?['error']?['message'])}",
"faultReason": "@{actions('Routing:_Call_RoutingSlipRouter')?['status']}"
}
}
},
"Routing:Error:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"Routing:Error:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the RoutingSlipRouter Logic App"
}
},
"Routing:Error:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"Routing:Error:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('Routing:Error:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('Routing:_Call_RoutingSlipRouter')?['fault']",
null
]
}
}
]
},
"type": "If"
},
"Routing:Error:_Send_NACK_response": {
"runAfter": {
"Routing:Error:_Build_NACK_message": [
"Succeeded"
]
},
"type": "Response",
"kind": "Http",
"inputs": {
"body": "@outputs('Routing:Error:_Build_NACK_message')",
"headers": {
"Aim-Clear-Cache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
"Aim-Enable-Trace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"statusCode": 200
}
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"Routing:_Set_StatusCode_variable": {
"runAfter": {
"Routing:_Call_RoutingSlipRouter": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('Routing:_Call_RoutingSlipRouter')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Step:_SendToFTP": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"else": {
"actions": {
"Failure:_Build_NACK_message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"body": [
{
"$content": {
"code": "500",
"message": "@variables('ErrorMessage')",
"lastCheckpoint": "@variables('Checkpoint')",
"fault": "@variables('FaultMessage')"
},
"$contentType": "application/json",
"$part": 1,
"$partType": "http://schemas.microsoft.com/aim#nack"
}
],
"header": {
"properties": {
"createDate": "@utcNow()",
"envelopeType": "nack",
"messageId": "@guid()",
"rootPart": 1,
"trackingId": "@triggerBody()?['header']?['properties']?['trackingId']"
},
"routing": {
"MessageType": "http://schemas.microsoft.com/aim#nack"
},
"routingSlip": {},
"state": {}
}
}
},
"Failure:_Send_NACK_response": {
"runAfter": {
"Failure:_Build_NACK_message": [
"Succeeded"
]
},
"type": "Response",
"kind": "Http",
"inputs": {
"body": "@outputs('Failure:_Build_NACK_message')",
"headers": {
"Aim-Clear-Cache": "@coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], false)",
"Aim-Enable-Trace": "@coalesce(triggerOutputs()?['headers']?['Aim-Enable-Trace'], false)",
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"statusCode": 200
}
}
}
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"SendToFTP"
]
}
]
},
"type": "If"
},
"Step:_Get_Configuration": {
"actions": {
"GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": {
"runAfter": {},
"type": "ApiManagement",
"inputs": {
"api": {
"id": "[variables('configurationManagerApiResourceId')]"
},
"method": "get",
"pathTemplate": {
"parameters": {
"scenario": "@{encodeURIComponent(triggerBody()?['header']?['properties']?['scenario'])}",
"step": "@{encodeURIComponent(parameters('scenarioStep'))}"
},
"template": "/aimconfigurationmanager/configuration/{scenario}/{step}"
},
"queries": {
"clearCache": "@{coalesce(triggerOutputs()?['headers']?['Aim-Clear-Cache'], 'false')}"
},
"retryPolicy": "[parameters('apimRetryPolicy')]",
"subscriptionKey": "@{parameters('apimSubscriptionKey')}"
}
},
"GetConfiguration:_Check_Status_Code": {
"runAfter": {
"GetConfiguration:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"GetConfiguration:Success:_Set_Checkpoint_variable": {
"runAfter": {
"GetConfiguration:Success:_Set_Configuration_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "GetConfiguration"
}
},
"GetConfiguration:Success:_Set_Configuration_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Configuration",
"value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
}
}
}
}
},
"default": {
"actions": {
"GetConfiguration:Failure:_Do_we_have_a_Fault_Message": {
"actions": {
"GetConfiguration:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetConfiguration:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
}
},
"GetConfiguration:Fault:_Set_FaultMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"GetConfiguration:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['statusCode'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'], outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['body']?['message'], actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['error']?['message'])}",
"faultReason": "@{actions('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['status']}"
}
}
},
"GetConfiguration:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetConfiguration:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the ConfigurationManager GetConfigurationForStep operation"
}
},
"GetConfiguration:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"GetConfiguration:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('GetConfiguration:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['fault']",
null
]
}
}
]
},
"type": "If"
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"GetConfiguration:_Set_StatusCode_variable": {
"runAfter": {
"GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('GetConfiguration:_Call_APIM_ConfigurationManager.GetConfigurationForStep')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Initialize_SendFileName_variable": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
""
]
}
]
},
"type": "If"
},
"Step:_Check_BodyContent": {
"actions": {
"CheckBodyContent:_Body_Content_is_missing": {
"actions": {
"CheckBodyContent:Missing:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "NoBodyContent"
}
}
},
"runAfter": {
"CheckBodyContent:_Select_Root_Part": [
"Succeeded"
]
},
"else": {
"actions": {
"CheckBodyContent:Success:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "CheckBodyContent"
}
}
}
},
"expression": {
"and": [
{
"equals": [
"@coalesce(body('CheckBodyContent:_Select_Root_Part')?[0]?['$content'], '')",
""
]
}
]
},
"type": "If"
},
"CheckBodyContent:_Select_Root_Part": {
"runAfter": {},
"type": "Query",
"inputs": {
"from": "@variables('Envelope')?['body']",
"where": "@equals(item()?['$part'], variables('Envelope')?['header']?['properties']?['rootPart'])"
}
}
},
"runAfter": {
"Step:_Get_Configuration": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"GetConfiguration"
]
}
]
},
"type": "If"
},
"Step:_Get_BodyContent": {
"actions": {
"GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": {
"runAfter": {},
"type": "ApiManagement",
"inputs": {
"api": {
"id": "[variables('messagingManagerApiResourceId')]"
},
"body": "@variables('Envelope')",
"headers": {
"Aim-Tracking-Id": "@{triggerBody()?['header']?['properties']?['trackingId']}",
"Content-Type": "application/json"
},
"method": "post",
"pathTemplate": {
"parameters": {},
"template": "/aimmessagingmanager/getbodycontent"
},
"queries": {
"clearCache": "@coalesce(variables('Configuration')?['globalConfig']?['clearCache'], 'false')",
"enableTrace": "@coalesce(variables('Configuration')?['globalConfig']?['enableTrace'], 'false')"
},
"retryPolicy": "[parameters('apimRetryPolicy')]",
"subscriptionKey": "@{parameters('apimSubscriptionKey')}"
}
},
"GetBodyContent:_Check_Status_Code": {
"runAfter": {
"GetBodyContent:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"GetBodyContent:Success:_Set_Checkpoint_variable": {
"runAfter": {
"GetBodyContent:Success:_Set_BodyContent_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "GetBodyContent"
}
},
"GetBodyContent:Success:_Set_BodyContent_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "BodyContent",
"value": "@{base64ToString(body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['$content'])}"
}
}
}
}
},
"default": {
"actions": {
"GetBodyContent:Failure:_Do_we_have_a_Fault_Message": {
"actions": {
"GetBodyContent:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetBodyContent:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
}
},
"GetBodyContent:Fault:_Set_FaultMessage_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"GetBodyContent:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['statusCode'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['statusCode'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'], outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['body']?['message'], actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['error']?['message'])}",
"faultReason": "@{actions('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['status']}"
}
}
},
"GetBodyContent:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"GetBodyContent:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to call the MessageManager GetBodyContent operation"
}
},
"GetBodyContent:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"GetBodyContent:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('GetBodyContent:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')?['fault']",
null
]
}
}
]
},
"type": "If"
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"GetBodyContent:_Set_StatusCode_variable": {
"runAfter": {
"GetBodyContent:_Call_APIM_MessageManager.GetBodyContent": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('GetBodyContent:_Call_APIM_MessageManager.GetBodyContent')['statusCode'], 500)"
}
}
},
"runAfter": {
"Step:_Check_BodyContent": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"CheckBodyContent"
]
}
]
},
"type": "If"
},
"Step:_GetSendFileName": {
"actions": {
"GetSendFileName:_Set_SendFileName_variable": {
"description": "A full list of supported FileName macros can be found here: https://social.technet.microsoft.com/wiki/contents/articles/8823.biztalk-server-list-of-macros.aspx. At this time we are not supporting the Party macros.",
"type": "SetVariable",
"runAfter": {},
"inputs": {
"name": "SendFileName",
"value": "@{replace(replace(replace(replace(replace(replace(replace(parameters('ftpSendFileName'), '%MessageID%', coalesce(triggerBody()?['header']?['properties']?['messageId'], guid())), '%SourceFileName%', coalesce(triggerBody()?['header']?['properties']?['receivedFileName'], 'myfile.txt')), '%datetime%', utcNow('yyyy-MM-ddThhmmss')), '%datetime_bts2000%', utcNow('yyyyMMddhhmmsss')), '%datetime.tz%', utcNow('yyyy-MM-ddThhmmssK')), '%time%', utcNow('hhmmss')), '%time.tz%', utcNow('hhmmssK'))}"
}
},
"SendToFTP:_Set_Checkpoint_variable": {
"runAfter": {
"GetSendFileName:_Set_SendFileName_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "GetSendFileName"
}
}
},
"runAfter": {
"Step:_Get_BodyContent": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"or": [
{
"equals": [
"@variables('Checkpoint')",
"GetBodyContent"
]
},
{
"equals": [
"@variables('Checkpoint')",
"NoBodyContent"
]
}
]
},
"type": "If"
},
"Step:_SendToFTP": {
"actions": {
"SendToFTP:_Check_Status_Code": {
"runAfter": {
"SendToFTP:_Set_StatusCode_variable": [
"Succeeded"
]
},
"cases": {
"Success": {
"case": 200,
"actions": {
"SendToFTP:Success:_Set_Checkpoint_variable": {
"runAfter": {},
"type": "SetVariable",
"inputs": {
"name": "Checkpoint",
"value": "SendToFTP"
}
}
}
}
},
"default": {
"actions": {
"SendToFTP:Failure:_Do_we_have_a_Fault_Message": {
"actions": {
"SendToFTP:Fault:_Set_ErrorMessage_variable": {
"runAfter": {
"SendToFTP:Fault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FTP connector"
}
},
"SendToFTP:Fault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('SendToFTP:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('SendToFTP:_Create_File')?['statusCode'], outputs('SendToFTP:_Create_File')?['body']?['statusCode'], actions('SendToFTP:_Create_File')?['error']?['code'])}",
"faultMessage": "@{coalesce(outputs('SendToFTP:_Create_File')?['error']?['message'], outputs('SendToFTP:_Create_File')?['body']?['message'], actions('SendToFTP:_Create_File')?['error']?['message'])}",
"faultReason": "@{actions('SendToFTP:_Create_File')?['status']}"
}
}
},
"SendToFTP:Fault:_Set_FaultMessage_variable": {
"runAfter": {
"SendToFTP:Fault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@body('SendToFTP:Fault:_Create_Fault_Message')"
}
}
},
"runAfter": {},
"else": {
"actions": {
"SendToFTP:NoFault:_Create_Fault_Message": {
"runAfter": {},
"type": "Compose",
"inputs": {
"fault": {
"faultActor": "@concat(workflow()?['name'], '.', actions('SendToFTP:_Create_File')?['name'], ' (', workflow()?['run']?['name'], ')')",
"faultCategory": "Error",
"faultCode": "@{coalesce(outputs('SendToFTP:_Create_File')?['statusCode'], outputs('SendToFTP:_Create_File')?['body']?['statusCode'])}",
"faultMessage": "@{coalesce(outputs('SendToFTP:_Create_File')?['error']?['message'], outputs('SendToFTP:_Create_File')?['body']?['message'])}",
"faultReason": "@actions('SendToFTP:_Create_File')?['inputs']?['path']"
}
}
},
"SendToFTP:NoFault:_Set_ErrorMessage_variable": {
"runAfter": {
"SendToFTP:NoFault:_Set_FaultMessage_variable": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "ErrorMessage",
"value": "An error occurred in @{workflow()?['name']} (@{workflow()?['run']?['name']}) trying to send a file using the FTP connector"
}
},
"SendToFTP:NoFault:_Set_FaultMessage_variable": {
"runAfter": {
"SendToFTP:NoFault:_Create_Fault_Message": [
"Succeeded"
]
},
"type": "SetVariable",
"inputs": {
"name": "FaultMessage",
"value": "@outputs('SendToFTP:NoFault:_Create_Fault_Message')"
}
}
}
},
"expression": {
"and": [
{
"not": {
"equals": [
"@body('SendToFTP:_Create_File')?['fault']",
null
]
}
}
]
},
"type": "If"
}
}
},
"expression": "@variables('StatusCode')",
"type": "Switch"
},
"SendToFTP:_Create_File": {
"inputs": {
"body": "@variables('BodyContent')",
"headers": {
"ReadFileMetadataFromServer": true
},
"host": {
"connection": {
"name": "@parameters('$connections')['ftpsend']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/files",
"queries": {
"folderPath": "@parameters('ftpSendFolder')",
"name": "@variables('SendFileName')",
"queryParametersSingleEncoded": true
}
},
"runAfter": {},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"SendToFTP:_Set_StatusCode_variable": {
"runAfter": {
"SendToFTP:_Create_File": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"type": "SetVariable",
"inputs": {
"name": "StatusCode",
"value": "@coalesce(outputs('SendToFTP:_Create_File')?['statusCode'], 500)"
}
}
},
"runAfter": {
"Step:_GetSendFileName": [
"Succeeded",
"Failed",
"Skipped",
"TimedOut"
]
},
"expression": {
"and": [
{
"equals": [
"@variables('Checkpoint')",
"GetSendFileName"
]
}
]
},
"type": "If"
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"ftpsend": {
"connectionId": "[variables('ftpSendApiConnectionResourceId')]",
"connectionName": "[parameters('ftpSendApiConnectionName')]",
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/ftp')]"
}
}
},
"ftpSendFolder": {
"value": "[parameters('ftpSendFolder')]"
},
"ftpSendFileName": {
"value": "[parameters('ftpSendFileName')]"
},
"scenarioStep": {
"value": "[parameters('scenarioStep')]"
},
"apimSubscriptionKey": {
"value": "[parameters('apimSubscriptionKey')]"
}
}
}
}
]
}
<#
.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
Creates an ftp send api connection access policy.
.DESCRIPTION
Prior to running this script ensure you are authenticated against Azure and have the desired subscription set.
.PARAMETER resourceGroupName
Name of the resource group where the resources will be created.
.PARAMETER templateFile
Path to the ARM template that needs to be deployed.
.PARAMETER templateParameterFile
Path to the ARM template parameter file that contains the parameter values related to the template file.
.PARAMETER deploymentName
The name used to identify this instance of the deployment.
.EXAMPLE
.\New-FtpSendAdapter-ApiConnPolicy.ps1 -resourceGroupName "rg-aimapp-application-dev-uksouth-xxxxx" -templateFile ".\ftpsendadapter.apiconnpolicy.json" -templateParameterFile ".\ftpsendadapter.apiconnpolicy.dev.parameters.json" -deploymentName "ftpsendadapter.apicaccesspolicy.xxxxx"
#>
[CmdletBinding()]
Param(
[parameter(Mandatory = $true)]
[string] $resourceGroupName,
[parameter(Mandatory = $true)]
[string] $templateFile,
[parameter(Mandatory = $true)]
[string] $templateParameterFile,
[parameter(Mandatory = $true)]
[string] $deploymentName
)
Write-Host "Deploying an api connection access policy`r`n Template File: $templateFile`r`n Parameter File: $templateParameterFile`r`n Deployment Name: $deploymentName`r`n"
az deployment group create --resource-group $resourceGroupName --template-file $templateFile --parameters $templateParameterFile --name $deploymentName
Write-Host "Deployment complete"
<#
.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": {
"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"
]