How does Session work in Azure - asp.net-mvc-4

How does Windows Azure handle Session is it InProc session or something else?
Also why should one not use Session and instead go for Windows Azure Cache to store transient data?

Session management in Windows Azure depends on how the application is deployed. If your application is deployed in Windows Azure Website, then InProc session will work. However if your application is deployed as Windows Azure Cloud Service, then InProc session will not work. Reason being the load balancer in front of your cloud service. In case of a cloud service, load balance works in a Round Robin manner and thus InProc session management would not work.
If you want, you can still use session in your cloud services however you would need to use a different session provider than default InProc provider. There is a session provider built on top of Windows Azure Cache which can be used (and is actually recommended). You don't have to make any changes in the code as far as session handling is concerned. Only thing that will change is an entry in your web.config file. Please see this link for more details: http://msdn.microsoft.com/en-us/library/windowsazure/gg185668.aspx.

Related

How can I detect if my application is running in AWS

I'm writing an aspnet core app which can be deployed to either azure or aws. The Microsoft libraries for accessing azure logging / configuration sources are well-behaved and fail silently if they're not in an appropriate environment. However the AWS SDK blows up with and exception Unable to get IAM security credentials from EC2 Instance Metadata Service. if the providers are configured outside of AWS. Are there some environment variables I can look at to determine if my application is running in AWS so I can skip those?
All EC2 instances (and therefore all AWS hosting methods) have access to an instance meta-data http service running on a local-link address at http://169.254.169.254/latest/meta-data/. The best process I can come up with is to make a call to this service. If the call fails -- the process is not hosted on an EC2 instance.

Azure Cloud Service remote desktop is not working

I have used Azure Cloud Services in the past and enabled RDP when I needed access to the machine for some troubleshooting. Today I needed access again, but I cannot access any cloud service anymore. I enabled RDP with my normal certificate and the same user and password as always, but I just cannot connect.
Adding the RDP connection works fine, but when logging in it just times out. It feels like a port that is blocked. Anyone knows if something has changed?
Your issue looks similar to the thread posted here.
Azure classic cloud service cannot RDP
Here is a document on enabling remote desktop connection for a role in Azure cloud services:
https://learn.microsoft.com/en-us/azure/cloud-services/cloud-services-role-enable-remote-desktop-new-portal

Confusion regarding WCF at Azure

I have few WCF services, deployed at IIS, which are consumed by some android devices. I'm have to move all my databases and services to Azure. I googled to find out how to deploy WCF at Azure, and found a concept of WebRole and Azure Cloud Service project. See THIS SO POST
But at the same time, I just tried creating a new webapp in Azure and simply published my WCF services project there, and it worked fine. (I tested with client).
My Question is,
What is the difference between the methods mentioned in the post I linked, and the way I deployed? I'm concerned, because I'm expecting high amount of requests.
Is it okay to deploy my already created/ready services the way I did?
What is preferred?
Both (WebApp and Web role) will work for your scenario.
The main difference between this two way is that Web role allows you to connect to it through remote desktop.
You can keep using WebApp and configure Auto Scaling (based on CPU usage or at a specific time).

Hosting a continuosly running Console application

Azure VM, Cloud service or Web job?
I have a configurable console application which runs continuosly. Currently it is running on a VM and consumes lot of memory (it is basically doing data mining).
The current requirement is to have multiple instances of this application with different set of configuration which can be changed by specific users.
So where should I host this application such that the configuration can be modified using some front end which provides access managements(like Sharepoint),ability to stop it/restart (like WCF service) without logging on the VM?
I am open to any suggestions/ideas. Thanks
I don't think there's any sold answer to this question as there is the preference variable but for what it's worth, if it were up to me I would deploy it against individual azure VM's for each specific set of users. That way if the server resources went up because of config changes the user group made it is isolated to that group, and with azure, will scale automatically to meet the resource demand. Then just build a little .net web app to allow user to authenticate and change configuration settings.
You could expose an "admin" endpoint for your service (obviously you need authentication here!) that:
1. can return the current configuration
2. accept new configuration
3. restart the service (if needed). Stopping the service will be harder, since that leaves the question on how to start it again.
Then you need to write your own (or use a 3-party (like sharepoint or a CMS)) application that will handle your users and under the hood consume your "admin" endpoint.
Edit: The hosting part: If I understand you correctly your app is just an console application today, and you don't know how to host it? Well, there are many answers to that question. If you have a operations department go talk to them, if you are on your own play around and see what fits you and your environment best!
My tip: go for a http/https protocol/interface - just because there are many web host out there, and you can easy find tools for that protocol. if you are on the .NET platform check out Web.API or OWASP
Azure now has Machine learning to process data mining.
You should check if it's suit to you.
Otherwise, you can use Webjob:
Allow you to have multiple instances of your long time running job (Webjon scaling out).
AppSettings can be change from the Azure Portal or using the Azure Management API

WCF call back in load balancing server

I have a chat application developed using WCF call back contract.This use netTcp binding for the client server communication.
Client is a Windows Forms application will be running in the client machine(XP or Windows8 machine)
This WCF service hosted as a windows service in the server machine.I am maintaining a Client Session list in the service, this will store the details about each client connected to the server, this list is static variable.
The work flow is, whenever a client connect to the server using the connect operation,client details will be added to the client session list,this session list will be used by the server to send message back to the client whenever its needed.
Everything works fine in the single server environment,Now I want to know how can I handle this in the load balancing scenario, that means I have two server machine,at a time one server will be active.if Server 1 is fail, Server 2 will be active. In this scenario, How can I manage my client sessions share between two servers and working as usual with out disturbing my clients?
One option is to use a Session State store provider, which will provide the session state for both instances of server service.
As MSDN states: http://msdn.microsoft.com/en-us/library/z414bbk9(v=vs.100).aspx
for Web farm configurations, it can be stored out of process using
either the ASP.NET State service or a Microsoft SQL Server database.
The ASP.NET state service is quite well documented http://msdn.microsoft.com/en-us/library/ms178581(v=vs.100).aspx
As for the database solution... well... you have to analyse the added overhead due to database access.
Also, if you are hosting the service using IIS, you could consider using Out-of-Process session state (http://technet.microsoft.com/en-us/library/cc754032%28v=ws.10%29.aspx).
These are just some ideas. You can look into other web farm synchronization techniques made available for Microsoft technologies.