Cannot connect to named shared LocalDB instance - iis

I spent hours on this with no success. Any help appriciated:
I create LocalDB instance
sqllocaldb create test
i start that instance
sqllocaldb start test
i share that instance with same user account that owns the original instance
sqllocaldb share "domain\user" test testShared
Both instances are in "running" state.
I launch MS SQL Management studio and try to connect to instances. Results:
I'm able to connect to both instances using named pipes - OK.
I'm able to connect to (localdb)\test - OK.
I'm not able to connect to (localdb)\.\testShared - NOT OK.
Error 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)
Any ideas? I tried that on 4 different computers. It works correctly on two of them. 3 of coputers are connected to domain (so it has probably nothing to do with domain environment).
In SQL Configuration Manager - all protocols are enabled.
What I need to achieve - share the LocalDB instance with IIS APPPOOL\ASP.NET v4.0 account according to this.

Based on the exact steps, as you described them, all you need to do is to restart your instance. It is required after you share it, so that it listens on the public pipe with the well known name that was assigned to it by the sharing process.

you need to enable setProfileEnvironment. This requires editing
applicationHost.config file which is usually located in
C:\Windows\System32\inetsrv\config. Following the instructions from KB
2547655 we should enable both flags for Application Pool ASP.NET v4.0,
like this:
http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-1-user-profile.aspx
<applicationPools>
<add name="DefaultAppPool">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>
<add name="ASP.NET v4.0" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>

Related

Azure Cloud - connecting web application to mysql database

Relatively new to azure cloud so go easy
Configuration as below on
1 x app service (running asp.net web application)
1 x azure database for mysql server
(so currently 2 resources)
Now whenever i put my connection string into my web app to point to the mysql database hosted on azure, it just times out, with the error below
[MySqlException: Unable to connect to any of the specified MySQL hosts.]
I have set the security to allow access to azure services as per documentation, and disabled the enforce SSL for now. I am able to connect to the database remotely from my machine, but my web app times out.
I have tried every permutation of connection string but it makes no difference. It works if i use the mysql in app but this is not a scalable solution for us.
Did you copy your connection string from Azure and plug it into your web config under the connectionstrings node? If so, did you remove the connectionstring name then re-add it? Such as:
<connectionStrings>
<remove name="conn" />
<add name="conn" connectionString="Server=localhost\SQLEXPRESS;Database=***;Trusted_Connection=True;" providerName="System.Data.SqlClient" />
This is the best practice for using a connectionstring in a webconfig file.
As well take a look at your error details. You are trying to use environment variables for connecting to the database. This won't work because you are in two different environments: the first being your web app environment and the second being the database environment.
Even if you are using Azure as a host, it still won't work.

RDP connection to Azure workerrole leads to AzureWebrole

I have the following issue.
I have created the following cloudservice setup.
Azureproject
Roles
AruzeWebRole
AzureWorkerRole
The webrole has two small instances, the workerrole one extrasmall.
When i deploy this to our azure environment, i see correctly three instances:
Name Status Role Size
---------------------------------------------------------------------
AzureWorkerRole_IN_0 Running AzureWorkerRole Extra Small
AruzeWebRole_IN_0 Running AruzeWebRole Small
AruzeWebRole_IN_1 Running AruzeWebRole Small
Everything works fine.
But when i open a RDP connection to my two web-instances, and a third rdp connection to the workerrole-instance, i get kicked out of one of the web-instance.
When i get a closer look, when opening the RDP session to the workerrole its just creating an RDP to a Webrole instance.
After a redeploy it is possible that i gt oin the other web-instance.
If i change the size of the workerrole from XS to M, it still opens the RDP to one of my webroles.
I'm not sure what I'm doing wrong.
Is my workerrole realy deployed on one of my webrole instances, or is Azure just fooling arround with me.
If anyone had a similar situation, or some good advice to check this out. That would be nice.
Thanks!
I can say it's kind strange behaviour. I've got approximately the same configuration and it works just fine.
Just a hint to think about.
The way RDP works in Azure is:
there is one public ip or yourapplication.cloudapp.net endpoint. All your instances are behind the load balancer. So that to be able to RDP any of your instances, there should be such rows in the serviceDefinition file.
<Imports>
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
In your case those rows are under your webrole instance. That means, when you try to connect to yourapplication.cloudapp.net endpoint and RemoreForwarder forwards you to a specific instance based on the information which is stored in the RDP connection file. So that to check this. Go to the azure portal and download rdp connection file for your webrole instance and for your workerrole instance. Open those with notepad and see yourself: the same endpoint and a section which says to the remoteforwader to which instance to connect.
And one thing I forgot to tell you. If you want to connect to your instances manually(not using the RDP connection file from azure portal), means that you omit the instance cookie, most likely you will be connected to the one of your webrole instances, probably to instance 0.
Why would you RDP to the web role and then RDP to the worker role from within the web role? Just RDP directly to the worker role from your local machine. From the portal you can pick the worker role instance from the Instances list and select Connect.

Entity Framework 5 and Amazon RDS - "The underlying provider failed on Open."

