سؤال

I'm currently setting up two websites using one web role on Windows Azure. When I deploy the sites to Azure they deploy successfully, but I get a warning:

Warning 1   The connection string 'DefaultConnection' is using a local database
'(LocalDb)\v11.0' in project 'GTCompanySite'. This connection string will not work when 
you run this application in Windows Azure. To access a different database, you should 
update the connection string in the web.config file. 

I've attempted several solutions: I published the second website and referenced the physical path to the published folder. No luck. Both websites reference the default LocalDB, but also seem to correctly hook up to the Azure Storage service. I haven't messed with those settings at all.

Any pro-tips for solving this issue?

Regards,

Jesse

هل كانت مفيدة؟

المحلول

In a local environment it iss possible to connect your application to a Local SQL Server Express Instance.

However when you deploy to Azure you'll need to connect your app to an actual running SQL Server Instance. A SQL Azure Instance is probably your simplest option as you can easily spin one up through the Azure Management Portal. (Though you could also host a regular SQL Server Install on a VM)

Once you've created your SQL Azure Instance, you'll be provided with all the Connection and Auth credentials you need. You'll need to change the DefaultConnection connection string in your Application Configuration or CSCFG file depending on where your storing it to point at the new SQL Azure Instance, instead of a SQL Express before you deploy your app.

<configuration>
    <connectionStrings>
        <add name="DefaultConnection"
            connectionString="Server=tcp:[serverName].database.windows.net;
                              Database=myDataBase;
                              User ID=[LoginForDb]@[serverName];
                              Password=myPassword;
                              Trusted_Connection=False;
                              Encrypt=True;"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top