configuring a Windows Server 2012 VM using IIS to call Azure - asp.net

I'm setting up an ASP.NET MVC5 application on a Windows Server 2012 VM running .Net 4.5 and IIS8. I've always leverages Azure for App and DB services (thank you Azure for your seamless 10 min server setup and publishing solution!) however I need to host this app using this alternative method. The VM is not an Azure VM. I've managed to configure the VM and publish the application (10 hrs of head banging experience... ) however when the application attempts to make a call to the Azure Db during the form registration process I receive a time out error; "The wait operation timed out".
My question is; I can access the application via the ip address from my local machine, I think port 80 is open by default. Do I need to specifically target this port in the applications web.config file for I/O calls?

If you want to connect a non-Azure Virtual machine which is behind a firewall to the resources in Azure, you will have to create a virtual network with either site to site or point to site VPN enabled. Please check this link which explains how to do it. https://azure.microsoft.com/en-us/documentation/articles/vpn-gateway-howto-site-to-site-resource-manager-portal/

Related

Azure SQL - localhost can't connect

I started coding an ASP.NET webapp (with Visual Studio 2015). I'm having problems with the connection to my Azure SQL database. I can connect to the database via MSSM Studio.
When I publish my app on the Azure webservice the app works fine. When I run my code locally I keep getting the following error:
SqlException: Cannot open server 'database' requested by the login. Client with IP address 'XX.XX.XX.XX' is not allowed to access the server. To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create a firewall rule for this IP address or address range. It may take up to five minutes for this change to take effect.
Altough the firewall of the database service is set (I've even tried with range 0.0.0.0 too 255.255.255.255). On my computer port 1433 is allowed.
Any help is deeply appreciated.
The problem was solved by editing the username of the database connectionstring.
my_username#my_app.database.windows.net -> only worked published on Azure (not via localhost)
my_username#database.windows.com -> works published on Azure and with my localhost

Connecting to database in asp.net website by Wp8 app

I created localhost website in asp.net in Visual Studio and i added there a MSSQL connection.
My problem is that I created an app for windows phone 8 but i dont know how to connect this app with database which is on this website.
Can you help me with this?
First of all: your Windows Phone app can't connect to a SQL Server database, so you'll have to create an API.
Since you're using ASP.NET, I suggest to have a look at Web API. In short: you'll have several URL endpoints which return json/xml to your Windows Phone app. It's your job to query the database and return a single item/list of items in the controller of that URL endpoint (this sentence will make sense if you read into creating a Web API).
Next task is connecting to this API. Normally you would host it on a public url, so your phone device can connect to it (a phone doesn't know about your pc's localhost). If you want to use localhost with the emulator for testing, you'll have to execute the tasks mentioned in the quote below as this doesn't work out of the box.
When you create a WCF web service in Visual Studio, by default the
service is hosted in IIS Express and only accepts connections at
http://localhost/. Apps that target Windows Phone OS 7.1 can connect
to the development computer as localhost because the Windows Phone 7.1
emulator uses the network connection of the development computer. The
Windows Phone 8 Emulator, however, configures itself as a separate
device on the network. As a result, an app running on the Windows
Phone 8 Emulator can’t connect to the development computer as
localhost. Before you can connect successfully from the emulator to
the local web service, you have to make two changes:
You have to configure the local web service and web server to accept connections from other devices on the network.
You have to configure the service reference in the Windows Phone app to connect to the service by using the IP address of the development
computer on which the service is running.
Source: https://msdn.microsoft.com/en-us/library/windows/apps/jj684580(v=vs.105).aspx

azure connect between azure myWebRole and nonazure server not working

My webapplication hosted on windows azure, needs to communicate with TFS Server. When any one login to my web app using live id, I want the logged in user to use my Team foundation server(TFS) credentials -username,password and domain to programatically authenticate and connect to our TFS server and create some work items.
I configured my azure connect for the communication to happen between azure WebRole and TFS server (our TFS is non-azure ).I added both the WebRole and the TFS Server into single Connection Group
In my azureportal ,I can see mywebrole and my TFSServer as connected the machine endpoint is active, and that it refreshes since the last connected updates
.But when I try to run my web application from azure and when it tries to communicate with our TFS server ,its throwing error message saying Error message : Team Foundation services are not available from server eg.,http://xyz-abcxyx-01:8080/tfs/eas/. Technical information (for administrator): The remote name could not be resolved: 'xyz-abcxyx-01'
Any suggestions to resolve this issue ?
You should enable remote desktop on your WebRole and connect to one of your instances. Then, try to ping the IP of your TFS server (not the hostname xyz-abcxyx-01). Maybe this is simply a DNS issue (even though using hostnames works with Windows Azure Connect).
If pinging the IP works, but pinging the hostname doesn't work you have a few options left:
Use the IP instead of the hostname. This won't work if you configured your TFS to use host headers.
Create an elevated startup task to modify the hosts file and map the IP to the hostname. In your code you can keep working with the hostname.
Try to modify the DNS server configured in your WebRole to use the default DNS server + your internal DNS server. But to me this doesn't look like a clean solution.
Anyways, in each solution you'll want to store the IP/hostname in the ServiceConfiguration and make sure your code supports changes to the ServiceConfiguration. This will allow you to change the IP/hostname without having to redeploy.
You should check if TFS server is listening on all network interfaces, include the one created by Azure Connect (start with 2a01). Next try to connect to TFS from a machine on the local LAN, just to make sure it is configured correctly. You don't need to use IP for referring to TFS, DNS name is definitely supported out of box.

should I use azure connect in this scenario

My webapplication hosted on windows azure needs to communicate with TFS Server.
my webroles connect to TFS using a uri similar to (http://ed12-ektfsp-01:8080/tfs/eeol/ )
While on azure I found that my webrole failed to communicate with tfs server.
Do I need to enable "azure connect" for for my azure webrole to
communicate with tfs ?
Do I need to remote into my tfs server and
install azure connect into my TFS server for the azure connect to
get enabled ?
Why azure cannot communicate using
"http://ed12-ektfsp-01:8080/tfs/eeol/ " ?
Your web application does not know the server ed12-ektfsp-01 (I'm assuming this is a server in your datacenter/in your internal network). But there are a few options to allow your web application to connect to this server even if it isn't hosted in Windows Azure:
Configure your firewall to allow traffic from the internet to reach the server ed12-ektfsp-01. This is probably something you do not want to do, unless the server is already available (maybe for developers working at home). Then instead of using the machine name, use the public domain instead (like tfs.mycompany.com) if it's available.
Like you already mentioned, use Windows Azure Connect. This allows you to create a secure tunnel between your roles and your datacenter/internal network. You'll be able to connect to ed12-ektfsp-01 even if it's not exposed to the internet through your firewall. In order for this to work you'll need to install the agent on each server you want to connect to your role, this includes your TFS server.
You can connect your role to a Virtual Network. Then you can use a VPN device on-premises to create a site-to-site VPN connection to this Virtual Network. See the tutorial here: Create a Virtual Network for Cross-Premises Connectivity
You can use Service Bus Relay. This allows you to create a WCF service that calls TFS and host that service within your datacenter/network, but publish it to the cloud. Your web application will be able to consume the WCF service as if it were hosted in Windows Azure.
Please take a look at my answer to this question.
As for your specific questions:
Do I need to enable "azure connect" for for my azure webrole to
communicate with tfs ?
YES.
Do I need to remote into my tfs server and install azure connect into
my TFS server for the azure connect to get enabled ?
YES. And add both the WebRole and the TFS Server into single Connection Group.
Why azure cannot communicate using
"http://ed12-ektfsp-01:8080/tfs/eeol/ " ?
Because the address given is known only within your corporate network, and only resolved by the Company's DNS server. Noone outside can access this address.

Connection to SQL server 2000 on a windows server 2003 domain controller

I am trying to connect an ASP.NET 2.0 application hosted on a client machine to an SQL server 2000 instance which is installed on a domain controller running windows server 2003 (I appreciate this is not best practise, but it is something I cannot change). I am using SQL server authentication, not Windows authentication.
During debugging, the following error is displayed at the point the 'connection' is attempted within the web application (not on running any object within Sql Server):
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
I have done some research, and have checked a variety of things:
1) I am certain the conection string is correct - in fact I built a little Windows app that uses the same connection information and connection succeeds...
2) This is limited to the web application - a windows application running on the remote client machine connects just fine using the same connection string (see 1).
3) The firewall settings on both computers do not prevent the connection (see 1).
4) I can ping the windows 2003 server (see 1)
5) The SQL Server credentials definitely have the rights to the objects needed
6) If I (temporarily) put the web application on the windows server 2003 and run it, it loads and runs fine (using a browser on a separate machine, or on the client machine I am trying to connect) - suggesting this is only an issue with a remote connection, and confirming the connectivity between the machines again, and also confirming the necessary security right of the SQL Server user.
7) I can start query analyser on the client machine and using the same SQL server credentials, can run the same queries on the target database just fine.
Stumped. Please help!
You need to go into the SQL Server Configuration Manager and make sure the Named Pipes option is turned on. It is not turned on by default when you install SQL Server.
Because of the research I did in the original question covering the ability of a windows app to connect but not the ASP.NET app to connect from the same machine, and the confirmation the web app was working on the server itself, I was convinced SQL server was set up correctly, that connectivity and firewalls were not a problem - it must have been a difference in the security credentials of the windows app versus the web app.
The windows app runs in the security credentials of the logged on windows user and authenticates using that, whereas the webapp runs in a restricted account and does not pass these credentials over when connecting to SQL server by default. I simply added to web.config, which impersonates the user account within which the web app runs, and it all worked!
Problem solved.

Resources