{"id":661,"date":"2023-10-27T17:46:00","date_gmt":"2023-10-27T17:46:00","guid":{"rendered":"http:\/\/draith.com\/?p=661"},"modified":"2024-02-15T02:00:39","modified_gmt":"2024-02-15T02:00:39","slug":"deploy-logic-apps-with-powershell","status":"publish","type":"post","link":"http:\/\/draith.azurewebsites.net\/?p=661","title":{"rendered":"Deploy Logic Apps with PowerShell"},"content":{"rendered":"\n<p>This post is basically just a way to refresh my memory when in the next 3 months I completely forget how easy this is.  Here&#8217;s how you can leverage PowerShell to manage your Logic Apps and their connections more effectively.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;powershell&quot;,&quot;mime&quot;:&quot;application\/x-powershell&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PowerShell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;powershell&quot;}\"># Define variables\n$resourceGroupName = 'YourResourceGroup'\n$logicAppName = 'YourLogicAppName'\n$templateFilePath = 'path\/to\/your\/template.json'\n$parametersFilePath = 'path\/to\/your\/parameters.json'\n\n# Deploy the Logic App\nNew-AzResourceGroupDeployment -Name DeployLogicApp `\n  -ResourceGroupName $resourceGroupName `\n  -TemplateFile $templateFilePath `\n  -TemplateParameterFile $parametersFilePath\n<\/pre><\/div>\n\n\n\n<p>If you need a template example or parameters example, check the end of this post!!<\/p>\n\n\n\n<p><strong>Managing Logic App Connections with PowerShell<\/strong><\/p>\n\n\n\n<p>PowerShell can also simplify the creation and management of Logic App connections, making it easier to connect to services like Office 365 or custom APIs:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;powershell&quot;,&quot;mime&quot;:&quot;application\/x-powershell&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PowerShell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;powershell&quot;}\"># Creating a connection to Office 365\n$connectionName = 'office365Connection'\n$connectionParams = @{\n    'token:TenantId' = '&lt;YourTenantId&gt;';\n    'token:PrincipalId' = '&lt;YourPrincipalId&gt;';\n    'token:ClientSecret' = '&lt;YourClientSecret&gt;'\n}\n\nNew-AzResource -ResourceType 'Microsoft.Web\/connections' -ResourceName $connectionName `\n  -ResourceGroupName $resourceGroupName -Location 'eastus' `\n  -Properties $connectionParams\n<\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Template and Parameter Json Files:<\/h2>\n\n\n\n<p>Template:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application\/json&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JSON&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;json&quot;}\">{\n  &quot;$schema&quot;: &quot;https:\/\/schema.management.azure.com\/schemas\/2019-04-01\/deploymentTemplate.json#&quot;,\n  &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,\n  &quot;resources&quot;: [\n    {\n      &quot;type&quot;: &quot;Microsoft.Logic\/workflows&quot;,\n      &quot;apiVersion&quot;: &quot;2019-05-01&quot;,\n      &quot;name&quot;: &quot;[parameters('logicAppName')]&quot;,\n      &quot;location&quot;: &quot;[parameters('location')]&quot;,\n      &quot;properties&quot;: {\n        &quot;state&quot;: &quot;Enabled&quot;,\n        &quot;definition&quot;: {\n          &quot;$schema&quot;: &quot;https:\/\/schema.management.azure.com\/providers\/Microsoft.Logic\/schemas\/2016-06-01\/workflowdefinition.json#&quot;,\n          &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,\n          &quot;triggers&quot;: {\n            &quot;When_a_HTTP_request_is_received&quot;: {\n              &quot;type&quot;: &quot;Request&quot;,\n              &quot;kind&quot;: &quot;Http&quot;,\n              &quot;inputs&quot;: {\n                &quot;method&quot;: &quot;POST&quot;,\n                &quot;schema&quot;: {}\n              }\n            }\n          },\n          &quot;actions&quot;: {\n            &quot;Send_an_email&quot;: {\n              &quot;type&quot;: &quot;ApiConnection&quot;,\n              &quot;inputs&quot;: {\n                &quot;host&quot;: {\n                  &quot;connection&quot;: {\n                    &quot;name&quot;: &quot;@parameters('$connections')['office365']['connectionId']&quot;\n                  }\n                },\n                &quot;method&quot;: &quot;post&quot;,\n                &quot;body&quot;: {\n                  &quot;Subject&quot;: &quot;Email Subject Here&quot;,\n                  &quot;Body&quot;: &quot;&lt;p&gt;Email Body Here&lt;\/p&gt;&quot;,\n                  &quot;To&quot;: &quot;example@example.com&quot;\n                },\n                &quot;path&quot;: &quot;\/Mail&quot;\n              }\n            }\n          },\n          &quot;outputs&quot;: {}\n        },\n        &quot;parameters&quot;: {\n          &quot;$connections&quot;: {\n            &quot;defaultValue&quot;: {},\n            &quot;type&quot;: &quot;Object&quot;\n          }\n        }\n      }\n    }\n  ],\n  &quot;parameters&quot;: {\n    &quot;logicAppName&quot;: {\n      &quot;defaultValue&quot;: &quot;YourLogicAppName&quot;,\n      &quot;type&quot;: &quot;String&quot;\n    },\n    &quot;location&quot;: {\n      &quot;defaultValue&quot;: &quot;eastus&quot;,\n      &quot;type&quot;: &quot;String&quot;\n    }\n  }\n}\n<\/pre><\/div>\n\n\n\n<p>Parameters:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application\/json&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;JSON&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;json&quot;}\">{\n  &quot;$schema&quot;: &quot;https:\/\/schema.management.azure.com\/schemas\/2015-01-01\/deploymentParameters.json#&quot;,\n  &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,\n  &quot;parameters&quot;: {\n    &quot;logicAppName&quot;: {\n      &quot;value&quot;: &quot;YourLogicAppName&quot;\n    },\n    &quot;location&quot;: {\n      &quot;value&quot;: &quot;eastus&quot;\n    }\n  }\n}\n<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This post is basically just a way to refresh my memory when in the next 3 months I completely forget how easy this is. Here&#8217;s how you can leverage PowerShell to manage your Logic Apps and their connections more effectively. If you need a template example or parameters example, check the end of this post!! &hellip; <a href=\"http:\/\/draith.azurewebsites.net\/?p=661\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Deploy Logic Apps with PowerShell&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[4,13,16],"class_list":["post-661","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-azure","tag-logic-apps","tag-powershell"],"_links":{"self":[{"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/posts\/661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=661"}],"version-history":[{"count":1,"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/posts\/661\/revisions"}],"predecessor-version":[{"id":662,"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=\/wp\/v2\/posts\/661\/revisions\/662"}],"wp:attachment":[{"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=661"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/draith.azurewebsites.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}