简体   繁体   中英

Azure application can't access database on Azure VM

I deployed a Asp.Net Core 2 application to Azure, using Visual Studio Community's Publish feature. The non-database-dependent parts of the application function, but the database-specific code returns an error.

The application's database is a Sql Server instance installed on a Windows server hosted on a Azure VM (not an Azure SQL database).

To fix this, I:

  • determined the application's IP address using the Url property (xxx.azurewebsites.net) of the app's blade
  • added an inbound rule to the network security group's blade that allows all ports from this IP address
  • added an entry to the VM's Windows firewall to allow ports from this IP address

Unfortunately, this did not solve the problem. What am I missing?

Incidentally, what's the recommended way to set the ASPNETCORE_ENVIRONMENT to development when publishing to Azure (to enable more-detailed error messages)?

I am assuming that your web application is deployed to an Azure Web App. You may not have the correct outbound IP address for your VM hosting. Note that a Web App's inbound IP address may be different from the Web App's outbound address. To find the outbound addresses for your Web App, do the following:

  1. Go to your Web App's management blade.
  2. Choose the Properties menu item (under Settings). On this screen, there's a list of possible outbound IP addresses. Try whitelisting them all in your VM's firewall.

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