Skip to main content

Posts

Showing posts with the label worker role

What should I do when on Azure Web Role I get "HTTP Error 401.2 - Unauthorized. You are not authorized to view this page due to invalid authentication headers"

This post is dedicated to a simple but annoying issue that can appear when you are developing a ASP.NET MVC Application. When I run my web application on my local machine, directly from Visual Studio, my web sites works perfectly. When I deploy it on a Web Role I get " HTTP Error 401.2 - Unauthorized. You are not authorized to view this page due to invalid authentication headers " The same problem can appears if you deploy on on-premises servers, but in general this problem pop-ups on Web Roles. Not because a web role is different (it has the same layers as a web server -OS and IIS), but because people that are working with cloud solutions forget about infrastructure layers. If we are reading the error message we can identify some possible root causes. But basically it seems that the user that is trying to access the page is not authorized. But why it is working on the development machine from Visual Studio? Simple, in general the developer is also the admin on the mach...

Lifecycle of Worker Roles (RoleEntryPoint)

In this post we will talk about 3 methods that are available in the RoleEntryPoint class for Web and Worker Roles (especially Worker Roles) OnStart Run OnStop This 3 methods are called in different moment of the lifecycle of a Worker Role. Each of them has a clear scope and output. OnStart This method is called automatically when the instance of Worker Role is initialized. It is used to initialized the context or prepare the instance before executing the task. This method returns a bool value that it is used to tell the system if the initialization was made with success or not. On the happy case the return value should be true. If an error occurs or the initialization fails, that the false value should be returned. When OnStart methods returns false, the Run method will not be called and the instance will be 'restarted' - No other methods will be called. Run The Run method is used to execute the batch operation or the logic that is necessary to be executed by the...