<?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 Afzal Muhammad on Medium]]></title>
        <description><![CDATA[Stories by Afzal Muhammad on Medium]]></description>
        <link>https://medium.com/@muafzal?source=rss-7e0a22273254------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HALu-cIglVqMGOvS9jaF-w.jpeg</url>
            <title>Stories by Afzal Muhammad on Medium</title>
            <link>https://medium.com/@muafzal?source=rss-7e0a22273254------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 19:57:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muafzal/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[Unlock Microsoft Fabric Chargeback Data: From Built-In Reports to a Custom Lakehouse and FinOps…]]></title>
            <link>https://medium.com/geekculture/unlock-microsoft-fabric-chargeback-data-from-built-in-reports-to-a-custom-lakehouse-and-finops-cdd8b449f3ac?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdd8b449f3ac</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[chargeback]]></category>
            <category><![CDATA[microsoft-fabric]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 13:52:01 GMT</pubDate>
            <atom:updated>2026-08-28T13:52:01.043Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ll5upWlBRb9JAyvs0TDXw.png" /></figure><h3>Unlock Microsoft Fabric Chargeback Data: From Built-In Reports to a Custom Lakehouse and FinOps Solution</h3><h3>Introduction</h3><p>When teams share a Fabric capacity, the obvious question is “<strong>which workloads and workspaces are driving capacity consumption?</strong>” The Microsoft Fabric Chargeback app answers it by breaking down Capacity Unit (CU) consumption across workspaces, items, domains, and users — so you can build chargeback on actual usage instead of flat estimates. Generally available since May 2026, it supports drill-through to workspace and item level plus data export for invoicing. Know the limits before you roll it out: data refreshes only once daily (not real-time), it isn’t supported in government clouds or private-link environments, exports can fail on deep drilldowns, and the underlying semantic model can’t be reused or modified outside the app</p><blockquote><strong><em>Disclaimer:</em></strong><em> This solution is a community implementation intended for educational and experimentation purposes. The Microsoft Fabric Chargeback semantic model is Microsoft-managed and direct consumption, modification, or reuse of the model is not supported by Microsoft. Always validate the approach against your organization’s governance and support requirements.</em></blockquote><h3>Reference Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bEud2j7oE6TEVBYH0D1wvQ.png" /></figure><h3>Key Limitations of the Fabric Chargeback App</h3><p>As of today, the <strong>semantic model used by the Microsoft Fabric Chargeback app is not intended to be modified or reused</strong>. Microsoft explicitly states that:</p><p>“The semantic model that the Microsoft Fabric Chargeback app uses is supported only for use by the reports provided in the app. Consumption from, usage of, or modification of the semantic model isn’t supported.” <a href="https://learn.microsoft.com/en-us/fabric/enterprise/chargeback-app">What is the Chargeback app? — Microsoft Fabric | Microsoft Learn</a></p><h4><strong>What this means</strong></h4><ul><li>✅ You can use the out-of-the-box Chargeback reports.</li><li>✅ You can filter, drill through, and export data from the app.</li><li>❌ Microsoft does not support modifying the app’s semantic model.</li><li>❌ Building custom reports directly against the app’s semantic model is not supported.</li><li>❌ Extending the model with your own measures, tables, or relationships is not supported.</li></ul><h4><strong>Limitation</strong></h4><p>The Fabric Chargeback app’s semantic model is a Microsoft-managed artifact intended only for the app’s built-in reports. Custom modifications or direct reuse of the semantic model are not supported</p><h3>Community Innovation Filling the Gap</h3><p>Because of these limitations, many customers and community contributors have explored alternative approaches to extract, operationalize, and enrich Chargeback App data. Several community blogs and technical walkthroughs demonstrate creative methods for building custom semantic models, integrating chargeback data with FinOps processes, creating alerts, powering AI agents, and persisting data within Lakehouse architectures. However, these approaches typically require custom development and are quite complex with respect to using DAX or PBI Desktop, and so on.</p><p>In the remainder of this article, I’ll walk through a practical, repeatable approach to extract raw Chargeback App data and make it available in your Fabric environment, enabling custom reporting, FinOps integration, automation, and advanced governance scenarios.</p><h3>Deployment Steps</h3><h4>Step-1: Install the Chargeback app.</h4><p><strong>Prerequisite:</strong> Sign in as an administrator of at least one Fabric capacity. For best reliability, install the app in a workspace backed by a Pro license.</p><ol><li>In the Power BI service, select <strong>Apps &gt; Get apps</strong>, search for <strong>Microsoft Fabric Chargeback</strong>, and select <strong>Get it now</strong>.</li><li>Complete the AppSource registration, return to Fabric, and select <strong>Install</strong> in the installation window.</li><li>Open <strong>Apps &gt; Microsoft Fabric Chargeback</strong>. When the sample-data message appears, select <strong>Connect your data</strong>.</li><li>Enter the requested configuration values, authenticate when prompted, and allow the initial data refresh to complete.</li><li>Verify that the report shows your capacities, workspace, and usage data before sharing it with stakeholders.</li></ol><p><em>Tip: The first refresh can take several minutes, depending on the number of capacities and the amount of usage data.</em></p><h4>Step-2: Create a Lakehouse in Chargeback app workspace</h4><p><strong>Purpose:</strong> Create a Lakehouse in the same workspace as the Chargeback app so extracted data can be stored and queried.</p><ol><li>Open the workspace where the <strong>Microsoft Fabric Chargeback</strong> app was installed.</li><li>Select <strong>+ New item</strong>, search for <strong>Lakehouse</strong>, and open the Lakehouse item.</li><li>Enter a clear name, such as “<strong>cblh”</strong>, and select <strong>Create</strong>.</li><li>Wait for the Lakehouse to finish provisioning, then confirm that the <strong>Tables</strong> and <strong>Files</strong> folders are visible.</li><li>Verify that the Lakehouse is created in the Chargeback app workspace and note its name for the notebook and data-extraction steps that follow.</li></ol><p><em>Tip: Use a dedicated Lakehouse name and keep it in the same workspace to simplify permissions, notebook references, and ongoing maintenance.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lPosXn-3Aho3_LZpkTyHiw.png" /></figure><h4>Step-3: Create paginated reports from chargeback semantic model</h4><blockquote><strong>Preview notice:</strong> Paginated report authoring in the Power BI service is currently in preview. Validate the experience in a nonproduction workspace and confirm its limitations before relying on it for production chargeback reporting.</blockquote><p><strong>Purpose:</strong> Create a separate paginated report for each Chargeback table exposed by the Chargeback semantic model so that every table can be inspected and exported independently.</p><ol><li>Open the workspace that contains the <strong>Microsoft Fabric Chargeback</strong> semantic model.</li><li>Confirm that you have <strong>Built</strong> permission on the semantic model and at least the required workspace role to create and save reports.</li><li>Click + New Item. Select a Paginated Report (preview).</li><li>In “Choose the data you want to connect”, select a chargeback semantic model. Then click “Create Paginated Report”</li><li>In the paginated report editor, select one Chargeback table from the <strong>Data</strong> pane.</li><li>Preview the report and validate that the rows and fields match the selected Chargeback table.</li><li>Save the report to the Chargeback workspace using a descriptive name, such as <strong>rpt_chargeback, rpt_capacities, rpt_workspaces, rpt_items</strong>.</li><li>Repeat the process for <strong>each Chargeback table</strong> in the Chargeback semantic model, creating one standalone paginated report per table.</li></ol><blockquote><strong><em>Important: This approach uses the Chargeback semantic model for reporting. Microsoft states that direct consumption, reuse, or modification of the app semantic model outside its supported reports is not supported; treat this preview workflow as an experimental option and use the Lakehouse extraction approach in the later steps for extensible production reporting.</em></strong></blockquote><p>The following items will be created as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcaRXvZ8JLg_CbfKpU_O8w.png" /></figure><h4>Step-4: Setup chargeback data extraction notebook</h4><p><strong>Purpose:</strong> Download the “<strong>extract chargeback data.ipynb”</strong> notebook from the GitHub repository and upload it to the same Fabric workspace as the Chargeback app and Lakehouse.</p><ol><li>Clone the GitHub repository using</li></ol><pre># git clone https://github.com/mafzal786/fabric-chargeback.git</pre><ol><li>In Microsoft Fabric, open the workspace that contains the Chargeback app and the Lakehouse created in Step 2.</li><li>On the workspace command bar, select <strong>Import</strong> or <strong>Upload</strong>, choose <strong>Notebook</strong>, and select <strong>From this computer</strong>.</li><li>Browse to “<strong>extract chargeback data.ipynb”</strong>, select the file, and choose <strong>Upload</strong>. After the import is complete, confirm that the notebook appears in the workspace.</li><li>Open the imported notebook and use the Lakehouse explorer to add or attach the Lakehouse created in Step 2 as the default Lakehouse.</li><li>Review the notebook configuration cells, update any workspace or Lakehouse-specific values if required, and save the notebook before running it.</li></ol><p><em>Tip: Keep the notebook, Chargeback app, and Lakehouse in the same workspace to simplify access and default Lakehouse configuration.</em></p><h4>Step-5: Run and validate the data extraction notebook</h4><p><strong>Purpose:</strong> Execute the imported notebook to extract Chargeback app data and persist it in the Lakehouse created in Step 2.</p><ol><li>Open <strong>extract chargeback data.ipynb</strong> in the Chargeback app workspace.</li><li>Confirm that Step 2 Lakehouse, such as “<strong>cblh”</strong>, is attached and selected as the default Lakehouse.</li><li>Review the configuration cells and update any workspace, semantic model, Lakehouse, or table values required by your environment.</li><li>Select <strong>Run all</strong>. Complete any authentication prompt and keep the notebook open until every cell finishes.</li><li>Review the cell outputs. If a cell fails, correct the reported configuration, permission, or connectivity issue, and then rerun the failed cell or select <strong>Run all</strong> again.</li><li>Open the Lakehouse explorer, refresh the <strong>Tables</strong> view, and verify that the expected Chargeback tables were created and contain data.</li><li>Open a table preview or use the SQL analytics endpoint to validate row counts, reporting dates, capacity names, and workspace names.</li><li>After a successful test, save the notebook. If recurring extraction is required, add it to a Fabric Data Factory pipeline and configure the appropriate schedule.</li></ol><p><em>Tip: Run the notebook manually first and confirm the output tables before adding automation. Rerun it after the Chargeback app completes its daily refresh, so the Lakehouse receives the latest available data.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X1Uod-X-tBQ7cUjOAqhJgg.png" /></figure><h3>About the notebook</h3><p>This notebook automates the extraction and ingestion of Microsoft Fabric Chargeback App data into Lakehouse Delta tables, making the data available for custom reporting, analytics, and chargeback analysis beyond the out-of-the-box application experience.</p><h4>Key Activities Performed</h4><ul><li>Installs required libraries including <strong>Semantic Link (sempy)</strong> and <strong>Requests</strong> for Fabric and Power BI REST API interactions.</li><li>Retrieves tenant metadata using Semantic Link: Fabric capacities, Fabric workspaces, Workspace items.</li><li>Obtains an authenticated Power BI access token using Fabric notebook credentials.</li><li>Discovers Power BI report IDs dynamically from the current workspace.</li><li>Uses the <strong>Power BI Export API</strong> to export Chargeback App report data to CSV format.</li><li>Monitors export jobs asynchronously until completion.</li><li>Downloads exported report datasets directly into the Fabric notebook environment.</li><li>Converts CSV files into Pandas Data Frames for processing and validation.</li><li>Loads the data into Fabric Lakehouse Delta tables for downstream consumption.</li><li>Creates curated Delta tables for:</li><li><strong>chargeback</strong> — Capacity consumption and cost allocation data</li><li><strong>workspaces</strong> — Workspace inventory and metadata</li><li><strong>items</strong> — Fabric item inventory across workspaces</li><li><strong>dates</strong> — Date dimension used by the Chargeback model</li><li><strong>capacities</strong> — Capacity-level metadata and configuration</li></ul><h4>Architectural Flow</h4><p>Below is the architectural flow for extracting data from Chargeback semantic model via paginated reports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ll5upWlBRb9JAyvs0TDXw.png" /></figure><h4>Outcome</h4><ul><li>Fully automated extraction of Chargeback App report data.</li><li>Five Delta tables were created and refreshed in the Lakehouse.</li><li>Data becomes accessible for enterprise-scale reporting, governance, chargeback, show back, and FinOps scenarios within Microsoft Fabric.</li></ul><h3>Validate the solution</h3><p>Open the “cblh” SQL analytics endpoint and query editor</p><ol><li>Open the Fabric workspace that contains the “<strong>cblh”</strong> Lakehouse.</li><li>In the workspace item list, locate and select the “<strong>cblh”</strong> SQL analytics endpoint. It has the same name as the Lakehouse and is created automatically.</li><li>Alternatively, open the “<strong>cblh”</strong> Lakehouse and use the selector in the upper-right corner to switch from <strong>Lakehouse</strong> to <strong>SQL analytics endpoint</strong>.</li><li>In the SQL analytics endpoint view, select <strong>New SQL query</strong> from the ribbon to open the query editor.</li><li>Expand <strong>Tables</strong> in Object Explorer and confirm that the extracted tables, including <strong>chargeback</strong>, <strong>workspaces</strong>, <strong>items</strong>, <strong>dates</strong>, and <strong>capacities</strong>, are visible.</li><li>Enter a validation query such as <strong>SELECT TOP 100 * FROM [dbo].[chargeback];</strong>, and select <strong>Run</strong>.</li><li>Review the <strong>Results</strong> and <strong>Messages</strong> panes to confirm that the query completed and returned Chargeback data.</li></ol><p><em>Note: The Lakehouse SQL analytics endpoint provides a read-only T-SQL surface over Delta tables. Use it for SELECT queries and analytical objects such as views; use the Lakehouse and Spark when data must be inserted, updated, or deleted.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lXxq_2627sj41DSsm75l5Q.png" /></figure><h4>Validation of Chargeback Data Using SQL Queries</h4><p>Run query for workspace capacity utilization analysis using Fabric chargeback data</p><p>Run the following query in the new query window.</p><pre>declare @startdate DATETIME2<br>declare @enddate DATETIME2<br><br>set @startdate = &#39;8/01/2026&#39;<br>set @enddate = &#39;8/31/2026&#39;<br><br>declare @total_cu float<br><br>select @total_cu = sum([Chargeback_CU_s_]) from [dbo].[chargeback]<br>where CONVERT(DATETIME2(0),[Chargeback_Date],103) BETWEEN @startdate AND @enddate<br><br>select sum([Chargeback_CU_s_]) as utilization,(sum([Chargeback_CU_s_])/@total_cu)*100 as utilization_percent,<br>c.Capacities_Capacity_name, w.Workspaces_Workspace_name<br>from [dbo].[chargeback] cb<br>join [dbo].[workspaces] w on w.Workspaces_Workspace_Id = cb.Chargeback_Workspace_Id<br>join [dbo].[capacities] c on c.Capacities_Capacity_Id = cb.Chargeback_Capacity_Id<br>where CONVERT(DATETIME2(0),[Chargeback_Date],103) BETWEEN @startdate AND @enddate<br>group by c.Capacities_Capacity_name, w.Workspaces_Workspace_name</pre><p>The following is the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HsaGkV8JZB8y7vqUpAA7eQ.png" /></figure><p>Now, let’s compare this output with a Capacity Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2XHfmHcnG9nKcwOdlG8_0Q.png" /></figure><p>To validate the accuracy of the data extracted from the Fabric Chargeback App, the results generated from the custom SQL query were compared against the corresponding metrics displayed in the Chargeback dashboard for the same reporting period (August 1, 2026, through August 27, 2026).</p><h4><strong>Comparison Results</strong></h4><p>The SQL query aggregates <strong>Chargeback_CU_s_ (Capacity Units Seconds)</strong> by workspace and calculates the percentage of overall utilization for the selected date range. The resulting values closely match the figures shown in the Chargeback reporting dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*2eLeSpq0a_o-AZy9r4TBBw.png" /></figure><h4><strong>Key Observations</strong></h4><ul><li>The exported Chargeback App data produced identical utilization values when queried directly from the Lakehouse/Warehouse tables.</li><li>Workspace rankings and utilization percentages aligned perfectly with the Top Workspaces visualization in the Chargeback dashboard.</li><li>Total CU consumption reported by the SQL query matched the dashboard’s aggregate utilization value of <strong>295,471.783 CU</strong>.</li><li>The validation confirms that the Power BI Export API extraction process preserved the underlying Chargeback metrics without introducing discrepancies.</li><li>This consistency provides confidence that the Lakehouse Delta tables can be used as a trusted source for: Chargeback and Show back reporting, Capacity utilization analysis, FinOps reporting, Cost allocation models, Custom governance dashboards.</li></ul><h4><strong>Takeaway</strong></h4><p>The side-by-side comparison demonstrates that data extracted from the Fabric Chargeback App through the Power BI Export API is fully consistent with the metrics displayed in the native Chargeback dashboard. This validation confirms that organizations can confidently leverage the exported data stored in Delta tables to build customized reporting and analytics solutions while maintaining fidelity with the official Chargeback App experience.</p><h3>Next Steps</h3><p>With the extraction validated, the next goal is to turn the Lakehouse tables into a governed and repeatable chargeback data product.</p><ol><li><strong>Automate the refresh.</strong> Add <strong>extract chargeback data.ipynb</strong> to a Fabric Data Factory pipeline and schedule it to run after the Chargeback app completes its daily refresh.</li><li><strong>Operationalize authentication.</strong> For production pipelines, use a managed service identity such as Fabric workspace identity where supported, and grant only the permissions required by the notebook.</li><li><strong>Build a curated reporting layer.</strong> Create SQL views or a separate semantic model over the <strong>chargeback</strong>, <strong>capacities</strong>, <strong>workspaces</strong>, <strong>items</strong>, and <strong>dates</strong> tables without modifying the Microsoft-managed Chargeback semantic model.</li><li><strong>Add cost-allocation logic.</strong> Combine CU utilization with the applicable capacity cost and document allocation rules, exclusions, shared-service treatment, and rounding behavior.</li><li><strong>Apply governance.</strong> Secure the workspace, Lakehouse, SQL analytics endpoint, semantic model, and reports with least-privilege access; consider row-level security for business-unit views.</li><li><strong>Monitor data quality.</strong> Track notebook and pipeline failures, stale refresh dates, missing workspaces or capacities, duplicate records, and unexplained differences from the built-in dashboard.</li><li><strong>Publish and iterate.</strong> Release show back dashboards first, validate allocations with Finance and workload owners, and introduce invoicing only after the allocation model is accepted.</li></ol><h4>Related Links</h4><ul><li><a href="https://learn.microsoft.com/en-us/fabric/enterprise/chargeback-app">Microsoft Fabric Chargeback app overview</a></li><li><a href="https://learn.microsoft.com/en-us/fabric/enterprise/chargeback-app-install">Install the Microsoft Fabric Chargeback app</a></li><li><a href="https://github.com/mafzal786/fabric-chargeback">Fabric Chargeback notebook and sample SQL queries on GitHub</a></li><li><a href="https://learn.microsoft.com/en-us/fabric/data-engineering/lakehouse-sql-analytics-endpoint">Lakehouse SQL analytics endpoint overview</a></li><li><a href="https://learn.microsoft.com/en-us/fabric/data-factory/notebook-activity">Run a Fabric notebook from a Data Factory pipeline</a></li><li><a href="https://learn.microsoft.com/en-us/fabric/data-factory/pipeline-runs">Run and schedule Fabric pipelines</a></li><li><a href="https://learn.microsoft.com/en-us/power-bi/paginated-reports/paginated-reports-quickstart-aw">Create and publish Power BI paginated reports</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdd8b449f3ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/unlock-microsoft-fabric-chargeback-data-from-built-in-reports-to-a-custom-lakehouse-and-finops-cdd8b449f3ac">Unlock Microsoft Fabric Chargeback Data: From Built-In Reports to a Custom Lakehouse and FinOps…</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consume Dataverse MCP server in Microsoft Foundry-Bringing business data to AI Agents]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://muafzal.medium.com/consume-dataverse-mcp-server-in-azure-ai-foundry-bringing-business-data-to-ai-agents-60256532f8d3?source=rss-7e0a22273254------2"><img src="https://cdn-images-1.medium.com/max/1536/1*1fSghL6BSo_TFpZPujNWXQ.png" width="1536"></a></p><p class="medium-feed-snippet">As organizations adopt AI agents, one challenge consistently emerges: how do agents securely access business data and perform actions in&#x2026;</p><p class="medium-feed-link"><a href="https://muafzal.medium.com/consume-dataverse-mcp-server-in-azure-ai-foundry-bringing-business-data-to-ai-agents-60256532f8d3?source=rss-7e0a22273254------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://muafzal.medium.com/consume-dataverse-mcp-server-in-azure-ai-foundry-bringing-business-data-to-ai-agents-60256532f8d3?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/60256532f8d3</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[dataverse]]></category>
            <category><![CDATA[ai-foundry]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[powerplatform]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 01:06:12 GMT</pubDate>
            <atom:updated>2026-08-21T15:59:33.549Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Deployment Guide-Copilot Studio agent with MCP Server exposed by API Management using OAuth 2.0]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://muafzal.medium.com/deployment-guide-copilot-studio-agent-with-mcp-server-exposed-by-api-management-using-oauth-2-0-08962589d617?source=rss-7e0a22273254------2"><img src="https://cdn-images-1.medium.com/max/600/0*F0BTmlN1LauRYG9Y" width="600"></a></p><p class="medium-feed-snippet">Who says OAuth is difficult!!! Solution deployment guide to learn how Azure API Management (APIM) enables secure and scalable access to&#x2026;</p><p class="medium-feed-link"><a href="https://muafzal.medium.com/deployment-guide-copilot-studio-agent-with-mcp-server-exposed-by-api-management-using-oauth-2-0-08962589d617?source=rss-7e0a22273254------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://muafzal.medium.com/deployment-guide-copilot-studio-agent-with-mcp-server-exposed-by-api-management-using-oauth-2-0-08962589d617?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/08962589d617</guid>
            <category><![CDATA[co-pilot]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[api-management]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 13:11:04 GMT</pubDate>
            <atom:updated>2026-04-21T13:11:04.472Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Step-by-Step Deployment Guide: MCP Tool Call in Copilot Studio agent with OAuth 2.0]]></title>
            <link>https://medium.com/analytics-vidhya/step-by-step-guide-mcp-tool-call-in-copilot-studio-agent-with-oauth-2-0-2064236c70f9?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/2064236c70f9</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[copilot-studio]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Mon, 06 Oct 2025 15:12:27 GMT</pubDate>
            <atom:updated>2025-10-08T01:04:11.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*7WcCB_b9FojWNsT6.png" /></figure><p>Securely integrating MCP tools within Copilot Studio by implementing OAuth 2.0 Authorization Code Flow</p><h3>Introduction</h3><p>Modern development workflows increasingly rely on secure integrations between tools and platforms. Copilot Studio, with its ability to extend functionality through MCP (Model Context Protocol) tools, offers developers powerful customization options. However, when these tools need to access sensitive APIs or user-specific data, robust authentication becomes essential.</p><p>OAuth 2.0, particularly the <strong>Authorization Code Flow</strong>, is the industry standard for secure delegated access. It enables applications to obtain tokens on behalf of users without exposing credentials, ensuring compliance with enterprise security policies. In this guide, we’ll walk through how to configure MCP tools in Copilot Studio using OAuth 2.0 Authorization Code Flow — covering prerequisites, configuration steps, token handling, and best practices for a seamless and secure setup.</p><h3>Disclaimer &amp; Context</h3><p>This article focuses on configuring an MCP tool within a <strong>Copilot Studio agent</strong> using OAuth 2.0 Authorization Code Flow. Every environment is unique, so the approach outlined here should be treated as a <strong>starting point</strong> rather than a one-size-fits-all solution. You can enhance this setup with additional security measures such as <strong>app roles</strong>, <strong>conditional access policies</strong>, or by extending the Python code for advanced scenarios.</p><p>We assume readers have a <strong>basic understanding of Python</strong>, <strong>MCP concepts</strong>, <strong>OAuth 2.0 flows</strong>, and some familiarity with <strong>Copilot Studio</strong>. For deeper dives into these individual technologies, refer to the official documentation linked throughout this article.</p><p><strong>Please note:</strong></p><ul><li>This solution reflects the state of the technology <strong>at the time of writing</strong>. Given the fast-paced nature of these platforms, minor adjustments may be required as features evolve.</li><li>MCP tool integration in Copilot Studio is currently a <strong>preview feature</strong>, so expect changes and improvements over time.</li></ul><h3>What is Authorization Code Flow?</h3><p>The <strong>Authorization Code Flow</strong> is designed for applications that can securely store a client secret (like server-side apps). It allows the app to obtain an <strong>access token</strong> on behalf of the user without exposing their credentials. This flow uses an intermediate <strong>authorization code</strong> to exchange for tokens, adding an extra layer of security.</p><h4>Steps in the Flow</h4><ol><li><strong>User Authentication</strong><br> The user is redirected to the <strong>Authorization Server</strong> (In this case: Azure AD) to log in and grant consent.</li><li><strong>Authorization Code Issued</strong><br> After successful login, the Authorization Server sends an <strong>authorization code</strong> to the app via the redirect URI.</li><li><strong>Token Exchange</strong><br> The app sends the authorization code (plus client credentials) to the <strong>Token Endpoint</strong> to get: <strong>Access Token</strong> (for API calls) and <strong>Refresh Token</strong> (to renew access without user interaction)</li><li><strong>API Access</strong><br> The app uses the <strong>Access Token</strong> to call protected resources.</li></ol><p>Below diagram shows the Authorization code flow in detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*puLSNfOazx6xz_YsnUos7Q.png" /><figcaption><a href="https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow">Microsoft identity platform and OAuth 2.0 authorization code flow — Microsoft identity platform | Microsoft Learn</a></figcaption></figure><h3>High Level Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EUbU9pcGzPe1wIZ29qKqJA.png" /><figcaption>High Level Architecture for MCP server as a backend server and Copilot Studio as a front-end client</figcaption></figure><h3>Develop MCP server in VS Code</h3><p>Clone the following repository and open in VS Code.</p><pre>git clone https://github.com/mafzal786/mcp-server.git</pre><p>Run the following to execute it locally.</p><pre>cd mcp-server <br>uv venv<br>uv sync<br>uv run mcpserver.py</pre><h3>Deploy MCP Server as Azure Container App</h3><p>Deploy the MCP server in Azure container App by running the following command. It can be deployed by many other various ways such as via VS Code or CI/CD pipeline. AZ Cli is used for simplicity.</p><pre>az containerapp up \<br>    --resource-group &lt;RESOURCE_GROUP_NAME&gt; \<br>    --name streamable-mcp-server2 \<br>    --environment mcp \<br>  --location &lt;REGION&gt; \<br>    --source .</pre><h3>Configure Authentication for Azure Container App</h3><p>Sign in Azure portal. Visit the container App in Azure and Click “Authentication” as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82eFVPcAXblyO7pGxg0Rdw.png" /></figure><p>For more details, visit the following link: <a href="https://learn.microsoft.com/en-us/azure/container-apps/authentication-entra">Enable authentication and authorization in Azure Container Apps with Microsoft Entra ID | Microsoft Learn</a></p><p>Click Add Identity Provider as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-5kXi_6OVkNkvhA0T6t1Q.png" /></figure><p>Select Microsoft from the drop down and leave everything as is as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lWsEweSQbHKu-X9lsNKLRQ.png" /></figure><p>This will create a new app registration for the container App. After it is all setup, it will look like as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*huXPu7PrQ0BX3SBqvQqqUw.png" /></figure><blockquote>As soon as authentication is configured. it will make container app inaccessible except for OAuth.</blockquote><h3>Review App Registration of Container App — Backend</h3><ol><li>Visit App registration and click streamable-mcp-server2 as in this case.</li><li>Click on Authentication tab. Verify the Redirect URIs. you should see a redirect URL for container app. URI will end with <strong>/.auth/login/aad/callback</strong> as shown in the green box in the below screenshot.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7nIMAr9NFda4yOsHiu2DQ.png" /></figure><p>3. Now click on “<strong>Expose an API</strong>”. Confirm Application ID URI is configured with scope as shown below. its format is <strong>api://&lt;client id&gt;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEVhAqSJzJVlMlMZqMoIww.png" /></figure><p>4. Verify API Permission. Make sure you Grant admin consent for your tenant as shown below. More scope can be created depending on the requirement of data access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NPbxu2KxwoK7iprAdhoMNw.png" /></figure><h3>Create App Registration for Client App — Copilot Studio</h3><p>In these steps, we will be configuring app registration for the client app, such copilot studio in this case acting as a client app. This is also mentioned in the “high level architecture” diagram in the earlier section of this article.</p><ol><li>Lauch Azure Portal. Visit App registration. Click New registration.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*Wq-adDB-ltHld2Ah4t2dqg.png" /></figure><p>2. Create a new App registration. leave the Redirect URL as of now, we will configure it later as it is provided by copilot studio when configuring custom MCP connector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsaAuQ4-HV7zy6PJV5UfJA.png" /></figure><p>3. Click on API permission and click “Add a permission”. Click Microsoft Graph and then click “Delegated permissions”. Select email, openid, profile as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*hmZ-RDaARCcBx3-vJJmkGg.png" /></figure><p>4. Make sure to Grant admin consent and it should look like as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jNKRSQnhoKxmc9txl8WhRw.png" /></figure><p>5. Create a secret. click “<strong>Certificates &amp; secrets</strong>”. Create a new client secret by clicking “New client secret”. store the value as it will be masked after some time. if that happens, you can always delete and re-create a new secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cnojt5Xwj9hOi5ynJ9rIbw.png" /></figure><p>5. Capture the following as you would need it in configuring MCP tool in Copilot Studio.</p><p>5a. Client ID from the Overview Tab of app registration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*hvU81lq6h9490FXaEH9wGQ.png" /></figure><p>5b. Client secret from “<strong>Certificates &amp; secrets</strong>” tab.</p><p>6. Configure API permissions for backend which is App registration of Azure container app i.e. streamable-mcp-server2 in this case. Click “<strong>API permissions</strong>” tab. Click “<strong>Add a permission</strong>”. Click on “<strong>My APIs</strong>” tab as shown below and select streamable-mcp-server2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xw0beX81lu668_lpQ1qTXg.png" /></figure><p>Select “Delegated permissions”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*3G0UzlqyOqzOgmd7wXhLsA.png" /></figure><p>Select the Permissions already created as a result of configuring Authentication for Azure Container App earlier. Click “Add permission”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VocSjBtoeF4IQ6B1WfOAaQ.png" /></figure><p>You MUST “<strong>Grant admin consent</strong>” as final step. It is very important!!! I can’t emphasize more on that. without it, nothing will work!!!</p><p>End result of this client app registration should look like as mentioned in the below figure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ONzKa2VPVsQYSL77XK3izw.png" /></figure><h3>MCP Tool configuration in Copilot Studio</h3><ol><li>Lauch copilot studio at <a href="https://copilotstudio.microsoft.com/">https://copilotstudio.microsoft.com/</a>. Configuration of environment and agent is beyond the scope of this article. It is assumed, you already have environment setup and agent has been created. Following link will help you, how to create an agent in copilot studio. <a href="https://learn.microsoft.com/en-us/microsoft-copilot-studio/fundamentals-get-started">Quickstart: Create and deploy an agent — Microsoft Copilot Studio | Microsoft Learn</a></li><li>Inside agent configuration, Click “Add tool”.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xh03nWYWs8wnzydTmAHeQg.png" /></figure><p>3. Click on New tool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s2c6zdiXhLwLs3D7AR3rVg.png" /></figure><p>4. Select Model Context Protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ms0gqJgbCCR76AZxpG_gYA.png" /></figure><p>5. Provide all relevant information for MCP server. Make sure your server URL ends with your mcp setup. In this case, it is Azure container app URL with <strong>/mcp</strong> in the end. Provide server name and server description.</p><p>Select OAuth 2.0 radio button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pseWG96czFSCF7opJ6lqlQ.png" /></figure><p>Provide the following in the OAuth 2.0 section</p><ul><li>Client ID of client app registration. In this case, copilot-studio-client as configured earlier.</li><li>Client secret of copilot-studio-client app registration.</li><li>Authorization URL: <a href="https://login.microsoftonline.com/50bd4340-8f6e-4d1a-8387-32e46da5051d/oauth2/v2.0/authorize">https://login.microsoftonline.com/common/oauth2/v2.0/authorize</a></li><li>Token URL template &amp; Refresh URL: <a href="https://login.microsoftonline.com/oauth2/v2.0/token">https://login.microsoftonline.com/oauth2/v2.0/token</a></li><li>Scopes: <strong>openid, profile, email</strong> — which we selected earlier for Microsoft Azure Graph permissions.</li><li>Click “Create”.</li></ul><p>This will provide you Redirect URL. you need to configure the redirect URL in client app registration. In this case, it is copilot-agent-client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1F-8A1IsVzvjc-uOew0GSg.png" /></figure><h4>Configure Redirect URL in Client App Registration</h4><p>Visit client app registration. i.e. copilot-studio-client. Click Authentication Tab and provide the Web Redirect URIs as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AE8y3mXj0b0uUR7IQMYx7g.png" /></figure><h4>Modify MCP connector in PowerApps</h4><p>Now visit the <a href="https://make.powerapps.com/">https://make.powerapps.com</a> and open the newly created connector as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jRThSWVkoYozWt8FePTrGg.png" /></figure><p>Change the Resource URL from “Expose an API” in streamable-mcp-server2 app registration. The backend “<strong>Application ID URI” and</strong> also add <strong>.default</strong> in the scope. Provide the <strong>secret</strong> of client app registration as it will not let you update the connector. This is extra security measure for updating the connector in Powerapps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TAN3sqr9lIte5HazylZgmg.png" /></figure><p>Click Update connector.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ypeL5g_m83ux8Is8_cnuBw.png" /></figure><h3>CORS Configuration</h3><p>Congratulation of getting that far!!!, We are getting close to make it work!!!</p><p>CORS configuration is a MUST!!! Since our Azure Container App is a remote MCP with totally different domain or origin.</p><h4>Power Apps and CORS for External Domains — Brief Overview</h4><p>When embedding or integrating <strong>Power Apps</strong> with external web applications or APIs, <strong>Cross-Origin Resource Sharing (CORS)</strong> becomes a critical consideration. CORS is a browser security feature that restricts web pages from making requests to a different domain than the one that served the page, unless explicitly allowed.</p><h4><strong>Key Points:</strong></h4><ul><li>Power Apps hosted on *.powerapps.com or within Microsoft 365 domains will block calls to external APIs unless those APIs include the proper <strong>CORS headers</strong>.</li><li>The external API must return:</li><li>Access-Control-Allow-Origin: https://apps.powerapps.com (or * for all origins, though not recommended for production)</li><li>Access-Control-Allow-Methods: GET, POST, OPTIONS (or as needed)</li><li>Access-Control-Allow-Headers: Content-Type, Authorization (and any custom headers)</li><li>If the API requires authentication (e.g., OAuth 2.0), ensure <strong>preflight OPTIONS requests</strong> are handled correctly.</li><li>For scenarios where you cannot modify the external API, consider using:</li><li><strong>Power Automate flows</strong> as a proxy</li><li><strong>Azure API Management</strong> or <strong>Azure Functions</strong> to inject CORS headers</li><li>Always validate security implications before enabling wide-open CORS.</li></ul><p>If the CORS are not setup. You will encounter following error in copilot studio after pressing F12 (Browser Developer)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bYolifb09CkDpVLGmZ7xPA.png" /><figcaption>CORS policy — blocking the container app</figcaption></figure><p>Azure container app provides very efficient way of configuring CORS in the Azure portal.</p><ol><li>Lauch Azure Portal. Visit Azure container app i.e. streamable-mcp-server2 in this case.</li><li>Click on <strong>CORS</strong> under <strong>Networkin</strong>g section.</li><li>Configure the following in <strong>Allowed Origin</strong> Section as shown below. localhost is added to make it work from local laptop, although it is not required for Copilot Studio.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NmGI2P90mWoKjOIaFWnxKQ.png" /></figure><p>4. Click on “<strong>Allowed Method</strong>” tab and provide the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xltME4ctE46uwRI5opKe3Q.png" /></figure><p>5. Provide wild card “*” in “<strong>Allowed Headers”</strong> tab. Although, it is not recommended for production system. it is done for the sake for simplicity. Configure that for added security</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cU7oIsV209xCf8fUHpZo9Q.png" /></figure><p>6. Click “<strong>Apply</strong>”. This will configure CORS for remote application.</p><h3>Test the connector</h3><p>We are in the final stages of configuring the connector. It is time to test it, if everything is configured correctly and works.</p><ol><li>Lauch the h<a href="http://http//make.powerapps.com">ttp://make.powerapps.com</a> and click on “<strong>Custom connectors”</strong>, select your configured connector and click “<strong>5. Test</strong>” tab as shown below. You will see Selected Connection as blank if you are running it first time. Click “<strong>+ New connection</strong>”</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZxi0RyPxbRKgRF1LaepZg.png" /></figure><p>2. New connection will launch the Authorization flow and browser dialog will pop up for making a request for authorization code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*6fzFTSexttyXCVLZwhmqTQ.png" /></figure><p>Click “Create”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*jloO9mpb5Yx4HSLSi0oTVA.png" /></figure><p>3. Complete the login process. This will create a successful connection.</p><p>4. Click “<strong>Test operation</strong>”. If the response is 406 means everything is configured correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L2ruljZUJY99kzpAr3ENgw.png" /></figure><h3>Test MCP Tool in Copilot Studio</h3><p>Lauch copilot studio and click on the Agent you created in earlier steps and click on “<strong>Tools tab</strong>”. Select your MCP tool as shown the following figure.</p><p>Make sure it is “<strong>Enabled</strong>” if you have other tools attached to the same agent, disable them for now for testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8KIMh5fQHubwUtWGLD2SOg.png" /></figure><p>Make sure you have connection available which we created during the testing of custom connector in earlier step. You can also initiate a fresh connection by clicking on the drop down under “Connection” as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g0H31ziubMzuQ8ntGtDmbQ.png" /></figure><p>Refreshing the tools will show all the tools available in this MCP server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8aR9GGXFi2dvA-sbM9senA.png" /></figure><p>Provide the prompt such as “Give me the stock price of tesla”. This will trigger the MCP server and call the respective method to bring the stock price of Tesla.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*QZC1C4n3M5ZGBgskyv3AMQ.png" /></figure><p>Now try a weather-related question to see more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*lY911E4O8n8DocavNY16Zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eoqIKeQ8f1h8YkHWeaONGQ.png" /></figure><h3>Conclusion</h3><p>Securing MCP tools in <strong>Copilot Studio</strong> with <strong>OAuth 2.0 Authorization Code Flow</strong> is a critical step toward building enterprise-ready integrations. By leveraging this flow, you ensure that user credentials remain protected while enabling delegated access to sensitive APIs and resources.</p><p>The approach outlined here provides a solid foundation, but it’s only the beginning. As environments differ, you should evaluate additional security enhancements such as <strong>app roles</strong>, <strong>conditional access policies</strong>, and <strong>token lifecycle management</strong> to meet organizational compliance standards.</p><p>Remember, MCP integration in Copilot Studio is still a <strong>preview feature</strong>, and the ecosystem evolves rapidly. Stay informed, revisit configurations periodically, and adapt to new best practices as they emerge. With a thoughtful implementation, you can unlock the full potential of MCP tools while maintaining robust security and user trust.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2064236c70f9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/step-by-step-guide-mcp-tool-call-in-copilot-studio-agent-with-oauth-2-0-2064236c70f9">Step-by-Step Deployment Guide: MCP Tool Call in Copilot Studio agent with OAuth 2.0</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securely expose Azure AI Foundry Projects via API Management]]></title>
            <link>https://muafzal.medium.com/securely-expose-azure-ai-foundry-projects-via-api-management-0fadcf43d3e8?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fadcf43d3e8</guid>
            <category><![CDATA[api-management]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[genai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Thu, 04 Sep 2025 16:01:58 GMT</pubDate>
            <atom:updated>2025-10-11T13:34:54.190Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IaX71cZ8yHAo13v7O3r2YA.png" /></figure><h3>A Practical Guide — Securely expose Azure AI Foundry Projects via API Management</h3><p>A Practical Guide — Build intelligent AI agent with AI Foundry projects via API Management (APIM). Step by step guide for setting up secure AI projects in AI Foundry</p><h3>Introduction</h3><p>To scale AI agent development effectively, it’s essential to expose your Azure AI Foundry APIs in a secure and manageable way. By importing these APIs into APIM, you enable controlled access, monitoring, and reuse across teams and applications.</p><blockquote>This blog walks through how to integrate Azure AI Foundry projects with API Management to support scalable AI solutions.</blockquote><h3>Must-Know Details Before You Proceed</h3><p>1 Azure AI Foundry integration with API management is very well documented at <a href="https://learn.microsoft.com/en-us/azure/api-management/azure-ai-foundry-api">Import an Azure AI Foundry API — Azure API Management | Microsoft Learn</a> for managing model endpoint in Azure AI and Azure Open AI. Clients can call the deployment at an /openai endpoint such as /openai/deployments/my-deployment/chat/completions.</p><p><strong>However,</strong> when it comes to consume Azure AI Foundry project for AI agent development, you need to consume project REST API operations, the central resource that brings together models, data, tools, and telemetry in Azure AI Foundry. Detail REST operations are available at <a href="https://learn.microsoft.com/en-us/rest/api/aifoundry/aiagents/operation-groups?view=rest-aifoundry-aiagents-v1">Data Plane | Microsoft Learn</a></p><blockquote>Note — Creating API in APIM using Azure AI Foundry does not automatically configure REST endpoints for AI Foundry projects. it requires minor tweaks, and this blog help you configure APIM for AI Foundry projects</blockquote><p>2 Agents in Azure AI Foundry projects refers to assistant in REST API operations constructs, similar to Azure AI assistant API. Such as, for listing all agents within a project, REST operations will look like as below.</p><pre>GET {endpoint}/assistants?api-version=v1<br><br>Project endpoint in the form of: https://&lt;aiservices-id&gt;.services.ai.azure.com/api/projects/&lt;project-name&gt;</pre><p>You can run a CURL command for the above endpoint as below for testing the REST operations. Below command will list all agents within a project.</p><pre> Curl --request GET --url &quot;https://&lt;ai service id&gt;.services.ai.azure.com/api/projects/&lt;project name&gt;/assistants?api-version=v1&quot;  --header &quot;Authorization:Bearer &lt;bearer token&gt;&quot;</pre><p>You have to generate the auth token and you can use the following CLI command to generate the auth token.</p><pre> az account get-access-token --resource https://ai.azure.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ubx2sg2bcS2QSCMD0ourkg.png" /></figure><p>Details of all REST operation can be found at <a href="https://learn.microsoft.com/en-us/rest/api/aifoundry/aiagents/operation-groups?view=rest-aifoundry-aiagents-v1">Data Plane | Microsoft Learn</a></p><p>3 Following are the prerequisite for setting up the environment.</p><ul><li>Existing API management instance. Create one if it does not exist. You can start with the Developer pricing tier.</li><li>An Azure AI service in your subscription with one or more models deployed. Make sure you have one project created.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*omh-cwNtVXg9Ew7GGRQAFg.png" /></figure><p>. Make sure, you have managed identity enabled for APIM.</p><h3>Step by Step Guide</h3><h4>Import AI Foundry API using Portal</h4><p>To import an AI Foundry API to API Management:</p><ol><li>In the <a href="https://portal.azure.com/">Azure portal</a>, navigate to your API Management instance.</li><li>In the left menu, under APIs, select APIs &gt; + Add API.</li><li>Under Create from Azure resource, select Azure AI Foundry.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*bR45RSuL3AAr3LZp0tvLYA.png" /></figure><p>4. On the Select AI service tab: Select the Subscription in which to search for AI services. If you want to get information about the model deployments in a service, select the deployments link next to the service name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqnWNyB1S2TJm_nkhw6rQ.png" /></figure><p>5. On the Configure API tab:</p><p>a. Enter a Display name and optional Description for the API.</p><p>b. In Base path, enter a path that your API Management instance uses to access the deployment endpoint.</p><p>c. Optionally select one or more Products to associate with the API.</p><p>d. In Client compatibility, select either of the following based on the types of client you intend to support. See <a href="https://learn.microsoft.com/en-us/azure/api-management/azure-ai-foundry-api#client-compatibility-options">Client compatibility options</a> for more information.</p><ul><li>Azure OpenAI — Select this option if your clients only need to access Azure OpenAI model deployments.</li><li>Azure AI — Select this option if your clients need to access other models in Azure AI Foundry.</li></ul><p>6. Select Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*slkfKT3aAfKmMxMzYer4kg.png" /></figure><p>7. You can skip rest of the tabs for the sake of simplicity here and get to Review + Create. After settings are validated. Click “Create”</p><h4>IAM Configuration in AI Service for APIM access</h4><p>API Import also orchestrate the necessary RBAC requirement to access Azure AI foundry API via APIM using managed identity. If you visit IAM tab of Azure AI service, you will find that APIM managed identity has “Azure AI User” role added as shown below for reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2TsU80n2cYgd5WQOfUKzQ.png" /></figure><h4>APIM Backend configuration</h4><p>If you look into APIM policy definition, API import also creates a backend in APIM as shown in the inbound policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tININUr55ILcYyrjwQj7xQ.png" /></figure><p>Lets find out this backend in APIM. Click on backends in APIM as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*9Ms7SXPMvwJRqyDPU1kvTg.png" /></figure><p>In order to use project endpoint for AI agent development, you need to change the backend Runtime URL under Properties. Default, you will get /openai which will work chat completions, NOT the agents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U9BWvbGEpd2DA3h_wZE5iA.png" /></figure><p>Now visit Authorization Credentials tab and make sure you provide <a href="https://ai.azure.com/">https://ai.azure.com</a> as a Resource ID to generate Auth Token. Otherwise, you will encounter 401 errors in your API calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4zwcyo-S-SbROTyfy7Yyw.png" /></figure><h3>Test the API</h3><p>In APIM, click on APIs and select the API such as aifoundry in this case. Click on the Test tab and filter for assistant. Select “Returns a list of assistants”. Make sure to update the api-version to v1 otherwise, you will encounter Bad request error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZWCujqYO8vMAHmJkDrz5bg.png" /></figure><p>Click “Send”. you will get the 200 ok response with the list of agents in AI foundry under Project01 as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEPmDyeYpoV9TlmoSSzhKg.png" /></figure><p>Following is the AI Foundry agents view in Azure AI Foundry UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09Ew_eIaobdIci_XwMYVMQ.png" /></figure><p>We can verify the same using the following curl command</p><pre>curl &quot;https://&lt;your apim resource&gt;.azure-api.net/agents/assistants?api-version=v1&amp;limit=20&quot; -H &quot;Content-Type: application/json&quot; -H &quot;api-key: &lt;subscription key from APIM&gt;&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oMunKxWvmAyZj1S2TMvU4Q.png" /></figure><h3>Making the Project Name Dynamic</h3><p>So far, everything works fine and looks good. However, did you notice project name is hard coded in the Runtime URL in APIM backend configuration which means, it will only work with agents in “Project01”. This is a big limitation!!!</p><p>We can solve this by modifying the inbound policy in APIM and can make the project name dynamic. We can send the project name as a query parameter. Below is the sample APIM policy for that.</p><pre>&lt;inbound&gt;<br>        &lt;base /&gt;<br>        &lt;authentication-managed-identity resource=&quot;https://ai.azure.com&quot; output-token-variable-name=&quot;msi-access-token&quot; ignore-error=&quot;false&quot; /&gt;<br>        &lt;set-header name=&quot;Authorization&quot; exists-action=&quot;override&quot;&gt;<br>            &lt;value&gt;@(&quot;Bearer &quot; + (string)context.Variables[&quot;msi-access-token&quot;])&lt;/value&gt;<br>        &lt;/set-header&gt;<br>        &lt;set-variable name=&quot;projectname&quot; value=&quot;@(context.Request.Url.Query.GetValueOrDefault(&quot;project&quot;, &quot;&quot;))&quot; /&gt;<br>        &lt;set-variable name=&quot;baseurl&quot; value=&quot;https://&lt;Your AI Service&gt;.services.ai.azure.com/api/projects/&quot; /&gt;<br>        &lt;set-backend-service base-url=&quot;@(&quot;https://muafz-me2afs4i-eastus2.services.ai.azure.com/api/projects/&quot; + context.Variables.GetValueOrDefault&lt;string&gt;(&quot;projectname&quot;))&quot; /&gt;<br>        &lt;!--set-backend-service id=&quot;apim-generated-policy&quot; backend-id=&quot;aifoundry-ai-endpoint&quot; --&gt;<br>    &lt;/inbound&gt;</pre><p>Let&#39;s run the curl command with project name being passed as query string as shown below.</p><pre>curl &quot;https://&lt;your apim resource&gt;.azure-api.net/agents-clone/assistants?api-version=v1&amp;project=Project01&quot; -H &quot;Content-Type: application/json&quot; -H &quot;api-key: &lt;apim key&gt;&quot;</pre><p>As you can see in the below screen shot, project name is being passed as a query string parameter in the CURL command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqWKNyPLaWY7wnbkLDE28w.png" /></figure><h3>Conclusion</h3><p>Exposing Azure AI Foundry projects through Azure API Management offers a robust and scalable approach to securely operationalize AI capabilities. By leveraging API Management, organizations can enforce authentication, authorization, rate limiting, and monitoring — ensuring that AI services are not only accessible but also protected against misuse and vulnerabilities. This integration empowers teams to deliver AI solutions with confidence, maintain governance, and accelerate innovation across enterprise environments. As AI adoption grows, secure API exposure becomes a critical enabler for responsible and efficient AI deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fadcf43d3e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Pattern Matching to Semantic Search: Azure SQL’s Vector Leap]]></title>
            <link>https://blog.devgenius.io/from-pattern-matching-to-semantic-search-azure-sqls-vector-leap-edc687f97fb0?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/edc687f97fb0</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Thu, 28 Aug 2025 15:40:50 GMT</pubDate>
            <atom:updated>2025-09-05T20:09:04.567Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d81hByiKh0ivGoZZ8zCxHw.png" /></figure><p><strong>Unlocking Intelligent Search with Azure SQL and Azure OpenAI Embeddings</strong></p><h3>Introduction</h3><p>In the evolving landscape of data-driven applications, the way we query and interpret textual data is undergoing a significant transformation. Traditional SQL Server’s LIKE clause has long been the go-to method for pattern matching in strings, offering a simple yet limited approach to search. However, with the rise of AI-powered features in cloud databases, Azure SQL now introduces <strong>Vector Similarity Search</strong>, enabling semantic search capabilities that go far beyond basic string matching. This blog explores the key differences between these two approaches, highlighting how vector search can unlock deeper insights and more intelligent querying for modern applications.</p><h3>What Is Vector Similarity Search in Azure SQL?</h3><p>Vector Similarity Search is a powerful new capability in Azure SQL that enables <strong>semantic search</strong> — a way to find data based on meaning rather than exact text matches. Unlike traditional SQL queries that rely on pattern matching (like the LIKE clause), vector search uses <strong>numerical representations of data</strong>, called <strong>embeddings</strong>, to measure how similar two pieces of information are.</p><p>These embeddings are typically generated using machine learning models that convert text, images, or other data types into high-dimensional vectors. Once stored in Azure SQL, these vectors can be compared using similarity metrics such as <strong>cosine similarity</strong> or <strong>Euclidean distance</strong>. This allows developers to perform queries like:</p><ul><li>Finding documents similar to a given paragraph</li><li>Matching user queries to relevant product descriptions</li><li>Recommending items based on semantic similarity</li></ul><p>Azure SQL integrates this functionality seamlessly, allowing you to store and index vector data alongside traditional relational data. With support for <strong>vector indexes</strong> and <strong>approximate nearest neighbor (ANN) search</strong>, it enables fast and scalable semantic search directly within your database — no need for external services or complex pipelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GcanIA--qFX8o6-acSx-uQ.png" /></figure><h3>Download sample SQL to setup demo environment</h3><p>Download the following .sql from the Github link below.</p><p><a href="https://github.com/mafzal786/Azure-SQL-Vector-Search">mafzal786/Azure-SQL-Vector-Search</a></p><h3>Getting Started</h3><p>This example shows how to use Azure OpenAI from Azure SQL database to get the vector embeddings and perform vector similarity search. This example uses “AdventureWorkLT” as a demo database. you can download this database from the following link. <a href="https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver17&amp;tabs=ssms">https://learn.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-ver17&amp;tabs=ssms</a></p><p>Restore this database into your SQL server. Vector data type is supported in SQL Server 2025, Azure SQL, Azure SQL Managed Instance, or SQL Database in Fabric (Preview). For more details follow. <a href="https://learn.microsoft.com/en-us/sql/t-sql/data-types/vector-data-type?view=sql-server-ver17&amp;tabs=csharp">https://learn.microsoft.com/en-us/sql/t-sql/data-types/vector-data-type?view=sql-server-ver17&amp;tabs=csharp</a></p><h4>Steps</h4><ul><li>Make sure, you have Azure OpenAI resource already provisioned. Modify the “get_embeddings.sql” with Azure OpenAI endpoint and access key.</li><li>Run “create vector embeddings table.sql”</li><li>Test output using “run vector similarity search.sql”</li></ul><p>Final output would look like as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yKRS38i0HgPvPGRjZ9utKg.png" /></figure><h3>Conclusion</h3><p>As data applications become more intelligent and user expectations rise, traditional search methods like SQL Server’s LIKE clause are no longer sufficient for delivering relevant, context-aware results. Azure SQL’s Vector Similarity Search marks a significant shift toward semantic understanding, enabling developers to build smarter, AI-enhanced applications directly within their database environment. By leveraging vector embeddings and similarity metrics, Azure SQL empowers you to go beyond pattern matching and unlock deeper insights from your data. Whether you&#39;re building recommendation systems, intelligent search features, or natural language interfaces, vector search is a game-changer worth exploring.</p><p>Azure SQL database, now has support to perform vector operations directly in the database, making it easy to perform vector similarity search. Using vector search along with fulltext search and BM25 ranking, it is possible to build powerful search engines that can be used in a variety of scenarios.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edc687f97fb0" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/from-pattern-matching-to-semantic-search-azure-sqls-vector-leap-edc687f97fb0">From Pattern Matching to Semantic Search: Azure SQL’s Vector Leap</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing MCP Remote Servers with Azure Function App and Github Copilot Integration]]></title>
            <link>https://medium.com/analytics-vidhya/implementing-mcp-remote-servers-with-azure-function-app-and-github-copilot-integration-96ffb674de1d?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/96ffb674de1d</guid>
            <category><![CDATA[github-copilot]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Tue, 12 Aug 2025 17:16:30 GMT</pubDate>
            <atom:updated>2025-09-18T14:44:45.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RJmQGn4_2LD6lJOU9z00jg.png" /></figure><p>Step by step guide to implement an Azure Function App as a remote MCP server</p><h3>Introduction</h3><p>In the evolving landscape of AI-driven applications, the ability to seamlessly connect large language models (LLMs) with external tools and data sources is becoming a cornerstone of intelligent system design. Model Context Protocol (MCP) — a specification that enables AI agents to discover and invoke tools dynamically, based on context.</p><p>While MCP is powerful, implementing it from scratch can be daunting !!! That’s where Azure Functions comes in handy. With its event-driven, serverless architecture, Azure Functions now supports a <strong>preview</strong> extension for MCP, allowing developers to build remote MCP servers that are scalable, secure, and cloud-native.</p><p>Further, In VS Code, GitHub Copilot Chat in Agent Mode can connect to your deployed Azure Function App acting as an MCP server. This connection allows Copilot to leverage the tools and services exposed by your function app.</p><h3>Why Use Azure Functions for MCP?</h3><ul><li><strong>Serverless Simplicity</strong>: Deploy MCP endpoints without managing infrastructure.</li><li><strong>Secure by Design</strong>: Leverage HTTPS, system keys, and OAuth via EasyAuth or API Management.</li><li><strong>Language Flexibility:</strong> Build in .NET, Python, or Node.js using QuickStart templates.</li><li><strong>AI Integration</strong>: Enable GitHub Copilot, VS Code, or other AI agents to invoke your tools via SSE endpoints.</li></ul><h3>Prerequisites</h3><ul><li><a href="https://www.python.org/downloads/">Python</a> version 3.11 or higher</li><li><a href="https://learn.microsoft.com/azure/azure-functions/functions-run-local?pivots=programming-language-python#install-the-azure-functions-core-tools">Azure Functions Core Tools</a> &gt;= 4.0.7030</li><li><a href="https://aka.ms/azd">Azure Developer CLI</a></li><li>To use Visual Studio Code to run and debug locally:</li><li><a href="https://code.visualstudio.com/">Visual Studio Code</a></li><li><a href="https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions">Azure Functions extension</a></li></ul><p>An storage emulator is needed when developing azure function app in VScode. you can deploy Azurite extension in VScode to meet this requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*le3YJwDdxeZX6oZWsayNsA.png" /></figure><p>You can run the Azurite in VS Code as shown below.</p><pre>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator&gt; .\azurite.exe</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rHIeSRw6aN47EG6qMfnfQ.png" /></figure><p>alternatively, you can also run Azurite in docker container as shown below.</p><pre>docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \<br>    mcr.microsoft.com/azure-storage/azurite</pre><p>For more information about setting up Azurite, visit <a href="https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio%2Cblob-storage">Use Azurite emulator for local Azure Storage development | Microsoft Learn</a></p><h3>Github Repositories</h3><p>Following Github repos are needed to setup this PoC.</p><p><strong>Repository for MCP server using Azure Function App</strong></p><p><a href="https://github.com/mafzal786/mcp-azure-functions-python.git">https://github.com/mafzal786/mcp-azure-functions-python.git</a></p><p><a href="https://github.com/mafzal786/mcp-azure-functions-python.git">GitHub - mafzal786/mcp-azure-functions-python: mcp server using azure function app</a></p><p><strong>Repository for AI Foundry agent as MCP Client</strong></p><p><a href="https://github.com/mafzal786/ai-foundry-agent-with-remote-mcp-using-azure-functionapp.git">https://github.com/mafzal786/ai-foundry-agent-with-remote-mcp-using-azure-functionapp.git</a></p><h3>Clone the repository</h3><p>Run the following command to clone the repository to start building your MCP server using Azure function app.</p><pre>git clone https://github.com/mafzal786/mcp-azure-functions-python.git</pre><h3>Run the MCP server in VS Code</h3><p>Once cloned. Open the folder in VS Code. Create a virtual environment in VS Code. Change directory to “src” in a new terminal window, install the python dependencies and start the function host locally as shown below.</p><pre>cd src<br>pip install -r requirements.txt<br>func start</pre><p>Note: by default this will use the webhooks route: /runtime/webhooks/mcp/sse. Later we will use this in Azure to set the key on client/host calls: /runtime/webhooks/mcp/sse?code=&lt;system_key&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*2YbtN0dFPRiWCdTx5Kfyow.png" /></figure><h3>MCP Inspector</h3><p>In a new terminal window, install and run MCP Inspector.</p><pre>npx @modelcontextprotocol/inspector</pre><p>Click to load the MCP inspector. Also provide the generated proxy session token.</p><pre>http://127.0.0.1:6274/#resources</pre><p>In the URL type and click “Connect”:</p><pre>http://localhost:7071/runtime/webhooks/mcp/sse</pre><p>Once connected, click List Tools under Tools and select “hello_mcp” tool and click “Run Tool” for testing as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uth-7CBODwVLhEYK-IXxHw.png" /></figure><p>Select another tool such as get_stockprice and run it as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*834GVUZx_NLIOgChxZqQew.png" /></figure><h3>Deploy Function App to Azure from VS Code</h3><p>For deploying function app to azure from vs code, make sure you have Azure Tools extension enabled in VS Code. To learn more about Azure Tools extension, visit the following <a href="https://code.visualstudio.com/docs/azure/overview">Azure Extensions</a></p><p>if your VS code environment is not setup for Azure development, follow <a href="https://learn.microsoft.com/en-us/dotnet/azure/configure-vs-code">Configure Visual Studio Code for Azure development with .NET — .NET | Microsoft Learn</a></p><p>Once Azure Tools are setup, sign in to Azure account with Azure Tools</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/0*N4FXUeHz7WxhJdGO.png" /></figure><p>Once Sign-in is completed, you should be able to see all of your existing resources in the Resources view. These resources can be managed directly in VS Code.</p><p>Look for Function App in Resource, right click and click “Deploy to Function App”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eb257vwqK2iDytIBUaQkZA.png" /></figure><p>If you already have it deployed, you will get the following pop-up. Click “Deploy”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*QiIkKkG1EO-7u6qm2mgkZA.png" /></figure><p>This will start deploying your function app to Azure. In VS Code, Azure tab will display the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*hLN8WtBaDFNLKpBCDfi2JQ.png" /></figure><p>Once the deployment is completed, you can view the function app and all the tools in Azure portal under function app as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HujDZtoBK-ZCmHsSOCtLNQ.png" /></figure><p>Get the mcp_extension key from Functions → App Keys in Function App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ISmajH1kSSHVNPT1TAkL0Q.png" /></figure><p>This mcp_extension key would be needed in mcp.json file in VS code, if you would like to test the MCP server using Github Copilot in VS Code. Your entries in mcp.json file will look like as below for example.</p><pre>{<br>    &quot;inputs&quot;: [<br>        {<br>            &quot;type&quot;: &quot;promptString&quot;,<br>            &quot;id&quot;: &quot;functions-mcp-extension-system-key&quot;,<br>            &quot;description&quot;: &quot;Azure Functions MCP Extension System Key&quot;,<br>            &quot;password&quot;: true<br>        },<br>        {<br>            &quot;type&quot;: &quot;promptString&quot;,<br>            &quot;id&quot;: &quot;functionapp-name&quot;,<br>            &quot;description&quot;: &quot;Azure Functions App Name&quot;<br>        }<br>    ],<br>    &quot;servers&quot;: {<br>        &quot;remote-mcp-function&quot;: {<br>            &quot;type&quot;: &quot;sse&quot;,<br>            &quot;url&quot;: &quot;https://${input:functionapp-name}.azurewebsites.net/runtime/webhooks/mcp/sse&quot;,<br>            &quot;headers&quot;: {<br>                &quot;x-functions-key&quot;: &quot;${input:functions-mcp-extension-system-key}&quot;<br>            }<br>        },<br>        &quot;local-mcp-function&quot;: {<br>            &quot;type&quot;: &quot;sse&quot;,<br>            &quot;url&quot;: &quot;http://0.0.0.0:7071/runtime/webhooks/mcp/sse&quot;<br>        }<br>    }<br>}</pre><h3><strong>Test Azure Function MCP Server in MCP Inspector</strong></h3><p>Launch MCP Inspector and provide the Azure Function in MCP inspector URL. Provide authentication as shown below. Bearer token is mcp_extension key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*iTqHA8qnIfKD0pHF-6a8Zw.png" /></figure><h3>Testing an MCP server with GitHub Copilot</h3><p>Testing an MCP server with GitHub Copilot involves configuring and utilizing the server within your development environment to provide enhanced context and capabilities to Copilot Chat.</p><p>Steps to Test an MCP Server with GitHub Copilot:</p><h4><strong>Ensure Agent Mode is Enabled:</strong></h4><p>Open Copilot Chat in Visual Studio Code and select “Agent” mode. This mode allows Copilot to interact with external tools and services, including MCP servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*7aiAkTSIELPxK8mIbEek-A.png" /></figure><h4><strong>Add the MCP Server:</strong></h4><ul><li>Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) and run the command MCP: Add Server.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*nc572jfZEZ54SOi33LJ6wA.png" /></figure><ul><li>Follow the prompts to configure the server. You can choose to add it to your workspace settings (creating a .vscode/mcp.json file) . Select HTTP or Server-Sent events</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*gimnrFlbWn92CetviKfR3Q.png" /></figure><p>Specify the URL and click Enter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*fPH6WthXqiLmIVSRfgke0g.png" /></figure><p>Provide a name of your choice</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*hpbk1yAxWiAX6cM_5N3oSg.png" /></figure><p>Select scope as Global or workspace. I selected Workspace</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*xQE9gZ2ACHd9Tguw5jRqEg.png" /></figure><p>This will generate mcp.json file in .vscode or create a new entry if mcp.json already exists as shown below. Click Start to “start” the server. Also make sure your Azure function app is locally running with func start command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*QSqpvj6EmiAfyd3k-o9FCQ.png" /></figure><p>Now Type the prompt as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*QVkQ45qmj-7Td9awWXGlZA.png" /></figure><p>Try another tool as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*Z8MLbBTVXWLQzJW55mSE_Q.png" /></figure><p>VS code terminal output for reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*GRsWjuSzWmBjhAkVQJQz4w.png" /></figure><h3>Testing an MCP server with Claude Desktop</h3><p>Claude Desktop is a standalone AI application that allows users to interact with Claude AI models directly from their desktop, providing a seamless and efficient experience. you can download Claude desktop at <a href="https://claude.ai/download">Download Claude</a></p><p>In this article, I have added another tool to utilize to test your MCP server running in Azure Function app.</p><p>Modify claude_desktop_config.json with the following. you can find this file in window environment at C:\Users\&lt;username&gt;\AppData\Roaming\Claude</p><pre>{ &quot;mcpServers&quot;: { &quot;my mcp&quot;: { &quot;command&quot;: &quot;npx&quot;, &quot;args&quot;: [ &quot;mcp-remote&quot;, &quot;http://localhost:7071/runtime/webhooks/mcp/sse&quot; ] } } }</pre><p>Note: If claude_desktop_config.json does not exists, click on setting in Claude desktop under user and visit developer tab.</p><p>You will see you MCP server in Claude Desktop as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*Fm_MQ6kh_dsORUO2fN400g.png" /></figure><p>Type the prompt such as “What is the stock price of Tesla” . After submitting, you will notice that it is invoking the tool “get_stockprice” from the MCP server running locally and configured in the .json earlier. Click Allow once or Allow always as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*8pCT6NaJvvRKgMrJyomW8w.png" /></figure><p>Following output will be displayed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*APVGW-YuAN6N2OWZvMSpiA.png" /></figure><p>Now lets try weather related prompt. As you can see, it has invoked “get_weatheralerts” tool from MCP server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2QZOfvAeLAS3hfiAKnFh-w.png" /></figure><h3>Azure AI Foundry agent as MCP Client</h3><p>Use the following Github repo to set up Azure AI Foundry agent as MCP client.</p><pre>git clone https://github.com/mafzal786/ai-foundry-agent-with-remote-mcp-using-azure-functionapp.git</pre><p>Open the code in VS code and follow the instructions mentioned in README.md file at Github repo. Once you execute the code, following output will show up in VS code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ssl1YOWoAFKLo1VzgBrUhA.png" /></figure><p>In this code, message is hard coded. Change the content to “what is weather advisory for Florida” and rerun the program. It will call <strong>get_weatheralerts</strong> tool and output will look like as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HNqnQsCfzrsinIbipS9fog.png" /></figure><h3>Conclusion</h3><p>The integration of <strong>Model Context Protocol (MCP)</strong> with <strong>Azure Functions</strong> marks a pivotal step in democratizing AI agent development. By leveraging Azure’s serverless architecture, developers can now build <strong>remote MCP servers</strong> that scale automatically, integrate seamlessly with other Azure services, and expose modular tools to intelligent agents like <strong>GitHub Copilot</strong>.</p><p>This setup not only simplifies the deployment and management of MCP servers but also enhances the developer experience — allowing tools to be invoked contextually by AI agents in environments like <strong>VS Code</strong>, <strong>GitHub Codespaces</strong>, or <strong>Copilot Studio</strong><a href="https://learn.microsoft.com/en-us/azure/app-service/tutorial-ai-model-context-protocol-server-dotnet">[2]</a>. Whether you’re building a tool to query logs, calculate metrics, or manage data, Azure Functions provides the flexibility, security, and scalability needed to bring your AI-powered workflows to life.</p><p>As the MCP spec continues to evolve, and GitHub Copilot expands its agentic capabilities, this architecture positions you to stay ahead — offering a robust foundation for cloud-native AI tooling that’s both powerful and future-proof.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96ffb674de1d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/implementing-mcp-remote-servers-with-azure-function-app-and-github-copilot-integration-96ffb674de1d">Implementing MCP Remote Servers with Azure Function App and Github Copilot Integration</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leveraging API Management for OpenAI Applications — Azure Multi-Node API Management (APIM) to…]]></title>
            <link>https://faun.pub/leveraging-api-management-for-openai-applications-azure-multi-node-api-management-apim-to-921c886f8441?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/921c886f8441</guid>
            <category><![CDATA[api-management]]></category>
            <category><![CDATA[azureopenai]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[genai]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 03:35:32 GMT</pubDate>
            <atom:updated>2025-07-14T19:11:47.783Z</atom:updated>
            <content:encoded><![CDATA[<h3>Leveraging API Management for Azure OpenAI Applications — Azure Multi-Region API Management (APIM) to manage, secure, and scale your LLM-based applications</h3><p>Empower intelligence securely at scale</p><h3>Introduction</h3><p>With the rapid growth of Artificial Intelligence (AI), industries are increasingly exploring its potential for innovation and development. Microsoft’s Azure OpenAI Service enables secure access to powerful language models like GPT-4 and GPT-3.5-Turbo, offering enterprise-grade features such as private networking, regional availability, and responsible AI filtering.</p><p>However, integrating AI into enterprise environments raises concerns around security, governance, and scalability. This is where Azure API Management (APIM) plays a critical role — providing secure, scalable, and observable access to Azure OpenAI endpoints. APIM helps manage throttling, monitoring, and secure API exposure, making it easier for internal and external users to adopt AI capabilities.</p><p>As organizations seek to quickly and securely build solutions like ChatGPT with proprietary data, the focus shifts from MVP development to scaling into production. Leveraging APIM ensures that these solutions are production-ready, secure, and reliable.</p><h3>Architecture</h3><p>Below diagram shows the high-level architecture of designing secure, scalable, and resilient Azure OpenAI platform for enterprise LLM based applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IYWCIlWdnwUR4uGEUm2aRg.png" /><figcaption>Scalable, secure, and highly resilient AOAI architecture with Azure API Management</figcaption></figure><p>Details of the architecture are as below.</p><ul><li>Hub vNet — Hub virtual network that contains Azure Network Gateway to connect to on-premises network or to other cloud providers. This Gateway is zonal redundant. Desing of regional redundant Hub network and gateway is beyond the scope of this document. This Hub to On-premises connectivity most of the time already exists in many Azure setup, either with site to site VPN connectivity or Azure Express Route.</li><li>Spoke vNet — Two spoke virtual networks. One in East US region and the other on West US region.</li><li>vNet Peering — There is vNet peering configured between Hub vNet to other spoke vNets.</li><li>Spoke Subnets — There are two subnets on each spoke vNets. One for private endpoint and another subnet for APIM internal vNet Mode.</li><li>APIM — API Management is deployment in internal vNet mode for private customer vNet connectivity. There are two APIM nodes deployed. Once in East US and another one in West US.</li></ul><blockquote>Note: APIM multi-region node setup is only supported in Premium SKU</blockquote><ul><li>Azure OpeAI — Azure OpenAI is setup in East US and West US region. Both OpenAI are disabled for public access and private endpoint is created on private endpoint subnet on respective regions.</li></ul><h3>API Management Deployment</h3><p>Azure API Management supports multi-region deployments, allowing API publishers to extend an existing APIM instance by adding API gateways in multiple supported Azure regions. This setup helps minimize latency for users across different geographies and enhances service availability in case of regional outages.</p><p>When configuring a new region, you can specify:</p><ul><li>The number of scale units to deploy in that region.</li><li>Availability zones, if supported, for added fault tolerance.</li><li>Virtual network settings, which must align with the networking configuration of the existing regions.</li></ul><h4>Deploy API Management service to an additional region</h4><p>Setup Two or more APIM location as shown below. In this setup 1 capacity unit is selected. you can scale the capacity unit as you grow. Premium tier for APIM support 31 capacity units per region.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Uxf_C45g-qxoWMg5sMAz8A.png" /><figcaption>Select APIM Premium Tier — You can also upgrade and downgrade the Tier. It takes about 45 minutes to upgrade the Tier</figcaption></figure><ol><li>In the Azure portal, navigate to your API Management service and select Locations from the left menu.</li><li>Select + Add in the top bar.</li><li>Select the added location from the dropdown list.</li><li>Select the number of scale <a href="https://learn.microsoft.com/en-us/azure/api-management/upgrade-and-scale">Units</a> in the location.</li><li>Optionally select one or more <a href="https://learn.microsoft.com/en-us/azure/reliability/migrate-api-mgt">Availability zones</a>.</li><li>If the API Management instance is deployed in a <a href="https://learn.microsoft.com/en-us/azure/api-management/api-management-using-with-vnet">virtual network</a>, configure virtual network settings in the location, including virtual network, subnet, and public IP address (if enabling availability zones).</li><li>Select Add to confirm.</li><li>Repeat this process until you configure all locations.</li><li>Select Save in the top bar to start the deployment process.</li></ol><p>End result will look as shown below in this case:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ZFyW2VeWmWfbGQf-qX4Ig.png" /></figure><h4>Deploy APIM in internal vNet Mode</h4><p>In Azure API Management, internal VNet mode restricts access to the API Management instance and its APIs to only within the virtual network it’s deployed in. This means that the API Management instance and its exposed APIs are not accessible from the public internet. Instead, access is limited to resources within the same virtual network, or peered networks, or those connected via ExpressRoute or VPN</p><p>In internal VNet mode, customers must configure their own solution to route and load-balance traffic across the regional gateways</p><ul><li>The gateway in each region (including the primary region) has a regional DNS name that follows the URL pattern of https://&lt;service-name&gt;-&lt;region&gt;-01.regional.azure-api.net, for example <a href="https://contoso-westus2-01.regional.azure-api.net./">https://contoso-westus2-01.regional.azure-api.net.</a></li><li>If a region goes offline, API requests are automatically routed around the failed region to the next closest gateway.</li><li>If the primary region goes offline, the APIM’s management plane and developer portal become unavailable, but secondary regions continue to serve API requests using the most recent gateway configuration.</li></ul><p>Below diagram shows the sample internal vNet mode configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aTqm1wOjWea0aB45Mi1hMw.png" /></figure><h4>DNS setup for APIM endpoints</h4><p>Make sure you can resolve APIM nodes private IP from your on-premises environment or from any other cloud. you can get those IPs in APIM overview tab as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*ZAMVkbcD9Zx-X___KZh1Wg.png" /></figure><p>You can run the following command to get the URL for additional location</p><pre>az apim show --name apimeastus4455 --resource-group Default-ActivityLogAlerts --query &quot;additionalLocations[].{Location:location,Disabled:disableGateway,Url:gatewayRegionalUrl}&quot; --output tabl</pre><p>This output of the above command will be shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*N82Z03G5w0jIY2CNuP0fbw.png" /><figcaption>Get the URL for additional APIM node</figcaption></figure><h3>Azure OpenAI Deployment</h3><p>Deploy Azure Open AI (AOAI) in both East US and West US regions. After setting up AOAI resource, launch the AI foundry and create gpt-4o deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5txEdtlLXq7p0DbLfu_-KQ.png" /></figure><p>AOAI resources MUST be configured with private endpoints and disable public access for security reasons.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DkFmX6BD66nX2C6zhaV8Yw.png" /><figcaption>Disable public access</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UM2dOrMreaqbUrV1hBa_0g.png" /><figcaption>AOAI Private Endpoint</figcaption></figure><p>Both East US and West US AOAI must be configured with private endpoints in the respective vNet’s subnet.</p><p>With private endpoints for AOAI and APIM internal vNet mode will allow APIM to access AOAI over customer private networks and public access completely disabled.</p><h3>Managed Identity configuration and APIM access to AOAI</h3><p>Make sure to configure APIM managed identity. In simple terms, system managed identity is configured. however, user managed identity can also be leveraged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hPQXaBK7b1NB8Bcc0fnxsw.png" /></figure><p>Configure AOAI IAM policies for both East US and West US to allows APIM to access AOAI resource via managed identity. It is recommended to use managed identity. Access key of AOAI is not recommended for secure architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_5Gu_AzWurHuBjgbOYb2Q.png" /><figcaption>IAM configuration in AOAI resource to allow APIM</figcaption></figure><h3>Configure API in APIM</h3><ul><li>Click API → APIs in APIM</li><li>Click Add API</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k_CfnEQOKSE99YgDUl7DYw.png" /><figcaption>Add API for Azure OpenAI</figcaption></figure><p>After adding the API, it should look as below. Provide names appropriately as per your environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AC3WycHFG-fQV6GKNQWXhQ.png" /><figcaption>API setting</figcaption></figure><blockquote>Note: As you can see Test is not available. Test API is not avilable in internal vNet mode. It requires additional configuration for this to work and beyond the scope of this article</blockquote><p>Click on All API and then &lt;/&gt; as shown below in red square.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k0b_u6qQRxJYwqfPWwvTjg.png" /></figure><p>Provide the following inbound polices. This will allow all APIM endpoints to communicate with AOAI using managed identity.</p><pre>    &lt;inbound&gt;<br>        &lt;authentication-managed-identity resource=&quot;https://cognitiveservices.azure.com&quot; output-token-variable-name=&quot;msi-access-token&quot; ignore-error=&quot;false&quot; /&gt;<br>        &lt;set-header name=&quot;Authorization&quot; exists-action=&quot;override&quot;&gt;<br>            &lt;value&gt;@(&quot;Bearer &quot; + (string)context.Variables[&quot;msi-access-token&quot;])&lt;/value&gt;<br>        &lt;/set-header&gt;<br>    &lt;/inbound&gt;</pre><h4>Route API calls to regional backend services</h4><ol><li>Navigate to your Azure API Management instance and select APIs from the left menu.</li><li>Select your desired API.</li><li>Select Code editor from the arrow dropdown in the Inbound processing.</li><li>Use the set-backend combined with conditional choose policies to construct a proper routing policy in the &lt;inbound&gt; &lt;/inbound&gt; section of the file.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/0*2ClcXOCnDOuLJ0W4.png" /></figure><p>For example,</p><pre>&lt;inbound&gt;<br>        &lt;set-variable name=&quot;clientIp&quot; value=&quot;@(context.Request.IpAddress)&quot; /&gt;<br>        &lt;set-variable name=&quot;Region&quot; value=&quot;@(context.Deployment.Region)&quot; /&gt;<br>        &lt;choose&gt;<br>            &lt;when condition=&quot;@(&quot;East US&quot;.Equals(context.Deployment.Region, StringComparison.OrdinalIgnoreCase))&quot;&gt;<br>                &lt;set-backend-service base-url=&quot;https://&lt;eastusopenai&gt;.openai.azure.com/openai&quot; /&gt;<br>            &lt;/when&gt;<br>            &lt;when condition=&quot;@(&quot;West US&quot;.Equals(context.Deployment.Region, StringComparison.OrdinalIgnoreCase))&quot;&gt;<br>                &lt;set-backend-service base-url=&quot;https://&lt;westusopenai&gt;.openai.azure.com/openai&quot; /&gt;<br>            &lt;/when&gt;<br>            <br>        &lt;/choose&gt;<br>        &lt;base /&gt;<br>    &lt;/inbound&gt;</pre><h3>APIM Log Analytics Configuration</h3><p>In this setup log analytics is configured for storing APIM logs in Diagnostics.</p><p>APIM is configured to send all log and audit data to log analytics. you can configure log analytics in Diagnostics settings. Make sure log analytics workspace is pre-configured.</p><p>To learn more, how to create log analytics. click the following link. <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/logs/quick-create-workspace?tabs=azure-portal">Create Log Analytics workspaces — Azure Monitor | Microsoft Learn</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCYkkcI5YJhFQdGZBA-wSQ.png" /></figure><h3>Configure Diagnostics Logs in APIM API</h3><p>Click on APIs. Then API →Settings tab as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lt1qrSPNluAEXLIrJSJFtg.png" /></figure><p>Click Advanced Option</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qAQPqe_-OkgsDt8QjOcoYg.png" /></figure><p>Check Frontend Request, Frontend Response, Backend Request, and Backend Response. Click Save to apply the settings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ljBTd8kfIVDHBVQV9KG0OQ.png" /></figure><h3>Private DNS zone configuration</h3><p>In internal VNet mode, you have to manage your own DNS to enable inbound access to your API Management endpoints.</p><p>We recommend:</p><ol><li>Configure an Azure <a href="https://learn.microsoft.com/en-us/azure/dns/private-dns-overview">DNS private zone</a>.</li><li>Link the Azure DNS private zone to the VNet into which you’ve deployed your API Management service.</li></ol><p>APIM West US node will not be able to resolve West US location DNS. for the sake of simplicity, in this solution, west us spoke vNet is linked in the private DNS zone of AOAI as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*bcayInMh5vhR6yHccl14VQ.png" /></figure><p>If proper private DNS zone is not configured. you will encounter the following error as shown below. APIM West US location will not be able to resolve West US AOAI endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*hQ4a-g4pvbVGywsZDkeIcg.png" /></figure><p>Learn more, how to create private DNS zone, visit the following. <a href="https://learn.microsoft.com/en-us/azure/dns/private-dns-getstarted-portal">Quickstart — Create an Azure private DNS zone using the Azure portal | Microsoft Learn</a></p><h3>Solution Validation</h3><p>In this setup, we ran validation test from on-premises VM which has the VPN connectivity with Azure VPN Gateway in hub network as shown in the architecture diagram.</p><p>We run the following Curl command first to send the traffic via East US node.</p><pre>curl &quot;https://&lt;your apim&gt;.azure-api.net/aoai-eastus-4455/openai/deployments/gpt-4o/chat/completions?api-version=2024-05-01-preview&quot; -H &quot;Content-Type: application/json&quot; -H &quot;api-key: &lt;api key for APIM&gt;&quot; -d &#39;{&quot;messages&quot;: [{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Tell me about New York city in few lines&quot;}]}&#39;</pre><p>output is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n_w4E6La2l6bm9dRBUlRyw.png" /></figure><p>Now, we ran the the same Curl command for west APIM node.</p><pre>curl -X POST &quot;https://&lt;your apim&gt;-westus-01.regional.azure-api.net/aoai-eastus-4455/openai/deployments/gpt-4o/chat/completions?api-version=2025-01-01-preview&quot; -H &quot;Content-Type: application/json&quot; -H &quot;api-key: &lt;apim key&gt;&quot; -d &#39;{&quot;messages&quot;: [{&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;Tell me about San Francisco in few lines&quot;}]}&#39;</pre><p>output is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmTLnphuszawzOePCkEuLg.png" /></figure><p>Since, extensive log analytics has been configured for APIM. Let’s run some KQL in log analytics to verify the request URL and backend URL and which APIM node served the API request.</p><p>As you can see in the below diagram. West US is the region with West US node URL and west US AOAI is the backend URL</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*14mYqtteeYjRElnNBWLfVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*692xvTCKftL_vrILjUFJjQ.png" /></figure><p>Similarly for East US.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0AYkd2TbiJpkPOFZeutWtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oGF9ugytQSHF9ykC-jml2Q.png" /></figure><h4>Retry Logic</h4><p>The retry policy executes its child policies once and then retries their execution until the retry condition becomes false or retry count is exhausted.</p><p>In this architecture, to implement the retry logic, configure the following in the backend policy.</p><pre>&lt;backend&gt;<br>        &lt;retry condition=&quot;@(context.Response.StatusCode &gt; 400)&quot; count=&quot;1&quot; interval=&quot;1&quot; first-fast-retry=&quot;true&quot;&gt;<br>            &lt;choose&gt;<br>                &lt;when condition=&quot;@(context.Response.StatusCode &gt; 400)&quot;&gt;<br>                    &lt;set-backend-service base-url=&quot;https://aoai-westus-4455.openai.azure.com/openai&quot; /&gt;<br>                &lt;/when&gt;<br>            &lt;/choose&gt;<br>            &lt;forward-request /&gt;<br>        &lt;/retry&gt;<br>    &lt;/backend&gt;</pre><p>In this test, number of tokens has been reduced to 1k in AOAI for triggering 429 error as shown in the AI foundry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*zrlgcw4oZvuVvnEMqkvZ_w.png" /></figure><p>Ran the CURL command for East US node.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*eoypkzdqyT8ZWEJiQ12tvw.png" /></figure><p>Based on the log analytics, it is shown below. Traffic is received by east US node, but due to 429 error, it is processed by West US AOAI</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HgiYp1Gr2IHEoIviirDxRg.png" /></figure><h4>Disable the APIM Node</h4><p>APIM additional location can be disabled by running the following command. However, this command is not available in APIM when configured with internal vNet mode.</p><blockquote>Note: You cannot disable primary APIM location.</blockquote><pre>az apim update --name contoso --resource-group apim-hello-world-resource --set additionalLocations[location=&quot;West US&quot;].disableGateway=true</pre><h3>Scale AOAI with load balancer pool</h3><p>AOAI can be scaled to multiple instance both in East US or West US and configured the load balancer pool in APIM as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*WBaC7V4yimlIQda2cE8kPQ.png" /></figure><p>Then Backends can be configured in APIM under backend blade with the load balancer. In the API policy, use the backend-id instead of backend-url</p><pre>    &lt;set-backend-service backend-id=&quot;aoai-eastus-4455&quot; /&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*H_84JOqRw-WDIh2NvnqEqg.png" /></figure><h3>Conclusion</h3><p>In conclusion, deploying Azure API Management across multiple regions significantly enhances the availability and resiliency of your APIs. When configured in external VNet mode, Azure manages traffic routing and load balancing automatically, ensuring seamless failover in case a region becomes unavailable.</p><p>However, in internal VNet mode, customers must take responsibility for implementing their own routing and private load balancing solutions for regional gateways. Each gateway has a distinctive DNS endpoint, and while API traffic is redirected to healthy regions during outages, management and developer portal access is lost if the primary region goes offline. Careful planning and configuration are therefore essential to maximize both uptime and operational continuity across regions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*Q5y4yWTJLmHyIQSC.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=921c886f8441" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/leveraging-api-management-for-openai-applications-azure-multi-node-api-management-apim-to-921c886f8441">Leveraging API Management for OpenAI Applications — Azure Multi-Node API Management (APIM) to…</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Azure OpenAI service API — Streaming with function calling]]></title>
            <link>https://blog.devgenius.io/use-azure-openai-service-api-streaming-with-function-calling-4ba7cd6922c5?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ba7cd6922c5</guid>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[functioncall]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Sun, 06 Oct 2024 20:05:43 GMT</pubDate>
            <atom:updated>2024-10-07T18:23:24.028Z</atom:updated>
            <content:encoded><![CDATA[<h3>Use Azure OpenAI service API — Streaming with function calling</h3><p>Function calls with streaming using Azure OpenAI</p><h3>Introduction</h3><p>Function calling enables you to link models such as GPT-4 to external tools and systems. This is beneficial for various purposes, including enhancing AI assistants with additional functionalities and creating robust integrations between your applications and the models.</p><p>Function calling is supported in both the Chat Completion API, Assistant API, and the Batch API. However, this short guide focuses on function calling using the Chat Completions API with streaming using Azure OpenAI service.</p><h3>Single tool/function calling example</h3><p>In this guide, we created a sample function to make a yahoo finance API call to retrieve the stock price of a given stock ticker symbol.</p><p>At a high level, working with functions can be divided into three steps:</p><ol><li>Use the chat completions API with your functions and the user’s input.</li><li>Utilize the model’s response to call your API or function.</li><li>Call the chat completions API once more, incorporating the response from your function to obtain a final response.</li></ol><p><em>Note: Creating python virtual or Conda environment is beyond the scope of this document. Make sure you have dependent libraries installed using pip</em></p><p><em>Note: Make sure to provide Azure OpenAI endpoint, API key, API version, and model deployment name</em></p><p>There are print statements and comment out print statements to help make the code understand. Uncomment those print statements, if you require to dig deeper. For example, how deltas look like in chunks.</p><pre>import os<br>import openai<br>from dotenv import load_dotenv<br>import json<br>import yfinance as yf  <br>from datetime import datetime<br><br># load environment variable.<br>load_dotenv()<br><br># Load OpenAI variables. Make sure to provide those variables as per your environment.<br>azure_endpoint: str = os.environ[&quot;AZURE_OPENAI_ENDPOINT&quot;] #PLACEHOLDER FOR YOUR AZURE OPENAI ENDPOINT<br>azure_openai_api_key: str = os.environ[&quot;AZURE_OPENAI_API_KEY&quot;] #PLACEHOLDER FOR YOUR AZURE OPENAI KEY<br>azure_openai_api_version: str = os.environ[&quot;AZURE_OPENAI_API_VERSION&quot;] # API VERSION PLACE HOLDER<br>azure_deployment: str = os.environ[&quot;OPENAI_DEPLOYMENT_NAME_GPT4o&quot;] # AZURE OPENAI DEPLOYMENT NAME<br><br><br># Define the function for the model<br>tools = [<br>        {<br>            &quot;type&quot;: &quot;function&quot;,<br>            &quot;function&quot;: {<br>                &quot;name&quot;: &quot;get_stock_price&quot;,<br>                &quot;description&quot;: &quot;Retrieve lowest and highest stock price for a given stock symbol and date&quot;,<br>                &quot;parameters&quot;: {<br>                    &quot;type&quot;: &quot;object&quot;,<br>                    &quot;properties&quot;: {<br>                        &quot;symbol&quot;: {<br>                            &quot;type&quot;: &quot;string&quot;,<br>                            &quot;description&quot;: &quot;Stock symbol, for example MSFT for Microsoft&quot;<br>                        }<br>                },<br>                    &quot;required&quot;: [&quot;symbol&quot;],<br>                },<br>            }   <br>        }<br>    ]<br><br># Initialize Azure OpenAI client with key-based authentication<br>client = openai.AzureOpenAI(<br>    azure_endpoint = azure_endpoint,<br>    api_key = azure_openai_api_key,<br>    api_version = azure_openai_api_version,<br>)<br><br># create a funtion<br>def get_stock_price(symbol):<br>    print(f&quot;Getting stock price for {symbol}&quot;)<br>    <br>    ticker = yf.Ticker(symbol)<br>    info = ticker.info<br>   <br>    date = datetime.today().strftime(&#39;%Y-%m-%d&#39;)  <br>    return json.dumps({  <br>        &quot;symbol&quot;: symbol,  <br>        &quot;date&quot;: date,<br>        &quot;current price&quot;: info[&#39;currentPrice&#39;], <br>        &quot;low price&quot;: info[&#39;dayLow&#39;],  <br>        &quot;high price&quot;: info[&#39;dayHigh&#39;],<br>        &quot;opening price&quot;: info[&#39;open&#39;],<br>        &quot;link&quot;: f&quot;https://finance.yahoo.com/quote/{symbol}/&quot;<br>    }<br>    )<br>    <br># initial user message    <br>messages = []<br>tool_call_accumulator = &quot;&quot;<br>messages.append({&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: &quot;what is the price of tesla stock&quot;}) # single function call<br><br><br># First API call: Ask the model to use the function<br>response = client.chat.completions.create(<br>    model= azure_deployment,<br>    messages=messages,<br>    tools=tools,<br>    tool_choice=&quot;auto&quot;,<br>    stream=True  # this time, we set stream=True<br>)<br><br># process the model <br>for chunk in response:<br>    if len(chunk.choices) &gt; 0:<br>        delta = chunk.choices[0].delta<br>        #print(f&quot;delta: {delta}&quot;) # print delta from the chunk for learning<br>        <br>        if delta.tool_calls:<br>                if(delta.tool_calls[0].function.name):<br>                    tool_name = chunk.choices[0].delta.tool_calls[0].function.name<br>                    tool_id = chunk.choices[0].delta.tool_calls[0].id<br>                    messages.append(delta)<br>                <br>                if(chunk.choices[0].delta.tool_calls[0].function.arguments):    <br>                    tool_call_accumulator+=delta.tool_calls[0].function.arguments<br><br># print function related outputs                    <br>print(f&quot;tool_name:{tool_name}&quot;)   <br>print(f&quot;tool_id:{tool_id}&quot;)    <br>print(f&quot;tool_call_accumulator:{tool_call_accumulator}&quot;)   <br><br><br><br># handle the function call<br>if tool_name == &quot;get_stock_price&quot;:<br>    function_args=json.loads(tool_call_accumulator)<br>    #print(function_args.get(&quot;symbol&quot;))<br>    stock_price_data = get_stock_price(symbol=function_args.get(&quot;symbol&quot;))<br>    #print(f&quot;stock_price_data: {stock_price_data}&quot;)<br>    messages.append({<br>                    &quot;tool_call_id&quot;: tool_id,<br>                    &quot;role&quot;: &quot;tool&quot;,<br>                    &quot;name&quot;: tool_name,<br>                    &quot;content&quot;: stock_price_data,<br>                    })<br><br>#print(f&quot;messages: {messages}&quot;) <br>print(&quot;=============================================&quot;)  <br>    <br>#  second API call: Get the final response with stream<br>response = client.chat.completions.create(<br>    model= azure_deployment,<br>    messages=messages,<br>    temperature=0.7,<br>    stream=True  # this time, we set stream=True<br>)<br><br><br>for chunk in response:<br>    if len(chunk.choices) &gt; 0:<br>        delta = chunk.choices[0].delta<br>        #print(f&quot;delta: {delta}&quot;)<br>        <br>       <br>        if delta.content:<br>            print(delta.content, end=&quot;&quot;, flush=True)</pre><p>Output:</p><pre>PS C:\Development\openai\chatgpt-demo&gt; &amp; C:/Users/muafzal/Miniconda3/envs/.conda39/python.exe c:/Development/openai/chatgpt-demo/Azure_OpenAI_FunctionCall_With_Stream.py<br>tool_name:get_stock_price<br>tool_id:call_grJz8BFcBcfIQD8HAdDuuQ6U<br>tool_call_accumulator:{&quot;symbol&quot;:&quot;TSLA&quot;}<br>Getting stock price for TSLA<br>=============================================<br>As of the latest data on October 6, 2024, the price of Tesla (TSLA) stock is $250.08. Here are some additional details:<br><br>- **Low Price:** $244.58<br>- **High Price:** $250.96<br>- **Opening Price:** $246.7<br><br>For more information, you can visit [Tesla on Yahoo Finance](https://finance.yahoo.com/quote/TSLA/).<br>PS C:\Development\openai\chatgpt-demo&gt; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U77QE6TKr5RepZcsX_687Q.png" /></figure><h3>Conclusion</h3><p>Azure OpenAI function calling enhances the AI assistant experience. It provides dynamic data retrievals and responses. Overall, OpenAI function calling bridges the gap between static language model responses and dynamic, actionable, and data-driven outcomes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ba7cd6922c5" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/use-azure-openai-service-api-streaming-with-function-calling-4ba7cd6922c5">Use Azure OpenAI service API — Streaming with function calling</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PoC for Connecting Azure SQL Managed Instance using Windows Authentication for Microsoft Entra ID]]></title>
            <link>https://muafzal.medium.com/poc-for-connecting-azure-sql-managed-instance-using-windows-authentication-for-microsoft-entra-id-5f8a1d23df7c?source=rss-7e0a22273254------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f8a1d23df7c</guid>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[windows-authentication]]></category>
            <category><![CDATA[managed-instance]]></category>
            <dc:creator><![CDATA[Afzal Muhammad]]></dc:creator>
            <pubDate>Fri, 23 Aug 2024 16:03:06 GMT</pubDate>
            <atom:updated>2024-08-23T19:00:20.686Z</atom:updated>
            <content:encoded><![CDATA[<p>Connect your Azure SQL MI using Window Auth</p><h3>Introduction</h3><p>Azure SQL Managed Instance (MI) is a PaaS service in Azure. It offers broadest SQL server database engine compatibility. It allows multiple types of authentication mechanism. However, some legacy application requires windows authentication especially when they are running in on-premises environment. When connecting those applications to Azure SQL MI, it brings some challenges. In this PoC, I’ll be demonstrating how to leverage windows authentication for connecting to SQL MI.</p><p>Kerberos authentication for Microsoft Entra ID (<a href="https://learn.microsoft.com/en-us/entra/fundamentals/new-name">formerly Azure Active Directory</a>) enables Windows Authentication access to Azure SQL Managed Instance.</p><h3>Architecture</h3><p>The following diagram gives an overview of how Windows Authentication is implemented for a managed instance using Microsoft Entra ID and Kerberos:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*e57ut27TSCjzD4GWyFAdUg.png" /></figure><h3>Infra Setup in Azure</h3><p>In this PoC, I provisioned the following:</p><p>1- Virtual Machine (Windows Server 2022)</p><p>2- Azure SQL Managed Instance</p><p>A Virtual Network (vNet) is created with two subnets. One for SQL MI which is a delegated subnet and one for VM as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*DTWhzNnQ5ora3SYPDokzRA.png" /></figure><h3>Setup VM</h3><p>In the following steps, a virtual machine will be deployed. This VM should be setup to allow login using Microsoft Entra ID based authentication.</p><p>To use Microsoft Entra login for a Windows VM in Azure, you must:</p><ol><li>Enable the Microsoft Entra login option for the VM.</li><li>Configure Azure role assignments for users who are authorized to sign in to the VM.</li></ol><p>There are two ways to enable Microsoft Entra login for your Windows VM:</p><ul><li>The Azure portal, when you’re creating a new Windows VM.</li><li>Add “AADLoginForWindows” extension if VM is already created.</li></ul><p>If you are creating a new VM, under Management Tab, Select Enable system assigned managed identity and Microsoft Entra ID checkbox as shown below. This action should happen automatically after you enable login with Microsoft Entra ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*qzW7_pmHufTEAEFIWuUDOg.png" /></figure><p>Upon creation of VM, you can verify if the extension AADLoginForWindows is installed in the VM. you can visit Settings →Entensions+applications tab as show below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q9mEDA_OThpxbCesVBZezQ.png" /></figure><p>If VM is already deployed, you can add this extension by clicking +Add and look for Azure AD based Windows Login and follow the Next button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ISqhruKjpoj9T9MvAaIL9g.png" /></figure><p>You can also add the extension by launching cloud shell and run the following CLI command.</p><pre>az vm extension set --publisher Microsoft.Azure.ActiveDirectory --name AADLoginForWindows --resource-group myResourceGroup --vm-name myVM</pre><p>After the extension is installed on the VM, provisioningState shows Succeeded.</p><h3>Configure role assignment for the VM</h3><p>Now that you’ve created the VM, you need to assign one of the following Azure roles to determine who can sign in to the VM. To assign these roles, you must have the <a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#virtual-machine-data-access-administrator-preview">Virtual Machine Data Access Administrator</a> role, or any role that includes the Microsoft.Authorization/roleAssignments/write action such as the <a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview">Role Based Access Control Administrator</a> role. However, if you use a different role than Virtual Machine Data Access Administrator, we recommend you <a href="https://learn.microsoft.com/en-us/azure/role-based-access-control/delegate-role-assignments-overview">add a condition to reduce the permission to create role assignments</a>.</p><ul><li>Virtual Machine Administrator Login: Users who have this role assigned can sign in to an Azure virtual machine with administrator privileges.</li><li>Virtual Machine User Login: Users who have this role assigned can sign in to an Azure virtual machine with regular user privileges.</li></ul><p>Add the role assignment at the resource group level where VM is. VM will inherit it.</p><ol><li>Go to the resource group of VM and select IAM tab, then click +Add and select Add role assignment as shown.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*3YZYI-VYUBzsW78IFCPkFA.png" /></figure><p>2. Select “Virtual Machine Administrator Login”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*T1lWSre72fEQhnz0sbqNWw.png" /></figure><p>3. Click Members Tab. with User, group, or service principal selected, click + Select members.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*WquazLdP5n7N9ktH0sVqmw.png" /></figure><p>4. Find user that you want to give access as an administrator to this VM. Click Select. Then Click “Review + Assign”</p><p>5. After the role is assigned. Under IAM, in Role assignment tab, it will look similar to as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfn2gPLXV1VBP7He7ixAQw.png" /></figure><h3>Remote Desktop the VM and Perform Kerberos Setup</h3><p><em>Note: if your Entra ID account is using MFA, you will find issues with RDP. you have to disable MFA for that account.</em></p><p>There are two ways SQL MI can be configured for window auth as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*NGyLYbeQyMi5ANATHp6Psw.png" /></figure><h4>In this PoC, we will be performing “Modern interactive flow”. Incoming trust-based flow is beyond the scope of this article.</h4><p>Launch the RDP session and connect to the VM. Provide Entra ID credentials as shown below. Provide password when asked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*2xP8kJ31KjWz4PnyYGGiZw.png" /></figure><p>Lauch Terminal. Run the following command.</p><pre>dsregcmd.exe /status</pre><p>Make sure “AzureAdJoined” should say “YES” as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*uJ2dS0MudwkIPrZkYxn6gg.png" /></figure><p>Lauch local group policy editor.</p><ol><li>Open Search in the Toolbar and type “Run”, or select Run from your Start Menu.</li><li>Type “gpedit. msc” in the Run command and click OK.</li><li>Open the group policy editor.</li><li>Navigate to Administrative Templates\System\Kerberos\.</li><li>Select the Allow retrieving the cloud kerberos ticket during the logon setting.</li><li>Select “Enabled”. Click OK.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*Q8polbZJb9C0XjGleMpG7g.png" /></figure><p>Once it is enabled. it should look like as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H6Apz1cQYcgSMhZyA_gMpQ.png" /></figure><p>Users with existing logon sessions may need to refresh their Microsoft Entra <a href="https://learn.microsoft.com/en-us/azure/active-directory/devices/concept-primary-refresh-token">Primary Refresh Token (PRT)</a> if they attempt to use this feature immediately after it has been enabled. It can take up to a few hours for the PRT to refresh on its own.</p><p>To refresh PRT manually, run this command from a command prompt:</p><pre>dsregcmd.exe /RefreshPrt</pre><h3>Provision Azure SQL Managed Instance</h3><p>Provision managed instance. Make sure it is reachable from the VM created in the earlier steps. Create MI with System assigned managed identity and System assigned service principal set to “On” as shown below. if SQL Managed instance is already provisioned. Modify the identity as shown below under Identity tab of SQM MI resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*PiM4WaqzWEt8dLaKwPgTBA.png" /></figure><h3>Grant admin consent to a system assigned service principal</h3><ol><li>Open Microsoft Entra ID.</li><li>Select App registrations.</li><li>Select All applications.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*lxXF14r7wcMBR_p46iqfaw.png" /></figure><p>3. Select the application with the display name matching your managed instance. The name will be in the format: &lt;managedinstancename&gt; principal.</p><p>4. Select API permissions.</p><p>5. Select Grant admin consent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*RmcZ3U0Ijl24YQInStaDsg.png" /></figure><p>Click “Yes” on confirmation as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*aValSC-BNmP8NlQ2hwypIw.png" /></figure><p>Once the consent is granted to the service principal, it will be shown as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GviECu9nMLJDnuzrcvNPGQ.png" /></figure><h3>Test and Validation</h3><p>Login to SQL server and add the following user</p><pre>create login &lt;user&gt; from external provider</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*_J-i2Q5oFEBAEbMb8UJMJg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*k2vhx_A5LLzXPkpC4p0SGg.png" /></figure><p>Then login to SQL Server using window auth as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*P14fPcknp8X0zcH5vK6C2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*ZryAFOQLkgSfJwAZ3YTv4w.png" /></figure><h3>Conclusion</h3><p>Windows Authentication for Azure SQL Managed Instance principals through Microsoft Entra ID (formerly known as Azure Active Directory) allows customers to transition their existing services to the cloud seamlessly, enhancing the user experience and laying the foundation for modernizing security infrastructure. To activate Windows Authentication for Microsoft Entra principals, you need to convert your Microsoft Entra tenant into a standalone Kerberos realm and establish an incoming trust with the customer domain.</p><h3>References</h3><ol><li><a href="https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/winauth-implementation-aad-kerberos?view=azuresql">How Windows Authentication for Azure SQL Managed Instance is implemented with Microsoft Entra ID and Kerberos — Azure SQL Managed Instance | Microsoft Learn</a></li><li><a href="https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/winauth-azuread-setup-modern-interactive-flow?view=azuresql">How to set up Windows authentication for Microsoft Entra ID with the modern interactive flow — Azure SQL Managed Instance | Microsoft Learn</a></li><li><a href="https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/winauth-azuread-setup?view=azuresql">How to set up Windows Authentication for Azure SQL Managed Instance using Microsoft Entra ID and Kerberos — Azure SQL Managed Instance | Microsoft Learn</a></li><li><a href="https://learn.microsoft.com/en-us/entra/identity/devices/howto-vm-sign-in-azure-ad-windows">Sign in to a Windows virtual machine in Azure by using Microsoft Entra ID — Microsoft Entra ID | Microsoft Learn</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f8a1d23df7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>