简体   繁体   中英

How to connect to a Sql Server VM via private IP with Azure Website

I have an Azure VM with port 1433 endpoint created. The internal IP is 110.119.38.72.

In my Azure Standard Website Web.Config connstring if have:

Server=110.119.38.72;Database=MyDB;uid=username;pwd=password;

I am getting the error:

[Win32Exception (0x80004005): Access is denied]

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server.

See screenshot for more details: 在此处输入图片说明

If I change my connection string to the Public IP of my Azure Sql Server I am able to connection.

How can I used the Internal IP of my Sql Server VM in my Azure Website?

By default you can't. However, Azure websites now support running on a Virtual Network, so (in theory) you should be able to create a vnet and place both your SQL Server vm and the Azure Website on that vnet. That should enable you to connect to the db using the internal (vnet) ip address of the vm. I haven't tried this tho, so no guarantees.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM