使用Visual Studio 2012将带有数据库的ASP.net Web应用程序发布到Azure

时间:2022-06-04 05:30:13

I have developed a simple web application. I have written it in VS2012 using ASP.net and C#. It links to a SQL database on my local machine in SQL Server Express. It works fine inside the debug environment on my local machine.

我开发了一个简单的Web应用程序。我使用ASP.net和C#在VS2012中编写了它。它链接到SQL Server Express中本地计算机上的SQL数据库。它在我的本地机器上的调试环境中工作正常。

I have an account with Windows Azure. I create a new website and database using the webform. I log in and synch the publish certificate in my VS2012. As I work through the wizard I test the connection and it connects. I get the connection string for the Azure database from the Azure portal and I enter it in the "Remote Connection String" field. I complete the wizard and it says it publishes successfully.

我有一个Windows Azure帐户。我使用webform创建一个新的网站和数据库。我在VS2012中登录并同步发布证书。当我完成向导时,我测试连接并连接。我从Azure门户获取Azure数据库的连接字符串,然后在“远程连接字符串”字段中输入该字符串。我完成了向导,它说它成功发布。

However I get a "403 Forbidden Error" instead of my web application in the browser. When I look at the Azure portal, I find that the database is not populated at all. I feel like there is an important step I am missing to make this work. Any help would be appreciated.

但是我在浏览器中得到了“403 Forbidden Error”而不是我的Web应用程序。当我查看Azure门户时,我发现数据库根本没有填充。我觉得有一个重要的步骤我缺少这个工作。任何帮助,将不胜感激。

1 个解决方案

#1


1  

you can try to get the script from your database then insert into the sql azure via the scripting of your sql server database. The script will contain any relationship such as PK or FK from there, you can add a web-config line to link your sql azure with your website like this

您可以尝试从数据库中获取脚本,然后通过sql server数据库的脚本插入到sql azure中。该脚本将包含任何关系,如PK或FK,你可以添加一个web-config行来链接你的sql azure与你的网站,像这样

<connectionStrings>
<add name="ConnectionString" connectionString="Server=**(will be given in sql azure)" /
</connectionStrings>

This should work already. Of course you got to make sure your publish profile is the new one. Don't use the old publish profile.

这应该已经有效了。当然,您必须确保您的发布配置文件是新的。不要使用旧的发布配置文件。

#1


1  

you can try to get the script from your database then insert into the sql azure via the scripting of your sql server database. The script will contain any relationship such as PK or FK from there, you can add a web-config line to link your sql azure with your website like this

您可以尝试从数据库中获取脚本,然后通过sql server数据库的脚本插入到sql azure中。该脚本将包含任何关系,如PK或FK,你可以添加一个web-config行来链接你的sql azure与你的网站,像这样

<connectionStrings>
<add name="ConnectionString" connectionString="Server=**(will be given in sql azure)" /
</connectionStrings>

This should work already. Of course you got to make sure your publish profile is the new one. Don't use the old publish profile.

这应该已经有效了。当然,您必须确保您的发布配置文件是新的。不要使用旧的发布配置文件。