I had restored an Azure SQL DB from .bacpac from Azure Storage..
I can connect successfully and access all object from SSMS 2019.
But my Azure App Service throws error, Login failed for 'user..XXXX'
I have given permission for "Allow Azure services and resources to access this server" on the Azure DB server.
How do I troubleshoot or fix the problem ?
FYI:
I can connect successfully from SSMS and do all the operation.
Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user 'XXXXXXAppUser'.
at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)
at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.Open()
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.OpenDbConnection(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected)
ClientConnectionId:XXXXXXXX-1e0a5b65dd11
Error Number:18456,State:1,Class:14
ClientConnectionId before routing:XXXXXXXX-c3154c7b1c61
Routing Destination:XXXXXXXXX.tr2023.northcentralus1-a.worker.database.windows.net,11002
The mentioned error could be because of multiple reasons, therefore I suggest you to look into the error logs to see what the exact reason for the login failure. I guess either the database name or password is misspelled.
However, the exact issue seems like with the format of your password. Your password might containing some special character like '$', due to which when you pass your password as command it is reading it as some parameter starting with '$' as a command and it read half of your password string as a different value.
Solution: Either create another user with simple normal password (without containing '$' symbol), or change the password of the existing user.
Related
I have a default ASP.NET Web Site template project that I created with VS2012. I'm trying to publish it to 1and1.com where only Medium trust is allowed. Apparently, this template expects Full trust, but I can't figure out what I need to do.
The error I'm getting is...
[SecurityException: Request for the permission of type 'System.Security.Permissions.TypeDescriptorPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(PermissionSet permSet, StackCrawlMark& stackMark) +31
System.Security.PermissionSet.Demand() +68
System.ComponentModel.TypeDescriptor.AddProviderTransparent(TypeDescriptionProvider provider, Type type) +153
System.Web.DynamicData.MetaModel.CreateSimpleModel(Type entityType) +77
System.Web.DynamicData.MetaTable.CreateTable(Type entityType) +9
System.Web.UI.DataControlExtensions.GetTableFromCache(Type entityType) +64
System.Web.UI.DataControlExtensions.EnableDynamicData(INamingContainer control, Type entityType) +14
From the stacktrace I infer you're using DynamicData in your website, and you said you're using the Web Site template in Visual Studio.
There are a couple of issues with that, but you can try a couple of things:
1: Don't use the Web Site template, but the Web Application template
or
2: Precompile the Website before deploying
or
3: Move the edmx file from the App_Code directory to a seperate library, compile it and add the resulting .dll to the websites bin folder.
Here and here you can find more info about this problem.
The below error occurs often. I wonder if anyone has ever experienced this or what would be the reason?
I use Entity Framework 4.0 and. NET 4.0 and Visual Studio 2010 and Windows Azure SDK 1.7 and 2.0.
Below is the connection string:
<add name="MyEntities"
connectionString="metadata=res://*/Model.ModelMy.csdl|res://*/Model.ModelMy.ssdl|res://*/Model.ModelMy.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=myserver.database.windows.net;
initial catalog=MyDatabase;
persist security info=True;
user id=myUser;
password=myPassword;
multipleactiveresultsets=True;
Trusted_Connection=False;
Encrypt=True;
Connection Timeout=30;
App=EntityFramework""
providerName="System.Data.EntityClient"
/>
Error information:
Server Error in '/' Application.
Database 'MyDatabase' on server '[NAMEMYSERVER]' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of 'efb529ba-14eb-46d0-8311-d48b03435cee'.
Login failed for user 'myUser'.
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: Database 'MyDatabase' on server '[NAMEMYSERVER]' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of 'efb529ba-14eb-46d0-8311-d48b03435cee'.
Login failed for user 'myUser'.
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): Database 'MyDatabase' on server '[NAMEMYSERVER]' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of 'efb529ba-14eb-46d0-8311-d48b03435cee'.
Login failed for user 'myUser'.]
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +706
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +89
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6425518
System.Data.SqlClient.SqlConnection.Open() +300
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +67
[EntityException: The underlying provider failed on Open.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4728195
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
MyProjectRules.Negocio.MyDatabaseHotel.HotelRN.PesquisarTodos(Include include) +0
MyProjectWebRole.MyDatabaseHotel.Views.ListaHoteis.CarregarGridViewEntidade() +183
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.551
Step 1: Simplify your connection string. Ours looks like this:
<add name="[CONTEXTNAME]"
providerName="System.Data.SqlClient"
connectionString="
Server=tcp:[SERVER].database.windows.net,1433;
Database=[DATABASE];
User ID=[USER]#[SERVER];
Password=[PASSWORD];
Trusted_Connection=False;
Encrypt=True;
Connection Timeout=30;"/>
So looking at your connection string, I would try something like:
<add name="MyEntities"
providerName="System.Data.SqlClient"
connectionString="
metadata=res://*/Model.ModelMy.csdl|res://*/Model.ModelMy.ssdl|res://*/Model.ModelMy.msl;
Server=myserver.database.windows.net;
Database=MyDatabase;
User id=myUser#myserver;
Password=myPassword;
Multipleactiveresultsets=True;
Trusted_Connection=False;
Encrypt=True;
Connection Timeout=30;
App=EntityFramework;" />
Step 2: It looks like you "User id" is missing the server name. It needs to be myUser#myServer. Try adding that back in.
Step 3: Probably not critical, but you're missing the ",1433" from the server address
I keep getting the following error when trying to access a particular webpage.
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
When I go into IIS and configure the directory as an application, as the error states I should do, the page seems to await a response, and shows a blank white page, for about 1-2 minutes, then I get the following error:
Server Error in '/inventory' Application.
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
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: 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
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): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +6256377
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +245
System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +6270399
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +181
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +6271242
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +6271208
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +354
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +703
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +54
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +6272472
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +81
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1657
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +88
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6275911
System.Data.SqlClient.SqlConnection.Open() +258
Inventory1.welcome.Page_Load(Object sender, EventArgs e) +219
System.Web.UI.Control.OnLoad(EventArgs e) +132
System.Web.UI.Control.LoadRecursive() +66
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428
The SQL Server is up and is accessible to all other pages on the site. I have been trying to troubleshoot this error for many hours a day for about a week now with no success. I am new to IIS, and I cannot think of other things to try at this point. I was wondering if someone can help me identify the cause of this error. This particular page was loading and working fine about 2 weeks ago.
It looks like that what ever you are doing on that page can't access to SQL Server.
How do you connect to database ? Using Windows Authentication or using SQL Server Login ? Do you use impersonation in IIS ? I would guess for example, you are tying to run some SP and this user doesn't have permission to run SP.
Can you check Database Connection accessibility (and availability) using database connection manager in IIS ? This IIS help shows how to do that.
You should definitely leave the virtual directory as an application.
The SQL error is likely something wrong with the connection string.
You said that other pages work...Is there a standard way that all your pages connect to SQL? Do they all take the connection string from the web.config? Or is it hard coded on the page?
I have requirements to configure IIS 6 to host a WCF service targeting .NET Framework 4.0 using a custom identity for the worker process. The identity is a highly restricted domain account that is used to identify and manage the permissions for an entire ecosystem of services that interact in the same business process.
I have run aspnet_regiis.exe with the -ga flag to grant this identity permissions to the relevant ASP.NET locations on the server environment and add it to the IIS_WPG group. For the most part, things seem to work relatively well... except for the auto-generated WSDL specification's includes. Accessing the top-level WSDL spec works fine (i.e. path.to/MyService.svc?wsdl), but IIS 6 is resetting the connection before returning the response for the WSDL's includes (i.e. path.to/MyService.svc?xsd=xsd0, etc). This happens both when accessed via loopback on the server and through the public IP. It does not happen when reconfiguring the app pool to run under the default Network Service account.
I haven't found any documentation for this particular problem, but it's not the first time I've had difficulty with certain bits of the .NET Framework not quite working correctly when the IIS 6 worker process is running under a custom domain identity. I haven't configured any special privileges in the Local Security Policy for this account, other than the pre-configured permission for members of IIS_WPG to log on as a batch job. What might I be missing to get the worker functioning correctly?
EDIT:
The Event Viewer contains no errors and IIS logs show the server responding with 200 OK to the request, but the full status value is 200 0 64, indicating a Win32 status code of 64.
The dump I receive on that error from net helpmsg 64 is as follows:
The specified network name is no longer available.
Responses from various entities are below:
Chrome: Error 101 (net::ERR_CONNECTION_RESET): The connection was reset
Firefox: The connection to the server was reset while the page was loading
Eclipse/Java: java.net.SocketException: Connection reset
EDIT:
Service logging (provided by BNL) produced the following exception dump:
System.InvalidOperationException: Unable to generate a temporary class
(result=1). error CS2001: Source file 'C:\WINDOWS\TEMP\vxmgwmnl.0.cs'
could not be found. error CS2008: No inputs specified.
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String
ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at
System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[]
xmlMappings, Type[] types, String defaultNamespace, Evidence evidence,
XmlSerializerCompilerParameters parameters, Assembly assembly,
Hashtable assemblies) at
System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings,
Type[] types, String defaultNamespace, String location, Evidence
evidence) at System.Xml.Serialization.XmlSerializer..ctor(Type type,
String defaultNamespace) at
System.Xml.Schema.XmlSchema.Write(XmlWriter writer,
XmlNamespaceManager namespaceManager) at
System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.XmlSchemaMessage.OnWriteBodyContents(XmlDictionaryWriter
writer) at
System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter
writer) at
System.ServiceModel.Channels.BufferedMessageWriter.WriteMessage(Message
message, BufferManager bufferManager, Int32 initialOffset, Int32
maxSizeQuota) at
System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message
message, Int32 maxMessageSize, BufferManager bufferManager, Int32
messageOffset) at
System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message
message) at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan
timeout) at
System.ServiceModel.Channels.HttpRequestContext.OnReply(Message
message, TimeSpan timeout) at
System.ServiceModel.Channels.RequestContextBase.Reply(Message message,
TimeSpan timeout) at
System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc&
rpc)
Using the guidelines on the Microsoft KB article Error message when ASP.NET 2.0 is configured to run with a user account: "Unable to generate a temporary class", I located the C:\Windows\Temp directory and inspected its folder properties by right-clicking and choosing Properties. I then navigated to the Security tab and clicked Advanced, then Add. I entered the name of the IIS_WPG group on the local computer and allowed it only the special permission List Folder / Read Data. This has now resolved the issue.
I am trying to deploy Raven DB to my site running .Net 4 in integrated mode (site was previously used to host ASP.Net MVC 3 site.
My configuration file is this:
<appSettings>
<add key="Raven/DataDir" value="~\App_Data"/>
<add key="Raven/AnonymousAccess" value="All"/>
<add key="Raven/Port" value="80"/>
</appSettings>
<system.webServer>
<handlers>
<add name="All" path="*" verb="*"
type="Raven.Web.ForwardToRavenRespondersFactory, Raven.Web"/>
</handlers>
</system.webServer>
However, the exception I get is this:
**Error FileAccessDenied (JET_errFileAccessDenied, Cannot access file, the file is locked or in use)
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: Microsoft.Isam.Esent.Interop.EsentErrorException: Error FileAccessDenied (JET_errFileAccessDenied, Cannot access file, the file is locked or in use)
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:
[EsentErrorException: Error FileAccessDenied (JET_errFileAccessDenied, Cannot access file, the file is locked or in use)]
Microsoft.Isam.Esent.Interop.Api.Fail(Int32 err) in C:\Work\ravendb\SharedLibs\Sources\ManagedEsent-48322\EsentInterop\Api.cs:2279
Microsoft.Isam.Esent.Interop.Api.JetInit(JET_INSTANCE& instance) in C:\Work\ravendb\SharedLibs\Sources\ManagedEsent-48322\EsentInterop\Api.cs:130
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\raven\Raven.Storage.Esent\TransactionalStorage.cs:169
[InvalidOperationException: Could not open transactional storage: d:\IIS\domainfolder\ravendb\App_Data\Data]
Raven.Storage.Esent.TransactionalStorage.Initialize(IUuidGenerator uuidGenerator) in c:\Builds\raven\Raven.Storage.Esent\TransactionalStorage.cs:182
Raven.Database.DocumentDatabase..ctor(InMemoryRavenConfiguration configuration) in c:\Builds\raven\Raven.Database\DocumentDatabase.cs:127
Raven.Web.ForwardToRavenRespondersFactory..cctor() in c:\Builds\raven\Raven.Web\ForwardToRavenRespondersFactory.cs:31
[TypeInitializationException: The type initializer for 'Raven.Web.ForwardToRavenRespondersFactory' threw an exception.]
Raven.Web.ForwardToRavenRespondersFactory..ctor() +0
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
System.Web.Configuration.HandlerFactoryCache..ctor(String type) +46
System.Web.HttpApplication.GetFactory(String type) +81
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184**
I have contacted my host and have confirmation that I have read/write access to App_Data and I have also confirmed this myself by writing some code to create a file there.
My host hinted that my problem might be due to double initialisation of my datastore - whatever that means.
Can any of you point me towards a solution here?
UPDATE 2011-05-18
I am using RavenDB-Build-360 currently available at http://builds.hibernatingrhinos.com/download/2004 . I am using the installation instructions on http://ravendb.net/documentation/docs-deployment-iis for running it on IIS 7.5. But instead of using own local IIS, I am simply copying the content of the /Web-folder to my host . This means the /bin-folder, the web.config and the SilverLight XAP-file. So I am not able to debug my way through anything.
I have not noticed the first line (about WebDAV module) but I will check with my host ASAP.How does Raven DB rely on this?
i had this exact same problem - my solution was to remove the default App Pool identity from 'ApplicationPoolIdentity' to an administrator account (such as myself for testing purposes).
after a restart of the web site, this then worked.
I also ran into this problem and was unable to fix it with any of the solutions found on the web.
I ended up going into IIS, right-clicking my web app that uses raven, edit permissions.
Selected the Security tab, clicked NETWORK Service, then checked Full Control. Hit apply, everything started working again.
Bottom line: it turned out to be a permissions issue. I'm unsure why my permissions were changed, as all this was working a few days ago. Perhaps an IIS patch? I don't know. Whatever the case, make sure the Network Service has permission for your web app that uses raven. I gave full control to the Network Service, but you may get away with read/write control.