How to best design secure network setup where ACI must write to SQL Server

Richard Haigh 45 Reputation points
2023-10-25T15:12:33.6266667+00:00

I'm deploying an Azure Container Instance (ACI) and an Azure SQL Database in the same virtual network but different subnets. The database has a private endpoint in a third subnet. I've configured the ACI to communicate with the database using the FQDN of the Azure SQL server (arc-azure-postgresql-server.database.windows.net).

However, my Python application within the ACI times out when attempting to write to the database. The subnets have the appropriate service endpoints and delegations, and I've verified the database server name. I suspect a networking or DNS resolution issue between the ACI and the SQL Database due to the private endpoint. How can I correctly configure my network layout to ensure smooth communication between the ACI and the database? Infrastructure as code can be provided if helpful.

Azure SQL Database
Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
687 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dan Rios 1,900 Reputation points MVP
    2023-10-25T15:30:02.5366667+00:00

    Hi,

    I can't quite tell from your post if it's timing out from being unable to reach, or permissions. So I'll detail both ways I would get it working.

    There should be a Private DNS for 'privatelink.database.windows.net' of which there is a Virtual network link to your virtual network where the SQL and ACI are located. Is that setup and associated?

    Bicep IaC for this is here: https://video2.skills-academy.com/en-us/azure/templates/microsoft.network/privatednszones/virtualnetworklinks?pivots=deployment-language-bicep

    For permissions, check you have enabled the system-assigned managed identity on the ACI https://video2.skills-academy.com/en-us/azure/container-instances/container-instances-managed-identity then you can look to add the managed identity of the ACI into the PostgreSQL with the appropriate permissions to write.

    SET aad_validate_oids_in_tenant = off; CREATE ROLE myuser WITH LOGIN PASSWORD 'CLIENT_ID' IN ROLE azure_ad_user;
    

    Client_id being the MS Entra Enterprise Application - Application Id guid.

    More information here on that setup: https://video2.skills-academy.com/en-us/azure/postgresql/single-server/how-to-connect-with-managed-identity#creating-a-postgresql-user-for-your-managed-identity

    Bicep IaC is here: https://video2.skills-academy.com/en-us/azure/templates/microsoft.containerinstance/containergroups?pivots=deployment-language-bicep

    You'll want configure this section to enable system-assigned MI on the ACI if it's not already from the code above:

      identity: {   
    	  type: 'SystemAssigned'  
     }
    
    

    With these two setup and verified, things should work for you. If this was helpful, feel free to mark as an accepted answer.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.