<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tzahi Kolber on Medium]]></title>
        <description><![CDATA[Stories by Tzahi Kolber on Medium]]></description>
        <link>https://medium.com/@tkolber?source=rss-4122b7295394------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8q7pYYHRCHjWabTDTdtNNw.jpeg</url>
            <title>Stories by Tzahi Kolber on Medium</title>
            <link>https://medium.com/@tkolber?source=rss-4122b7295394------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:44:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tkolber/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Embedding PowerShell Scripts in Azure ARM Templates for Zero-Touch VM Configuration]]></title>
            <link>https://tkolber.medium.com/embedding-powershell-scripts-in-azure-arm-templates-for-zero-touch-vm-configuration-af399b0442f6?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/af399b0442f6</guid>
            <category><![CDATA[encodedcommand]]></category>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[arm-templates]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Tue, 03 Mar 2026 19:54:26 GMT</pubDate>
            <atom:updated>2026-03-03T19:54:26.863Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When Azure provisions a VM, it delivers a clean OS — nothing configured. If you want every VM to come up with the firewall disabled, the right DNS settings, and a working directory already in place, you&#39;d normally have to log in and run a script manually after deployment.</p><p>The <strong>Custom Script Extension (CSE)</strong> eliminates that step. You embed a PowerShell script directly in your ARM template, and Azure runs it automatically inside the VM the moment it finishes booting — fully unattended.</p><p>This post shows you exactly how to do that with a simple, self-contained example: one resource group, one VNet, one VM, and one PowerShell script — no external dependencies.</p><h3>What We&#39;re Building</h3><p>We&#39;ll deploy everything into a single resource group called <strong>RG-Test</strong>:</p><ul><li>A Virtual Network (TESTNET) with one subnet (TestSubnet, 10.0.0.0/24)</li><li>A Windows Server 2025 VM (VM01) with static IP 10.0.0.10</li><li>A PowerShell script that runs automatically on first boot</li></ul><p>The script will:</p><ol><li>Create a C:\Temp directory</li><li>Disable the Windows Firewall</li><li>Set the DNS suffix search list and DNS server addresses</li></ol><h3>The PowerShell Script</h3><p>Save this as C:\scripts\deploy.ps1:</p><pre># Create working directory<br>New-Item -ItemType Directory -Path C:\Temp -Force | Out-Null<br><br># Disable Windows Firewall on all profiles<br>Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled false<br><br># Configure DNS<br>$nic = (Get-NetAdapter).name<br>Set-DnsClientGlobalSetting -SuffixSearchList @(&quot;contoso.com&quot;)<br>Set-DnsClientServerAddress -InterfaceAlias $nic -ResetServerAddresses<br>Set-DnsClientServerAddress -InterfaceAlias $nic -ServerAddresses (&quot;10.0.0.10&quot;,&quot;10.0.0.11&quot;) -Confirm:$false</pre><blockquote><strong><em>Note:</em></strong><em> We use </em><em>New-Item -Force instead of </em><em>mkdir because </em><em>mkdir throws a terminating error if </em><em>C:\Temp already exists, which would cause the entire CSE to fail with exit code </em><em>1.</em></blockquote><h3>Converting the Script to an EncodedCommand</h3><p>The Custom Script Extension runs PowerShell via the -EncodedCommand parameter, which expects the script as a <strong>Base64-encoded UTF-16LE string</strong>. This avoids all quoting and escaping headaches — your script goes in as-is.</p><p>Run these three lines in any PowerShell session on your machine:</p><pre>$script  = Get-Content -Path &quot;C:\scripts\deploy.ps1&quot; -Raw<br>$encoded = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($script))<br>$encoded | Set-Clipboard</pre><p><strong>What each line does:</strong></p><p>Get-Content -Raw reads the entire file as one string, preserving all newlines exactly as written.</p><p>[System.Text.Encoding]::Unicode is UTF-16LE — this is mandatory. PowerShell&#39;s -EncodedCommand only accepts UTF-16LE. Using UTF-8 produces a corrupt command that silently fails.</p><p>Set-Clipboard copies the result straight to your clipboard so you can paste it directly into the ARM template.</p><p>To verify your encoding looks right before deploying, decode it back and check:</p><pre>$decoded = [System.Text.Encoding]::Unicode.GetString([Convert]::FromBase64String($encoded))<br>Write-Output $decoded</pre><p>It should print your original script exactly.</p><h3>The ARM Template</h3><p>Paste your encoded string into the scriptEncodedCommand variable. Everything else is ready to deploy as-is.</p><pre>{<br>    &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,<br>    &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,<br>    &quot;parameters&quot;: {<br>        &quot;virtualMachines_VM01_name&quot;: {<br>            &quot;defaultValue&quot;: &quot;VM01&quot;,<br>            &quot;type&quot;: &quot;String&quot;<br>        },<br>        &quot;networkInterfaces_VM01_NIC_name&quot;: {<br>            &quot;defaultValue&quot;: &quot;VM01-NIC&quot;,<br>            &quot;type&quot;: &quot;String&quot;<br>        },<br>        &quot;virtualNetworks_TESTNET_name&quot;: {<br>            &quot;defaultValue&quot;: &quot;TESTNET&quot;,<br>            &quot;type&quot;: &quot;String&quot;<br>        },<br>        &quot;networkSecurityGroups_VM01_NSG_name&quot;: {<br>            &quot;defaultValue&quot;: &quot;VM01-NSG&quot;,<br>            &quot;type&quot;: &quot;String&quot;<br>        }<br>    },<br>    &quot;variables&quot;: {<br>        &quot;scriptEncodedCommand&quot;: &quot;TgBlAHcALQBJAHQAZQBtACAALQBJAHQAZQBtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgAEMAOgBcAFQAZQBtAHAAIAAtAEYAbwByAGMAZQAgAHwAIABPAHUAdAAtAE4AdQBsAGwACgBTAGUAdAAtAE4AZQB0AEYAaQByAGUAdwBhAGwAbABQAHIAbwBmAGkAbABlACAALQBQAHIAbwBmAGkAbABlACAARABvAG0AYQBpAG4ALABQAHUAYgBsAGkAYwAsAFAAcgBpAHYAYQB0AGUAIAAtAEUAbgBhAGIAbABlAGQAIABmAGEAbABzAGUACgAkAG4AaQBjACAAPQAgACgARwBlAHQALQBOAGUAdABBAGQAYQBwAHQAZQByACkALgBuAGEAbQBlAAoAUwBlAHQALQBEAG4AcwBDAGwAaQBlAG4AdABHAGwAbwBiAGEAbABTAGUAdAB0AGkAbgBnACAALQBTAHUAZgBmAGkAeABTAGUAYQByAGMAaABMAGkAcwB0ACAAQAAoACIAYwBvAG4AdABvAHMAbwAuAGMAbwBtACIAKQAKAFMAZQB0AC0ARABuAHMAQwBsAGkAZQBuAHQAUwBlAHIAdgBlAHIAQQBkAGQAcgBlAHMAcwAgAC0ASQBuAHQAZQByAGYAYQBjAGUAQQBsAGkAYQBzACAAJABuAGkAYwAgAC0AUgBlAHMAZQB0AFMAZQByAHYAZQByAEEAZABkAHIAZQBzAHMAZQBzAAoAUwBlAHQALQBEAG4AcwBDAGwAaQBlAG4AdABTAGUAcgB2AGUAcgBBAGQAZAByAGUAcwBzACAALQBJAG4AdABlAHIAZgBhAGMAZQBBAGwAaQBhAHMAIAAkAG4AaQBjACAALQBTAGUAcgB2AGUAcgBBAGQAZAByAGUAcwBzAGUAcwAgACgAIgAxADAALgAwAC4AMAAuADEAMAAiACwAIgAxADAALgAwAC4AMAAuADEAMQAiACkAIAAtAEMAbwBuAGYAaQByAG0AOgAkAGYAYQBsAHMAZQA=&quot;<br>    },<br>    &quot;resources&quot;: [<br><br>        {<br>            &quot;type&quot;: &quot;Microsoft.Network/networkSecurityGroups&quot;,<br>            &quot;apiVersion&quot;: &quot;2024-01-01&quot;,<br>            &quot;name&quot;: &quot;[parameters(&#39;networkSecurityGroups_VM01_NSG_name&#39;)]&quot;,<br>            &quot;location&quot;: &quot;westeurope&quot;,<br>            &quot;properties&quot;: {<br>                &quot;securityRules&quot;: [<br>                    {<br>                        &quot;name&quot;: &quot;Allow-RDP&quot;,<br>                        &quot;properties&quot;: {<br>                            &quot;description&quot;: &quot;Allow RDP access to VM01 on port 3389&quot;,<br>                            &quot;protocol&quot;: &quot;Tcp&quot;,<br>                            &quot;sourcePortRange&quot;: &quot;*&quot;,<br>                            &quot;destinationPortRange&quot;: &quot;3389&quot;,<br>                            &quot;sourceAddressPrefix&quot;: &quot;Internet&quot;,<br>                            &quot;destinationAddressPrefix&quot;: &quot;*&quot;,<br>                            &quot;access&quot;: &quot;Allow&quot;,<br>                            &quot;priority&quot;: 100,<br>                            &quot;direction&quot;: &quot;Inbound&quot;<br>                        }<br>                    }<br>                ]<br>            }<br>        },<br><br>        {<br>            &quot;type&quot;: &quot;Microsoft.Network/virtualNetworks&quot;,<br>            &quot;apiVersion&quot;: &quot;2024-01-01&quot;,<br>            &quot;name&quot;: &quot;[parameters(&#39;virtualNetworks_TESTNET_name&#39;)]&quot;,<br>            &quot;location&quot;: &quot;westeurope&quot;,<br>            &quot;properties&quot;: {<br>                &quot;addressSpace&quot;: {<br>                    &quot;addressPrefixes&quot;: [ &quot;10.0.0.0/16&quot; ]<br>                },<br>                &quot;subnets&quot;: [<br>                    {<br>                        &quot;name&quot;: &quot;TestSubnet&quot;,<br>                        &quot;properties&quot;: {<br>                            &quot;addressPrefix&quot;: &quot;10.0.0.0/24&quot;<br>                        }<br>                    }<br>                ]<br>            }<br>        },<br><br>        {<br>            &quot;type&quot;: &quot;Microsoft.Network/networkInterfaces&quot;,<br>            &quot;apiVersion&quot;: &quot;2024-01-01&quot;,<br>            &quot;name&quot;: &quot;[parameters(&#39;networkInterfaces_VM01_NIC_name&#39;)]&quot;,<br>            &quot;location&quot;: &quot;westeurope&quot;,<br>            &quot;dependsOn&quot;: [<br>                &quot;[resourceId(&#39;Microsoft.Network/virtualNetworks&#39;, parameters(&#39;virtualNetworks_TESTNET_name&#39;))]&quot;,<br>                &quot;[resourceId(&#39;Microsoft.Network/networkSecurityGroups&#39;, parameters(&#39;networkSecurityGroups_VM01_NSG_name&#39;))]&quot;<br>            ],<br>            &quot;properties&quot;: {<br>                &quot;networkSecurityGroup&quot;: {<br>                    &quot;id&quot;: &quot;[resourceId(&#39;Microsoft.Network/networkSecurityGroups&#39;, parameters(&#39;networkSecurityGroups_VM01_NSG_name&#39;))]&quot;<br>                },<br>                &quot;ipConfigurations&quot;: [<br>                    {<br>                        &quot;name&quot;: &quot;ipconfig1&quot;,<br>                        &quot;properties&quot;: {<br>                            &quot;privateIPAddress&quot;: &quot;10.0.0.10&quot;,<br>                            &quot;privateIPAllocationMethod&quot;: &quot;Static&quot;,<br>                            &quot;subnet&quot;: {<br>                                &quot;id&quot;: &quot;[resourceId(&#39;Microsoft.Network/virtualNetworks/subnets&#39;, parameters(&#39;virtualNetworks_TESTNET_name&#39;), &#39;TestSubnet&#39;)]&quot;<br>                            },<br>                            &quot;primary&quot;: true,<br>                            &quot;privateIPAddressVersion&quot;: &quot;IPv4&quot;<br>                        }<br>                    }<br>                ],<br>                &quot;dnsSettings&quot;: { &quot;dnsServers&quot;: [] },<br>                &quot;enableAcceleratedNetworking&quot;: false,<br>                &quot;enableIPForwarding&quot;: false,<br>                &quot;nicType&quot;: &quot;Standard&quot;<br>            }<br>        },<br><br>        {<br>            &quot;type&quot;: &quot;Microsoft.Compute/virtualMachines&quot;,<br>            &quot;apiVersion&quot;: &quot;2024-07-01&quot;,<br>            &quot;name&quot;: &quot;[parameters(&#39;virtualMachines_VM01_name&#39;)]&quot;,<br>            &quot;location&quot;: &quot;westeurope&quot;,<br>            &quot;dependsOn&quot;: [<br>                &quot;[resourceId(&#39;Microsoft.Network/networkInterfaces&#39;, parameters(&#39;networkInterfaces_VM01_NIC_name&#39;))]&quot;<br>            ],<br>            &quot;properties&quot;: {<br>                &quot;hardwareProfile&quot;: { &quot;vmSize&quot;: &quot;Standard_D2s_v3&quot; },<br>                &quot;storageProfile&quot;: {<br>                    &quot;imageReference&quot;: {<br>                        &quot;publisher&quot;: &quot;MicrosoftWindowsServer&quot;,<br>                        &quot;offer&quot;: &quot;WindowsServer&quot;,<br>                        &quot;sku&quot;: &quot;2025-datacenter-g2&quot;,<br>                        &quot;version&quot;: &quot;latest&quot;<br>                    },<br>                    &quot;osDisk&quot;: {<br>                        &quot;osType&quot;: &quot;Windows&quot;,<br>                        &quot;name&quot;: &quot;[concat(parameters(&#39;virtualMachines_VM01_name&#39;), &#39;-OS&#39;)]&quot;,<br>                        &quot;createOption&quot;: &quot;FromImage&quot;,<br>                        &quot;caching&quot;: &quot;ReadWrite&quot;,<br>                        &quot;managedDisk&quot;: { &quot;storageAccountType&quot;: &quot;Standard_LRS&quot; },<br>                        &quot;deleteOption&quot;: &quot;Detach&quot;<br>                    },<br>                    &quot;dataDisks&quot;: []<br>                },<br>                &quot;osProfile&quot;: {<br>                    &quot;computerName&quot;: &quot;[parameters(&#39;virtualMachines_VM01_name&#39;)]&quot;,<br>                    &quot;adminUsername&quot;: &quot;wsadmin&quot;,<br>                    &quot;adminPassword&quot;: &quot;Pa$$word67890&quot;,<br>                    &quot;windowsConfiguration&quot;: {<br>                        &quot;provisionVMAgent&quot;: true,<br>                        &quot;enableAutomaticUpdates&quot;: true<br>                    },<br>                    &quot;allowExtensionOperations&quot;: true<br>                },<br>                &quot;networkProfile&quot;: {<br>                    &quot;networkInterfaces&quot;: [<br>                        {<br>                            &quot;id&quot;: &quot;[resourceId(&#39;Microsoft.Network/networkInterfaces&#39;, parameters(&#39;networkInterfaces_VM01_NIC_name&#39;))]&quot;<br>                        }<br>                    ]<br>                },<br>                &quot;diagnosticsProfile&quot;: {<br>                    &quot;bootDiagnostics&quot;: { &quot;enabled&quot;: true }<br>                },<br>                &quot;licenseType&quot;: &quot;Windows_Server&quot;<br>            }<br>        },<br><br>        {<br>            &quot;type&quot;: &quot;Microsoft.Compute/virtualMachines/extensions&quot;,<br>            &quot;apiVersion&quot;: &quot;2024-07-01&quot;,<br>            &quot;name&quot;: &quot;[concat(parameters(&#39;virtualMachines_VM01_name&#39;), &#39;/BGInfo&#39;)]&quot;,<br>            &quot;location&quot;: &quot;westeurope&quot;,<br>            &quot;dependsOn&quot;: [<br>                &quot;[resourceId(&#39;Microsoft.Compute/virtualMachines&#39;, parameters(&#39;virtualMachines_VM01_name&#39;))]&quot;<br>            ],<br>            &quot;properties&quot;: {<br>                &quot;autoUpgradeMinorVersion&quot;: true,<br>                &quot;publisher&quot;: &quot;Microsoft.Compute&quot;,<br>                &quot;type&quot;: &quot;BGInfo&quot;,<br>                &quot;typeHandlerVersion&quot;: &quot;2.2&quot;<br>            }<br>        },<br><br>        {<br>            &quot;type&quot;: &quot;Microsoft.Compute/virtualMachines/extensions&quot;,<br>            &quot;apiVersion&quot;: &quot;2024-07-01&quot;,<br>            &quot;name&quot;: &quot;[concat(parameters(&#39;virtualMachines_VM01_name&#39;), &#39;/CustomScriptExtension&#39;)]&quot;,<br>            &quot;location&quot;: &quot;westeurope&quot;,<br>            &quot;dependsOn&quot;: [<br>                &quot;[resourceId(&#39;Microsoft.Compute/virtualMachines/extensions&#39;, parameters(&#39;virtualMachines_VM01_name&#39;), &#39;BGInfo&#39;)]&quot;<br>            ],<br>            &quot;properties&quot;: {<br>                &quot;publisher&quot;: &quot;Microsoft.Compute&quot;,<br>                &quot;type&quot;: &quot;CustomScriptExtension&quot;,<br>                &quot;typeHandlerVersion&quot;: &quot;1.10&quot;,<br>                &quot;autoUpgradeMinorVersion&quot;: true,<br>                &quot;protectedSettings&quot;: {<br>                    &quot;commandToExecute&quot;: &quot;[concat(&#39;powershell -ExecutionPolicy Unrestricted -EncodedCommand &#39;, variables(&#39;scriptEncodedCommand&#39;))]&quot;<br>                }<br>            }<br>        }<br><br>    ]<br>}</pre><h3>Deploying</h3><p>First, create the resource group:</p><pre>az group create --name RG-Test --location westeurope</pre><p>Then deploy the template:</p><pre>az deployment group create \<br>  --resource-group RG-Test \<br>  --template-file vm-deploy.json \<br>  --mode Incremental</pre><p>The deployment takes around 3-5 minutes. When it completes, the VM is fully provisioned, the firewall is off, and DNS is configured — no manual steps required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*djXreFuqq0YPiCz5cNEVaw.png" /></figure><h3>How the Execution Chain Works</h3><p>The dependsOn relationships in the template enforce a strict deployment order:</p><pre>VNet  -&gt;  NIC  -&gt;  VM  -&gt;  BGInfo  -&gt;  CustomScriptExtension</pre><p>The CSE always runs last, after the VM is fully booted and the VM agent is healthy and ready to receive instructions.</p><p>The encoded command is placed in protectedSettings rather than settings so that Azure encrypts it before sending it to the VM agent — it will never appear in deployment logs or the Azure portal activity log.</p><p>We can check that the Powershell script ran and that the configuration was set successfully by running a remote Powershell command on the VM01 properties from Azure Portal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FfaiyFymIGziXF2bZ7K69g.png" /></figure><p>We can see that the C:\Temp folder was created, the Firewall settings changed and that the DNS settings according to configuration located in the ARM Template.</p><h3>Troubleshooting</h3><p>If the extension fails, the most useful place to look is the CSE log file written directly on the VM:</p><pre>C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension\</pre><p>You can also check the extension status from the Azure CLI:</p><pre>az vm extension show \<br>  --resource-group RG-Test \<br>  --vm-name VM01 \<br>  --name CustomScriptExtension</pre><p><strong>The two most common failure causes are using </strong><strong>mkdir on an existing directory (exit code </strong><strong>1) and leaving a </strong><strong>Read-Host call in the script which hangs the extension until it times out. <br>Both are avoided in the script above.</strong></p><p><em>This template is intended for lab and learning use. For production, passwords should be passed as secure parameters or sourced from Azure Key Vault rather than hardcoded in the template.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af399b0442f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Burning Azure Credits on Bastion — The Developer SKU Is Your New Best Friend]]></title>
            <link>https://tkolber.medium.com/stop-burning-azure-credits-on-bastion-the-developer-sku-is-your-new-best-friend-a36e4d713aea?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/a36e4d713aea</guid>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Thu, 19 Feb 2026 16:20:17 GMT</pubDate>
            <atom:updated>2026-02-19T16:20:17.551Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever spun up a couple of virtual machines in Azure for a dev/test lab, a proof of concept, or just to try something out, you’ve probably run into the same uncomfortable realization: connecting to those VMs <em>securely</em> is surprisingly expensive.</p><p>Azure Bastion is the right answer from a security standpoint — it eliminates the need to expose RDP or SSH ports to the internet, acting as a fully managed jump-box hosted inside Azure. But the moment you look at the price tag, enthusiasm tends to cool off fast. The Basic SKU runs around <strong>$130/month</strong>, and the Standard SKU can push past <strong>$200/month</strong>. For enterprise teams managing hundreds of VMs, that’s a rounding error. For an individual developer or a small team burning through an MSDN subscription? It’s the entire budget.</p><p>Enter the <strong>Azure Bastion Developer SKU</strong> — a free, zero-configuration tier designed specifically for developers and testers who just need to connect to their VMs securely, without the overhead of a full Bastion deployment.</p><h3>What Problem Does It Actually Solve?</h3><p>Before the Developer SKU existed, developers faced an uncomfortable choice:</p><ul><li><strong>Pay ~$130–$200/month</strong> for a proper Bastion deployment that may sit mostly idle.</li><li><strong>Expose a public IP with open RDP/SSH ports</strong>, which is a well-known security anti-pattern.</li><li><strong>Set up a VPN gateway</strong>, which adds its own complexity and cost.</li></ul><p>None of these options are great for someone who just wants to hop into a test VM for an hour. The Developer SKU removes that friction entirely by offering secure, browser-based connectivity at no cost, with no subnet configuration required.</p><h3>How It Works Under the Hood</h3><p>Traditional Bastion deployments require you to provision a dedicated host inside a special subnet (AzureBastionSubnet) within your virtual network, alongside a Standard public IP. That dedicated resource is what drives the hourly cost.</p><p>The Developer SKU takes a completely different architectural approach. Instead of deploying a dedicated Bastion host into your VNet, it taps into a <strong>shared pool of Bastion resources managed by Microsoft</strong>. Your VM connection is still private and encrypted over TLS on port 443 — but the underlying infrastructure is shared, similar to how serverless platforms work. You get the security benefit without the dedicated resource cost.</p><p>The practical result: you reference your existing VNet, skip the AzureBastionSubnet entirely, and connect directly from the VM blade in the Azure portal. Zero extra configuration.</p><h3>Features Supportability by SKU</h3><p>The table below compares key features across all four Azure Bastion tiers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*pOfVpQLI5GvZikK-alqSOQ.png" /></figure><blockquote><strong><em>Note:</em></strong><em> The Developer SKU supports </em><strong>one VM connection per user at a time</strong><em>. It is available in select Azure regions and is not intended for production workloads.</em></blockquote><h3>Pros of the Developer SKU</h3><p><strong>It’s completely free.</strong> This is the headline. There are no hourly charges, and the first 5 GB of outbound data per month is also free across all Bastion SKUs. For light dev/test usage, your Bastion cost is literally $0.</p><p><strong>Zero configuration.</strong> No need to create a dedicated subnet, allocate a public IP, or follow a multi-step deployment wizard. You enable it directly from the VM’s Connect blade in the portal. It takes about 30 seconds.</p><p><strong>No public exposure on your VM.</strong> Even though the Developer SKU uses shared infrastructure, your VM never needs a public IP or open inbound firewall rules. The security posture is the same as a paid tier — connections are encrypted over TLS and authenticated through Azure AD.</p><p><strong>Deployable via Infrastructure as Code.</strong> Despite its lightweight nature, the Developer SKU uses the standard Microsoft.Network/bastionHosts resource type in Bicep and ARM templates, so it integrates cleanly into existing IaC workflows.</p><p><strong>Multiple free instances across VNets.</strong> Since the SKU doesn’t support VNet peering, the natural workaround is deploying a separate Developer Bastion in each VNet — and since each one is free, this is a perfectly valid and cost-effective pattern.</p><p><strong>Good starting point for security culture.</strong> Because it removes the cost barrier, teams are far more likely to adopt it consistently. This helps organizations establish a “no public IP” baseline even in non-production environments.</p><h3>Cons of the Developer SKU</h3><p><strong>One VM connection at a time, per user.</strong> If you need to work on multiple VMs simultaneously — say, debugging a distributed system across several nodes — you’ll be context-switching between sessions rather than having them open concurrently. This can be a real workflow interruption.</p><p><strong>No VNet peering.</strong> The Developer SKU cannot reach VMs in peered virtual networks. In architectures where a hub-and-spoke network topology is used, this is a significant limitation. You’d need to deploy a paid SKU in the hub, or deploy separate Developer instances in each spoke (which works, but adds management overhead).</p><p><strong>Available only in select regions.</strong> The Developer SKU is not yet available in every Azure region. Before committing to it as your standard connectivity method, verify your target regions are supported.</p><p><strong>Shared infrastructure.</strong> Unlike the paid tiers where you get a dedicated Bastion host, the Developer SKU runs on a shared pool. In practice this is rarely a problem for individual developers, but it means there are no performance guarantees or SLA-backed latency commitments in the way a dedicated host would provide.</p><p><strong>No native client support.</strong> You cannot use your local RDP client or SSH terminal via Azure CLI with the Developer SKU. All access is browser-based through the Azure portal. For power users who rely on native tooling — clipboard integration, file transfers, multiple monitor support — this is a notable gap.</p><p><strong>No Key Vault integration.</strong> If your team manages SSH keys through Azure Key Vault, the Developer SKU won’t pull those automatically. You’ll need to provide credentials manually during connection.</p><p><strong>Not suitable for production.</strong> This is explicitly a dev/test tier. It lacks the scalability, SLA guarantees, auditing capabilities (session recording is Premium-only), and advanced networking features that production workloads require.</p><p><strong>Upgrade path requires manual steps.</strong> You can upgrade from Developer to a higher SKU, but it’s not seamless — you’ll need to create an AzureBastionSubnet and provision a public IP before the upgrade can proceed.</p><h3>When Should You Use It (and When Shouldn’t You)?</h3><p><strong>Use the Developer SKU when:</strong></p><ul><li>You’re building or testing in a personal subscription or MSDN/Visual Studio subscription.</li><li>You have a small number of VMs and access them one at a time.</li><li>You’re setting up a sandbox, proof of concept, or training environment.</li><li>You want to enforce a “no public IP on VMs” policy without budget justification.</li><li>You’re deploying ephemeral environments (CI/CD pipelines, lab environments) where cost control matters.</li></ul><p><strong>Upgrade to a paid SKU when:</strong></p><ul><li>You’re managing production infrastructure or need SLA-backed access.</li><li>Your team requires concurrent VM connections from a single Bastion deployment.</li><li>You use a hub-and-spoke topology and need VNet peering support.</li><li>You require native SSH/RDP client access, file transfers, or custom ports.</li><li>You need compliance-grade session recording (Premium).</li></ul><h3>The Real Cost Picture</h3><p>To put the savings in context: a developer running a small Azure lab with three VMs and previously using the Basic Bastion SKU to stay secure was paying roughly <strong>$130/month just for Bastion access</strong>. That’s $1,560/year for a jump-box. Switching to the Developer SKU brings that to <strong>$0</strong> — with the only trade-off being the loss of concurrent multi-VM connections and VNet peering, neither of which matter in a solo lab context.</p><p>For teams running multiple dev/test subscriptions, the savings can multiply quickly.</p><h3>Getting Started</h3><p>Enabling the Developer SKU is straightforward:</p><ol><li>Navigate to your Virtual Machine in the Azure portal.</li><li>Select <strong>Bastion</strong> under the <em>Operations</em> section in the left menu.</li><li>Choose <strong>Deploy Bastion</strong> and select the <strong>Developer</strong> SKU.</li><li>Connect — that’s it.</li></ol><p>No subnet creation, no public IP allocation, no waiting for a full Bastion deployment to complete.</p><h3>Final Thoughts</h3><p>The Azure Bastion Developer SKU is one of those rare additions that’s easy to recommend without caveats — <em>for its intended use case</em>. If you’re a developer, tester, or cloud engineer running non-production workloads, there is simply no longer a good reason to expose RDP or SSH ports to the internet, or to skip Bastion because of cost.</p><p>The limitations are real, and they’re worth understanding before you commit to it across an environment. But for the solo developer or small team building in Azure, the Developer SKU eliminates the last remaining excuse for insecure VM access. Use it.</p><p><em>For more details on SKU comparison and deployment steps, see the official </em><a href="https://learn.microsoft.com/en-us/azure/bastion/bastion-sku-comparison"><em>Azure Bastion SKU documentation</em></a><em> on Microsoft Learn.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a36e4d713aea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add a “Remind Me” option to Your GitHub Issues]]></title>
            <link>https://tkolber.medium.com/add-a-remind-me-button-to-your-github-issues-0a79b8a170b1?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a79b8a170b1</guid>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Sun, 08 Feb 2026 21:36:41 GMT</pubDate>
            <atom:updated>2026-02-09T06:01:30.199Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I will cover a very useful option that can assist you on a daily basis to keep doing your CICD tasks without forgetting anything.<br>Ever star an issue to “check back later” and then completely forget about it? Let’s fix that with a simple GitHub Action that adds a clickable “Remind Me” button to any issue.</p><h3>What We’re Building</h3><p>A workflow that:</p><ul><li>Lets you click a button and select when to be reminded (3 days, 1 week, 2 weeks)</li><li>Posts a reminder comment tagging (labeling) you when the time comes</li><li>Works on any issue in your repo</li></ul><h3>The Labels</h3><p>We need to have a few issues created to assign the “reminder” labels to.<br>In my example, I have created 2 issues with numbers 1 &amp; 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zl-_Vdtoa36RJGDf27hPHA.jpeg" /></figure><ol><li>The first step we need to take after we have open issues, is to create the labels according to the amount days you want to get reminders for.<br>To do so, navigate to the <strong>Labels </strong>tab under the <strong>Issues </strong>menu:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*goXpYitbYhwFk8p-fzJF2g.jpeg" /></figure><p>2. Now click on New Label:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dbzY22rG9XwMeaF2pp7mqw.jpeg" /></figure><p>3. Under the name, type <strong>⏰ Reminder-set</strong> (or any other name you want), choose a new color that will be assign to the new label and click <strong>Create label</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*XqFmKqszH4SBsXQgFvlVCA.jpeg" /></figure><p>You will be able to see now the new label under the list of all exiting labels.</p><ul><li>To assign the label we have just created to the issue, just navigate to the issues menu and click on the relevant issue.</li><li>At the Labels option, click on the settings option and select the label we have just created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DORUHwWdHU-IPlvdjSn8hg.jpeg" /></figure><ul><li>By the way, you do not need to save anything, the label will automatically will be attached to the issue</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w1yBjtox9cXGfA3QE_8IKQ.jpeg" /></figure><p>You can see now that issues are set with the <strong>⏰ Reminder-set</strong> labels.</p><h3>The Workflows</h3><p>Create .github/workflows/issue-reminder.yml:</p><pre><br>name: Issue Reminder<br><br>on:<br>  workflow_dispatch:<br>    inputs:<br>      issue_number:<br>        description: &#39;Issue number to remind about&#39;<br>        required: true<br>        type: number<br>      remind_in:<br>        description: &#39;Remind me in&#39;<br>        required: true<br>        type: choice<br>        options:<br>          - &#39;1 days&#39;<br>          - &#39;3 days&#39;<br>          - &#39;1 weeks&#39;<br>          - &#39;1 month&#39;<br><br># The workflow needs permissions to modify issues. Add this to both workflow files at the top level (same level as on:)<br>permissions:<br>  issues: write<br>  contents: read<br><br>jobs:<br>  set-reminder:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Add reminder label<br>        uses: actions/github-script@v7<br>        with:<br>          script: |<br>            await github.rest.issues.addLabels({<br>              owner: context.repo.owner,<br>              repo: context.repo.repo,<br>              issue_number: ${{ inputs.issue_number }},<br>              labels: [&#39;⏰ reminder-set&#39;]<br>            });<br>            <br>            await github.rest.issues.createComment({<br>              owner: context.repo.owner,<br>              repo: context.repo.repo,<br>              issue_number: ${{ inputs.issue_number }},<br>              body: `⏰ Reminder set for **${{ inputs.remind_in }}** by @${context.actor}`<br>            });<br><br>      - name: Calculate reminder date<br>        id: date<br>        run: |<br>          case &quot;${{ inputs.remind_in }}&quot; in<br>            &quot;3 days&quot;)<br>              DAYS=3<br>              ;;<br>            &quot;1 week&quot;)<br>              DAYS=7<br>              ;;<br>            &quot;2 weeks&quot;)<br>              DAYS=14<br>              ;;<br>            &quot;1 month&quot;)<br>              DAYS=30<br>              ;;<br>          esac<br>          <br>          if [[ &quot;$OSTYPE&quot; == &quot;darwin&quot;* ]]; then<br>            REMIND_DATE=$(date -v+${DAYS}d -u +&quot;%Y-%m-%dT%H:%M:%SZ&quot;)<br>          else<br>            REMIND_DATE=$(date -u -d &quot;+${DAYS} days&quot; +&quot;%Y-%m-%dT%H:%M:%SZ&quot;)<br>          fi<br>          <br>          echo &quot;remind_date=$REMIND_DATE&quot; &gt;&gt; $GITHUB_OUTPUT<br>          echo &quot;Reminder will trigger at: $REMIND_DATE&quot;<br><br>      - name: Schedule reminder<br>        uses: actions/github-script@v7<br>        with:<br>          script: |<br>            const reminderDate = &#39;${{ steps.date.outputs.remind_date }}&#39;;<br>            const issueNumber = ${{ inputs.issue_number }};<br>            const actor = context.actor;<br>            <br>            // Store reminder data in issue comment (hidden metadata)<br>            await github.rest.issues.createComment({<br>              owner: context.repo.owner,<br>              repo: context.repo.repo,<br>              issue_number: issueNumber,<br>              body: `&lt;!-- reminder:${reminderDate}:${actor} --&gt;\n🔔 I&#39;ll remind you about this on ${new Date(reminderDate).toLocaleDateString()}`<br>            });</pre><p>Now create .github/workflows/check-reminders.yml:</p><pre>name: Check Reminders<br><br>on:<br>  schedule:<br>    - cron: &#39;0 9 * * *&#39;  # Run daily at 9 AM UTC<br>  workflow_dispatch:  # Allow manual trigger for testing<br><br># The workflow needs permissions to modify issues. Add this to both workflow files at the top level (same level as on:)<br>permissions:<br>  issues: write<br>  contents: read<br><br>jobs:<br>  check-reminders:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Check for due reminders<br>        uses: actions/github-script@v7<br>        with:<br>          script: |<br>            const now = new Date();<br>            <br>            // Search for issues with reminder label<br>            const issues = await github.rest.issues.listForRepo({<br>              owner: context.repo.owner,<br>              repo: context.repo.repo,<br>              labels: &#39;⏰ reminder-set&#39;,<br>              state: &#39;all&#39;,<br>              per_page: 100<br>            });<br>            <br>            for (const issue of issues.data) {<br>              // Get all comments on the issue<br>              const comments = await github.rest.issues.listComments({<br>                owner: context.repo.owner,<br>                repo: context.repo.repo,<br>                issue_number: issue.number<br>              });<br>              <br>              // Find reminder metadata<br>              for (const comment of comments.data) {<br>                const match = comment.body.match(/&lt;!-- reminder:(.+?):(.+?) --&gt;/);<br>                if (match) {<br>                  const reminderDate = new Date(match[1]);<br>                  const user = match[2];<br>                  <br>                  // Check if reminder is due<br>                  if (now &gt;= reminderDate) {<br>                    await github.rest.issues.createComment({<br>                      owner: context.repo.owner,<br>                      repo: context.repo.repo,<br>                      issue_number: issue.number,<br>                      body: `🔔 Hey @${user}! You asked to be reminded about this issue.\n\nIs there any update here?`<br>                    });<br>                    <br>                    // Remove the reminder label<br>                    await github.rest.issues.removeLabel({<br>                      owner: context.repo.owner,<br>                      repo: context.repo.repo,<br>                      issue_number: issue.number,<br>                      name: &#39;⏰ reminder-set&#39;<br>                    }).catch(() =&gt; {});<br>                    <br>                    // Delete the metadata comment<br>                    await github.rest.issues.deleteComment({<br>                      owner: context.repo.owner,<br>                      repo: context.repo.repo,<br>                      comment_id: comment.id<br>                    });<br>                  }<br>                }<br>              }<br>            }<br># ## How to Use It<br><br># 1. Commit both workflow files to your repo<br># 2. Create the `⏰ reminder-set` label in your repo (Settings → Labels)<br># 3. Go to Actions tab → &quot;Issue Reminder&quot; workflow<br># 4. Click &quot;Run workflow&quot;<br># 5. Enter the issue number and select when to be reminded<br># 6. Done! You&#39;ll get a comment when the reminder is due<br><br># ## What You&#39;ll See<br><br># When you set a reminder:<br># ```<br># ⏰ Reminder set for 1 week by @yourname<br># 🔔 I&#39;ll remind you about this on 2/15/2026<br># ```<br><br># When the reminder triggers (at 9 AM UTC daily):<br># ```<br># 🔔 Hey @yourname! You asked to be reminded about this issue.</pre><h3>Running the workflows</h3><p>There are basically 2 parts for running and setting the labels:</p><ol><li>Run the issue-reminder.yml workflow to set the “Remind me” label with the relevant time option, to the selected issue.</li><li>Scheduler (by cron), the check-reminders.yml workflow that reviews all issues with the <strong>⏰ Reminder-set</strong> labels and sends an alert as needed</li></ol><ul><li>In this example, I ran the issue-reminder.yml workflow and choose that Issue #2 will get a reminder in 3 days:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OoditvYofjKBJo3vclfBBg.jpeg" /></figure><ul><li>The workflow ran successfully and set the reminder to the issue:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kN4CHHIhkEm5bJhPM4Uq7g.png" /></figure><ul><li>We can also see that the label was attached to the issue and set a remider for 3 days from the issues menu:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XBGmA9suOcVfUkyLtVpXkw.png" /></figure><h3>Alerts</h3><p>When the time for a reminder will arrive, you will be able to see it under your inbox as a new alert:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJTBl5k-ib6rkU_ZqsJu-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*mNNC1Y7kwZHCsbBA6AXKFg.png" /></figure><h3>Bonus Tips</h3><p><strong>Change the reminder time:</strong> Edit the cron schedule in check-reminders.yml. Use <a href="https://crontab.guru/">crontab.guru</a> to customize.</p><p><strong>Add more time options:</strong> Just add them to the options list in the first workflow:</p><p>yaml</p><pre>options:<br>  - &#39;1 day&#39;<br>  - &#39;3 days&#39;<br>  - &#39;1 week&#39;<br>  - &#39;2 weeks&#39;<br>  - &#39;1 month&#39;</pre><p><strong>Make it team-wide:</strong> Anyone with write access can set reminders on any issue!</p><h4>Adding Email Reminder</h4><p>Update the “Check Reminders” workflow to send emails:</p><pre>name: Check Reminders<br><br>on:<br>  schedule:<br>    - cron: &#39;0 * * * *&#39;<br>  workflow_dispatch:<br><br>permissions:<br>  issues: write<br>  contents: read<br><br>jobs:<br>  check-reminders:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Check for due reminders<br>        uses: actions/github-script@v7<br>        with:<br>          script: |<br>            const now = new Date();<br>            <br>            const issues = await github.rest.issues.listForRepo({<br>              owner: context.repo.owner,<br>              repo: context.repo.repo,<br>              state: &#39;all&#39;,<br>              per_page: 100<br>            });<br>            <br>            for (const issue of issues.data) {<br>              const comments = await github.rest.issues.listComments({<br>                owner: context.repo.owner,<br>                repo: context.repo.repo,<br>                issue_number: issue.number<br>              });<br>              <br>              for (const comment of comments.data) {<br>                const match = comment.body.match(/&lt;!-- reminder:(.+?):(.+?) --&gt;/);<br>                if (match) {<br>                  const reminderDate = new Date(match[1]);<br>                  const user = match[2];<br>                  <br>                  if (now &gt;= reminderDate) {<br>                    // Post comment on issue<br>                    await github.rest.issues.createComment({<br>                      owner: context.repo.owner,<br>                      repo: context.repo.repo,<br>                      issue_number: issue.number,<br>                      body: `🔔 Hey @${user}! You asked to be reminded about this issue.\n\nIs there any update here?`<br>                    });<br>                    <br>                    // Store data for email step<br>                    core.exportVariable(&#39;REMINDER_FOUND&#39;, &#39;true&#39;);<br>                    core.exportVariable(&#39;ISSUE_NUMBER&#39;, issue.number);<br>                    core.exportVariable(&#39;ISSUE_TITLE&#39;, issue.title);<br>                    core.exportVariable(&#39;ISSUE_URL&#39;, issue.html_url);<br>                    core.exportVariable(&#39;USER_EMAIL&#39;, user);<br>                    <br>                    // Delete metadata comment<br>                    await github.rest.issues.deleteComment({<br>                      owner: context.repo.owner,<br>                      repo: context.repo.repo,<br>                      comment_id: comment.id<br>                    });<br>                  }<br>                }<br>              }<br>            }<br><br>      - name: Send email reminder<br>        if: env.REMINDER_FOUND == &#39;true&#39;<br>        uses: dawidd6/action-send-mail@v3<br>        with:<br>          server_address: smtp.gmail.com<br>          server_port: 587<br>          username: ${{ secrets.EMAIL_USERNAME }}<br>          password: ${{ secrets.EMAIL_PASSWORD }}<br>          subject: &quot;🔔 GitHub Reminder: Issue #${{ env.ISSUE_NUMBER }}&quot;<br>          to: ${{ secrets.EMAIL_TO }}<br>          from: GitHub Reminders<br>          body: |<br>            You asked to be reminded about this issue:<br>            <br>            Issue #${{ env.ISSUE_NUMBER }}: ${{ env.ISSUE_TITLE }}<br>            <br>            View it here: ${{ env.ISSUE_URL }}<br>            <br>            Is there any update?</pre><p><strong>Setup for email:</strong></p><ol><li>Go to repo Settings → Secrets and variables → Actions</li><li>Add secrets:</li></ol><ul><li>EMAIL_USERNAME: Your Gmail address</li><li>EMAIL_PASSWORD: <a href="https://support.google.com/accounts/answer/185833">App password</a> (not your regular password!)</li><li>EMAIL_TO: Email address to receive reminders</li></ul><h4>Adding Slack Reminder</h4><pre>name: Check Reminders<br><br>on:<br>  schedule:<br>    - cron: &#39;0 * * * *&#39;<br>  workflow_dispatch:<br><br>permissions:<br>  issues: write<br>  contents: read<br><br>jobs:<br>  check-reminders:<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Check for due reminders<br>        id: check<br>        uses: actions/github-script@v7<br>        with:<br>          script: |<br>            const now = new Date();<br>            let reminders = [];<br>            <br>            const issues = await github.rest.issues.listForRepo({<br>              owner: context.repo.owner,<br>              repo: context.repo.repo,<br>              state: &#39;all&#39;,<br>              per_page: 100<br>            });<br>            <br>            for (const issue of issues.data) {<br>              const comments = await github.rest.issues.listComments({<br>                owner: context.repo.owner,<br>                repo: context.repo.repo,<br>                issue_number: issue.number<br>              });<br>              <br>              for (const comment of comments.data) {<br>                const match = comment.body.match(/&lt;!-- reminder:(.+?):(.+?) --&gt;/);<br>                if (match) {<br>                  const reminderDate = new Date(match[1]);<br>                  const user = match[2];<br>                  <br>                  if (now &gt;= reminderDate) {<br>                    // Post comment on issue<br>                    await github.rest.issues.createComment({<br>                      owner: context.repo.owner,<br>                      repo: context.repo.repo,<br>                      issue_number: issue.number,<br>                      body: `🔔 Hey @${user}! You asked to be reminded about this issue.\n\nIs there any update here?`<br>                    });<br>                    <br>                    // Collect reminder info<br>                    reminders.push({<br>                      number: issue.number,<br>                      title: issue.title,<br>                      url: issue.html_url,<br>                      user: user<br>                    });<br>                    <br>                    // Delete metadata comment<br>                    await github.rest.issues.deleteComment({<br>                      owner: context.repo.owner,<br>                      repo: context.repo.repo,<br>                      comment_id: comment.id<br>                    });<br>                  }<br>                }<br>              }<br>            }<br>            <br>            return reminders;<br><br>      - name: Send Slack notification<br>        if: steps.check.outputs.result != &#39;[]&#39;<br>        uses: slackapi/slack-github-action@v1<br>        with:<br>          payload: |<br>            {<br>              &quot;text&quot;: &quot;🔔 GitHub Issue Reminder&quot;,<br>              &quot;blocks&quot;: [<br>                {<br>                  &quot;type&quot;: &quot;section&quot;,<br>                  &quot;text&quot;: {<br>                    &quot;type&quot;: &quot;mrkdwn&quot;,<br>                    &quot;text&quot;: &quot;*You have issue reminders!*\n\n${{ join(fromJSON(steps.check.outputs.result).*.title, &#39;\n&#39;) }}&quot;<br>                  }<br>                },<br>                {<br>                  &quot;type&quot;: &quot;section&quot;,<br>                  &quot;text&quot;: {<br>                    &quot;type&quot;: &quot;mrkdwn&quot;,<br>                    &quot;text&quot;: &quot;&lt;${{ fromJSON(steps.check.outputs.result)[0].url }}|View Issue #${{ fromJSON(steps.check.outputs.result)[0].number }}&gt;&quot;<br>                  }<br>                }<br>              ]<br>            }<br>        env:<br>          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}</pre><p><strong>Setup for Slack:</strong></p><ol><li>Create a Slack webhook:</li></ol><ul><li>Go to <a href="https://api.slack.com/apps">https://api.slack.com/apps</a></li><li>Create new app → “From scratch”</li><li>Enable “Incoming Webhooks”</li><li>“Add New Webhook to Workspace”</li><li>Copy the webhook URL</li></ul><p>2. Add to GitHub:</p><ul><li>Repo Settings → Secrets → Actions</li><li>Add SLACK_WEBHOOK_URL with your webhook</li></ul><h3>Why This Is Useful</h3><ul><li>No browser extensions or external tools needed</li><li>Works across all your repos once set up</li><li>Great for issues waiting on external feedback</li><li>Helps with long-running feature discussions</li><li>Perfect for “check back on this experiment” scenarios</li></ul><p>That’s it! A simple, clickable way to never forget about important issues again. What will you use it for?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a79b8a170b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Export email attachments from Exchange Online mailboxes using Microsoft Graph]]></title>
            <link>https://tkolber.medium.com/export-email-attachments-from-exchange-online-mailboxes-using-microsoft-graph-b50e93b3244c?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/b50e93b3244c</guid>
            <category><![CDATA[exchange-online]]></category>
            <category><![CDATA[email-attachment]]></category>
            <category><![CDATA[microsoft-graph-api]]></category>
            <category><![CDATA[export-attachments]]></category>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 09:11:11 GMT</pubDate>
            <atom:updated>2026-02-05T09:11:11.976Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>In this technical blog, I’ll demonstrate an effortless approach to exporting email attachments from Exchange Online mailboxes using a professional PowerShell GUI application. This tool leverages the Microsoft Graph API (MgGraph) to extract attachments from any user’s mailbox within your organization, providing a streamlined solution for a common administrative challenge.</p><p>While Microsoft Graph offers numerous powerful capabilities for managing Microsoft 365 services, this application focuses specifically on one practical use case: retrieving email attachments (excluding calendar items, tasks, and other content types) from designated mailbox folders. Through this walkthrough, you’ll see how MgGraph’s simple yet robust PowerShell commands can be combined with Windows Forms to create an enterprise-ready tool that transforms a complex task into a guided, user-friendly experience.</p><p>Whether you’re handling compliance requests, performing data migrations, or managing backup operations, this solution showcases how modern API integration and thoughtful GUI design can streamline email attachment management in Exchange Online environments.</p><h3>Deployment Considerations</h3><h4>System Requirements</h4><ul><li>Windows 10/11 or Windows Server 2016+</li><li>PowerShell 5.1 or PowerShell 7+</li><li>.NET Framework 4.7.2+</li><li>Internet connectivity for Microsoft Graph API</li></ul><h4>Execution Policy</h4><p>Users may need to adjust PowerShell execution policy:</p><p>powershell</p><pre>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser</pre><h4>First-Run Experience</h4><ol><li>Script auto-installs required modules (2–3 minutes)</li><li>Browser opens for Microsoft authentication</li><li>Admin consent may be required (one-time)</li><li>Application launches automatically</li></ol><h3>Security Considerations</h3><h4>Delegated Permissions Model</h4><p>The application uses delegated permissions, meaning:</p><ul><li>User authenticates with their own credentials</li><li>Access is limited to what the user can access</li><li>No service account credentials stored</li><li>Token-based authentication (OAuth2)</li></ul><h4>Admin Role Requirements</h4><p>Accessing other users’ mailboxes requires:</p><ul><li>Exchange Administrator role</li><li>Global Administrator role</li><li>Compliance Administrator role</li></ul><h4>Microsoft.Graph permissions</h4><ul><li>User.Read.All - Enumerate directory users for autocomplete</li><li>Mail.ReadWrite - Access mailbox content</li><li>Mail.Read.Shared - Access shared/delegated mailboxes</li><li>MailboxSettings.Read - Read mailbox configuration</li></ul><h4>Audit Trail</h4><p>All operations are logged through Microsoft 365 audit logs:</p><ul><li>Connection attempts</li><li>Mailbox access events</li><li>Message read operations</li><li>Attachment downloads</li></ul><h3><strong>Running the Tool</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*oX7kgZ3YriSaJjei3oY9uA.png" /></figure><ul><li>It is most recommended to run the tool from PowerShell or any other PowerShell platform as an Administrator to save a few headaches</li></ul><ol><li>In case you have the Microsoft.Graph module installed, the app will open and allow you to connect to Microsoft Graph.<br>In case the module was not installed, the app will download and install the module automatically for you.<br>Please pay attention that this process might take a few minutes.</li><li>Click on <strong><em>Step1: Connect to Microsoft Graph</em></strong> and login with an account that has all the needed permissions as mentioned earlier.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*g-Mfy-0j7wDxymzukyjL4A.png" /></figure><p>You will be able to see now the domain you belong to and the amount of mailboxes the application got from the EXO address list.</p><p>3. Start typing the name of the mailbox you would like to export the attachments from, and the app will autocomplete the names</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*Spk-kbQmNo2qZK0JNNSveA.png" /></figure><p>4. After choosing the right mailbox, click on <strong><em>Search User </em></strong>button<br>Then, you will get the next approval message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*t2LCDYqT0-FyoZq3_um5_w.png" /></figure><p>5. Click on <strong><em>Load Folders</em></strong><br>In case you don’t have the needed permissions for the user’s mailbox (full access), you will get the next error message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*1TvKNfYWKaAlmJpznf31iQ.png" /></figure><p>If everything is OK, the list of the mailbox’s folder will be loaded into the dropdown box, including the total number of folders inside the mailbox:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*7I75I4w-1Ha9qmlRhycFEQ.png" /></figure><ul><li><strong>I could export attachments from any email folder in the mailbox, including custom folders (like work and Temp which I have created) and even folders in Hebrew!</strong></li></ul><p>6. After selecting the user’s mailbox, the relevant folder, the date ranges of the attachments you want to export, and the folder path you want to export to, click on <strong><em>Export Attachments</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*zRcZIO4UrSPTgO6bfB8EuQ.png" /></figure><p>7. When the process finished, you will get a message that summary of the results with the amount of attachments exported</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*6d1k86NOVHroH3xbK2v5Mw.png" /></figure><p>8. Now open the path you have configured in the app and search for a folder with the name of the mailbox and the date of running the process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*odNUVebLPbHHhiAIuRBZUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*eeKjLZYb-Ekd0AB1ITZKDg.png" /></figure><h3>Technical Architecture</h3><h3>Core Technologies</h3><p><strong>1. Microsoft Graph API</strong></p><ul><li>Modern REST API for accessing Microsoft 365 services</li><li>Replaces legacy Exchange Web Services (EWS)</li><li>Provides delegated and application-level permissions</li></ul><p><strong>2. PowerShell Modules</strong></p><ul><li>Microsoft.Graph.Authentication - Handles OAuth2 authentication</li><li>Microsoft.Graph.Users - User directory operations</li><li>Microsoft.Graph.Mail - Mailbox and message operations</li></ul><p><strong>3. Windows Forms (.NET Framework)</strong></p><ul><li>Native Windows GUI framework</li><li>Rich control library for professional interfaces</li><li>Event-driven programming model</li></ul><h3>Key Features</h3><h3>1. Automatic Module Management</h3><p>The application includes intelligent module detection and installation:</p><p>powershell</p><pre>function Install-RequiredModules {<br>    $requiredModules = @(<br>        &#39;Microsoft.Graph.Authentication&#39;,<br>        &#39;Microsoft.Graph.Users&#39;,<br>        &#39;Microsoft.Graph.Mail&#39;<br>    )<br>    <br>    $missingModules = @()<br>    <br>    foreach ($module in $requiredModules) {<br>        if (-not (Get-Module -ListAvailable -Name $module)) {<br>            $missingModules += $module<br>        }<br>    }<br>    <br>    if ($missingModules.Count -eq 0) {<br>        return $true<br>    }<br>    <br>    # Install missing modules automatically<br>    foreach ($module in $missingModules) {<br>        Install-Module -Name $module -Scope CurrentUser -Force -AllowClobber<br>    }<br>}</pre><p><strong>Benefits:</strong></p><ul><li>Zero manual setup required</li><li>First-run automation</li><li>User-scoped installation (no admin rights needed)</li><li>Silent continuation when modules exist</li></ul><h3>2. OAuth2 Authentication Flow</h3><p>The application uses delegated permissions with interactive authentication:</p><p>powershell</p><pre>Connect-MgGraph -Scopes &quot;User.Read.All&quot;, <br>                        &quot;Mail.ReadWrite&quot;, <br>                        &quot;Mail.Read.Shared&quot;, <br>                        &quot;MailboxSettings.Read&quot;</pre><p><strong>Permission Breakdown:</strong></p><ul><li>User.Read.All - Enumerate directory users for autocomplete</li><li>Mail.ReadWrite - Access mailbox content</li><li>Mail.Read.Shared - Access shared/delegated mailboxes</li><li>MailboxSettings.Read - Read mailbox configuration</li></ul><h3>3. User Discovery with Autocomplete</h3><p>One of the standout features is intelligent user discovery:</p><p>powershell</p><pre># Load all users during connection<br>$allUsers = Get-MgUser -All -Property Mail, DisplayName | <br>            Where-Object { $_.Mail -ne $null }</pre><pre># Populate autocomplete collection<br>$autoCompleteCollection = New-Object System.Windows.Forms.AutoCompleteStringCollection<br>foreach ($user in $allUsers) {<br>    $autoCompleteCollection.Add($user.Mail)<br>}</pre><pre># Bind to textbox<br>$userEmailTextBox.AutoCompleteMode = &#39;SuggestAppend&#39;<br>$userEmailTextBox.AutoCompleteSource = &#39;CustomSource&#39;<br>$userEmailTextBox.AutoCompleteCustomSource = $autoCompleteCollection</pre><p><strong>User Experience Benefits:</strong></p><ul><li>Instant email address suggestions</li><li>Reduces typing errors</li><li>Familiar autocomplete behavior</li><li>Domain-aware filtering</li></ul><h3>4. Dynamic Folder Enumeration</h3><p>The application retrieves the complete folder hierarchy from the selected mailbox:</p><p>powershell</p><pre>$folders = Get-MgUserMailFolder -UserId $script:selectedUser.Id -All</pre><pre>foreach ($folder in $folders) {<br>    $folderComboBox.Items.Add($folder.DisplayName)<br>}</pre><h3>Use Cases</h3><h3>1. Compliance and eDiscovery</h3><p>Export attachments from specific users during legal holds or investigations.</p><h3>2. Mailbox Migration</h3><p>Extract attachments before migrating to new systems or archiving.</p><h3>3. Backup and Recovery</h3><p>Scheduled backup of critical attachments from executive mailboxes.</p><h3>4. Data Analysis</h3><p>Extract financial reports, invoices, or contracts for bulk processing.</p><h3>5. Onboarding/Offboarding</h3><p>Preserve departing employee attachments or restore for new employees.</p><h3>Conclusion</h3><p>This email attachment exporter demonstrates the power of combining Microsoft Graph API with PowerShell GUI development to create enterprise-grade tools. By leveraging modern authentication, intelligent user experience design, and robust error handling, the application provides a professional solution for a common administrative task.</p><p>The modular architecture and comprehensive documentation make it easy to extend and customize for specific organizational requirements. Whether used for compliance, migration, or backup purposes, this tool showcases best practices in modern Microsoft 365 administration.</p><h3>The Script</h3><p><a href="https://1drv.ms/u/c/684e16591f0e9705/IQCIbBnjlOhmTomadV3CWtcEAWyLa14PKwQaj37FN0LJNso?e=kw91S5">Export-Email-Attachments-GUI.ps1</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b50e93b3244c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshoot Azure Authentication with Terraform in DevOps Pipelines]]></title>
            <link>https://tkolber.medium.com/troubleshoot-azure-authentication-with-terraform-in-devops-pipelines-d5b860f64227?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5b860f64227</guid>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Thu, 06 Nov 2025 06:23:54 GMT</pubDate>
            <atom:updated>2025-11-06T06:23:54.320Z</atom:updated>
            <content:encoded><![CDATA[<p>Running Terraform in Azure DevOps pipelines often looks simple — until it fails with cryptic authentication errors.<br> If you’ve ever seen messages like these, you’re not alone:</p><pre>Error building ARM Config: Authenticating using the Azure CLI is only supported as a User (not a Service Principal)</pre><p>or</p><pre>Error: Error building ARM Config: obtain subscription() from Azure CLI: parsing json result from the Azure CLI: waiting for the Azure CLI: exit status 1: ERROR: Please run &#39;az login&#39; to setup account</pre><p>Both are Terraform authentication issues in Azure DevOps. Let’s break down what causes them, and how to fix them using proper Service Principal authentication.</p><h3>🔍 Understanding the Problem</h3><p>Terraform needs credentials to talk to Azure.<br> It can authenticate in several ways:</p><ul><li>Using the <strong>Azure CLI</strong> (az login)</li><li>Using a <strong>Service Principal</strong> (ARM_CLIENT_ID, ARM_CLIENT_SECRET, etc.)</li><li>Using <strong>Managed Identity</strong></li></ul><p>When running in Azure DevOps, your pipeline agent <strong>does not stay logged in</strong> to Azure CLI between jobs.<br>So, if you rely on az login or AzureCLI@2 without setting proper environment variables, Terraform fails with one of the above messages.</p><h3>💥 Common Error #1 — CLI vs Service Principal Mismatch</h3><p><strong>Error Message:</strong></p><pre>Authenticating using the Azure CLI is only supported as a User (not a Service Principal)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DRMB06dnjE42a04HGJYBVQ.png" /></figure><p><strong>Root Cause:</strong><br> Terraform is trying to authenticate via az login, but the pipeline is actually using a Service Principal. CLI-based authentication doesn’t support SPs in non-interactive environments.</p><p><strong>When It Happens:</strong></p><ul><li>Terraform uses the Azure CLI provider (use_cli = true)</li><li>No ARM_ environment variables are exported</li><li>The AzureCLI@2 login task was run incorrectly</li></ul><h3>💥 Common Error #2 — “Please run ‘az login’”</h3><p><strong>Error Message:</strong></p><pre>Error building ARM Config: obtain subscription() from Azure CLI... ERROR: Please run &#39;az login&#39; to setup account</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLUh3QfsO_ZdkUIDElbcMw.png" /></figure><p><strong>Root Cause:</strong><br> Terraform expects Azure CLI to be logged in, but the pipeline didn’t execute az login, or the session expired.<br> This is the most common failure during Terraform init/plan stages.</p><p><strong>When It Happens:</strong></p><ul><li>Missing Service Principal credentials</li><li>AzureCLI@2 wasn’t configured properly</li><li>Terraform runs without any authentication context</li></ul><h3>✅ The Correct Way — Use Service Principal Variables</h3><p>Azure DevOps pipelines should authenticate Terraform with a <strong>Service Principal</strong>, not the Azure CLI session.</p><ul><li>In my example I will use variables which are dedicate to the pipeline we are running. <br>In case you would like to use a “global” variables for all the Azure DevOps’s environment, you can use <strong>Vibrable Groups</strong>:<br><a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops&amp;tabs=azure-pipelines-ui%2Cyaml">Manage variable groups — Azure Pipelines | Microsoft Learn</a></li></ul><p>1. The first step is to create the service principal using cli with the needed scope like the whole subscription, a specific resource group, storage account or virtual machine as describe at the next link:<br><a href="https://learn.microsoft.com/en-us/cli/azure/azure-cli-sp-tutorial-1?view=azure-cli-latest&amp;tabs=bash">Create Azure service principals using the Azure CLI | Microsoft Learn</a></p><p><strong><em>az ad sp create-for-rbac --name &quot;TerraformSP&quot; --role Contributor --scopes /subscriptions/xxxxx-xxxxxx-xxx-xxxxxxxxx</em></strong></p><p>2. We will use the output of the previous command as the variables for authentication:</p><p>{<br> “appId”: “myAppId”,<br> “displayName”: “myServicePrincipalName”,<br> “password”: “myServicePrincipalPassword”,<br> “tenant”: “myTentantId”<br>}</p><p>3. Define these credentials securely in your pipeline variables, by editing your pipeline from the <strong><em>Pipelines </em></strong>menu and selecting the <strong>Variables </strong>at the top right side of the pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*0A6r7Y8U40xRqCdtrME7xQ.png" /></figure><p>4. Click the <strong>New Variables</strong> option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*OTzY7hV7SHM5kMPzQuPDtA.png" /></figure><p>5. Now we need to fill up the next 4 variables based on the outcome of the command in section 2 above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*1zoJyMY82rYxhIGkGK5Uuw.png" /></figure><ul><li>ARM_CLIENT_IDWhich is the Service Principal Application (Client) ID or the first outcome of the output in section 2 — <strong><em>myAppId </em></strong>value<strong><em>.</em></strong></li><li>ARM_CLIENT_SECRETService Principal Secret (stored as secret variable 🔒) or the third outcome of the output in section 2 — <strong><em>myServicePrincipalPassword </em></strong>value<strong><em>.<br></em></strong>Please notice that the <strong><em>Keep this value secret</em></strong> should be marked!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lqrw84HnhLQw5Tqmpp_Tsg.png" /></figure><ul><li>ARM_SUBSCRIPTION_IDIs the Azure Subscription ID</li><li>ARM_TENANT_IDAzure Is the AD Tenant ID</li></ul><p>6. At the end of the process, all the 4 variables should be filled up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*RUVTzdz4WRO-fzw2gaMyQA.png" /></figure><h3>⚙️ YAML Example — Terraform Pipeline with Proper Auth</h3><p>Here’s a simple working example that avoids both errors.<br>The 5 rows in bold, include the new environment’s setting that uses the 4 variables we have just added:</p><pre>variables:<br>  TF_VERSION: &#39;1.7.5&#39;<br>  ENV_DIR: &#39;$(System.DefaultWorkingDirectory)/terraform&#39;</pre><pre>stages:<br>- stage: Terraform<br>  jobs:<br>  - job: terraform<br>    pool:<br>      vmImage: &#39;ubuntu-latest&#39;<br>    steps:</pre><pre>    - task: TerraformInstaller@1<br>      inputs:<br>        terraformVersion: &#39;$(TF_VERSION)&#39;</pre><pre>    - task: AzureCLI@2<br>      displayName: &#39;Terraform Init &amp; Plan&#39;<br>      inputs:<br>        targetType: &#39;inline&#39;<br>        script: |<br>          cd $(ENV_DIR)<br>          terraform init<br>          terraform plan<br><strong><em>      env:<br>        ARM_CLIENT_ID: $(ARM_CLIENT_ID)<br>        ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)<br>        ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)<br>        ARM_TENANT_ID: $(ARM_TENANT_ID)</em></strong></pre><pre>displayName: &#39;Terraform Init &amp; Plan&#39;<br>      inputs:<br>        targetType: &#39;inline&#39;<br>        script: |<br>          cd $(ENV_DIR)<br>          terraform init<br>          terraform plan<br><strong><em>      env:<br>        ARM_CLIENT_ID: $(ARM_CLIENT_ID)<br>        ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)<br>        ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)<br>        ARM_TENANT_ID: $(ARM_TENANT_ID)</em></strong></pre><p><strong>Key Points:</strong></p><ul><li>You don’t need to call az login in this flow.</li><li>Terraform will pick up the ARM_ variables automatically.</li><li>Works for both hosted and self-hosted agents.</li><li>All the configured variables can be used in this way only to the pipeline that was configured.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ZHlBd2c3o_lBRCOfvRscw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pse7KyBH3_ikLsIskfpYxw.png" /></figure><h3>🧩 Summary</h3><p>ErrorCauseFixAuthenticating using Azure CLI is only supported as a UserTerraform using CLI with SPUse ARM_ variables or AzureCLI@2 correctlyPlease run &#39;az login&#39;Azure CLI session missingUse SP env vars or Azure DevOps service connection</p><h3>🚀 Final Thoughts</h3><p>Most Terraform authentication issues in Azure DevOps come from <strong>mixing authentication methods</strong>.<br> Pick <strong>one</strong> approach:</p><ul><li>Either run Terraform under AzureCLI@2 with a valid service connection,</li><li>Or pass the ARM_ environment variables for Service Principal login.</li></ul><p>Once the authentication is clean and consistent, both errors disappear — and your pipeline becomes stable, predictable, and fully automated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5b860f64227" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automating Terraform Module Documentation with terraform-docs]]></title>
            <link>https://tkolber.medium.com/automating-terraform-module-documentation-with-terraform-docs-9d8508791c3d?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d8508791c3d</guid>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Tue, 30 Sep 2025 13:48:21 GMT</pubDate>
            <atom:updated>2025-09-30T13:48:21.868Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When working with Terraform, documentation often becomes an afterthought. Variables, outputs, and requirements are defined in code, but without proper documentation, teams struggle to understand how to use a module. <br>Manually maintaining README.md files is both error-prone and time-consuming — especially as modules evolve.</p><p>This is where <strong>terraform-docs</strong> comes in. It’s a small but powerful CLI utility that automatically generates documentation directly from your Terraform code. With it, you can keep your documentation consistent, accurate, and always up to date.</p><h3>What is terraform-docs?</h3><p>terraform-docs is an open-source tool that parses Terraform modules and generates documentation in different formats, such as:</p><ul><li><strong>Markdown tables</strong> (ideal for GitHub or GitLab READMEs)</li><li><strong>JSON / YAML</strong> (for automation or integrations)</li><li><strong>Asciidoc</strong> (for enterprise wikis)</li></ul><p>Instead of writing out each variable and output manually, terraform-docs reads your variables.tf, outputs.tf, and versions.tf files and builds clean documentation for you.</p><h3>Installing terraform-docs</h3><p>Installation is straightforward and depends on your operating system.</p><h3>macOS (with Homebrew)</h3><pre>brew install terraform-docs</pre><h3>Linux</h3><p>Download the precompiled binaries from the <a href="https://github.com/terraform-docs/terraform-docs/releases">releases page</a>:</p><pre>curl -sSLo terraform-docs.tar.gz \<br>  https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz<br>tar -xzf terraform-docs.tar.gz<br>sudo mv terraform-docs /usr/local/bin/</pre><h3>Windows</h3><p>On Windows, you have two main options:</p><p><strong>Option 1: Scoop (recommended)</strong><br> If you use Scoop as a package manager:</p><pre>scoop install terraform-docs</pre><p><strong>Option 2: Manual installation</strong></p><ol><li>Go to the <a href="https://github.com/terraform-docs/terraform-docs/releases">terraform-docs releases page</a>.</li><li>Download the latest Windows binary (terraform-docs-vX.Y.Z-windows-amd64.zip).</li><li>Extract the zip file.</li><li>Add the folder containing terraform-docs.exe to your <strong>PATH</strong> environment variable.</li></ol><p>Now verify installation:</p><pre>terraform-docs --version</pre><h3>The Command Explained</h3><p>Here’s the most common way to use it:</p><pre>terraform-docs markdown table --output-file README.md .</pre><p>Breaking it down:</p><ul><li><strong>terraform-docs</strong> → runs the tool.</li><li><strong>markdown table</strong> → generates output in a clean Markdown table format.</li><li><strong>--output-file README.md</strong> → saves the documentation into README.md.</li><li><strong>.</strong> → points to the current directory, where your Terraform module lives.</li></ul><p>The result is a properly formatted section in your README containing Inputs, Outputs, Providers, and Requirements.</p><h3>Example in Action</h3><p>In my example, I’m having the main tf file called <strong>3vmscode.tf</strong> and a variable tf file called <strong>variables.tf</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*6ftbfKS-hoKpusJVbbHVcA.png" /></figure><p>Now, run:</p><pre>terraform-docs markdown table --output-file README.md .</pre><p>A README.md file will be automatically created:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6GBTvwEi44AknGJkzZOIOA.png" /></figure><p>That’s it! Instead of writing docs by hand, your module is now <strong>self-documenting</strong>.</p><p>BUT…… it doesn’t look so nice, right?<br>Well,</p><p>So, let’s just right click theREADME.md in VS Code and select <strong>Open Preview</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*HWqJI2GwOBWkbA1fqC9HnA.png" /></figure><p>Opening theREADME.md in a Preview mode, will allow us to get a more readable and organized tables with all the next objectives:</p><ol><li>All the required versions of the different vendors and providers.</li><li>The modules need to be implemented in case there are ones at the tf files.</li><li>The resource types included at the tf files.</li><li>A list of variables including all the relevant properties of each one of them.</li><li>The Output s names and descriptions in case you are using an Output file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNufg8JaAO4L6rUlHMvg4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8F0oJ3Vb53tmn3bRfOq8iw.png" /></figure><h3>Why Use terraform-docs?</h3><ol><li><strong>Consistency</strong> — All modules follow the same format.</li><li><strong>Automation</strong> — No more manual copy-paste or outdated docs.</li><li><strong>Integration</strong> — Can run in CI/CD pipelines (e.g., GitHub Actions, GitLab CI, Azure DevOps).</li><li><strong>Collaboration</strong> — Makes modules easier to consume for teammates or external users.</li></ol><h3>Advanced Usage</h3><ul><li><strong>Other formats</strong>:</li></ul><pre>terraform-docs json .<br>terraform-docs yaml .</pre><ul><li><strong>Custom config</strong>: Create a .terraform-docs.yml file to customize what sections to include (e.g., Inputs only, or hide Defaults).</li><li><strong>CI/CD integration</strong>: Add terraform-docs to your pipeline so docs regenerate automatically on every commit or pull request. This ensures your documentation never goes stale.</li></ul><h3>Automating terraform-docs in CI/CD</h3><p>One of the biggest benefits of terraform-docs is automation. Instead of relying on developers to run the command locally, you can integrate it into your CI/CD pipeline so that documentation is <strong>always in sync</strong> with your code.</p><h3>Example: GitHub Actions</h3><p>Here’s a workflow that runs terraform-docs whenever you push changes to a module:</p><pre>name: Terraform Docs</pre><pre>on:<br>  push:<br>    branches: [ &quot;main&quot; ]</pre><pre>jobs:<br>  generate-docs:<br>    runs-on: ubuntu-latest</pre><pre>    steps:<br>      - name: Checkout repository<br>        uses: actions/checkout@v3</pre><pre>      - name: Install terraform-docs<br>        run: |<br>          curl -sSLo terraform-docs.tar.gz \<br>            <a href="https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz">https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz</a><br>          tar -xzf terraform-docs.tar.gz<br>          sudo mv terraform-docs /usr/local/bin/</pre><pre>      - name: Generate README documentation<br>        run: terraform-docs markdown table --output-file README.md .<br>        <br>      - name: Commit changes<br>        run: |<br>          git config user.name &quot;github-actions[bot]&quot;<br>          git config user.email &quot;github-actions[bot]@users.noreply.github.com&quot;<br>          git add README.md<br>          git commit -m &quot;docs: update Terraform module documentation [skip ci]&quot; || echo &quot;No changes to commit&quot;<br>          git push</pre><p>This workflow will:</p><ol><li>Install terraform-docs.</li><li>Generate the Markdown table into your README.md.</li><li>Commit and push the updated file back to your repo.</li></ol><h3>Example: Azure DevOps Pipeline</h3><p>If your team uses Azure DevOps, you can add a job in your pipeline like this:</p><pre>- job: GenerateDocs<br>  displayName: &quot;Generate Terraform Docs&quot;<br>  pool:<br>    vmImage: ubuntu-latest<br>  steps:<br>    - task: Bash@3<br>      displayName: &quot;Install terraform-docs&quot;<br>      inputs:<br>        targetType: &#39;inline&#39;<br>        script: |<br>          curl -sSLo terraform-docs.tar.gz \<br>            https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz<br>          tar -xzf terraform-docs.tar.gz<br>          sudo mv terraform-docs /usr/local/bin/</pre><pre>    - task: Bash@3<br>      displayName: &quot;Generate README.md&quot;<br>      inputs:<br>        targetType: &#39;inline&#39;<br>        script: terraform-docs markdown table --output-file README.md .</pre><pre>    - task: Bash@3<br>      displayName: &quot;Commit changes&quot;<br>      inputs:<br>        targetType: &#39;inline&#39;<br>        script: |<br>          git config user.name &quot;Azure DevOps&quot;<br>          git config user.email &quot;devops@yourorg.com&quot;<br>          git add README.md<br>          git commit -m &quot;docs: update Terraform module documentation&quot; || echo &quot;No changes&quot;<br>          git push origin HEAD:$(Build.SourceBranch)</pre><p>✅ With these pipelines in place, your Terraform module documentation will always be <strong>generated automatically</strong> whenever the code changes. No more stale READMEs!</p><h3>Best Practices</h3><ul><li>Always store documentation in README.md at the root of the module.</li><li>Add terraform-docs as part of your developer workflow (or a pre-commit hook).</li><li>In CI/CD, fail builds if docs are outdated, enforcing documentation quality.</li><li>Combine generated docs with <strong>usage examples</strong> to give full context.</li></ul><h3>Conclusion</h3><p>Good documentation is just as important as good infrastructure code. With terraform-docs, you can automate the boring part — keeping your documentation accurate and consistent — and focus on building reliable Terraform modules.</p><p>Next time you create or update a Terraform module, run:</p><pre>terraform-docs markdown table --output-file README.md .</pre><p>and enjoy clean, always up-to-date documentation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d8508791c3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ From a Diagram/Picture to any code, using GitHub Copilot & VS Code]]></title>
            <link>https://tkolber.medium.com/from-azure-visualizer-to-any-code-using-github-copilot-vs-code-3b2904af4ce3?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b2904af4ce3</guid>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Tue, 08 Apr 2025 10:33:23 GMT</pubDate>
            <atom:updated>2025-05-30T08:54:35.268Z</atom:updated>
            <content:encoded><![CDATA[<p>Managing infrastructure in Azure often begins with manually setting up services in the portal. But what if you’ve already built a beautiful setup in a resource group and want to replicate it across environments or subscriptions? That’s where <strong>Azure Resource Visualizer</strong>, <strong>Terraform</strong>, and <strong>ARM templates</strong> come into play.</p><p>In this blog, we’ll explore how to:</p><ul><li>Export its structure as a visual reference</li><li>Leverage <strong>GitHub Copilot</strong> and <strong>VS Code</strong> to streamline the process, to produce a <strong>Terraform</strong> or an <strong>ARM template</strong> as Infrastructure-as-Code (IaC)</li><li>Recreate the same infrastructure in another Azure subscription</li></ul><h4>🔴 Please note that the “translated code” won’t be 100% accurate, and you may need to make minor adjustments, since not all the details of the objects appears in the diagram/picture. However, it will still save you a significant amount of time when writing or translating code.</h4><h3>📸 Export the Picture Using Azure Resource Visualizer</h3><ul><li>You can use any diagram as an input, not only from Azure Resource Visualizer of course 😁</li></ul><ol><li><strong>Go to the Azure Portal</strong>: <a href="https://portal.azure.com/">https://portal.azure.com</a></li><li><strong>Navigate to your resource group (</strong><strong>rsg)</strong></li><li>In the left menu of the resource group, click on <strong>Resource Visualizer</strong></li><li>It auto-generates a visual map of resources and their dependencies</li><li>Click <strong>Export</strong> (top right corner) → Choose <strong>PNG</strong> or <strong>SVG</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jtoDeA12VUqIQSYCewubkQ.jpeg" /></figure><blockquote><em>💡 While the visual is helpful, it doesn’t export infrastructure code — for that, continue to Step 2.</em></blockquote><h3>🧱Option 1: Translate to ARM Template with GitHub Copilot</h3><p>Now let’s translate the exported picture into an ARM Template.</p><ol><li><strong>Open VS Code</strong></li><li>Make sure the following extensions are installed:</li></ol><ul><li>✅ <a href="https://marketplace.visualstudio.com/items?itemName=GitHub.copilot">Azure Resources</a></li><li>✅ <a href="https://marketplace.visualstudio.com/items?itemName=GitHub.copilot">GitHub Copilot</a></li></ul><p>3. Open the Copilot chat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DbkjYurxu3KBd1sPMN5R6g.png" /></figure><p>4. Insert the exported jpg to the chat box and type your request, for example:</p><p><em>Please create an arm template to implement in Azure from the attached picture</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fdnm3998rLNTRRO6juiT9Q.png" /></figure><p>5. The output will contain the full ARM template for a quick implementation in Azure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7SURd5ky4RTIeTo0LqlgkQ.jpeg" /></figure><p>6. Now just copy the code and use it for IAC or deploy it in another subscription.</p><h3>📦Option 2: Translate to a Terraform code with GitHub Copilot</h3><p>Now let’s translate the exported picture into a Terraform code.</p><ol><li><strong>Open VS Code</strong></li><li>Make sure the following extensions are installed:</li></ol><ul><li>✅ <a href="https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform">Terraform</a></li><li>✅ <a href="https://marketplace.visualstudio.com/items?itemName=GitHub.copilot">GitHub Copilot</a></li></ul><p>3. Open the Copilot chat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jmDKUw7czNDaIZLKsUg7Jw.jpeg" /></figure><p>4. Insert the exported jpg to the chat box and type your request, for example:</p><p><em>Please create a Terraform script to implement in Azure from the attached picture</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P57XmdlJvkHNpyOgRI5HqQ.png" /></figure><p>5. The output will contain the Terraform code for a quick implementation in Azure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*hSfTBIUVr7nXv-1zT7agWw.jpeg" /></figure><p>6. Now just copy the code and use it for IAC or deploy it in another subscription.</p><h3>💻Option 3: Translate to CLI code with GitHub Copilot</h3><p>Now let’s translate the exported picture into a CLI code.</p><ol><li><strong>Open VS Code</strong></li><li>Make sure the following extensions are installed:</li></ol><ul><li>✅ <a href="https://marketplace.visualstudio.com/items?itemName=GitHub.copilot">GitHub Copilot</a></li></ul><p>3. Open the Copilot chat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DbkjYurxu3KBd1sPMN5R6g.png" /></figure><p>4. Insert the exported jpg to the chat box and type your request, for example:</p><p><em>Please create a cli script to implement in Azure from the attached picture</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQJL4V-ivjj9pyJtgJd-cw.jpeg" /></figure><p>5. The output will contain the full CLI code for a quick implementation in Azure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hjBCkVLdcYL_bQI-3CSqNA.png" /></figure><p>6. Now just copy the code and use it for IAC or deploy it in another subscription.</p><h3>🛠 Bonus: Helpful Tools</h3><ul><li><a href="https://github.com/Azure/aztfexport"><strong>Azure Terrafy (aztfy)</strong></a> — Converts existing Azure resources into Terraform.</li><li><strong>ARM-to-Terraform converters</strong> — ARM2TF or <a href="https://github.com/andyt530/arm2tf">arm2tf tool</a>.</li><li><strong>VS Code</strong> + <a href="https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform">Terraform plugin</a> — for comfortable IaC editing.</li></ul><h3>🧩 Conclusion: Copilot + Azure = IaC Superpowers</h3><p>GitHub Copilot is a powerful productivity enhancer when translating Azure infrastructure into reusable code — especially when working with outputs from the <strong>Azure Resource Visualizer</strong> and <strong>Export Template</strong> features.</p><p>While <strong>Azure doesn’t natively convert visuals into Terraform</strong>, combining <strong>Copilot’s AI code generation</strong> with your exported <strong>ARM templates</strong> bridges that gap. Copilot helps by:</p><ul><li>Autocompleting Terraform and ARM template syntax</li><li>Translating resource definitions faster</li><li>Reducing human error and repetitive typing</li><li>Speeding up the overall Infrastructure-as-Code workflow</li></ul><p>That said, Copilot is most effective <strong>as a smart assistant, not a replacement for your understanding</strong>. You still need to verify dependencies, naming conventions, and resource relationships — especially in complex Azure environments.</p><p>✅ <strong>Best of both worlds</strong>: Use <strong>Azure’s export capabilities</strong> for structure, and let <strong>Copilot assist in translating that structure into code you can reuse, version, and scale across subscriptions.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b2904af4ce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[List All Personal Access Tokens (PATs) expiration dates in Azure DevOps for all users.]]></title>
            <link>https://tkolber.medium.com/list-all-personal-access-tokens-pats-expiration-dates-in-azure-devops-for-all-users-7c4ed87dacef?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c4ed87dacef</guid>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Mon, 24 Mar 2025 15:51:09 GMT</pubDate>
            <atom:updated>2025-03-24T16:02:12.022Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this blog post, I will walk you through setting up an Azure DevOps pipeline using a YAML file to retrieve a list of all PATs, including their names, expiration dates, and the users who created them.</p><p>In Azure DevOps, managing and monitoring Personal Access Tokens (PATs) is crucial for security and access control.</p><p><strong>Personal Access Tokens (PATs) in Azure DevOps expire</strong> based on the duration set when they are created. While expiration is a security measure, it can cause significant issues if not properly managed. Here’s why:</p><h3>🔴 Consequences of PAT Expiration in Azure DevOps</h3><h4>1️⃣ CI/CD Pipeline Failures</h4><ul><li>Many teams use PATs for authentication in Azure DevOps <strong>pipelines</strong> to access repositories, artifacts, or external services.</li><li>If a PAT expires, <strong>automated builds, deployments, and scheduled jobs can fail</strong>, causing delays.</li></ul><h4>2️⃣ Git Authentication Issues</h4><ul><li>Developers and automated scripts often use PATs for <strong>Git operations</strong> (cloning, pushing, or pulling repositories).</li><li>When a PAT expires, users might suddenly lose access, leading to errors like:</li></ul><pre>remote: HTTP 401 Unauthorized<br>fatal: Authentication failed</pre><ul><li>This can disrupt development workflows and block critical code commits.</li></ul><h4>3️⃣ Service Integration Breakdowns</h4><ul><li>PATs are often used for <strong>integration between Azure DevOps and third-party tools</strong> (e.g., Jenkins, Terraform, external monitoring tools).</li><li>An expired token can break these integrations, leading to unmonitored services, failed deployments, or missing notifications.</li></ul><h4>4️⃣ Access Denied for Automation Scripts</h4><ul><li>Many teams use <strong>PowerShell, Python, or other scripts</strong> that rely on PATs for automating DevOps tasks (e.g., managing work items, running queries).</li><li>When a PAT expires, these scripts <strong>fail unexpectedly</strong>, causing operational headaches.</li></ul><h4>5️⃣ Production Downtime Risks</h4><ul><li>If an expired PAT is used in production-critical processes, it can lead to system outages, failed updates, or untracked incidents.</li></ul><h3>Prerequisites</h3><p>Before running the YAML pipeline, we must ensure the following prerequisites:</p><ol><li><strong>Azure DevOps access with appropriate permissions to retrieve PATs</strong>.</li></ol><p>To access and list PATs using the Azure DevOps REST API, you need to be assigned one of the following Azure DevOps security roles:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*NV_9JIw2BLvQJ1yGKWOieA.png" /></figure><p>🔹 <strong>By default, only Organization Owners and Administrators can access PATs.</strong></p><p><strong>2. Azure Key Vault configured to store the PAT securely.</strong></p><p>In my example, I have created a Key Vault named: <strong>kvdevops1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*oZy0AqrqZtItSVkWrL5mmQ.png" /></figure><p><strong>3. A service connection to access Azure Key Vault and Azure DevOps APIs.</strong></p><p>Before I will describe the technical steps to give access for an Azure DevOps service connection to a Key Vault, I would like to explain a tricky issue.</p><p>To allow a service connection access in Azure DevOps to retrieve information for all the PATs in the DevOps organization, we need………….. <strong>A PAT!</strong></p><p>So, we will store an <strong>active PAT</strong> in Azure Key Vault and use it in an API request to get an Authorization header.</p><ul><li><strong><em>Be aware that if the pipeline will suddenly stop working, probably the PAT was expired!</em></strong></li></ul><p>To allow access to Azure Key Vault for an Azure DevOps service connection, we need to add Key Vault Administrator permissions to the Key Vault and stores the PAT that allows retrieving all exiting PATs information in our Azure DevOps’s organization.</p><pre>az role assignment create - assignee &lt;your-user-id&gt; - role &quot;Key Vault Administrator&quot; - scope &quot;/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/mydevops/providers/Microsoft.KeyVault/vaults/kvdevops1&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rt23gqGe1nsC1SHW9lCOfA.png" /></figure><p><strong>4. Storing the PAT in Azure Key Vault</strong></p><ul><li>To store the PAT in Azure Key vault, just navigate to the Azure Key Vault we have created in step 2, named <strong>kvdevops1.</strong></li><li>Now navigate to <strong>Secrets </strong>and click on <strong>Generate/Import.</strong></li><li>At the name area, type <strong>DevOpsPAT</strong></li><li>At the secret value field, fill in one of your active PATs from Azure DevOps. Click <strong>create</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sf9PRVdb6bhyujgna-pA0Q.png" /></figure><ul><li>Verify that you can see the DevOpsPAT under the secrets field.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*FY8cB1QovgA4NQMUd-fwmQ.png" /></figure><p><strong>5. A configured YAML pipeline in your Azure DevOps repository.</strong></p><p>At the next paragraph, we will review the Yaml file and its different components.</p><pre>trigger: none<br><br>variables:<br><br>  - name: keyvname<br>    value: &quot;kvdevops1&quot;<br>  - name: ADOName<br>    value: tzahikolber<br>    <br>jobs:<br>- job: CheckPATExpiry<br>  steps:<br><br>   - task: AzureKeyVault@2<br>     displayName: Get PAT from KeyVault<br>     inputs:<br>      azureSubscription: DemoSA<br>      keyVaultName: &quot;$(keyvname)&quot;<br>      secretsFilter: &#39;DevOpsPAT&#39;<br>      <br>   - task: AzurePowerShell@5<br>     displayName: Get PAT expiriation date<br>     inputs: <br>          azureSubscription: DemoSA<br>          ScriptType: &#39;InlineScript&#39;<br>          Inline: | <br>            $PAT = &quot;$(DevOpsPAT)&quot;<br>            # Create the Authorization header with the provided PAT<br>            $AzureDevOpsAuthenicationHeader = @{Authorization = &#39;Basic &#39; + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(&quot;:$($PAT)&quot;)) }<br><br>            # Azure DevOps API URL for fetching users<br>            $UriUsers = &quot;https://vssps.dev.azure.com/$(ADOName)/_apis/graph/users?api-version=6.1-preview.1&quot;<br><br>            # Fetch all users<br>            $UsersResult = Invoke-RestMethod -Uri $UriUsers -Method Get -Headers $AzureDevOpsAuthenicationHeader<br><br>            # Iterate through users<br>            foreach ($user in $UsersResult.value)<br>            {<br>                # Fetch the PAT details for each user<br>                $UriUserPAT = &quot;https://vssps.dev.azure.com/$(ADOName)/_apis/tokenadmin/personalaccesstokens/$($user.descriptor)?api-version=6.1-preview.1&quot;<br>                $UserPATResult = Invoke-RestMethod -Uri $UriUserPAT -Method Get -Headers $AzureDevOpsAuthenicationHeader<br>                <br>                # Iterate through each user&#39;s PATs<br>                foreach ($up in $UserPATResult.value)<br>                {<br>                    # Check if the PAT scope is &#39;app_token&#39;, otherwise show the specific scope<br>                    if ($up.scope -eq &#39;app_token&#39;) {<br>                        $accessToken = &#39;Full access&#39;<br>                    } else {<br>                        $accessToken = $up.scope.Replace(&quot; &quot;, &quot;`r`n&quot;)<br>                    }<br><br>                    # Output the user and associated PAT information<br>                    Write-Host &quot;User: $($user.displayName)&quot;<br>                    Write-Host &quot;Scope: $accessToken&quot;<br>                    Write-Host &quot;Valid To: $($up.validTo)&quot;<br>                    Write-Host &quot;PATNAME: $($up.displayName)&quot;<br>                    Write-Host &quot;---------------------------------&quot;<br>                    <br>                    # Optionally, you could export this data to a CSV for further use<br>                    $output = [PSCustomObject]@{<br>                        UserDisplayName = $user.displayName<br>                        Scope = $accessToken<br>                        ValidTo = $up.validTo<br>                        PATNAME = $up.displayName<br>                    }<br><br>                }<br>            }<br><br>          azurePowerShellVersion: &#39;LatestVersion&#39;  <br><br><br><br></pre><h3>Breakdown of the Pipeline</h3><ul><li><em>The Yaml above is the simple version of the listing the PATs into the pipeline’s console.<br>Later on, I will demonstrate a small add-on that also creates a CSV and saves it to one of the repo’s folders.</em></li></ul><p>Before breaking the pipeline into tasks, we can configure few variables in order to make the tasks easier to read and save some work in case we are changing one of the components in the Yaml like the Key Vault name or Azure DevOps organization name.</p><h4>1. Fetching the PAT from Azure Key Vault</h4><ul><li>The AzureKeyVault@2 task securely retrieves the stored PAT from Azure Key Vault, that we created on step 4.</li></ul><h3>2. Authenticating with Azure DevOps API</h3><ul><li>The script generates an authentication header using the PAT:</li></ul><pre>$AzureDevOpsAuthenicationHeader = @{Authorization = &#39;Basic &#39; + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(&quot;:$($PAT)&quot;)) }</pre><ul><li>The API call retrieves all users from the Azure DevOps organization.</li></ul><pre>$UsersResult = Invoke-RestMethod -Uri $UriUsers -Method Get -Headers $AzureDevOpsAuthenicationHeader</pre><h3>3. Fetching PATs for Each User</h3><ul><li>The script iterates through each user and fetches their associated PATs.</li></ul><pre>$UserPATResult = Invoke-RestMethod -Uri $UriUserPAT -Method Get -Headers $AzureDevOpsAuthenicationHeader</pre><ul><li>It extracts and displays relevant details such as name, expiration date, and scope.</li></ul><pre>Write-Host &quot;User: $($user.displayName)&quot;<br>                    Write-Host &quot;Scope: $accessToken&quot;<br>                    Write-Host &quot;Valid To: $($up.validTo)&quot;<br>                    Write-Host &quot;PATNAME: $($up.displayName)&quot;<br>                    Write-Host &quot;---------------------------------&quot;</pre><h3>4. Output and Logging</h3><ul><li>The script prints the details to the pipeline logs on screen with all the parameters you need to know about all the PATs status.</li></ul><h3>Running the Pipeline</h3><p>When you run the pipeline, the first part as I mentioned, is to retrieve the PAT from the Key Vault.</p><ul><li>In case you configured the secret, and the Azure DevOps Service account has the right permissions as described on step 3, the <strong>Get PAT from KeyVault</strong> step will pass:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q3KHAuqgqXa0jbNbpgwuFw.png" /></figure><ul><li>In case that the Azure DevOps service account wasn’t assigned with the Key Vault Administrator permissions, we will get the next error at the <strong>Get PAT from KeyVault</strong> step:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgOi-p2_sMu0eAerCjCSHg.png" /></figure><ul><li>In case that the secret wasn’t configured, we will get the next error at the <strong>Get PAT from KeyVault</strong> step:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*v6BWC9VdhtzBd59_YSzVRA.png" /></figure><ul><li>After the <strong>Get PAT from KeyVault</strong> step passed successfully, we will get the list of all the PATs, expiration dates and the users that owns the PATs:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oOt5bil0JdB-Ish1i8CEQQ.png" /></figure><h3>Exporting the PAT’s details to a CSV in DevOps Repo</h3><p>In case you would like to export the PAT’s details to a CSV file in a folder at the DevOps repo, use the next pipeline, that saves the output to a file called <strong>UserPATInfo.csv</strong> at folder called <strong>Alerts</strong>.</p><pre>trigger: none<br><br>variables:<br>#  - template: ../conf/shared.ref.conf.yml<br><br>  - name: keyvname<br>    value: &quot;kvdevops1&quot;<br>  - name: ADOName<br>    value: tzahikolber<br>  - name: ProjectName<br>    value: Demo<br>  - name: FolderPath<br>    value: Alerts<br>    <br>jobs:<br>- job: CheckPATExpiry<br>  #pool: &quot;myPoolName&quot;<br>  steps:<br>   - checkout: self<br>     persistCredentials: true<br>   - task: AzureKeyVault@2<br>     displayName: Get PAT from KeyVault<br>     inputs:<br>      azureSubscription: DemoSA<br>      keyVaultName: &quot;$(keyvname)&quot;<br>      secretsFilter: &#39;DevOpsPAT&#39;<br>      <br>   - task: AzurePowerShell@5<br>     displayName: Get PAT expiriation date<br>     inputs: <br>          azureSubscription: DemoSA<br>          ScriptType: &#39;InlineScript&#39;<br>          Inline: | <br>            #Import-Module Az<br>            # Get the current date<br>            $currentDate = Get-Date<br>            $PAT = &quot;$(DevOpsPAT)&quot;<br>            # Create the Authorization header with the provided PAT<br>            $AzureDevOpsAuthenicationHeader = @{Authorization = &#39;Basic &#39; + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(&quot;:$($PAT)&quot;)) }<br><br>            # Azure DevOps API URL for fetching users<br>            $UriUsers = &quot;https://vssps.dev.azure.com/$(ADOName)/_apis/graph/users?api-version=6.1-preview.1&quot;<br><br>            # Fetch all users<br>            $UsersResult = Invoke-RestMethod -Uri $UriUsers -Method Get -Headers $AzureDevOpsAuthenicationHeader<br><br>            # Iterate through users<br>            foreach ($user in $UsersResult.value)<br>            {<br>                # Fetch the PAT details for each user<br>                $UriUserPAT = &quot;https://vssps.dev.azure.com/$(ADOName)/_apis/tokenadmin/personalaccesstokens/$($user.descriptor)?api-version=6.1-preview.1&quot;<br>                $UserPATResult = Invoke-RestMethod -Uri $UriUserPAT -Method Get -Headers $AzureDevOpsAuthenicationHeader<br>                <br>                # Iterate through each user&#39;s PATs<br>                foreach ($up in $UserPATResult.value)<br>                {<br>                    # Check if the PAT scope is &#39;app_token&#39;, otherwise show the specific scope<br>                    if ($up.scope -eq &#39;app_token&#39;) {<br>                        $accessToken = &#39;Full access&#39;<br>                    } else {<br>                        $accessToken = $up.scope.Replace(&quot; &quot;, &quot;`r`n&quot;)<br>                    }<br><br>                    # Output the user and associated PAT information<br>                    Write-Host &quot;User: $($user.displayName)&quot;<br>                    Write-Host &quot;Scope: $accessToken&quot;<br>                    Write-Host &quot;Valid To: $($up.validTo)&quot;<br>                    Write-Host &quot;PATNAME: $($up.displayName)&quot;<br>                    Write-Host &quot;---------------------------------&quot;<br>                    <br>                    # Optionally, you could export this data to a CSV for further use<br>                    $output = [PSCustomObject]@{<br>                        UserDisplayName = $user.displayName<br>                        Scope = $accessToken<br>                        ValidTo = $up.validTo<br>                        PATNAME = $up.displayName<br>                    }<br><br>                    # Define the file path inside the repository<br>                    $repoFolder = &quot;$(System.DefaultWorkingDirectory)\$(FolderPath)&quot;<br>                    $csvFilePath = &quot;$repoFolder\UserPATInfo.csv&quot;<br><br>                    # Ensure the folder exists<br>                    if (!(Test-Path -Path $repoFolder)) {<br>                        New-Item -ItemType Directory -Path $repoFolder -Force | Out-Null<br>                    }<br><br>                    # Initialize an empty CSV file (if not exists)<br>                    if (!(Test-Path -Path $csvFilePath)) {<br>                        New-Item -Path $csvFilePath -ItemType File | Out-Null<br>                    }<br><br>                    # Append the result to a CSV file<br>                    $output | Export-Csv -Path $csvFilePath -NoTypeInformation -Append<br><br>                    Write-Host &quot;CSV file saved at: $csvFilePath&quot;<br>                }<br>            }<br>          azurePowerShellVersion: &#39;LatestVersion&#39;  <br><br>   - script: |<br>              git config --global user.name &quot;tzahik77&quot;              <br>              git config --global user.email &quot;tzahik77@msft.com&quot;<br>              git checkout -b master<br>              git add .       <br>              git commit -m &quot;Updating json $csvFilePath&quot;<br>              #git push origin HEAD:master<br>              git push origin HEAD:$(Build.SourceBranchName)<br>     displayName: Commit CSV to Repository<br>     env:<br>       SYSTEM_ACCESSTOKEN: $(System.AccessToken)</pre><ul><li>After pipeline completed running, we will be able to see the csv file named UserPATInfo.csv under the Alerts folder:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*XziKxU4pBt7_AsURpOaoYA.png" /></figure><h3>🔧 Best Practices to Avoid PAT Expiration Issues</h3><p>✅ <strong>Use Azure DevOps Managed Identities or OAuth</strong> instead of PATs where possible.<br> ✅ <strong>Use Service Connections with Managed Identity</strong> for pipelines instead of hardcoding PATs.<br> ✅ <strong>Regularly Rotate PATs</strong> and track expiration dates using Azure DevOps security policies.<br> ✅ <strong>Store PATs Securely</strong> in Azure Key Vault or a secrets manager instead of embedding them in scripts.<br> ✅ <strong>Enable Alerts for PAT Expiry</strong> so teams get notified before expiration.</p><h3>Conclusion</h3><p>This YAML pipeline provides a streamlined method to audit PATs in Azure DevOps. <br>By running this pipeline regularly, you can enhance security by monitoring expiring tokens and identifying unnecessary or overly permissive PATs.</p><p>Stay proactive in managing access controls and ensure that expired or unused tokens are revoked in a timely manner.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c4ed87dacef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting a list of installed applications on a Windows core server]]></title>
            <link>https://tkolber.medium.com/getting-a-list-of-installed-applications-on-a-windows-core-server-0166ddc14e5b?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/0166ddc14e5b</guid>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Wed, 11 Dec 2024 09:15:25 GMT</pubDate>
            <atom:updated>2024-12-11T09:15:25.915Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog I will review a few options using PowerShell, to get a list of all installed applications on a windows server core in a different version.</p><p>I guess that in case you are working with Windows server core versions you are missing the <strong>appiz.cpl</strong> (control panel shortcut), which allows you easily to check which applications are installed on your system.</p><p>Although the cpl shortcuts doesn’t work anymore, there are few old (but nice) shortcuts since Windows 2008 (!!!) that still works:</p><p><a href="https://learn.microsoft.com/en-us/previous-versions/technet-magazine/dd630943(v=msdn.10)?redirectedfrom=MSDN">Commands and Tools for Managing Windows Server 2008 Server Core</a></p><h3>Option #1: Querying the registry</h3><p>The registry is the ultimate Windows’s data storage that contains everything.<br>Therefore it&#39;s an easy way to query all the installed applications by using the next command:</p><p><em>Get-ItemProperty -Path “HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*”, “HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*”, “HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*” -ErrorAction SilentlyContinue |where { $_.DisplayName -ne $null }</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*D2tlDrA6cfNW9rzvPLCCwg.jpeg" /></figure><ul><li>In case you would like to get only specific information like the name of the applications and date of installation, you can use the next command</li></ul><p><em>Get-ItemProperty -Path “HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*”, “HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*”, “HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*” -ErrorAction SilentlyContinue |where { $_.DisplayName -ne $null } | Select-Object DisplayName, DisplayVersion, InstallDate</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*VsRISwShW0dhdghTiJLMTA.jpeg" /></figure><h3>Option #2: Querying using WMI</h3><p>The WMI command-line (WMIC) utility provides a command-line interface for Windows Management Instrumentation (WMI)<br>Although <a href="https://learn.microsoft.com/en-us/windows/win32/wmisdk/wmic">WMIC is deprecated</a>, it still works on Windows Server 2025 Core!</p><p>So, to get a list of all the installed applications using WMIC, we can run the next command:</p><p><em>wmic product get name /value</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*S0D19MGdnTGjN2CUhcDeCQ.jpeg" /></figure><p>You can also export the list of installed applications to a file, export to notepad and get the content:</p><p>wmic product get &gt; list.txt ; notepad list.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*xPT2w-bOOjKdJarIqmv7Dw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vkyKZnrMzqDbPtksQuusTg.jpeg" /></figure><h3>Summery</h3><p>Working with Windows server core sometimes keeps people away because they think that they cannot get as much information as they can get from a Windows server desktop edition.<br>There are many tweaks what can help us still getting all the benefits of Windows Core server (Security &amp; Performance) and still get all the information and data from the system.<br>This blog is just a small and simple example to do it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0166ddc14e5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Passing variables in Azure Pipelines YAML tasks, jobs and stages.]]></title>
            <link>https://tkolber.medium.com/passing-variables-in-azure-pipelines-yaml-tasks-jobs-and-stages-6ce2af2f165a?source=rss-4122b7295394------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ce2af2f165a</guid>
            <category><![CDATA[yaml-conditions]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[pipelines-dependencies]]></category>
            <category><![CDATA[azure-devops]]></category>
            <dc:creator><![CDATA[Tzahi Kolber]]></dc:creator>
            <pubDate>Thu, 22 Aug 2024 15:07:34 GMT</pubDate>
            <atom:updated>2024-08-22T15:07:34.223Z</atom:updated>
            <content:encoded><![CDATA[<p>recently I found it very useful to get a variable in one task, job or even a stage, and pass them on to the next step in the Yaml file in Azure DevOps.</p><p>There are many examples out there, but still, I didn’t find a good simple Yaml with explanations, of all the important fields of it.</p><p>In this blog, I will provide 3 basic examples of passing variables between tasks, jobs and stages, with a very simple explanation for each one of the major parts involved.</p><p>Just before we start, I would like to add a list of the best links related to variables, conditions and expressions in Yamls:</p><ul><li>Variables: <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&amp;tabs=yaml%2Cbatch#share-variables-across-pipelines">Define variables — Azure Pipelines | Microsoft Learn</a></li><li>Dependencies and conditions: <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/process/stages?view=azure-devops&amp;tabs=yaml#specify-dependencies">Stages in Azure Pipelines — Azure Pipelines | Microsoft Learn</a></li><li>Expressions: <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#succeeded">Expressions — Azure Pipelines | Microsoft Learn</a></li></ul><h3>Passing variables between tasks in the same job</h3><p>In this example we will get a variable (VM name in this case) at the first task and pass it through to the next task:</p><ol><li>At the first step named <strong>vstat</strong>, I will get a list of all the virtual machines (VMs) by names and save them to a vibrable named <strong>vmnameselected.</strong></li><li>Afterwords, I will save the <strong>vmnameselected </strong>to an “output variable” inside the Yaml called <strong>vmname.<br>This output variable (vmname) will be used in the next task.</strong></li></ol><ul><li>Please notice to the format of the variable&#39;s settings!<br>In this example, when we pass a variable from task to task, the syntax will be as the following:</li></ul><pre>echo &quot;##vso[task.setvariable variable=output-vibrable]$original-vibrable&quot;</pre><h4>Examples:</h4><ol><li><strong>At the first example, the 2 conditions MUST meet:</strong></li></ol><pre>condition: and(succeeded(), contains(variables[&#39;vmname&#39;], &#39;vm1&#39;))</pre><p>A. The previous task was succeeded<br>&amp;<br>B. The variables contains <em>VM1</em></p><pre>trigger: none<br><br>jobs:<br>  - job: Variabletest<br>    steps:<br>      - task: AzureCLI@2<br>        name: vstat<br>        displayName: Get VM name variables<br>        inputs:<br>              connectedServiceNameARM: &quot;DEMOSA&quot;<br>              scriptType:  pscore<br>              scriptLocation: inlineScript<br>              inlineScript: |<br>                $vmnameselected = (az vm list | ConvertFrom-Json).name <br>                echo &quot;##vso[task.setvariable variable=vmname]$vmnameselected&quot;<br>                echo &quot;variable vmname is $vmnameselected&quot;<br><br>      - task: AzureCLI@2<br>        displayName: dependency by variable<br>        condition: and(succeeded(), contains(variables[&#39;vmname&#39;], &#39;vm1&#39;))<br>        inputs:<br>          azureSubscription: &#39;DEMOSA&#39;<br>          scriptType: &#39;pscore&#39;<br>          scriptLocation: &#39;inlineScript&#39;<br>          inlineScript: |<br>                    Write-Host &quot;##[warning] listing resource groups&quot;<br>                    (az group list | ConvertFrom-Json).name</pre><p><strong><em>The variables as we can see contain VM1 &amp; VM2</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wCWxBoTPqSyXVB0qtTxB4A.png" /></figure><p><strong>Since BOTHS 2 contentions met, the second task (dependency by vibrable) was executed.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*ls5Av5uyTTSu_dSY5Xtlww.png" /></figure><p>2. <strong>At the second example, there are 2 different conditions that MUST meet:</strong></p><pre>condition: and(succeeded(), not(contains(variables[&#39;vmname&#39;], &#39;vm1&#39;)))</pre><p>A. The previous task was succeeded<br>&amp;<br>B. The variables should <strong>NOT </strong>contain <em>VM1</em></p><pre>trigger: none<br><br>jobs:<br>  - job: Variabletest<br>    steps:<br>      - task: AzureCLI@2<br>        name: vstat<br>        displayName: Get VM name variables<br>        inputs:<br>              connectedServiceNameARM: &quot;DEMOSA&quot;<br>              scriptType:  pscore<br>              scriptLocation: inlineScript<br>              inlineScript: |<br>                $vmnameselected = (az vm list | ConvertFrom-Json).name <br>                echo &quot;##vso[task.setvariable variable=vmname]$vmnameselected&quot;<br>                echo &quot;variable vmname is $vmnameselected&quot;<br><br>      - task: AzureCLI@2<br>        displayName: dependency by variable<br>        condition: and(succeeded(), not(contains(variables[&#39;vmname&#39;], &#39;vm1&#39;)))<br>        inputs:<br>          azureSubscription: &#39;DEMOSA&#39;<br>          scriptType: &#39;pscore&#39;<br>          scriptLocation: &#39;inlineScript&#39;<br>          inlineScript: |<br>                    Write-Host &quot;##[warning] listing resource groups&quot;<br>                    (az group list | ConvertFrom-Json).name</pre><p><strong><em>The variables as we can see contain VM1 &amp; VM2</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*wCWxBoTPqSyXVB0qtTxB4A.png" /></figure><p><strong>Since only 1 condition was met, the second task (dependency by vibrable) was skipped.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*fDPBSZvviJWQedmaEq5-gA.png" /></figure><ul><li>By the way, you use many types of <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops">conditions </a>like:</li></ul><p>condition: and(succeeded(), <strong>ne</strong>(variables[‘vmname’], ‘vm1’)) <br>In case the previous task was succeeded <strong>AND </strong>the output vibrable <strong>NOT equals</strong> to vm1</p><p>condition: and(succeeded(), <strong>eq</strong>(variables[‘vmname’], ‘vm1’))<br>In case the previous task was succeeded <strong>AND </strong>the output vibrable <strong>equals </strong>to vm1</p><h3>Passing variables between jobs in the same YAML</h3><p>In this example we will get a variable (VM name in this case) at the first job and pass it through to other job in the same YAML:</p><ol><li>At the first job named <strong>GettingVariable</strong>, I will get a list of all the virtual machines (VMs) by names and save them to a vibrable named <strong>vmnameselected.</strong></li><li>Afterwords, I will save the <strong>vmnameselected </strong>to an “output variable” inside the Yaml called <strong>vmname.<br>This output variable (vmname) will be used in the next job.</strong></li></ol><ul><li>Please notice to the format of the variable’s settings!<br>In this example, when we pass a variable from one job to another job, the syntax will be as:</li></ul><pre>echo &quot;##vso[task.setvariable variable=vmname;isOutput=true]$vmnameselected&quot;</pre><ul><li>Also please notice that the condition syntax was changed:</li></ul><p>Syntax: and(succeeded(), eq(dependencies.&lt;job-name&gt;.outputs[&#39;&lt;step-name&gt;.&lt;variable-name&gt;&#39;], &#39;true&#39;))</p><h4>Examples:</h4><ol><li><strong>At the first example, the 2 conditions MUST meet:</strong></li></ol><pre>condition: and(succeeded(), contains(dependencies.GettingVariable.outputs[&#39;vstat.vmname&#39;], &#39;vm1&#39;))</pre><p>A. The previous job was succeeded<br>&amp;<br>B. The variables contain <em>VM1</em></p><ul><li>Notice that the condition’s syntax, between jobs and tasks are DIFFERENT!</li></ul><pre>trigger: none<br><br>jobs:<br>  - job: GettingVariable<br>    steps: <br>      - task: AzureCLI@2<br>        name: vstat<br>        displayName: Get VM name variables<br>        inputs:<br>              connectedServiceNameARM: &quot;DEMOSA&quot;<br>              scriptType:  pscore<br>              scriptLocation: inlineScript<br>              inlineScript: |<br>                $vmnameselected = (az vm list | ConvertFrom-Json).name <br>                echo &quot;##vso[task.setvariable variable=vmname;isOutput=true]$vmnameselected&quot;<br>                echo &quot;variable vmname is $vmnameselected&quot;<br><br>  - job: TestVariable<br>    dependsOn: GettingVariable<br>    condition: and(succeeded(), contains(dependencies.GettingVariable.outputs[&#39;vstat.vmname&#39;], &#39;vm1&#39;))<br>    steps:<br>      - task: AzureCLI@2<br>        displayName: dependency by variable<br>        inputs:<br>          azureSubscription: &#39;DEMOSA&#39;<br>          scriptType: &#39;pscore&#39;<br>          scriptLocation: &#39;inlineScript&#39;<br>          inlineScript: |<br>                    Write-Host &quot;##[warning] listing resource groups&quot;<br>                    (az group list | ConvertFrom-Json).name</pre><p><strong><em>The variables as we can see contain VM1 &amp; VM2</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*ZuZ7Fmskh5Wsi7OySix3Eg.png" /></figure><p><strong>Since BOTHS 2 contentions met, the second job (dependency by vibrable) was executed.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*T4GKBPKb_xdKrvdYPVoXAQ.png" /></figure><p>2. <strong>At the second example, there are 2 different conditions that MUST meet:</strong></p><pre>    condition: and(succeeded(), not(contains(dependencies.GettingVariable.outputs[&#39;stat.vmname&#39;], &#39;vm1&#39;)))</pre><p>A. The previous task was succeeded<br>&amp;<br>B. The variables should <strong>NOT </strong>contain <em>VM1</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*lbbeKrudeNVhRM1zVlKmMA.png" /></figure><p><strong>Since only 1 contention was met, the second task (dependency by vibrable) was skipped.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xsWDn7-DFUtrm--pEkGWXg.png" /></figure><h3>Passing variables between stages in the same YAML</h3><p>In this example we will get a variable (VM name in this case) at the first stage and pass it through to other stage in the same YAML:</p><ol><li>At the first stage named <strong>stg1</strong>, I will get a list of all the virtual machines (VMs) by names and save them to a vibrable named <strong>vmnameselected.</strong></li><li>Afterwords, I will save the <strong>vmnameselected </strong>to an “output variable” inside the Yaml called <strong>vmname.<br>This output variable (vmname) will be used in the next stage.</strong></li></ol><ul><li>Please notice to the format of the variable’s settings!<br>In this example, when we pass a variable from step to step, the syntax will be the same as job to job:</li></ul><pre>echo &quot;##vso[task.setvariable variable=vmname;isOutput=true]$vmnameselected&quot;</pre><ul><li>Please notice that the condition syntax was changed:</li><li>Syntax: and(succeeded(), eq(stageDependencies.&lt;stage-name&gt;.outputs[&#39;&lt;job-name&gt;.&lt;step-name&gt;.&lt;variable-name&gt;&#39;], &#39;true&#39;))</li></ul><h4>Examples:</h4><ol><li><strong>At the first example, the 2 conditions MUST meet:</strong></li></ol><pre>condition: and(succeeded(), contains(stageDependencies.Stg1.outputs[&#39;GettingVariable.vstat.vmname&#39;], &#39;vm1&#39;))</pre><p>A. The previous stage was succeeded<br>&amp;<br>B. The variables contain <em>VM1</em></p><ul><li>Notice that the condition’s syntax, between stages and jobs are DIFFERENT!</li></ul><pre>trigger: none<br><br>stages:<br>  - stage: Stg1<br>    jobs:<br>    - job: GettingVariable<br>      steps: <br>        - task: AzureCLI@2<br>          name: vstat<br>          displayName: Get VM name variables<br>          inputs:<br>                connectedServiceNameARM: &quot;DEMOSA&quot;<br>                scriptType:  pscore<br>                scriptLocation: inlineScript<br>                inlineScript: |<br>                  $vmnameselected = (az vm list | ConvertFrom-Json).name <br>                  echo &quot;##vso[task.setvariable variable=vmname;isOutput=true]$vmnameselected&quot;<br>                  echo &quot;variable vmname is $vmnameselected&quot;<br>                  <br>  - stage: Stg2<br>    dependsOn: stg1<br>    condition: and(succeeded(), contains(stageDependencies.Stg1.outputs[&#39;GettingVariable.vstat.vmname&#39;], &#39;vm1&#39;))<br>    jobs:<br>    - job: TestVariable<br>      steps:<br>        - task: AzureCLI@2<br>          displayName: dependency by variable<br>          #condition: and(succeeded(), ne(variables[&#39;vmname&#39;], &#39;vm1&#39;))<br>          inputs:<br>            azureSubscription: &#39;DEMOSA&#39;<br>            scriptType: &#39;pscore&#39;<br>            scriptLocation: &#39;inlineScript&#39;<br>            inlineScript: |<br>                      Write-Host &quot;##[warning] listing resource groups&quot;<br>                      (az group list | ConvertFrom-Json).name</pre><p><strong><em>The variables as we can see contain VM1 &amp; VM2</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*dJJfEXSBQhiyNOkdKlx-KQ.png" /></figure><p><strong>Since BOTHS 2 contentions met, the second stage (dependency by vibrable) was executed.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U9kjxaEdx7MB36efTkMElA.png" /></figure><p>2. <strong>At the second example, there are other 2 conditions that MUST meet:</strong></p><pre>    condition: and(succeeded(), not(contains(stageDependencies.Stg1.outputs[&#39;GettingVariable.vstat.vmname&#39;], &#39;vm1&#39;)))</pre><p>A. The previous task was succeeded<br>&amp;<br>B. The variables should <strong>NOT </strong>contain <em>VM1</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5XdXALNPqfl3iIgwnRE3w.png" /></figure><p><strong>Since only 1 contention was met, the second task (dependency by vibrable) was skipped.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*QliB1-t7z-ZFrzJPMBpVpA.png" /></figure><h3>Summery</h3><p>Using different types of expressions and conditions, we can get a lot of possibilities manipulating our tasks, jobs and stages in our YAML files for different pipeline needs.</p><p>Knowing the variety of options allows us to implement the right pipeline according to our missions and projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ce2af2f165a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>