简体   繁体   English

Azure SQL-本地主机无法连接

[英]Azure SQL - localhost can't connect

I started coding an ASP.NET webapp (with Visual Studio 2015). 我开始使用ASP.NET Webapp(使用Visual Studio 2015)进行编码。 I'm having problems with the connection to my Azure SQL database. 我与Azure SQL数据库的连接出现问题。 I can connect to the database via MSSM Studio. 我可以通过MSSM Studio连接到数据库。 When I publish my app on the Azure webservice the app works fine. 当我在Azure Web服务上发布我的应用程序时,该应用程序运行良好。 When I run my code locally I keep getting the following error: 当我在本地运行代码时,不断出现以下错误:

SqlException: Cannot open server 'database' requested by the login. SqlException:无法打开登录请求的服务器“数据库”。 Client with IP address 'XX.XX.XX.XX' is not allowed to access the server. IP地址为“ XX.XX.XX.XX”的客户端不允许访问服务器。 To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. 若要启用访问,请使用Windows Azure管理门户或在主数据库上运行sp_set_firewall_rule为该IP地址或地址范围创建防火墙规则。 It may take up to five minutes for this change to take effect. 此更改最多可能需要五分钟才能生效。

Altough the firewall of the database service is set (I've even tried with range 0.0.0.0 too 255.255.255.255). 总共设置了数据库服务的防火墙(我甚至尝试过将范围0.0.0.0设置为255.255.255.255)。 On my computer port 1433 is allowed. 在我的计算机上允许使用端口1433。

Any help is deeply appreciated. 任何帮助深表感谢。

The problem was solved by editing the username of the database connectionstring. 通过编辑数据库连接字符串的用户名解决了该问题。

my_username@my_app.database.windows.net -> only worked published on Azure (not via localhost) my_username@my_app.database.windows.net->仅在Azure上发布(不通过本地主机)

my_username@database.windows.com -> works published on Azure and with my localhost my_username@database.windows.com->在Azure和我的本地主机上发布的作品

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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