<p>I have hosted my SQL on Azure SQL.<br/>
From my AKS, each of the pods, I found out it is not able to connect to Azure SQL.
<br/>
DB Connection:</p>
<blockquote>
<p>Data Source=tcp:dbname.database.windows.net,1433;Initial Catalog=dbname;User Id={account};Password={password}</p>
</blockquote>
<p>In Azure Portal &gt; I have enable this below
<a href="https://i.stack.imgur.com/emhiI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/emhiI.png" alt="enter image description here" /></a></p>
<p>I double checked the connection string and is able to connect from my local machine, but inside the kubenetes pod, I try to perform telnet to the server it responds</p>
<blockquote>
<p>Connection closed by foreign host.</p>
</blockquote>
<p>May I know what going wrong on this.</p>

Herman
<p>Azure provides two options for pods running on an AKS worker nodes to access a MySQL or PostgreSQL DB instance:</p>
<p>Create a <a href="https://learn.microsoft.com/en-us/azure/mysql/concepts-firewall-rules#connecting-from-azure" rel="nofollow noreferrer">firewall rule</a> on the Azure DB Server with a range of IP addresses that encompasses all IPs of the AKS Cluster nodes (this can be a very large range if using node auto-scaling).</p>
<p>Create a <a href="https://learn.microsoft.com/en-us/azure/mysql/concepts-data-access-and-security-vnet" rel="nofollow noreferrer">VNet Rule</a> on the Azure DB Server that allows access from the subnet the AKS nodes are in. This is used in conjunction with the Microsoft.Sql VNet Service Endpoint enabled on the cluster subnet.</p>
<p>VNet Rules are recommended and preferable in this situation for several reasons. Nodes are often configured with dynamic IP addresses that can change when a node is restarted resulting in broken firewall rules that reference specific IPs. Nodes can be added to a cluster which would require updating the firewall rule to add additional IPs. VNet Rules avoid these issues by granting access to an entire subnet of AKS nodes.</p>
<p><strong>Manual steps</strong></p>
<p>Configuring a secure networking environment for AKS and Azure DB requires the following:</p>
<ol>
<li>AKS cluster setup</li>
</ol>
<p><code>ResourceGroup:</code> a logical grouping a resources required for all resources.</p>
<p><code>VNet:</code> creates a virtual network for the AKS cluster nodes.</p>
<p><code>Subnet</code> has a range of private IPs for AKS cluster nodes
Create an AKS cluster using the above resources.</p>
<ol start="2">
<li>Configure managed service access</li>
</ol>
<p><code>VNet Service Endpoint:</code> update the cluster subnet above with a service endpoint for <code>Microsoft.Sql</code> to enable connectivity for new Azure DB service resource.</p>
<ol start="3">
<li>Provision managed services with private IPs on the cluster’s network</li>
</ol>
<p>Provision managed Azure DB service instances: PostgreSQL, MySQL.
<code>VNet Rule</code> for each managed service instance to allow traffic from all nodes in the cluster subnet to a given Azure DB service instance (PostgreSQL, MySQL).</p>
