title: Azure: Login failed for user
body: <p>What I have done:</p>
  
  <ul>
  <li>I added Resource group in Azure.</li>
  <li>Added Web Service with previous resource group.</li>
  <li>Added SQL Server Database with previous resource group.</li>
  <li>Retrieved generated connection string from this database and provided here username and password.</li>
  <li>Added this connection string to App Settings in Web Service.</li>
  <li>Published app via Visual Studio.</li>
  </ul>
  
  <p>Problem:
  I get this error when I tries to test this hosted app in azure, but on my local version of app and exactly this connection string everything works just fine..</p>
  
  <pre><code>Server Error in '/' Application.
  
  Login failed for user 'USERNAME'.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'USERNAME'.
  
  Source Error: 
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  Stack Trace: 
  
  
  [SqlException (0x80131904): Login failed for user 'USERNAME'.]
     System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling) +1418
     System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +470
     System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +70
     System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +777
     System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +114
     System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection) +1637
     System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection) +117
     System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&amp; connection) +267
     System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +318
     System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +132
     System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +246
     System.Data.SqlClient.SqlConnection.Open() +122
     System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +104
     System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext) +509
     System.Data.Entity.SqlServer.&lt;&gt;c__DisplayClass1.&lt;Execute&gt;b__0() +15
     System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +238
     System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +331
     System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +916
     System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +413
     System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +116
  
  [ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
     System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +377
     System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +35
  
  [ProviderIncompatibleException: An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.]
     System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +266
     System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +84
     System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest&amp; providerManifest) +89
     System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +63
     System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +91
     System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +227
     System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +846
     Hakon.HamiltonCargo.Web.NinjectWebCommon.InitializeDatabase() +111
     Hakon.HamiltonCargo.Web.NinjectWebCommon.Start() +124
  
  [TargetInvocationException: Exception has been thrown by the target of an invocation.]
     System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
     System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +260
     System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146
     System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +34
     WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +288
     WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +785
     WebActivatorEx.ActivationManager.RunPreStartMethods(Boolean designerMode) +58
     WebActivatorEx.ActivationManager.Run() +82
  
  [InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
     System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +877
     System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
     System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean&amp; isRefAssemblyLoaded) +133
     System.Web.Compilation.BuildManager.ExecutePreAppStart() +176
     System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734
  
  [HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
     System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +539
     System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +125
     System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +731
  
  Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1590.0
  </code></pre>