I have a C# / Entity Framework web application runs fine against a local SQL 2012 db. I copied the db out to a new RDS instance, and can access the db via Visual Studio and SQL Server Management Studio.
I hav a unit test which authenticates the user and then attempts inserts a record in a table using an Entity Framework call -- dataContext.SaveChanges().
I get the following error:
{"The underlying provider failed on Open."}
{"No such host is known"}
{"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: TCP Provider, error: 0 - No such host is known.)"}
I've poked around the web for answer all day, and so far no success with any of the suggestions I found:
Port 1433 is open I can access the entry point via Telnet
My IP address is covered by the CIDR/IP range for the default security
group.
The error occurs as soon as I attempt to open the connection
on the datacontext.
The db server is configured to accept remote
connections.
The db server is configured to use mixed authentication
(both Windows and SQL Server).
Entity Framework Connection String
connectionString = "metadata=res://*/MyDb.csdl|res://*/MyDb.ssdl|res://*/MyDb.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MyAwsEntryPoint;Initial Catalog=MyDb;User ID=MyUser;Password=MyPassword;Persist Security Info=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"
Standard Db Connection String
connectionString = "Data Source=MyAwsEntryPoint,1433;Initial Catalog=MyDb;User ID=MyUser;Password=MyPassword;Persist Security Info=True;Application Name=MyAppName;"
The problem was in the connection string. Specifically, I had "Application Name" and "App" properties in there. Once I removed those, it worked.
BAD:
<add name="MyDbEntities" connectionString="metadata=res://*/MyDb.csdl|res://*/MyDb.ssdl|res://*/MyDb.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MyDbServer;Initial Catalog=MyDb;Persist Security Info=True;User ID=MyDb;Password=MyPassword;Application Name=MyDb.API.Models;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
GOOD:
<add name="MyDbEntities" connectionString="metadata=res://*/MyDb.csdl|res://*/MyDb.ssdl|res://*/MyDb.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MyDbServer;Initial Catalog=MyDb;Persist Security Info=True;User ID=MyDb;Password=MyPassword;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />

Protect test/beta site running in azure

We're developing a new website running in azure. We are currently developing against the local azure dev environment. But now we need to publish and test the site in the real Azure world. But we would like to run in a "closed" environment, where only know users have access, as the site should not go live yet. Any suggestions to accomplish this?
/Rasmus
Windows Azure has something called 'staging mode', see this post: http://sevans.info/2010/10/10/windows-azure-staging-model/
It's very powerful, and exactly what you need as far as I can see.
You could remove the endpoints of your instance configuration, so there will be no forwarding through the load balancer. After that you could use the Remote Desktop to log into your azure instance and test your web application.
Above suggestions are great and I would also like to add two more in this list as well:
Using production deployment and having a dummy index/default page with directory browsing disabled (already set as default) So when someone come you your site there is nothing they will see. And as there is no directory browsing so they can not guess the page*.aspx to visit your site. This will keep your production site running and you can test it from outside.
Removing your instance form Load Balancer while keeping your instance healthy. This will require you to test the Azure Application by RDP to your instance and then launch internally. If you wish to do so here is the Powershell based trick.
You could restrict the IP addresses that are allowed to access your app if you have a static IP address. As per this link: https://azure.microsoft.com/en-us/blog/ip-and-domain-restrictions-for-windows-azure-web-sites/
Developers can use IP and Domain Restrictions to control the set of IP addresses, and address ranges, that are either allowed or denied access to their websites. With Windows Azure Web Sites developers can enable/disable the feature, as well as customize its behavior, using web.config files located in their website.
Here's the code:
<system.webServer>
<security>
<ipSecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="123.456.0.0" subnetMask="255.255.0.0"/>
</ipSecurity>
</security>
</system.webServer>

Access denied creating App_Data subdirectory

I've created a user from the ASP.NET Configuration
I'm using sql server but I haven't created any database for membership.
I did add this to the config file:
<authentication mode="Forms">
<forms loginUrl="Login.aspx"></forms>
</authentication>
<authorization>
<allow users="admin" />
<deny users="?" />
</authorization>
where admin is the user I did creat.
and it works very well localy.
after I have uploded my website I got an error that I have to create an App_Data folder with write permission and add it to my application folder, now I get this :
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: 26 - Error Locating Server/Instance Specified)
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.
The above error message that you are getting will only occur on a remote call. It may work locally fine. This is due to the fact that the remote connections are not enabled on the SQL Server surface Area configuration. To accomplish this, please follow below steps:
Make sure your database engine is configured to accept remote connections:
• Start > All Programs > SQL Server 2005 > Configuration Tools > SQL Server Surface Area Configuration
• Click on Surface Area Configuration for Services and Connections
• Select the instance that is having a problem > Database Engine > Remote Connections
• Enable local and remote connections
• Restart instance
Alternatively, if you are using a named SQL Server instance, make sure you are using that instance name in your connection strings in your ASweb P.NET application
• Usually the format needed to specify the database server is machinename\instancename
• Check your connection string as well
**
**

Resources