{"id":725,"date":"2025-02-08T01:16:23","date_gmt":"2025-02-08T01:16:23","guid":{"rendered":"https:\/\/draith.com\/?p=725"},"modified":"2025-03-19T01:24:41","modified_gmt":"2025-03-19T01:24:41","slug":"running-powershell-inline-with-azure-standard-logic-apps-because-sometimes-no-code-is-too-much-work","status":"publish","type":"post","link":"https:\/\/draith.com\/?p=725","title":{"rendered":"Running PowerShell Inline with Azure Standard Logic Apps: Because Sometimes, No-Code is Too Much Work"},"content":{"rendered":"\n<p>Azure Logic Apps are fantastic\u2014until you need to do something <strong>slightly <\/strong>complex. The built-in workflow language is powerful but, let\u2019s be honest, sometimes writing expressions in that JSON-esque nightmare is more painful than debugging a spaghetti-coded PowerShell script written by an intern.<\/p>\n\n\n\n<p>Enter PowerShell in Azure Logic Apps (Standard Edition)\u2014where you can run inline PowerShell scripts, skipping the need for convoluted <code>@{json_expression}<\/code> gymnastics.<\/p>\n\n\n\n<p class=\"has-medium-font-size\">Why?<\/p>\n\n\n\n<p><strong>Readability<\/strong>: Ever tried debugging a <code>concat(split(base64(binary), ','))<\/code> expression? Yeah, me neither. PowerShell is just easier to read and debug.<\/p>\n\n\n\n<p><strong>Flexibility<\/strong>: You can manipulate JSON, handle dates, perform string operations, and even call APIs\u2014all in a single PowerShell script instead of chaining actions together.<\/p>\n\n\n\n<p><strong>Less Clicks, More Code<\/strong>: Instead of adding multiple Compose, Condition, and Parse JSON actions, you can just run a PowerShell script inline and return exactly what you need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Run PowerShell in Azure Standard Logic Apps<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Add the Inline Code Action<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your <strong>Azure Logic App (Standard Edition)<\/strong>.<\/li>\n\n\n\n<li>Click <strong>&#8220;Add an action&#8221;<\/strong> in your workflow.<\/li>\n\n\n\n<li>Search for <strong>Inline Code<\/strong> and select it.<\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note<\/strong>: This works <strong>only<\/strong> in <strong>Standard Logic Apps<\/strong>, not Consumption-based ones.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Write Your PowerShell Script<\/strong><\/h3>\n\n\n\n<p>The <strong>I<\/strong>nline Code action lets you use PowerShell directly inside the workflow.<\/p>\n\n\n\n<p>Here\u2019s a simple example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>param ($inputData)\n\n# Convert input JSON into a PowerShell object\n$data = $inputData | ConvertFrom-Json\n\n# Get current timestamp in ISO format\n$timestamp = Get-Date -Format \"yyyy-MM-ddTHH:mm:ssZ\"\n\n# Concatenate values (because Logic Apps JSON expressions are a pain)\n$fullName = \"$($data.firstName) $($data.lastName)\"\n\n# Return an object\n@{\n    fullName = $fullName\n    timestamp = $timestamp\n} | ConvertTo-Json -Compress\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step 3: Pass Data Into the Script<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click the &#8220;Parameters&#8221; section in the Inline Code action.<\/li>\n\n\n\n<li>Add a new parameter (e.g., <code>inputData<\/code>).<\/li>\n\n\n\n<li>Pass data from a previous action (like an HTTP request, a database call, or another Logic App action).<\/li>\n<\/ol>\n\n\n\n<p>When executed, the script will return a structured JSON response\u2014without needing multiple Logic App actions for transformation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Real-World Use Cases<\/strong><\/h2>\n\n\n\n<p><strong>Date Manipulation<\/strong>: Logic Apps date functions are limited, but PowerShell handles them easily.<\/p>\n\n\n\n<p><strong>Complex String Operations<\/strong>: Need to extract a value from a string? Regex it in PowerShell.<\/p>\n\n\n\n<p><strong>API Calls &amp; Data Formatting<\/strong>: Fetch data, process it, and return the exact structure you need.<\/p>\n\n\n\n<p>PowerShell in Logic Apps Standard is a game-changer. Instead of wrestling with the built-in workflow language, you can just script it. It\u2019s faster, cleaner, and doesn\u2019t require chaining a dozen actions together just to manipulate a date or merge strings.<\/p>\n\n\n\n<p>So next time you\u2019re staring at an ugly <code>@concat<\/code> expression, ask yourself: <em>\u201cCould I just do this in PowerShell?\u201d<\/em> The answer is <strong>yes<\/strong>\u2014and your future self will thank you.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure Logic Apps are fantastic\u2014until you need to do something slightly complex. The built-in workflow language is powerful but, let\u2019s be honest, sometimes writing expressions in that JSON-esque nightmare is more painful than debugging a spaghetti-coded PowerShell script written by an intern. Enter PowerShell in Azure Logic Apps (Standard Edition)\u2014where you can run inline PowerShell &hellip; <a href=\"https:\/\/draith.com\/?p=725\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Running PowerShell Inline with Azure Standard Logic Apps: Because Sometimes, No-Code is Too Much Work&#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":[13,16],"class_list":["post-725","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-logic-apps","tag-powershell"],"_links":{"self":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/725","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=725"}],"version-history":[{"count":2,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/725\/revisions"}],"predecessor-version":[{"id":727,"href":"https:\/\/draith.com\/index.php?rest_route=\/wp\/v2\/posts\/725\/revisions\/727"}],"wp:attachment":[{"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/draith.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}