2017-08-31 8 views
0

Ich entwickle eine Azure-Website und einen WebJob. Die Entwicklungsdatenbank ist eine MDF-Datei. Die Mvc-App kann eine Verbindung zum Azure-Speicher und zur Datenbank herstellen. Die WebJob kann dem Azure-Speicher verbinden, aber die Datenbank führt dies:Azure WebJobs kann keine Verbindung zur MDF-Datenbank herstellen

System.Data.SqlClient.SqlException occurred 
    HResult=0x80131904 
    Message=A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Specified LocalDB instance name is invalid. 
) 
    Source=Core .Net SqlClient Data Provider 
    StackTrace: 
    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling) 
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) 
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) 
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 
    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) 
    at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) 

Sowohl die Mvc und WebJob die gleichen Verbindungszeichenfolgen teilen:

Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=D:\\Projects\\Test1\\Code\\Database\\Test1.mdf;Integrated Security=True;Connect Timeout=30;Encrypt=False 

Es macht keinen Unterschied, ob der Mvc App wird ausgeführt, wenn der WebJob gestartet wird.

Antwort

0

In den App-Benutzer Geheimnisse MVC, ich doppelte Schrägstriche, wie diese zu verwenden hatte:

Data Source=(LocalDB)\\MSSQLLocalDB 

In der app.config-Datei für die webjob Konsole app, hatte ich so einzelne Schrägstriche zu verwenden:

Data Source=(LocalDB)\MSSQLLocalDB 
Verwandte Themen