<?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 Morsi Masmoudi on Medium]]></title>
        <description><![CDATA[Stories by Morsi Masmoudi on Medium]]></description>
        <link>https://medium.com/@morsi.masmoudi?source=rss-dc586e1b2c84------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*b_Tc2l_83nMchAgcJMSAdA.jpeg</url>
            <title>Stories by Morsi Masmoudi on Medium</title>
            <link>https://medium.com/@morsi.masmoudi?source=rss-dc586e1b2c84------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 00:39:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@morsi.masmoudi/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[Hands-On Lab: Deploy Azure SQL Managed Instance and Restore Your First Database]]></title>
            <link>https://medium.com/@morsi.masmoudi/hands-on-lab-deploy-azure-sql-managed-instance-and-restore-your-first-database-501c2a783c55?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/501c2a783c55</guid>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 08:41:08 GMT</pubDate>
            <atom:updated>2026-10-02T08:41:08.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*d_NqmG1faWjc99MUKJemRQ.png" /></figure><p>A step-by-step walkthrough, from the portal wizard to a native restore from Azure Blob Storage, including the network clean-up nobody warns you about.</p><p>If you run SQL Server on-premises and want to move to Azure with as few application changes as possible, <strong>Azure SQL Managed Instance (SQL MI)</strong> is usually the first service to evaluate. It offers near-complete compatibility with the SQL Server engine, including instance-scoped features such as SQL Server Agent and cross-database queries, while Azure takes care of patching, backups and high availability. That is why Microsoft positions it for “lift-and-shift” migrations of existing SQL Server workloads.</p><p>In this lab we deploy an instance from scratch, fix the default network settings so the instance fits a real IP plan, connect it to a hub network through peering, and finish by restoring a database from a .bak file stored in Azure Blob Storage. Along the way I point out the gotchas I ran into, so you don’t have to.</p><h3>Lab at a glance</h3><ul><li><strong>Goal:</strong> deploy a SQL MI, align its network with an enterprise addressing plan, and restore a database from Blob Storage.</li><li><strong>Level:</strong> intermediate. You should be comfortable with the Azure portal, basic VNET concepts and SSMS.</li><li><strong>Duration:</strong> plan for a full day. Creating the instance can take up to 6 hours, and the subnet move adds more waiting time.</li><li><strong>Region:</strong> West Europe.</li><li><strong>Cost:</strong> the portal estimate for this lab (General Purpose, 4 vCores, 32 GB storage, Azure Hybrid Benefit applied) was about €458 per month (Figure 3). Stop or delete the instance when you are done.</li></ul><h3>Prerequisites</h3><ul><li>An Azure subscription where you can create SQL managed instances, virtual networks and network security groups.</li><li>A hub VNET with a firewall, if you want to follow the peering step. If you don’t have one, skip Step 9.</li><li>SQL Server Management Studio (SSMS) on a machine that can reach the VNET (a VM in Azure, a VPN client, or a workstation routed through the firewall).</li><li>A SQL Server database to back up. Any database works; I used a small one named budget.</li><li>An Azure Storage account with a blob container.</li><li>A SQL Server license with Software Assurance, only if you want to use Azure Hybrid Benefit. Otherwise, use pay-as-you-go.</li></ul><h3>What we are building</h3><p>The instance lives in its own dedicated subnet, which is delegated to SQL MI and protected by an NSG and a route table. That VNET is peered with a hub network where a firewall controls access. SSMS reaches the instance through the firewall, and the instance reads the backup file directly from Blob Storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*ngJN6I_lMLahiskjAbbhBQ.png" /><figcaption><em>Figure 1 — The lab architecture: SQL MI in a dedicated, delegated subnet, peered to a hub VNET with a firewall, restoring a backup from Blob Storage.</em></figcaption></figure><p>The lab follows this sequence:</p><p>1. Create the managed instance in the portal.</p><p>2. Configure authentication.</p><p>3. Review the networking options.</p><p>4. Set security and additional settings.</p><p>5. Review and create, then wait for the deployment.</p><p>6. Replace the default address space with a compliant one and move the instance to a new subnet.</p><p>7. Recreate the NSG rules that the move did not carry over.</p><p>8. Delete the default subnet, address space and rules.</p><p>9. Peer the VNET with the firewall VNET.</p><p>10. Connect with SSMS.</p><p>11. Restore a database from Azure Blob Storage.</p><h3>Step 1 — Create the managed instance</h3><p>In the Azure portal, open <strong>SQL managed instances</strong> and click <strong>Create</strong>. On the <strong>Basics</strong> tab, select the subscription and resource group, then give the instance a name and pick a region. I used the name sqlmip001 in West Europe (Figure 2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*R2Q7_5lawv6PYCDSbknyFQ.png" /><figcaption><em>Figure 2 — Basics tab: subscription, resource group, instance name and region.</em></figcaption></figure><p>Choose the size</p><p>Under <strong>Compute + storage</strong>, click <strong>Configure Managed Instance</strong>. For this lab I picked the <strong>General Purpose</strong> tier with <strong>Standard-series (Gen 5)</strong> hardware, 4 vCores and 32 GB of storage. The estimate on the right-hand side updates as you move the sliders (Figure 3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*mHx5VLGVD16z-HG7quCn3Q.png" /><figcaption><em>Figure 3 — Compute + storage: General Purpose, Standard-series (Gen 5), 4 vCores, 32 GB. The panel on the right shows the monthly estimate.</em></figcaption></figure><p>Further down the same blade you will find the zone redundancy and license options (Figure 4).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*TgiM7-O4psa75eofnoWs1w.png" /><figcaption><em>Figure 4 — Zone redundancy and SQL Server license options.</em></figcaption></figure><blockquote><strong>Heads-up </strong>If you plan to stop and start the instance to save money, <strong>disable Zone redundancy</strong>. Microsoft’s documentation states that stop/start is available for the General Purpose tier, and the API rejects a stop request on a zone-redundant instance.</blockquote><blockquote><strong>Heads-up </strong>Only select <strong>Azure Hybrid Benefit</strong> if you own SQL Server licenses with Software Assurance. Otherwise, choose <strong>Pay-as-you-go</strong>.</blockquote><p>Finally, choose the backup storage redundancy (Figure 5). The portal reminds you that backup storage up to the size of your data storage (32 GB here) is free for point-in-time restore, and that the redundancy setting applies to both PITR and long-term retention backups.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*ISC8nbRM3_0MI-07wKCKgg.png" /><figcaption><em>Figure 5 — Backup storage redundancy.</em></figcaption></figure><h3>Step 2 — Configure authentication</h3><p>The portal now uses the name <strong>Microsoft Entra ID</strong> (formerly Azure Active Directory). I selected <strong>Use both SQL and Microsoft Entra authentication</strong>, which keeps a SQL admin login available for quick tests while letting you manage access through Entra ID (Figure 6).</p><ul><li>Set a <strong>Microsoft Entra admin</strong>. An Entra group is easier to maintain than a single user.</li><li>Create the <strong>Managed Instance admin login</strong> and a strong password, and store that password in a secure place.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*VFcecLd1ZYow_9BREBSAdA.png" /><figcaption><em>Figure 6 — Authentication: SQL and Microsoft Entra authentication, with an Entra admin and a SQL admin login.</em></figcaption></figure><h3>Step 3 — Review the networking options</h3><p>A managed instance is deployed inside a virtual network, in a subnet dedicated to it. On the <strong>Networking</strong> tab, the portal proposes a new VNET and subnet (Figure 7).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*NPu8SsC3lQI5I2U0mFklmA.png" /><figcaption><em>Figure 7 — Networking tab: Azure creates the VNET for you. Connection type, public endpoint and minimum TLS version are set here.</em></figcaption></figure><p>The wizard does not let you choose the name or the IP addressing of that new VNET. You could create the VNET beforehand, but then you also have to create the NSG yourself. When you let Azure create everything, it also creates the NSG with all the rules the instance needs to work.</p><p>For this lab, I took the VNET suggested by Azure and did not follow my usual naming conventions for VNET, subnet and NSG. The default address space is too large for a real environment, so we will fix it in Step 6.</p><p>The other settings on this tab:</p><ul><li><strong>Connection type:</strong> I left the default (Proxy) for now. We will switch to Redirect after the deployment.</li><li><strong>Public endpoint:</strong> disabled. Access happens over private networking only.</li><li><strong>Minimum TLS version:</strong> 1.2.</li></ul><h3>Step 4 — Set the security and additional options</h3><p>On the <strong>Security</strong> tab (Figure 8), I kept the defaults that fit a lab:</p><ul><li><strong>Microsoft Defender for SQL:</strong> “Not now”. The portal offers a 30-day free trial if you want to try it.</li><li><strong>Identity:</strong> system-assigned managed identity enabled.</li><li><strong>Transparent data encryption:</strong> service-managed key.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*eLHX4_oqSGQ463AchjEGSg.png" /><figcaption><em>Figure 8 — Security tab: Microsoft Defender, managed identity and Transparent Data Encryption.</em></figcaption></figure><p>On the <strong>Additional settings</strong> tab (Figure 9), two choices deserve your full attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*hCTbn4bx48ATBvA6uFoueg.png" /><figcaption><em>Figure 9 — Additional settings: collation and time zone (both fixed after creation) and the failover secondary option.</em></figcaption></figure><blockquote><strong>Heads-up </strong>The <strong>collation</strong> and the <strong>time zone</strong> cannot be changed after the instance is created. Match them to your source SQL Server. I used SQL_Latin1_General_CP1_CI_AS and the (UTC+01:00) Brussels, Copenhagen, Madrid, Paris time zone.</blockquote><p>The same tab lets you pick a <strong>maintenance window</strong> and an <strong>update policy</strong> (Figure 10). The default window limits most maintenance activity to 5 pm to 8 am, but urgent updates can still happen outside it. To keep all updates inside a window, select a non-default one. I chose 10:00 PM to 6:00 AM (W. Europe), Friday to Sunday.</p><p>For the update policy, I selected <strong>SQL Server 2022</strong> rather than Always-up-to-date. You keep receiving bug fixes and security patches, but no new engine features, and the database format stays compatible with SQL Server 2022.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*pnAoJxCv6tJXCXCQ9tHYSg.png" /><figcaption><em>Figure 10 — Maintenance window and SQL engine update policy.</em></figcaption></figure><h3>Step 5 — Review, create and wait</h3><p>Click <strong>Review + create</strong>, check the summary, then start the deployment (Figure 11).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*PNTa0MEGGTiw_BLpUBshow.png" /><figcaption><em>Figure 11 — The deployment is in progress.</em></figcaption></figure><blockquote><strong>Note </strong>The creation of a SQL MI can take <strong>up to 6 hours</strong>. Use that time for something else. You can follow the progress from the deployment page or from the resource group.</blockquote><h3>Step 6 — Re-address the network and move the instance</h3><p>Once the instance is ready, we deal with the address space. The wizard created a VNET with the default range 10.0.0.0/16, which is too large and unlikely to match your IP plan. The plan is simple: add a compliant address space, create a small subnet in it, move the instance there, then remove the defaults.</p><blockquote><strong>Heads-up </strong>I use 172.10.40.0/24 and 172.10.40.0/27 as example ranges in this lab. In your own environment, take the ranges from your IP addressing plan, and prefer private (RFC 1918) address space.</blockquote><h4>6.1 Add the new address space</h4><p>Open the VNET, go to <strong>Address space</strong>, and add a new address range. In this lab: 172.10.40.0/24 (Figure 12).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*69AtfIHTOMmyrCs7_Or4wA.png" /><figcaption><em>Figure 12 — Adding a new address space to the VNET, next to the default 10.0.0.0/16.</em></figcaption></figure><h4>6.2 Create the new subnet</h4><p>Go to <strong>Subnets</strong> and create a subnet in the new address space. Here: 172.10.40.0/27, which gives 32 addresses and is the smallest subnet size SQL MI supports (Figure 13).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*fT4me-9d9Q9wZz3MEQMTPw.png" /><figcaption><em>Figure 13 — Creating the new /27 subnet inside the new address space.</em></figcaption></figure><p>In the same pane, attach the <strong>NSG</strong> and the <strong>route table</strong> that Azure created for the instance (Figure 14), and delegate the subnet to <strong>Microsoft.Sql/managedInstances</strong> (Figure 15). Then click <strong>Save</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*j66X4uof2p5y4pJg15eXsA.png" /><figcaption><em>Figure 14 — Attaching the network security group (NSG) and the route table to the new subnet.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*eczPupnd6XaLK1s3PqSZqA.png" /><figcaption><em>Figure 15 — Delegating the subnet to Microsoft.Sql/managedInstances.</em></figcaption></figure><blockquote><strong>Heads-up </strong>Don’t skip the NSG and the route table. The subnet must have both before the instance can move into it.</blockquote><h4>6.3 Move the instance to the new subnet</h4><p>Open the managed instance, then go to <strong>Security &gt; Networking</strong> and select the new VNET and subnet (Figure 16). While you are on this blade, also set the connection type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*n2r9ojzfUzKvZ1ckWw6-cA.png" /><figcaption><em>Figure 16 — Security &gt; Networking on the managed instance: selecting the new subnet. The connection type setting sits on the same blade.</em></figcaption></figure><p>• Change <strong>Connection type (VNet local endpoint)</strong> to <strong>Redirect</strong>, which is the recommended mode. It gives better latency than Proxy, but it requires more open ports (see Step 9).</p><p>• Click <strong>Save</strong> to start the move.</p><p>The move operation takes time. Microsoft’s documentation says that the NSG rules required for the instance to work are created automatically. The portal banner on this blade adds an important detail: only the <strong>default</strong> configuration is applied to the destination subnet, so any custom rules from the source subnet must be recreated by you.</p><h3>Step 7 — Recreate the missing NSG rules</h3><p>When the move completes, check the NSG before you celebrate. In my lab, some rules had not followed the instance, both inbound and outbound.</p><h4>Inbound rules</h4><p>Figure 17 shows the inbound rules. The three custom rules in the red frame still target the old 10.0.0.0/24 subnet. Recreate them with the new subnet as the destination:</p><p>• allow_tds_inbound: TCP <strong>1433</strong>, source VirtualNetwork</p><p>• allow_redirect_inbound: TCP <strong>11000–11999</strong>, source VirtualNetwork</p><p>• allow_geodr_inbound: TCP <strong>5022</strong>, source VirtualNetwork</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*UoLCFVarMQIk6JMYJd-BsA.png" /><figcaption><em>Figure 17 — Inbound rules after the move: the three custom rules (highlighted) still point to the old 10.0.0.0/24 subnet.</em></figcaption></figure><h4>Outbound rules</h4><p>For outbound traffic, transpose the rules of the default subnet to the new one: same ports, but with the new subnet as the source and VirtualNetwork as the destination. In Figure 18, the new rules sit at priorities 200 to 230, next to the originals at 1000 to 1300:</p><ul><li>allow_linkedserver_outbound: TCP <strong>1433</strong></li><li>allow_redirect_outbound: <strong>11000–11999</strong></li><li>allow_geodr_outbound: TCP <strong>5022</strong></li><li>allow_privatelink_outbound: TCP <strong>443</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*PpXsQ1zQ1ukBwAMpwUkVcA.png" /><figcaption><em>Figure 18 — Outbound rules: the new rules (priorities 200 to 230) mirror the originals (1000 to 1300) for the new subnet.</em></figcaption></figure><h3>Step 8 — Delete the default network objects</h3><p>Once every missing rule has been recreated and verified, clean up what the wizard created:</p><p>• <strong>Delete the default subnet</strong> (10.0.0.0/24).</p><p>• <strong>Delete the default address space</strong> (10.0.0.0/16).</p><p>• <strong>Remove the NSG rules</strong> associated with the default subnet (10.0.0.0/24).</p><p><strong>Heads-up </strong>Before deleting anything, verify that all configurations and rules have been migrated. A rule that is still needed and gets deleted can interrupt connectivity.</p><h3>Step 9 — Peer the VNET with the firewall</h3><p>With the public endpoint disabled, clients reach the instance through private networking. Here, that means peering the SQL MI VNET with the VNET that hosts the firewall.</p><p>1. Open the <strong>Peerings</strong> section of the SQL MI VNET.</p><p>2. Click <strong>Add</strong> to create a new peering.</p><p>3. Set the <strong>Remote</strong> side to the firewall VNET and the <strong>Local</strong> side to the SQL MI VNET.</p><p>4. For the <strong>Remote</strong> configuration, check all options <strong>except the last one</strong>.</p><p>5. For the <strong>Local</strong> configuration, check <strong>all options</strong>.</p><p>Make sure the peering exists in both directions, so the firewall and the instance can communicate.</p><p>On the firewall, allow TCP <strong>1433</strong> and <strong>11000–11999</strong> to the instance, and allow traffic from all the IP addresses of the managed instance. These ports are needed because we switched the connection type to Redirect.</p><h3>Step 10 — Connect with SSMS</h3><p>From a machine that can reach the VNET through the firewall, open SSMS and connect to the instance’s private host name, using the SQL admin login created in Step 2 or your Entra identity. If the connection times out, the first things to check are the peering status, the firewall rules and the NSG rules from Step 7.</p><h3>Step 11 — Restore a database from Azure Blob Storage</h3><p>To complete the lab, restore any database of your choice into the new instance. The process has three parts: back up, upload, restore.</p><h4>11.1 Back up the source database</h4><p>Use SSMS or T-SQL to take a full backup on the source server. COPY_ONLY keeps the backup chain of the source database untouched:</p><pre>BACKUP DATABASE [budget]<br>TO DISK = N&#39;D:\Backup\budgzr.bak&#39;<br>WITH COPY_ONLY, COMPRESSION, CHECKSUM, STATS = 10;</pre><h4>11.2 Upload the backup to a storage account</h4><p>Upload the .bak file to a blob container in your Azure Storage account, with the Azure portal, Azure Storage Explorer or AzCopy.</p><blockquote><strong>Heads-up </strong>Check your permissions and the storage configuration before restoring. You need to be able to create a Shared Access Signature (SAS) for the container, and the managed instance must be able to reach the storage account. If the account has a firewall enabled, make sure the instance is allowed through.</blockquote><h4>11.3 Restore from SSMS</h4><p>In Object Explorer, right-click the target database and choose <strong>Tasks &gt; Restore &gt; Database</strong> (Figure 19).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*DpiswinvyV8iVf5Z0x7dpQ.png" /><figcaption><em>Figure 19 — In SSMS, right-click the database, then Tasks &gt; Restore &gt; Database.</em></figcaption></figure><p>In the <strong>Restore Database</strong> window, select <strong>Device</strong> as the source and click the <strong>…</strong> button (Figure 20).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*xwyDRwOVDvkJAxXXwih8HQ.png" /><figcaption><em>Figure 20 — Restore Database: choose Device as the source and click the … button.</em></figcaption></figure><p>In <strong>Select backup devices</strong>, set the media type to <strong>URL</strong> and click <strong>Add</strong> (Figure 21). Then, in <strong>Select a Backup File Location</strong>, click <strong>Add</strong> again to browse your Azure storage containers (Figure 22).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*M-Ml0K3vznCcezz9yTfvxw.png" /><figcaption><em>Figure 21 — Select backup devices: set the media type to URL and click Add.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*fxyUXhAaeO_eW2Rj4N3tSA.png" /><figcaption><em>Figure 22 — Select a Backup File Location: click Add to browse your Azure subscriptions.</em></figcaption></figure><p>Click <strong>Sign In</strong> and authenticate with your Azure account (Figure 23).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*KzDIQW0S1LVoQhaAMi7cTg.png" /><figcaption><em>Figure 23 — Connect to a Microsoft Subscription: sign in with your Azure account.</em></figcaption></figure><p>Select your subscription, the <strong>storage account</strong> and the <strong>blob container</strong> that holds the backup. Choose an expiration date for the SAS, then click <strong>Create Credential</strong> (Figure 24). SSMS generates the SAS and registers a SQL credential on the instance for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*C5XBCIyj4scabfzdU8RTBQ.png" /><figcaption><em>Figure 24 — Pick the storage account and the blob container, set the SAS expiration, then click Create Credential.</em></figcaption></figure><blockquote><strong>Tip </strong>Use a short SAS expiration. The credential is only needed for the restore, and you can delete it afterwards.</blockquote><p>Back in <strong>Select a Backup File Location</strong>, the container URL and the Shared Access Signature are filled in. Click <strong>OK</strong> (Figure 25), then select the backup file in the container (Figure 26).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*OE4gGiDgyI7kUZmJpHyhYQ.png" /><figcaption><em>Figure 25 — The container URL and the Shared Access Signature are now filled in.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*lBOFh0cj_iJl7GObYkbJhw.png" /><figcaption><em>Figure 26 — Selecting the backup file inside the container.</em></figcaption></figure><p>The backup URL now appears in <strong>Select backup devices</strong>. Click <strong>OK</strong> (Figure 27). Back in the Restore Database window, check the restore plan (a full database backup) and click <strong>OK</strong> to start. The title bar shows the source URL while the restore runs (Figure 28), and SSMS confirms when it is done (Figure 29).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*SaL7ulJF6WodRAMnObsAlQ.png" /><figcaption><em>Figure 27 — The backup URL is now listed as the backup media.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*Ec-CDzLvYue0Ek10fsQ6Fw.png" /><figcaption><em>Figure 28 — The restore is running. The title bar shows the source URL.</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*6A4GKYov8HsqR5F-dv-MWg.png" /><figcaption><em>Figure 29 — SSMS confirms that the database was restored.</em></figcaption></figure><h4>11.4 The T-SQL alternative</h4><p>If you prefer scripts, create the credential yourself and run the restore. The credential name must match the container URL:</p><pre>-- 1. Credential named after the container URL<br>CREATE CREDENTIAL [https://&lt;storageaccount&gt;.blob.core.windows.net/&lt;container&gt;]<br>WITH IDENTITY = &#39;SHARED ACCESS SIGNATURE&#39;,<br>     SECRET = &#39;&lt;SAS token without the leading ?&gt;&#39;;<br> <br>-- 2. Restore the database from the backup file<br>RESTORE DATABASE [budget]<br>FROM URL = &#39;https://&lt;storageaccount&gt;.blob.core.windows.net/&lt;container&gt;/budgzr.bak&#39;;</pre><h4>11.5 Verify</h4><p>Refresh Object Explorer, or run a quick query</p><pre>SELECT name, state_desc, compatibility_level<br>FROM sys.databases;</pre><h3>Troubleshooting cheat sheet</h3><p>• <strong>SSMS can’t connect or times out.</strong> Check the peering status, the firewall rules (1433 and 11000–11999) and the NSG rules on the new subnet.</p><p>• <strong>Connections work in Proxy mode but not in Redirect mode.</strong> The 11000–11999 range is blocked somewhere on the path.</p><p>• <strong>Applications lose connectivity after the subnet move.</strong> Custom NSG rules were not carried over. Recreate them (Step 7).</p><p>• <strong>The restore can’t read the backup file.</strong> Check that the SAS has not expired, that it targets the right container, and that the storage firewall lets the instance in.</p><p>• <strong>The Stop button is greyed out.</strong> Stop/start requires the General Purpose tier and an instance without zone redundancy.</p><h3>Clean up and control the cost</h3><p>• <strong>Stop the instance</strong> when you are not using it (General Purpose, zone redundancy disabled). Stopping clears the cache, so the first queries after a restart will be slower.</p><p>• <strong>Delete the lab resources</strong> when you are finished, including the resource group that contains the instance and its VNET.</p><p>• <strong>Delete the SAS credential</strong> and the blob container that holds the backup.</p><h3>Key takeaways</h3><p>• Decide on zone redundancy and licensing <strong>before</strong> creating the instance. Zone redundancy blocks stop/start.</p><p>• Collation and time zone are permanent. Choose them to match your source server.</p><p>• Letting Azure create the VNET is the safest path. Plan to re-address it afterwards.</p><p>• A subnet move does not carry custom NSG rules. Check inbound and outbound rules before deleting anything.</p><p>• Redirect mode is recommended, but it needs ports 1433 and 11000–11999 open end to end.</p><p>• Restoring from Blob Storage with a SAS is the simplest way to land your first database in SQL MI.</p><h3>Further reading</h3><p>• <a href="https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/sql-managed-instance-paas-overview?view=azuresql">What is Azure SQL Managed Instance?</a></p><p>• <a href="https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/?view=azuresql">Azure SQL Managed Instance documentation</a></p><p>• <a href="https://learn.microsoft.com/en-us/azure/azure-sql/database/sql-database-paas-overview?view=azuresql">What is the Azure SQL Database service?</a></p><p>• <a href="https://learn.microsoft.com/azure/azure-sql/managed-instance/instance-stop-start-how-to">Stop and start an instance (Azure SQL Managed Instance)</a></p><blockquote><em>Portal screenshots were taken during the lab and labels may differ slightly in newer versions of the Azure portal.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=501c2a783c55" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Escaping “Microsoft 365 from GoDaddy”: a tenant-to-tenant migration with imapsync, OAuth, and one…]]></title>
            <link>https://medium.com/@morsi.masmoudi/escaping-microsoft-365-from-godaddy-a-tenant-to-tenant-migration-with-imapsync-oauth-and-one-413f64b2c8b3?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/413f64b2c8b3</guid>
            <category><![CDATA[microsoft-365]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Fri, 31 Jul 2026 10:10:30 GMT</pubDate>
            <atom:updated>2026-07-31T10:10:30.485Z</atom:updated>
            <content:encoded><![CDATA[<h3>Escaping “Microsoft 365 from GoDaddy”: a tenant-to-tenant migration with imapsync, OAuth, and one irreversible click</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zaU1vlkBXyoPOeFPVpxONw.png" /></figure><p>When a client asked us to “move our email off GoDaddy and onto our own Microsoft 365,” we expected a fairly routine job. What we found instead was a migration that looked simple on the surface and turned out to be a tenant-to-tenant Microsoft 365 move, wrapped in two constraints that shaped every decision we made: basic authentication was disabled on the source, and the only way to free the domain was to destroy the source tenant entirely.</p><p>This is how we did it — 15 mailboxes, roughly 59 GB of mail, a domain at a third-party DNS provider, and a cutover window with no undo button. Everything here is anonymized: example.com stands in for the real domain, newtenant.onmicrosoft.com for the destination, and IDs, case numbers, and names have been stripped.</p><h3>The thing that wasn’t what it looked like</h3><p>The client bought their email years ago as “Microsoft 365 from GoDaddy.” That product is real Microsoft 365 — the mailboxes live in Exchange Online — but the tenant is provisioned and controlled by GoDaddy as a reseller. It shows up in Azure/Entra as a machine-named tenant (NETORG…), and GoDaddy holds a delegated-admin (GDAP) relationship over it.</p><p>So this was never an IMAP migration from a classic mail host like imap.secureserver.net. Both the source and the destination were Exchange Online. That reframed the whole project: we weren&#39;t importing mail into Microsoft 365, we were copying it <strong>between two Microsoft 365 tenants</strong>, and then moving the domain from one to the other.</p><p>Two facts drove the entire design:</p><ol><li><strong>You cannot verify a domain in two tenants at once.</strong> example.com could live in the GoDaddy tenant or in the new tenant, never both. Freeing it is the hard part.</li><li><strong>Basic authentication was blocked on the source tenant.</strong> A quick IMAP login test returned a1 NO AUTHENTICATE failed, and the tenant config confirmed it (BasicAuthBlockedApps, OAuth2ClientProfileEnabled: True). No username/password IMAP would work. We needed modern auth.</li></ol><h3>Copying the mail: imapsync over XOAUTH2</h3><p>We chose imapsync (Windows binary exe is here in the zip file: <a href="https://imapsync.lamiral.info/dist/">https://imapsync.lamiral.info/dist/</a>) over the native Exchange migration batches.</p><p>imapsync is incremental, resumable, and gives fine-grained control over which folders to skip — all of which mattered here. But because basic auth was dead, we had to feed it an OAuth token instead of a password, on <strong>both</strong> ends.</p><p>The setup, done symmetrically in each tenant:</p><ol><li>Register an app in Entra ID (<strong>Identity → App registrations</strong>).</li><li>Grant it the application permission <strong>IMAP.AccessAsApp</strong> (Office 365 Exchange Online API) with admin consent.</li><li>Create a client secret.</li><li>Register the service principal in Exchange Online, then scope it to the mailboxes:</li></ol><pre>New-ServicePrincipal -AppId &quot;&lt;APP_ID&gt;&quot; -ObjectId &quot;&lt;SP_OBJECT_ID&gt;&quot; -DisplayName &quot;Migration-IMAP&quot;<br><br>New-ApplicationAccessPolicy `<br>  -AppId &quot;&lt;APP_ID&gt;&quot; `<br>  -PolicyScopeGroupId &quot;migration-mailboxes@example.com&quot; `<br>  -AccessRight RestrictAccess `<br>  -Description &quot;Migration - 15 mailboxes&quot;</pre><p>A couple of things that cost us time and are worth flagging:</p><ul><li>The ObjectId in New-ServicePrincipal is the <strong>enterprise application</strong> object ID, not the app registration&#39;s. Easy to grab the wrong one.</li><li>ApplicationAccessPolicy changes take <strong>up to 30 minutes to propagate</strong>. Test too early and it looks broken when it isn&#39;t.</li><li>RestrictAccess is your friend. The app can only touch the mailboxes in the named group — a clean least-privilege boundary you can point to in any security review.</li></ul><p>imapsync consumes an app-only access token from a file. You get one via the client-credentials flow, scoped to <a href="https://outlook.office365.com/.default:">https://outlook.office365.com/.default:</a></p><pre>$body = @{<br>    client_id     = $clientId<br>    scope         = &quot;https://outlook.office365.com/.default&quot;<br>    client_secret = $clientSecret<br>    grant_type    = &quot;client_credentials&quot;<br>}<br>$resp = Invoke-RestMethod -Method Post `<br>  -Uri &quot;https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token&quot; `<br>  -ContentType &quot;application/x-www-form-urlencoded&quot; -Body $body<br>$resp.access_token | Out-File -Encoding ascii -NoNewline C:\Migration\token_source.txt</pre><p>That -Encoding ascii -NoNewline is not optional. Any trailing newline or BOM in the token file breaks XOAUTH2 authentication in a way that is genuinely painful to diagnose.</p><p>The copy command itself, per mailbox:</p><pre>imapsync.exe --addheader ^<br>  --exclude &quot;^(Calendar|Contacts|Tasks|Notes|Journal|...)&quot; ^<br>  --host1 outlook.office365.com --user1 user@example.com --oauthaccesstoken1 C:\Migration\token_source.txt ^<br>  --host2 outlook.office365.com --user2 user@newtenant.onmicrosoft.com --oauthaccesstoken2 C:\Migration\token_cible.txt</pre><p>Three hard-won details are baked into that line:</p><p><strong>--exclude is mandatory.</strong> The Calendar, Contacts, Tasks, and Notes folders aren&#39;t real IMAP mail folders; imapsync hits &quot;could not be fetched&quot; errors on them, and once it accumulates 50 errors it stops — before your mail is done. You have to exclude them explicitly. And because users had their mailboxes in different languages, the folder names varied (French, Spanish, Portuguese), so the exclude pattern had to catch Calendrier, Calendario, Calendário, and so on. One user&#39;s encoded &quot;Tasks&quot; folder (T&amp;AOI-ches in modified UTF-7) slipped through until we widened the filter.</p><p><strong>--addheader is also mandatory.</strong> Without it, imapsync silently skips Sent and Drafts. You do not want to discover that after the source is gone.</p><p><strong>Tokens live for one hour.</strong> Any mailbox over ~3 GB will outlast its token mid-transfer. The symptom is abrupt: * BYE Session invalidated - AccessTokenExpired, then a cascade of BAD Command Error on every folder. It looks catastrophic and is completely benign — regenerate the token, rerun, and imapsync picks up exactly where it left off with no duplicates. For the big mailboxes we wrapped the whole thing in a relaunch loop that regenerated the token before each pass. The largest mailbox (~13 GB, 13,000 messages) took three passes.</p><p>The initial copy ran across two days: 15 mailboxes, ~59 GB, throughput swinging from 325 KB/s to 3.5 MB/s depending on the network. One corrupt message on the source was unrecoverable; everything else came across clean.</p><h3>What imapsync does not carry</h3><p>Because we excluded them, <strong>contacts and calendars were not migrated.</strong> imapsync moves mail, full stop. We handled those as a self-service step: each user exported their contacts (.csv) and calendar (.ics) from Outlook <em>before</em> cutover and reimported them after. Not elegant, but reliable — and it kept personal data out of our hands entirely, with nothing but app-scoped tokens ever touching the mailboxes.</p><h3>The domain: the part with no undo</h3><p>Copying mail was the long pole in effort. Moving the domain was the long pole in risk.</p><p>Our strongly preferred plan was <strong>defederation</strong>: flip example.com from Federated to Managed authentication ourselves, which would let us detach it from the source tenant <em>without destroying anything</em> and keep the old tenant alive as a rollback net. Critically, defederation doesn&#39;t touch mail flow — the MX record is unchanged, mail keeps arriving — it only changes how authentication is handled. So it was safe to try.</p><p>We tried it. With a confirmed Global Admin token and Domain-InternalFederation.ReadWrite.All consented, we sent the delete against the federation configuration:</p><pre>DELETE https://graph.microsoft.com/v1.0/domains/example.com/federationConfiguration/&lt;id&gt;</pre><p>It returned <strong>403 Authorization_RequestDenied — Insufficient privileges</strong>. We ruled out the usual suspects — fresh token, correct scope, valid URL — and the conclusion was unavoidable: GoDaddy&#39;s delegated-admin (GDAP) relationship locks federation. We were Global Admin of the tenant on paper, but the reseller held the real keys. Self-service defederation was off the table.</p><p>That left exactly one path, confirmed with GoDaddy’s own support: <strong>delete the source tenant.</strong> For a “Microsoft 365 from GoDaddy” product, freeing the domain means canceling the email plans and destroying the tenant — mailboxes included — after which the domain becomes reusable in about 90 minutes to 24 hours. There is no non-destructive variant. This turns the migration’s safety model on its head: once you give GoDaddy the go-ahead, your migrated copy is the <em>only</em> copy. There is no rollback of source data, ever.</p><h3>Cutover day</h3><p>With no undo, the order of operations is everything.</p><p><strong>1. Final incremental pass — the go/no-go gate.</strong> imapsync captures a point in time. Our last full copy was days old, so any mail that arrived since then existed <em>only</em> on the source about to be deleted. So the very first thing on cutover day, before anything destructive, we regenerated tokens and ran one more incremental pass across all 15 mailboxes to catch the delta. Detected 0 errors on every mailbox was a hard gate — no green, no deletion.</p><p>One nice gotcha here: the exclude pattern that works on the command line breaks inside a Windows .bat file, because |, (, and ) are shell metacharacters. We swapped the single regex for several plain --exclude &quot;Calend&quot; --exclude &quot;Contact&quot; ... flags with no special characters.</p><p><strong>2. GoDaddy deletes the tenant — the point of no return.</strong> This isn’t self-service either; their agent canceled the email plans, removed the mailboxes (each required an email confirmation we couldn’t action, so the agent did it on their side after explicit authorization), and deleted the tenant. From this moment, the source no longer exists.</p><p><strong>3. Wait for release, then claim the domain.</strong> After the announced propagation delay, we added example.com in the new tenant (<strong>admin.microsoft.com → Domains → Add</strong>). The verification TXT record had been placed at the DNS provider days earlier, so verification was instant. Then we renamed all 15 mailboxes from their temporary @newtenant.onmicrosoft.com addresses to @example.com as the primary address and UPN.</p><p><strong>4. DNS.</strong> This is where an earlier assumption paid off. A Microsoft 365 domain’s MX value is <strong>identical regardless of which tenant owns it</strong> — example-com.mail.protection.outlook.com. What routes mail to the <em>right</em> tenant is the domain being attached to that tenant, not the MX value. So the MX record needed <strong>no change at all</strong>. What we did change at the DNS provider:</p><ul><li><strong>SPF</strong>: deleted the legacy SPF-type record (pointing at the old host) and recreated it as a <strong>TXT</strong> record — v=spf1 include:spf.protection.outlook.com -all. Two coexisting SPF records break SPF, so it&#39;s a delete-then-create, not an add.</li><li><strong>DKIM</strong>: two CNAME selectors from the new tenant&#39;s Exchange admin center, then enabled DKIM.</li><li><strong>DMARC</strong>: a TXT record at _dmarc with p=none to start.</li><li><strong>Autodiscover</strong>: already autodiscover.outlook.com, no change.</li></ul><p>We’d dropped the TTLs to 300 seconds 48 hours ahead, so propagation was 5–15 minutes. We watched it land on mxtoolbox, sent mail in from an external Gmail account, sent mail back out, and confirmed both directions with no NDRs.</p><h3>What we’d tell the next person</h3><p>A few things generalize well beyond this one job.</p><p><strong>Diagnose the migration type before you plan it.</strong> “Move us off GoDaddy” sounded like an IMAP import and was actually tenant-to-tenant. Recognizing that early is what surfaced the two real constraints instead of discovering them mid-flight.</p><p><strong>A reseller-managed tenant is not fully yours.</strong> Being Global Admin didn’t grant the ability to defederate; the GDAP lock returned a 403. If you’re on “Microsoft 365 from GoDaddy,” budget for a destructive tenant deletion and a support-desk dependency, not a clean self-service handoff.</p><p><strong>When there’s no rollback, the pre-cutover verification <em>is</em> the safety net.</strong> We treated the final imapsync pass and spot-checks as a formal go/no-go, because after the deletion there was nothing to fall back to but the copy we’d made.</p><p><strong>Know which DNS records actually matter.</strong> Half the anxiety around a mail cutover evaporates once you internalize that the M365 MX value is tenant-independent, and that reception follows domain-to-tenant attachment, not the MX record. Lowering TTLs in advance turns a scary switch into a five-minute one.</p><p>The migration succeeded: 15 mailboxes, full history preserved, the domain operational in the client’s own tenant, and users back on Outlook the next morning — free of the reseller and finally in control of their own email.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=413f64b2c8b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Hardcoding Secrets: Why Your Azure Functions Should Rely on Key Vault]]></title>
            <link>https://medium.com/@morsi.masmoudi/stop-hardcoding-secrets-why-your-azure-functions-should-rely-on-key-vault-47e192a99048?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/47e192a99048</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 13:52:13 GMT</pubDate>
            <atom:updated>2026-02-04T13:52:13.060Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFlTiF9ho8iGjYty4Uu5TA.png" /></figure><h3>Introduction</h3><p>In cloud applications, security is not a feature — it’s a fundamental responsibility. Yet many developers still hardcode sensitive secrets such as database connection strings, API tokens, or storage keys directly inside their Azure Function code or configuration files. This creates a massive security risk: if your repository is leaked, cloned, or simply shared with the wrong person, your credentials go with it.</p><p>Azure Key Vault provides a secure, centralized, and compliant way to store secrets and access them at runtime. When combined with Azure Functions and Managed Identities, it eliminates the need to embed secrets anywhere in your code.</p><p>In this article, you’ll learn:</p><ul><li>Why hardcoding secrets is dangerous</li><li>How Azure Key Vault strengthens your security posture</li><li>How to configure Azure Functions to retrieve secrets securely</li><li>Practical examples using C#, .NET, and Azure CLI</li><li>Best practices for secret rotation and access policies</li></ul><h3>1. The Problem With Hardcoded Secrets</h3><p>Developers often hardcode secrets because:</p><ul><li>It “just works”</li><li>Deployment pipelines are not well configured</li><li>They assume the repository is private</li><li>They forget that logs, dumps, and backups may expose values</li></ul><h3>Risks include:</h3><ul><li>Accidental exposure through GitHub or package registries</li><li>Compromised developers’ machines</li><li>Difficulty rotating secrets across environments</li><li>Compliance violations (GDPR, ISO, SOC, PCI…)</li><li>Secrets leaking in logs or telemetry</li></ul><p><strong>Hardcoding secrets is not only insecure — it’s also operationally fragile.</strong></p><h3>2. Azure Key Vault: A Safer Alternative</h3><p>Azure Key Vault is designed to store:</p><ul><li>Secrets</li><li>Keys</li><li>Certificates</li></ul><h3>Key benefits</h3><ul><li><strong>Centralized secret management</strong></li><li><strong>Easy secret rotation</strong></li><li><strong>Full access control with RBAC and policies</strong></li><li><strong>Automatic integration with managed identities</strong></li><li><strong>Audit logs for compliance</strong></li></ul><h3>3. Recommended Architecture</h3><p>A clean architecture for Azure Functions with Key Vault looks like this:</p><pre>+------------------------+<br>| Azure Function App     |<br>| - No secrets inside!   |<br>+-----------+------------+<br>            |<br>            | Managed Identity (no password)<br>            |<br>+-----------v------------+<br>|     Azure Key Vault    |<br>|  Stores secrets safely |<br>+------------------------+</pre><p>Your Function App uses its <strong>Managed Identity</strong> to authenticate to Key Vault without needing credentials.</p><h3>4. Enabling Managed Identity on Your Azure Function</h3><h3>Step 1 — Enable the identity</h3><p>In Azure Portal:</p><p><strong>Function App → Identity → System Assigned → ON</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pKHCi0AXJG7GzpJ6ik4SHA.png" /></figure><p>Or with Azure CLI:</p><pre>az functionapp identity assign \<br>  --name MyFunctionApp \<br>  --resource-group MyResourceGroup</pre><h3>5. Grant Access to Key Vault</h3><p>The managed identity must be allowed to retrieve secrets.</p><p>Indeed, it is essential to ensure that no other resources or accounts can access the Key Vault or view its secrets. Only the Managed Identity should have the necessary permissions to do so.</p><p>In your Azure Key Vault from Azure Portal, go to the <em>Access policies </em>menu and then select “<em>+ Create”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*heWjqAoWpz1XsoG_XmMqnA.png" /></figure><p>Start by choosing the permissions. Since we only need to read the secrets, the permission should be set to ‘get’ and ‘list’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cngofu0VNLoXGOKTLTxzyw.png" /></figure><p>Of course, depending on your needs, you can choose permissions on keys, secrets, or certificates. You can also grant additional permissions such as ‘list’, ‘create’, or others if required.</p><p>In this next step, you will select your Managed Identity — in this case, the Azure Function — by searching for it in the directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GS2PvOnHsgBRCSfHFTl2mQ.png" /></figure><p>Next, Next and then create …</p><p>After creating it, we will observe that the application has been added to the Access Policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UDnPvJoQIm3fUKDN-0_7IA.png" /></figure><h3>Using Azure CLI:</h3><pre>az keyvault set-policy \<br> - name MyKeyVault \<br> - object-id &lt;MANAGED_IDENTITY_PRINCIPAL_ID&gt; \<br> - secret-permissions get list</pre><h3>6. Accessing Key Vault Secrets from Azure Functions</h3><p>The simple approache is using Configuration Binding (@Microsoft.KeyVault)</p><p>Azure App Configuration allows built‑in Key Vault references.</p><h3>Inside Application Settings:</h3><p>Now, to read our secret, we will add an environment variable and point its value to the Key Vault reference we previously configured.</p><p>Create your vairable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSXNif45GgmC-CtZLPAfdQ.png" /></figure><p>Give the variable a clear and identifiable name, and then in the value field you must enter:</p><pre>@Microsoft.KeyVault(SecretUri=https://my-keyvault.vault.azure.net/secrets/DatabasePassword/versionXXXXX)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k885IMivVIfXggaEkgVjBA.png" /></figure><p>versionxxx represents the version ID of the secret.</p><p>After validating the configuration, you should see that the environment variable successfully connects to the Key Vault.</p><p>If something goes wrong (such as missing permissions, forgotten Managed Identity assignment, or other access issues), the variable will simply fail to retrieve the secret’s value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IVdgWJMNzph36X4pc6dCjg.png" /></figure><p>Now your function simply reads:</p><pre>string secret = Environment.GetEnvironmentVariable(&quot;MySecret&quot;);</pre><p><strong>Simple and secure.</strong></p><h3>7. Best Practices</h3><ul><li>Always use Managed Identity : Never store client IDs or passwords in configuration.</li><li>Use separate Key Vaults per environment : Production secrets should never touch dev/staging.</li><li>Enable logging and auditing : Use Azure Monitor and Key Vault diagnostics.</li><li>Rotate secrets periodically : Either manually or using Azure Automation.</li><li>Never log secrets : Mask values before logging.</li></ul><h3>8. Conclusion</h3><p>Hardcoding secrets in Azure Functions may seem convenient, but it exposes your application to avoidable risks. By using Azure Key Vault with Managed Identities, you ensure:</p><ul><li>No secrets in code</li><li>Full control over access</li><li>Simplified rotations</li><li>Compliance with security standards</li></ul><p>Integrating Key Vault into Azure Functions is not only best practice — it’s essential for any cloud‑native application that handles sensitive data.</p><p>Please feel free to ask me questions and make comments :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47e192a99048" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to restore a local database on an Azure SQL Managed Instance]]></title>
            <link>https://medium.com/@morsi.masmoudi/how-to-restore-a-local-database-on-an-azure-sql-managed-instance-99c9bede5065?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/99c9bede5065</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[sql-managed-instance]]></category>
            <category><![CDATA[paas]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 14:52:48 GMT</pubDate>
            <atom:updated>2024-09-23T14:52:48.664Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QPbKS79GiDX7Zs1yLAc1gw.png" /></figure><p>The purpose of this article is to demonstrate how to restore a database from a local server to an Azure SQL Managed Instance database.</p><p>In other articles, we will discuss the choice of Azure instances and other SQL database options in Azure, but that is not the focus of our article</p><h3>1.Create a backup of your local database</h3><p>The first step is very simple.</p><p>You just need to create a backup of the database with the .bak extension.</p><p>Simply go to your database server, choose the database to back up:</p><ul><li>right-click on the database,</li><li>select Tasks,</li><li>then Back Up…</li><li>choose a location, and click OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*hbC4ym1amkBiNkedtmQz1w.png" /></figure><p>A few moments later:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*B6hrs95GSSDRjlIUPZysLQ.png" /></figure><h3>2.Copy the backup to an Azure storage account</h3><p>The SQL Managed Instance database only accepts restoring databases from URLs on storage accounts.</p><p>Therefore, we need to transfer our .bak backup to an Azure storage account that we created beforehand.</p><p>To do this, we will use the AzCopy command.</p><p>If you don’t have AzCopy, download it from this address.</p><p><a href="https://learn.microsoft.com/fr-fr/azure/storage/common/storage-use-azcopy-v10?tabs=dnf#download-the-azcopy-portable-binary">Copier ou déplacer des données vers Stockage Azure avec AzCopy v10 | Microsoft Learn</a></p><p>It’s an executable; simply download it and run the executable.</p><p>Connect to your Azure tenant and launch Sign in:</p><p>.\azcopy login</p><p>This command will redirect you to a web URL with an authentication code. Copy the code into your browser to log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*ZhMDjNrPOLWajsuFLz-oBA.png" /></figure><p>And after authentication:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*dvuuHLBAi-7wBp98YReEtw.png" /></figure><p>Run the copy command:</p><pre>.\azcopy copy &#39;source&#39; &#39;destination&#39;</pre><p>To obtain the destination path, go to the container and generate a SAS with write permissions (in the screenshot it’s a read permission but it must be write permission for the SAS)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*kI9yXQJS93nudtipJL6-1w.png" /></figure><p>In my case, I will use permissions on the storage account (rather than the SAS key), which is why I went through the step of connecting to the tenant as the very first step.</p><p>I am checking if I have the permissions.</p><p>I need to have the “<strong>Storage Blob Data Contributor</strong>” role on the storage account.</p><p>If I don’t have this role, I must ask an administrator to add this role for me on the specific storage account.</p><p>I can run now the AzCopy command</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LMGeKo9XQTxa3-vo2jhVkw.png" /></figure><h3>3. Restore the database on the SQL Managed Instance.</h3><p>Connect to the VM that has an open connection to the SQL MI, and launch SSMS.</p><p>Right-click on database folder, select Restore Database ..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*HxxZ8GeDWi07xPECId9awA.png" /></figure><blockquote><strong>Take care, all next steps will be shown as screenshots</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ed14coIGKTGQfF0QYnNlnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*_u2wgVnt4gySkE2l2M7_iA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EuBmVwlzfkJvi2BYHgIKjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-MFg-259caRh6Q7t5YRLyA.png" /></figure><p>You will be redirect to a web browser and you must enter your Azure credential, after that you will see :</p><blockquote>Authentication complete. You can return to the application. Feel free to close this browser tab.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CGiv7fSFQR-lZ0-8t7dvLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQF3rE4yJ7QbRTeNvY6Bsg.png" /></figure><p>Pickup your container and your database backup</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EKEXnFqeNL_MjIH9htd8uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*pJF0ZV8sOT2UnvkNoN22fg.png" /></figure><p>Click on “Ok” and the restore process begin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gnwzw_2ZnsG9vJ-egcBU2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*wjscV2PiBdg1aC5zJX2GeA.png" /></figure><h3>4.Some other information to know</h3><p>The restore process does not allow using the same managed database name to overwrite it.</p><p>You will need to restore it with a different database name and then perform the renaming operation afterward.</p><p><a href="https://learn.microsoft.com/en-us/azure/azure-sql/database/recovery-using-backups?view=azuresql&amp;tabs=azure-portal">Restore a database from a backup — Azure SQL Database | Microsoft Learn</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uU9oo6Rdducis_L4XRfqxw.png" /></figure><p>By default, the backup retention period is 7 days, but you can change this in the policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qS4xKqLd-7kGNzpg3PokMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*XNyyfiJmywf1jbdl_VPlQw.png" /></figure><p>If you delete a database, all backups of that database will also be deleted.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99c9bede5065" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All You Need to Know About Azure Load Balancer]]></title>
            <link>https://medium.com/@morsi.masmoudi/all-you-need-to-know-about-azure-load-balancer-bab07462253b?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/bab07462253b</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[iaas]]></category>
            <category><![CDATA[load-balancer]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 14:13:21 GMT</pubDate>
            <atom:updated>2024-06-10T14:13:21.164Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dHJG4NZyaQgXwmqtVroonQ.png" /></figure><p>In this article, you will understand everything you need to know about the Azure Load Balancer.</p><p>The role of a load balancer is to improve the availability of services by distributing the load across a pool of backend servers.</p><p>Regarding load balancing, Azure offers several different products:</p><ul><li><strong>Azure Application Gateway</strong> — If you need a load balancer that can provide features such as SSL offloading, reverse proxy, and operates at the application layer (layer 7), Azure Application Gateway is the answer.</li><li><strong>Azure Load Balancer</strong> — The Azure Load Balancer operates at layer 4 (transport layer) and can distribute network traffic to endpoints within the same Azure region. It can be used to distribute both internet traffic and internal traffic. In this article, we will examine this service in detail.</li><li><strong>Azure Traffic Manager </strong>— If you are looking for DNS-level load balancing capable of distributing traffic to global endpoints, Azure Traffic Manager will be the product to examine.</li></ul><p>Here is the architecture we will deploy in our article:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KCZc-ORAa81FyhAb.png" /></figure><h3>Creating the Load Balancer</h3><p>Sign in to the Azure portal and navigate to the “Load Balancers” service.</p><p>Click on “Add” to start the process of creating a new load balancer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/0*7ZmxQVGRXZnyeIAc.jpg" /></figure><p>In the “Basics” tab of the Create Load Balancer page, enter the necessary information for creation such as the Azure subscription or resource group, accept the default values for the remaining parameters, then select “Review + create”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/0*mMCalsrVxWQhHZF-.png" /></figure><p>The creation operation is quick, and we end up with our resources in the resource group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/0*TYhdM1Qx0UcfCEgD.png" /></figure><h3>Creating a Virtual Network</h3><p>Search for “Virtual network”, and then “Create”</p><p>Enter the necessary information in the “Basics” tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y_mFdF1jVb0lzuQw.png" /></figure><p>You’ll notice that we’ve chosen the same region as our “Load Balancer” as well as the same resource group.</p><p>In the “IP Addresses” tab, add the addressing below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/0*QVUgS47X_9eKzyIy.png" /></figure><p>Change the name of the default subnet to “myBackEndSubnet”, then “Review + create”.</p><h3>Create a Backend Pool</h3><p>A backend pool contains the IP addresses of the virtual machine network interfaces (NICs) connected to the Load Balancer.</p><p>Find your Load Balancer (named myLoadBalancer)</p><p>Settings &gt;&gt; Backend pools &gt;&gt; Add.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i_GwzPmSCYOfXUXt.png" /></figure><p>Here are the details to fill in the “Add a backend pool” section:</p><p>Once you’ve entered the details, click “Add” to create the backend pool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/0*rGP_zikVOJ0XJJX7.png" /></figure><h3>Create a Health Probe</h3><p>This probe will allow the detection of the endpoint’s status.</p><p>The Load Balancer monitors the state of your application with this health probe. The health probe adds or removes virtual machines from the load balancer based on their response to the health checks.</p><p>In the Load Balancer, select Settings &gt;&gt; Health probes &gt;&gt; Add.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xN_1LiXthtnsmgEm.png" /></figure><p>Here are the details to enter in the “Add a health probe” section:</p><ul><li>Name: myHealthProbe</li><li>Protocol: Http</li><li>Port: 80</li><li>Path: /</li><li>Interval: 15 (seconds)</li><li>Unhealthy threshold: 2</li></ul><p>Once you have entered this information, click “OK” to create the health probe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/0*qLkw0RtXzxqxhRc7.png" /></figure><h3>Create a Load Balancing Rule</h3><p>A load balancing rule is used to define how traffic is distributed to the virtual machines.</p><p>You define the frontend IP configuration for the incoming traffic and the backend IP pool to receive the traffic.</p><p>The source and destination ports are defined in the rule.</p><p>Still in your “myLoadBalancer” Load Balancer, select Settings &gt;&gt; Load balancing rules &gt;&gt; Add</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lf3RGP3-GCI1RSne.png" /></figure><p>Use these values to configure the load balancing rule, then select OK.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*9iyTWvZT67QHiGvs.png" /></figure><h3>Configure two new Windows Virtual Machines</h3><p>Create the two virtual machines in an availability set and select the virtual network created earlier named “myVNet” under the Networking tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/0*mR-T-Obu9Ph-puQ9.png" /></figure><h4>Install IIS for Testing</h4><p>Install the IIS web server on the virtual machines to test the load balancer.</p><p>Run the following command in the Azure Cloud Shell (PowerShell) to install IIS on the virtual machine.</p><p>Modify the Location and Resource Group parameters based on what you have chosen.</p><blockquote>Set-AzVMExtension -ResourceGroupName LBresourcegroup<br>-ExtensionName IIS -VMName VM2<br>-Publisher Microsoft.Compute -ExtensionType CustomScriptExtension<br>-TypeHandlerVersion 1.4 -SettingString &#39;{&quot;commandToExecute&quot;:&quot;powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \&quot;C:\\inetpub\\wwwroot\\Default.htm\&quot; -Value $($env:computername)&quot;}&#39;<br>-Location FranceCentral</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xptV9ncexL3zG08Y.png" /></figure><p>Do the same for VM2.</p><h4>Add Virtual Machines to the Backend Pool</h4><p>Select your Load Balancer<br>Then Settings &gt;&gt; Backend pools &gt;&gt; myBackendPool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mHC1DfJ7JJi4pOb9.png" /></figure><p>Click on myBackendPool</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aB2xXwP1VZ7XeALY.png" /></figure><p>In the Virtual machines section, select “+ Add”, then select the two newly created VMs, select Save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/0*j0t4ybdWIvHbbgEU.png" /></figure><h3>Test the Load Balancer</h3><p>Look up the public IP address of the load balancer to connect and verify that the Load Balancer is working properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xK-GvGfzQacCIED2.png" /></figure><p>Copy the public IP address, then paste it into the address bar of your browser.</p><p>Check the response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/0*6jLAbKg9eEsUfKlE.png" /></figure><p>Refresh the browser multiple times and you should see connections to VM1 and VM2.</p><p>You can also stop, for example, VM2 and verify that the Load Balancer consistently redirects to VM1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/0*1iuQFt7usWwv3rcJ.png" /></figure><h3>Conclusion</h3><p>The Azure Load Balancer is used to distribute network traffic load across the backend virtual machines, and its scaling function provides great value during higher or lower loads.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bab07462253b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Azure DevTest Labs]]></title>
            <link>https://medium.com/@morsi.masmoudi/getting-started-with-azure-devtest-labs-9a55027046a2?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a55027046a2</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Tue, 28 May 2024 08:41:02 GMT</pubDate>
            <atom:updated>2024-05-28T08:41:02.618Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tOjlvcsaXt5lEHz496Ag7Q.png" /></figure><p>In this article, I propose to get started with the exploration of the Azure DevTest Labs service.</p><p>Azure DevTest Labs helps us quickly create environments in Azure while controlling costs.</p><p>We can test the latest version of our application by quickly providing test environments using reusable templates and artifacts such as Visual Studio, Notepad++, etc. and easily integrate it into our DevOps pipeline or create pre-configured environments for training and demonstrations.</p><h3>Prerequisites</h3><p>To be able to follow this guide, you will need an Azure subscription (if you don’t have an Azure subscription, create a free account before getting started).</p><h3>Create Your First DevTest Lab</h3><p>We will create a small DevTest Lab environment that we can use for software development.</p><p>Let’s start and create the DevTest Labs resource in Azure:</p><ol><li>Access the Azure portal</li><li>In the search field, search for “DevTest Labs”</li><li>Click on “Create”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*pxZWSGoOUgZ6_QAo.png" /></figure><p>Here are the next steps:</p><ol><li>Select an existing resource group or create a new one</li><li>Provide a name for the lab</li><li>Select a location for the lab</li><li>Leave the Public environments setting to Enabled</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/0*69Ytm3IC4kmY76fQ.png" /></figure><p>Next steps:</p><ol><li>Click on “Next: Auto-shutdown”</li><li>Select “Enabled” for the Enabled setting. This will enable the automatic shutdown of all virtual machines you create in the lab.</li><li>Fill in the scheduled shutdown time.</li><li>Choose the correct time zone.</li><li>Click on “Review + create”, then “Create” to create the lab.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/0*q4tFTZuFfTGgCJob.png" /></figure><p>Once the DevTest Lab is created (up to 10 minutes for a full deployment of a DevTest Lab), access the Lab in the Azure portal.</p><h3>Create a pool of virtual machines (VMs) with pre-installed tools</h3><p>In the DevTest Lab overview panel, click on “Add” to start creating a virtual machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/0*OqVqLTxZV5nWKZQj.png" /></figure><p>You can now choose pre-installed tools for our environment.</p><p>Search for “Visual Studio” and click on one of the results containing Visual Studio. (choose a base)</p><p>This will create a virtual machine with Visual Studio pre-installed on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/0*nmqdIkht9xM6tPgw.png" /></figure><ul><li>Fill in a name for the VM</li><li>Enter the username</li><li>Also fill in a password</li><li>Check the box “Save as default password” You can leave the disk and VM size as is or modify them.</li><li>Leave the OS disk type as the default</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/0*jwfb6gG076cQqM1G.png" /></figure><h3>Add artifacts</h3><p>Click on Add or Remove Artifacts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/0*CR0TVH3qj_EGxjES.png" /></figure><p>In the Add Artifacts options, you can choose software that will be pre-installed on all the virtual machines in your Lab.</p><p>There are many standard software items you can choose from the DevTest Labs public repository. You can also add artifacts from your own Git repository.</p><p>Search for Notepad++</p><p>Click the arrow next to the result</p><p>Select OK to add the artifact</p><p>Click OK</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/0*YhoAMJH6HnfxTOGH.png" /></figure><p>Next, click on the Advanced Settings tab.</p><p>Set “Make this machine claimable” to Yes. This will allow lab users to claim the VM so they can use it exclusively</p><p>Change the number of instances to 3</p><p>Go back to the Basic Settings tab and click Create to create the Lab with 3 VMs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*teejARpUU7w_Oz16.png" /></figure><p>When the virtual machines are created (expect 20 minutes for our example of 3 VMs, the time will of course vary depending on the number of VMs to be created), you can find them in the Claimable virtual machines menu of the DevTest Lab resource.</p><p>Click on one of the VMs to see its details. You will see that the auto-shutdown feature is enabled by default.</p><p>Click on Claim machine to claim the virtual machine.</p><p>This means the virtual machine is now yours, until you unclaim it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iptnDbIUwjQk9xIQ.png" /></figure><p>Go to the Create formula menu.</p><p>Here, you can create a reusable base from this VM, including its artifacts. This is useful when you want to create more virtual machines based on this one.</p><p>Next, click on the Artifacts menu. This shows you the artifacts you configured earlier and indicates when they were installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gW5uzikqL-aXpUa8.png" /></figure><p>Go back to the virtual machine overview panel and click Connect.</p><p>This downloads an RDP file.</p><p>Open the RDP file and enter the username and password for the VM, then look for Notepad. You will see that it is pre-installed on the machine.</p><h3>Conclusion</h3><p>Azure DevTest Labs is great for quickly creating custom virtual machine environments that your team can use for development, testing, and training.</p><p>And with smart features like auto-shutdown, policies, and integration with Azure DevOps, administrators maintain control over costs, security, and customization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a55027046a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Azure Template Specs to create your resources more quickly and easily]]></title>
            <link>https://blog.devops.dev/use-azure-template-specs-to-create-your-resources-more-quickly-and-easily-aa624d71cbb8?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa624d71cbb8</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops-tool]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 13:21:35 GMT</pubDate>
            <atom:updated>2024-04-10T17:33:24.726Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jqI6N4JhWCZYjmeC6P8VaQ.png" /></figure><p>Azure Template Specs is a feature provided by Microsoft Azure that allows you to define and manage templates for resource deployment.</p><p>It is part of Azure Resource Manager (ARM) templates, which are JSON files used to describe and provision Azure resources.</p><h3>Introduction</h3><p>Azure Template Specs provide a way to package and version templates, making it easier to reuse and share them across different projects and teams. They enable you to define a set of resource configurations, including virtual machines, storage accounts, networking, and other Azure services, in a declarative manner.</p><p>With Azure Template Specs, you can create reusable templates with parameterization and conditionals, allowing for dynamic resource provisioning. They provide a standardized and efficient way to deploy resources consistently and reliably, reducing manual effort and potential errors.</p><p>By utilizing Azure Template Specs, you can accelerate the deployment process, improve consistency, and simplify the management of your Azure resources.</p><h3>Find templates for your resources</h3><p>The most difficult part may be finding the templates to create the resources you need.</p><p>Of course, it is possible to learn how to create templates from scratch, but that is not the purpose of this tutorial.</p><p>We want to use ready-to-use templates to show you how it works.</p><p>Microsoft documentation provides a lot of ready-to-use templates.</p><p>For example, you can simply search on Google for “ARM Template to create Azure VM,” and you will come across the first link, which is the Microsoft website with the VM creation template.</p><p><a href="https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-template">Quickstart: Use a Resource Manager template to create a Windows VM — Azure Virtual Machines | Microsoft Learn</a></p><p>Copy the code and save it in JSON format.</p><p>This is a website to guide and assist you in finding ready-to-use templates.</p><p><a href="https://azurecharts.com/templates">Azure Template Explorer (azurecharts.com)</a></p><h3>Create your first template spec</h3><p>In Azure, perform a search for “Template specs”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGf-bm12Pk-N2OwiP9FOgw.png" /></figure><p>Choose “Import template”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*geAke-j308FGfqxsFHqVlA.png" /></figure><p>Select the ARM template in JSON format that you have already saved.</p><p>Browse your template</p><p>Import</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*nCiVriYsRtZCvnYW8g09Mg.png" /></figure><p>Provide the necessary information for the template creation, then select the template version, and click on “Edit Template.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*RSsNfEr69KLQOBwhbPtTgQ.png" /></figure><p>You can edit the template and modify certain parameters or proceed to the next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*l4I_b2-0CcyHqrZsZRSR1w.png" /></figure><p>“Review + Create”</p><p>Once saved, we now have our ready-to-use template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*idAytQqK17n1pH390CdHcg.png" /></figure><h3>Create your ressource from your Template Specs</h3><p>Now comes the simplest part.</p><p>Click on your template spec, and then click on “Deploy.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*UIqMwYIWZQCujzCH_DzUjA.png" /></figure><p>Our template will create 6 resources and also takes parameters for the resource group name, VM name, region, etc.</p><p>You can specify the parameters you want.</p><p>Of course, depending on your template, you may have parameters or hardcoded values, but since the goal is to have a reusable template, it’s important to have parameters to be filled during deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*v2_aTUkkkVrKeiYerNIdzQ.png" /></figure><p>Review+create</p><p>Create</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_Rg3pxe6RpBYzE87iDOyQ.png" /></figure><p>Once the deployment is complete (in just 1 or 2 minutes), you can view your resources and connect to the virtual machine.</p><p>Therefore, you can use this very quick method to create your VMs, whether it’s for testing purposes or even in production if your VMs have similar configurations (same size, same disks, etc.).</p><p>Of course, there are templates available to create various Azure resources.</p><p>Please let us know in the comments if you found the article useful and also if you have any links to other interesting templates for our readers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa624d71cbb8" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/use-azure-template-specs-to-create-your-resources-more-quickly-and-easily-aa624d71cbb8">Use Azure Template Specs to create your resources more quickly and easily</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete Guide to Cloning and Moving a VM from One Azure Tenant to Another]]></title>
            <link>https://medium.com/@morsi.masmoudi/complete-guide-to-cloning-and-moving-a-vm-from-one-azure-tenant-to-another-8fa65dd6955a?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fa65dd6955a</guid>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Fri, 15 Mar 2024 08:24:17 GMT</pubDate>
            <atom:updated>2024-03-15T08:24:17.823Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pQVJE6ZoC9DOA7zasZmWnw.png" /></figure><p>Cloning and moving a virtual machine (VM) from one Azure tenant to another may be required in various scenarios, such as environment migration, tenant consolidation, or resource relocation.</p><p>In this article, we will guide you through the essential steps to successfully accomplish this operation.</p><p>Here are the steps we will need to clone and move our VM from one tenant to another tenant.</p><ol><li>Capturing the Image of the Source VM</li><li>Transferring the Custom Image to the Destination Tenant using a Storage Account</li><li>Creating a disk from a snapshot in the container</li><li>Creating a new VM in the destination tenant from our snapshot.</li></ol><p>Let’s go !</p><h3>1. Capturing the Image of the Source VM</h3><p>Stop the source VM in the source tenant.</p><p>Go to <strong>Azure portal</strong>, navigate to the <strong>virtual machine</strong> you want to clone.</p><p>In the <strong>Disks</strong> section, click on its <strong>operating system disk</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*e08dQyCihJcLkJK4V-yAdw.png" /></figure><h3>2. Transferring the Custom Image to the Destination Tenant using a Storage Account</h3><p>To transfer the image created in the first step, several methods are available.</p><p>We need to first create a storage account and download our created image.</p><p>Creating a storage account is fairly simple.</p><p>We just need to show you how to download the image. Go to your tenant where the image is created, click on the snapshot name, then select the “Snapshot Export” menu.</p><p>Click on “Generale URL”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*eo88gRoPr2oMCNDzrmdlwA.png" /></figure><p>After few moments, you can download the VHD file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*ruDJsZgE8R8QV73CyEgxvw.png" /></figure><p>Please note that the disk download process may take several hours depending on its size and your network bandwidth. Additionally, ensure that you have sufficient storage space for the download. In our example, the disk is only 127 GB, so it is manageable.</p><p>After 1 hour of downloading, we now need to transfer the snapshot to the destination tenant and consider a solution. Here are a few solutions that we can use:</p><ul><li>Using Azure File Explorer: It is an Azure explorer that you can install and use to transfer data to Azure.</li><li>Using a web browser: You can log in to Azure, navigate to the container, and use the file upload method. This method is not very efficient for large transfers.</li></ul><p>Go to your storage account, containers, and then créate a new container. Click on your container and then “uplaod” option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*Ku-uqs5p91iqbxIi35ZobQ.png" /></figure><ul><li>Using the PowerShell AzCopy command: This is the most efficient method.</li></ul><p>For our example, we will use AzCopy.</p><p>Download AzCopy : <a href="https://aka.ms/downloadazcopy-v10-windows">Copier ou déplacer des données vers Stockage Azure avec AzCopy v10 | Microsoft Learn</a></p><p>It’s a simple zip folder.</p><p>No installation is required; you simply need to run the executable. On Windows, open a PowerShell command, navigate to the folder where you have placed the AzCopy command executable, and then execute it.</p><pre>.\azcopy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*qTaBKLwAy4YTROFNUIa4tQ.png" /></figure><p>The AzCopy command is very straightforward. It takes the source file as a parameter and the destination container with a Shared Access Signature (SAS).</p><p><strong>A Shared Access Signature (SAS)</strong> is a secure way to grant limited access to Azure resources without sharing the account keys. It provides granular control over permissions, validity period, and access conditions.</p><p>We will generate a SAS for our storage account.</p><p>In Azure portal, Go to the storage account, and then Shared access signature, select “container” as Allowed resource types and than click on “Generate SAS and connection string”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9yKkz0GAZuzE-uFB8mFXQ.png" /></figure><p>Copy the SAS token generated.</p><p>Syntaxe :</p><pre>.\azcopy make &#39;https://&lt;storage-account-name&gt;.file.core.windows.net/&lt;file-share-name&gt;&lt;SAS-token&gt;&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*DN9KH7VSRFNh_qQl-0vu6Q.png" /></figure><blockquote>Please note that the snapshot downloaded from Azure should have the VHD extension. If it doesn’t, you can simply rename your file locally and add the VHD extension before performing the transfer.</blockquote><p>After the transfer to the new tenant is complete, we can proceed to the next step, which is creating a hard disk from the snapshot.</p><h3>3. Create a disk from a snapshot in the container</h3><p>To create a disk from a snapshot in the container, you can follow these steps:</p><p>In the portal, search for and open “Disks” in the left navigation pane.</p><p>Click on the “Create disk” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*To3mu4NAoDwI1YKCf8FDDA.png" /></figure><p>Select “Storage blob” as the source type. Browse for your snapshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*gEyEU7lDW3fFn4Z7xf1JPQ.png" /></figure><p>Choose the OS type : Linux, Windows or None if it’s a data disk</p><p>Choose the size of your disk</p><p>Create</p><p>A few moments later, your deployment is complete</p><h3>4. Create a new VM in the destination tenant from our snapshot</h3><p>Now that we have our managed disk created from the snapshot, we can proceed to create our VM. Simply navigate to the disk overview and click on “+ Create VM.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*uYrLEkx7zKQJjHDYEZm9zA.png" /></figure><blockquote>Please note that you can only create a single VM from an OS disk. If you need to create multiple VMs, you will need to create as many disks from the snapshot.</blockquote><p>Fill in the necessary information for VM creation, including subscription selection, resource group, VM name, and VM size.</p><p>You can also choose to skip the other steps and simply click on “Review + create.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*Pjd5Nx33YaSCry5z.png" /></figure><p>After a few moments, we have completed the creation of the VM, and we can now launch it. We will find everything that was in the original cloned and migrated VM.</p><h3>Conclusion</h3><p>In this complete guide to cloning and moving a VM from one Azure tenant to another, we have explored the step-by-step process of successfully migrating virtual machines. We then discussed various methods of transferring the VM, including disk downloads, Azure services, and tools like AzCopy.</p><p>We highlighted the significance of the Shared Access Signature (SAS) for secure data transfer and provided instructions on finding it within the Azure portal. Furthermore, we covered the creation of a new disk from a snapshot and the subsequent steps to create a VM. We emphasized the limitation of creating only one VM from an OS disk and the need to create additional disks for multiple VMs.</p><p>Finally, we concluded that by following these guidelines and leveraging the appropriate Azure tools and services, organizations can successfully clone and move their VMs between Azure tenants while preserving the integrity of their data and configurations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fa65dd6955a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Dive into Microsoft Azure Log Analytics Worksapce]]></title>
            <link>https://medium.com/@morsi.masmoudi/deep-dive-into-microsoft-azure-log-analytics-worksapce-4efac164ece9?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/4efac164ece9</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[azure-services]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Thu, 07 Mar 2024 09:17:30 GMT</pubDate>
            <atom:updated>2024-03-07T09:17:30.866Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3vxYCNkPHWe4l6OkSfdiA.png" /></figure><p>In this article, discover the power of Azure Log Analytics Workspace for streamlined log management and advanced data analysis.</p><p>Unlock the potential of your log data to improve troubleshooting, security monitoring, and operational efficiency with Azure Log Analytics Workspace.</p><h3>Table of contents</h3><ol><li>Overview and definition</li><li>Set up a log analytics Workspace</li></ol><h3>1. Overview and definition</h3><p>Analytics workspace is a very important component available and responsible for multiple Azure service like Azure Monitor, Microsoft Sentinel and Microsoft Defender for cloud.</p><p>There services use log analytics workspace for Data ingestion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27gM6hRGziUe0Ti4sPA_Gg.png" /></figure><p>Almost every computing system generate logs, it can host machines, network devices, security solutions and identity solutions or practically any solution that you are using.</p><p>Depending upon the log format, dedicated tables must be created. For example, for structured data windows event log, a specific table will be created.</p><p>For every table created (logs), you can use any this capabilities :</p><p>- Insights</p><p>- Dashboards</p><p>- Alerts</p><p>- Security SIEM / SOAR</p><p>Data collected and stored in tables are called Log analytics Workspace</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V16clitT95Dwm2ZcpO01Wg.png" /></figure><p>Log analytics workspace is also a decentralized repository where all the data is ingested.</p><p>Data sources can be :</p><ul><li>EndPoints</li><li>Security Solutions</li><li>Directory service solution</li><li>Asset Management Solution</li><li>Network devices</li><li>IDAM solutions (user provisioning, authentication, authorization, password management, single sign-on (SSO), multi-factor authentication (MFA), directory services, role-based access control (RBAC) …)</li></ul><p>Logs can be :</p><ul><li>Structured data CEF (Common Event Format)</li><li>Strutured data Syslog (Linux)</li><li>Structured data WEF (Windows Event Forwarding)</li></ul><p>Each component in our latest image has a role.</p><p>The data sources feed into the logs, which are then sent to the Log Analytics workspace for data collection.</p><p>Analysis takes place at the Log Analytics workspace level, while visualization is done through insights and dashboards. Finally, monitoring is done using alerts and SIEM/SOAR tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CYONRALHBvsZ6RfrbUHDQ.png" /></figure><p>Now if you open any log analytics workspace in your Azure tenant, you will find tables blade, and then many tables, like “alert” table where columns are basically the attributes wich exist in a specific log format all together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*ZiGLZ9iypXTpbiltAxVDUw.png" /></figure><p>Microsoft official document :</p><p><a href="https://learn.microsoft.com/fr-fr/azure/azure-monitor/logs/log-analytics-workspace-overview">Vue d’ensemble de l’espace de travail Log Analytics — Azure Monitor | Microsoft Learn</a></p><blockquote>From compliance standpoint, Log analytics workspace can be used to ingest and save data from multiple solutions for up to 7 years (retention periode).</blockquote><h3>Set up a log analytics Workspace</h3><p>It is pretty quick and easy to do so:</p><p>Search for “Log Analytics workspaces” in the global search box.</p><p>This will open up a window displaying your existing workspaces. To create a new one, click on the “Add” button on the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*LL9Htgc_unHMqwsNQNDXkQ.png" /></figure><p>Fill in the required details and click OK. It may take a minute to deploy.</p><p>When you create your log analytics workspace, you don’t have the choise to shoose pricing tier, but after creating this, you can change your usage and estimated cost.</p><p>Go to your created log analytics workspace</p><p>Go to blade “usage and estimate costs”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*C8bie_o44s9rA3le3O1Gew.png" /></figure><p>Creating a Log Analytics workspace incurs NO initial cost.</p><p>You will only be charged for the data ingested into the workspace.</p><p>Additionally, the cost is influenced by the retention period you select.</p><p>Opting for a region closer to your data sources can help minimize egress costs.</p><p>To further manage expenses, you have the option to set a daily cap for data collection within the Log Analytics workspace, enabling better cost control.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*EZAsEEEIRbCH2BOhcXXjvA.png" /></figure><p>The security logs are excluded from the daily cap, so you will continue receiving security event even you arrive at your daily cap data collection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*r4ehAgb1OlJAQDS_YPW-4A.png" /></figure><p>We can also change the retention period for our Workspace.</p><p>If we change this, tables in our log analytics workspace will ineherit the new data retention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*cbKEK4qMeHnOBDr7WHQuhg.png" /></figure><p>You can after that change the retention period for every table in your log analytics workspace</p><p>The plan you choose for your tables affect the total retention period.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4efac164ece9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create an Azure Entreprise application for a legacy Desktop SSO login.]]></title>
            <link>https://medium.com/@morsi.masmoudi/create-an-azure-entreprise-application-for-a-legacy-desktop-sso-login-9a0169a72da0?source=rss-dc586e1b2c84------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a0169a72da0</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[sso]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Morsi Masmoudi]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 14:17:09 GMT</pubDate>
            <atom:updated>2024-02-12T14:17:09.428Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MOtQ25ekjvb-62aWsyo2sA.png" /></figure><p>In this document, we will see how to create an Azure Enterprise Application to connect your application (whether it is legacy or web-based) to an Azure AD directory (Entra ID).</p><p>Please feel free to provide feedback on your experience with the topic and the article.</p><h3>Table of Contents</h3><ol><li>What is SSO?</li><li>What is Azure AD (Entra ID)?</li><li>Use Case</li><li>Create Azure Entreprise application</li><li>Add permission to your Azure Entreprise Application</li><li>Creat a “Mobile and Desktop applications” Authentication</li><li>Configure your application to use SSO</li></ol><h3>1. What is SSO?</h3><p>SSO, or Single Sign-On, is an authentication mechanism that allows users to access multiple applications and systems with a single set of credentials. It eliminates the need for users to remember and manage multiple usernames and passwords.</p><p>With SSO, users from a domain connected to Azure AD can use their domain account to log in to application, eliminating the need for a separate account and managing multiple logins and passwords.</p><h3>2. What is Azure AD (Entra ID)?</h3><p>The goal is not to master Azure AD but to have a simple definition.</p><p>Azure Active Directory (Azure AD) is the user directory of a company hosted on Microsoft’s Azure platform.</p><p>This directory enables, among other things:</p><ul><li>Simplifying access to multiple tools by offering single sign-on (SSO) authentication.</li><li>Facilitating secure communication between internal and external users.</li></ul><p>Azure AD supports the SAML 2.0 protocol.</p><h3>3. Use case</h3><p>Here is our use case: we have a legacy application that we want to access via SSO. We will grant access rights to specific groups within the directory, rather than the entire directory.</p><p>Each user within the domain is associated with a group. This same group exists in the application and determines the user’s permissions within that group.</p><p>During the SSO login process for the application, three steps are followed:</p><ul><li>A mechanism verifies the existence of the user and the correctness of their password.</li><li>Upon successful validation, the application retrieves a “token” containing all the information of the logged-in user, including the user’s group memberships.</li><li>The application retrieves the group rights for the user and grants those rights to the logged-in user</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OtRiBUxOoPKdPBTDOSeNwg.png" /></figure><h3>4. Create Azure Entreprise application</h3><p>Sign in to the Azure portal.</p><p>Navigate to ‘Enterprise applications’ and click on ‘New application’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q3VsjrTFaabzmVZWPpHBDQ.png" /></figure><p>create your own application</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*cLCFPJ9d_KDLfDSRAUGTIw.png" /></figure><p>Choose a name for your Entreprise application</p><p>choose “<br>Integrate any other application you don’t find in the gallery (Non-gallery)”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*YoWzKGf6kSLm6qII4vo10A.png" /></figure><p>At the end of the creation process, we obtain our created application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V1GcCakC9nF4BWux1z02YA.png" /></figure><p>Now we need to configure SSO.</p><p>Click on “Get started” in the “Set up single sign-on” section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l2_DL2e-jTXw8BnN-ZyM1A.png" /></figure><p>Choose “SAML”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5vibz9iaPtA1upvggGVhA.png" /></figure><p>Edit the first block to enter an “Entity ID” and a “Reply URL”.</p><p>Click on the pencil icon on the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UvrmqfejQkoTV4e3mCZ4yw.png" /></figure><p>Start by adding an “Entity ID” (1) and then a “Reply URL” (2).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9TocBmygQsx9bO08l2rEg.png" /></figure><p>Enter a unique identifier for “Entity ID”. For example, ‘SSO-MYAPP’.</p><p>For “Reply URL”, enter “<a href="https://localhost/">https://localhost</a>”.</p><blockquote>Don’t forget, we are configuring an Azure Enterprise Application for a legacy desktop application, so we will use ‘localhost’ as the reply address. For example, if you are testing your web application locally and it is running on port 1234 (for example), you should set the return address as <a href="http://localhost:1234/">http://localhost:1234</a></blockquote><p>Save the changes by clicking on “Save”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9hp9yhzPPmX_MCbnc0df7g.png" /></figure><p>If you receive a prompt to test, you can choose the “No, I’ll test later” button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DKDZvJH2PesuGqFltAja1g.png" /></figure><p>We have now configured SAML, which results in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kRYvVrmbjcFTs8Yw4zRNEA.png" /></figure><p>Access “Users and groups” to add either individual users or a user group who will have the permission to use the created application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gRqm5RhjBrhb7CEIREP_kw.png" /></figure><p>Select the user or group (in this example, we will choose a user).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J24mlTjes8J3sVY7A9ztIw.png" /></figure><p>After selecting the users, click on “Assign”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*li5MsEiPne8k1NcPdJucFA.png" /></figure><p>After adding the users, we have the following list of users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hjG62p0huN8EDotGdtlpkQ.png" /></figure><h3>5. Add permission to your Azure Entreprise Application</h3><p>We will now add the necessary permissions to the application to retrieve the user group name for this application.</p><p>To do this, go to “Azure Active Directory” and select “App registrations”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wv_NHMcLzhAI2RqfGnvz9g.png" /></figure><p>Choose “API permission”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*okNcnVeCQTDY_VttYeIMuw.png" /></figure><p>Click on “+ Add a permission”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPgmMYZBG-FQz5wNCjvDug.png" /></figure><p>Choose “Microsoft Graph”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*T_fwwRdcG6HgmO4Eu9optA.png" /></figure><p>Choose “Delegated permissions”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*-DyWb9mpLcH4_PU37pxDig.png" /></figure><p>Select (you can use the search bar):</p><ul><li>Directory.Read.All</li><li>Group.Read.All (because we want to read the user group)</li><li>GroupMember.Read.All</li></ul><p>and then “Add permission”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDWpXcl-ws-skC9yoxz9lQ.png" /></figure><p>Grant the “Admin” privilege to the permissions we just provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4yExEHmP5lx3IRwpdLh0Q.png" /></figure><p>Choose “Yes”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bOxPWC9-UpVEE4_7ykrx_Q.png" /></figure><p>We can see the permissions with the status “Granted”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*haDXscAQftsFD2ZJSG2Klg.png" /></figure><h3>6. Creat a “Mobile and Desktop applications” Authentication</h3><p>Our use case include is a desktop application, so we need to create a new platform called “Mobile and Desktop applications”.</p><p>Go to “Azure Active Directory” (Entra ID), then “App registrations”, and select the already created application.</p><p>Next, select “Authentication”.</p><p>Click on “+ Add Platform”, then choose “Mobile and Desktop applications”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*m9HPhOS6xdhMoM6C5ra2Yg.png" /></figure><p>Check the URL for the native client: “<a href="https://login.microsoftonline.com/common/oauth2/nativeclient">https://login.microsoftonline.com/common/oauth2/nativeclient</a>”, then click on “Configure”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*8HXxEI-0ghBbxFVen2gCXw.png" /></figure><p>We also need to register the application as a public client.</p><p>Stay in the same window and scroll down (‘Azure Active Directory’, then ‘App registrations’, select the SSO-MYAPP application, then choose ‘Authentication’).</p><p>Select ‘Yes’ and then click on “Save”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*l9Mz6tskmrARAj_IFq1aGg.png" /></figure><h3>7. Configure your application to use SSO</h3><p>Retrieve the configuration of your SSO application: (client) ID and (tenant) ID.</p><p>Go to “Entra ID”, then “App registrations”, and select the already created application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*MVY-wKgvKEJwoJhhm89ufg.png" /></figure><p>Configure your application to be able to retrieve and explore the token (which is not the focus of this article), and this is done by retrieving the tenant ID and client ID.</p><p>Sign in to your application and request authentication.</p><p>You will see the Microsoft screen to authenticate with your Azure AD account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*CBgJ7OYG9hmqKLxkldYxng.png" /></figure><h3>8. Conclusion</h3><p>In this article, we discussed the creation of an enterprise application in Azure for a desktop application.</p><p>Of course, the same approach can be used for a web application.</p><p>We also used the SAML standard, but it is possible to use other standards like OIDC (OpenID).</p><p>Thank you for leaving your comments and questions. I will respond to them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a0169a72da0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>