Skip to content

jeffhollan/LogicAppTemplateCreator

Repository files navigation

Logic App Template Creator Script

This is a simple PowerShell script module I wrote to convert Logic Apps into a template that can be included in a deployment.

How to use

  1. Clone the project, open, and build.
  2. Open PowerShell and Import the module: Import-Module C:\{pathToSolution}\LogicAppTemplateCreator\LogicAppTemplate\bin\Debug\LogicAppTemplate.dll
  3. Run the PowerShell command Get-LogicAppTemplate. You can pipe the output as needed, and recommended you pipe in a token from armclient armclient token 80d4fe69-xxxx-4dd2-a938-9250f1c8ab03 | Get-LogicAppTemplate -LogicApp MyApp -ResourceGroup Integrate2016 -SubscriptionId 80d4fe69-xxxx-4dd2-a938-9250f1c8ab03 -Verbose | Out-File C:\template.json

Example when user is connected to multitenants: Get-LogicAppTemplate -LogicApp MyApp -ResourceGroup Integrate2016 -SubscriptionId 80d4fe69-xxxx-4dd2-a938-9250f1c8ab03 -TenantName contoso.onmicrosoft.com

Example with diagnostic settings: Get-LogicAppTemplate -LogicApp MyApp -ResourceGroup Integrate2016 -SubscriptionId 80d4fe69-xxxx-4dd2-a938-9250f1c8ab03 -DiagnosticSettings

How to use (via Powershell Gallery)

  1. Open a Powershell session / console.
  2. Open PowerShell and Import the module(s):
Install-Module Az.Accounts -Force #Only if you don't if you have it or not, it is safe to run when in doubt
Import-Module Az.Accounts
Install-Module LogicAppTemplate -Force
Import-Module LogicAppTemplate
#Ensure that you are signed into an account with enough permissions
Login-AzAccount
  1. Run the PowerShell command Get-LogicAppTemplate.
$token = Get-AzAccessToken -ResourceUrl "https://management.azure.com" | Select-Object -ExpandProperty Token
Get-LogicAppTemplate -LogicApp MyApp -ResourceGroup Integrate2016 -SubscriptionId 80d4fe69-xxxx-4dd2-a938-9250f1c8ab03 -Token $token -Verbose | Out-File C:\template.json

Important Change 2019-08-09

There has been a change from previous version on parameters that where Boolean are now SwitchParameter there will be an error when you run it the first time. Error is easy fixed, in your script just remove the $true part in your command se example bellow:

 -DiagnosticSettings $true 

To:

-DiagnosticSettings

Updates Change 2020-05-06

There has been alot of small changes and contribution around extraction of connectors, Integration Account and nested templates. New is that service bus connector now comes out with inputs needed for Azure Resource Manager to create the connection string rather than providing it manually.

Specifications

Parameter Description Required
LogicApp The name of the Logic App true
ResourceGroup The name of the Resource Group true
SubscriptionId The subscription Id for the resource true
TenantName Name of the Tenant i.e. contoso.onmicrosoft.com false
Token An AAD Token to access the resources - should not include Bearer, only the token false
ClaimsDump A dump of claims piped in from armclient - should not be manually set false
DiagnosticSettings If supplied, diagnostic settings are included in the ARM template false
IncludeInitializeVariable If supplied, Initialize Variable actions will be included in the ARM template false
FixedFunctionAppName If supplied, the functionApp gets a static name false
GenerateHttpTriggerUrlOutput If supplied, generate an output variable with the http trigger url. false
StripPassword If supplied, the passwords will be stripped out of the output false
DisabledState If supplied, the LA ARM Template will be set to Disabled and won't be automatically run when deployed false
ForceManagedIdentity If supplied, Managed Identity for the Logic App will be set in the ARM template false
DisableConnectionGeneration If supplied, Connections for the Logic App will not be output in the ARM template false
DisableTagParameters If supplied, Tags are not parameterized for the Logic App will not be output in the ARM template false
IncludeEvaluatedRecurrence If supplied, EvaluatedRecurrence is added in the ARM template, this is a non documented object false
DisableFunctionNameParameters If supplied, FunctionNames are not parameterized for the Logic App will not be output in the ARM template false
SkipOauthConnectionAuthorization If supplied, Oauth Connections Authorization are not set in the ARM template false
UseServiceBusDisplayName If supplied, the ServiceBusDisplayNames is used within the parameters in the ARM template false
OnlyParameterizeConnections If supplied, the connections are generated with paramters only, no listkeys or other functions is added in the connection object false

After extraction a parameters file can be created off the LogicAppTemplate. (works on any ARM template file):

Get-ParameterTemplate -TemplateFile $filenname | Out-File 'paramfile.json'

For extraction with KeyVault reference mockup links created use: (only static reference)

Get-ParameterTemplate -TemplateFile $filenname -KeyVault Static | Out-File $filennameparam

Specifications

Parameter Description Required
TemplateFile File path to the template file true
KeyVault Enum describing how to handle KeyVault possible values Static Noce, default None false
GenerateExpression Whether to generate parameters whose default value is an ARM expression. If not specified then will not generate parameters per original code false

Other supported commands:

  • Get-IntegrationAccountSchemaTemplate: extract a schema from an integration account
  • Get-IntegrationAccountMapTemplate: extract a map from an integration account
  • Get-CustomConnectorTemplate: extract a custom connector

About

Script to convert Logic Apps into templates for deployment

Resources

License

Stars

Watchers

Forks

Packages

No packages published