Introduction

In today’s date a great percentage of business in IT service and solution industry comes from cloud computing. Windows Azure is one of the major platforms in the field of Cloud Computing provided by Microsoft Technologies.This article does not describe the migration or development process to azure, rather it depicts some issues that one can face during development/migration phase on Azure platform.Purpose of this document is to highlight some very basic key points which can be very useful in order to trouble shoot issues in Windows Azure environment.

Key Points to remember

1.   Project type for Windows Azure  Web Role should be WEB Application 

To migrate a web based project azure cloud service should contain a web role. For web roles, web project should be of web application type. Web roles do not support website projects. In case we need to move an existing website to windows azure it has to be modified to a web application before migrating to cloud platform.

 2.   Unable to load assemblies on runtime.

Very often after deployment on cloud, application may throw an error stating unable to load assembly on runtime. It can be resolved in the following ways 

Process 1:-Mark the Copy local property to true for the required assembly.It will place the dll in bin folder hence on runtime application loads the dll from bin folder. But in case if app domain change this process will fail again. To avoid this we need to register the dll in server GAC [Process 2]. 

Process 2:-Register the DLL in to GAC.

  • Add the GACUtil.exe to the web role project and set the Copy Always value for Copy to Output Directory property.
  • Create a cmd file containing the following commands

gacutil /nologo /i .\<AssemlyName>.dll 

exit /b 0

Set the Copy Always value for Copy to Output Directory property. 

  • Add the following configuration in ServiceDefinition.csdef file

<Startup>

     <Task commandLine="<cmdfilenmae.cmd>" taskType="simple" executionContext="elevated"></Task>

   </Startup>        

3.   Classic ASP application Migration. 

Classic ASP application can be moved to azure without upgrading.

Following process can be followed for the same

  • Create an empty web role project.
  • Add all the exising files along with folder structure from existing asp project under the web role project.
  • Create a cmd file with the following commands

start /w pkgmgr /iu:IIS-ASP

regasm.exe /tlb /codebase IdentityCheck.dll

gacutil.exe /i IdentityCheck.dll

echo %errorlevel%

 Add this cmd file to the web role project and Set the Copy Always value for Copy to Output Directory property. Add the following configuration in ServiceDefinition.csdef file

<Startup>

     <Task commandLine="<cmdfilenmae.cmd>" taskType="simple" executionContext="elevated"></Task>

   </Startup>

 Note: In case of simple application we can follow the above procedure for complex application it is advisable to re factor the application in .net framework 3.5/4.0 before migration.

 4.   Process of dealing with cloud server drives/folder/files requires to use azure Temp Storage

 Apart from the "Development Storage" and "SQL Azure", there is something called "local storage" which is provided for every web / worker role. This is just a temporary file storage which can be mostly used for caching on temporary value storage.  They can also be set to be cleaned when there is recycle on role. This can be done by adding below line of code in ServiceDefinition.csdef file of cloud project

          <LocalResources>

    <LocalStorage name="TempStorage" cleanOnRoleRecycle="true" sizeInMB="3" />           

  </LocalResources>

Name is the Folder/Storage name where the files will be saved. Also remember that if there is a VM crash, the files won’t be recovered and these files cannot be shared across instances if you running a multiple instances and therefore your code should accommodate considering the fact.

 5.   Azure service  cannot be named with Global word

6.   Azure Storage account/Blob name should be in lower case

In case Azure storage account/Blob name contains any character in upper case during storage creation one will face the following issue. In order to resolve this while dealing with Azure storage naming convention should be followed with lower casing.

 

Note: In case if we try to access an already created storage with Uppercase it will not throw any exception. It will be able to access.

7.   In Azure storage table column name should not be same as table name

In azure storage table if we have a column named after the parent table we will encounter the following exception on runtime.

 It does not state much detail about the exception thrown, but it has been observed if we rename the column other than the containing table name this issue resolved.

8.   Set Configuration Publisher should be called in Global.asax on Application_Start Event

 While dealing with the azure storage we need to place the following piece of code under Application_Start event Microsoft.WindowsAzure.CloudStorageAccount.SetConfigurationSettingPublisher

((configName, configSetter) =>

            {

                configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

            });

 Otherwise application will throw the following exception

9.   Process to deal with local storage emulator

Sometime we may face the following problem while using Development storage.

 

 

It may occur due to the following reasons

 

1)   Logged in user does not have admin rights over the SQL Server 2008 Express.

 

When some other user has installed that, you will be facing difficulties while initializing the azure development storage from your windows login credentials

 

Resolution:-Logged in windows user name should be added as admin in SQL Server master DB

 

2)     Alias name is not specified for the default sql instance.

 

Resolution:-

 

  • Specify an alias name for the default instance of SQL.
  • Navigate to the following path in command prompt

 

\\Windows Azure SDK\[SDK Version]\bin\devstore

 

  • Run the following command

 

dsinit /sqlinstance:[instancename]

 

 10.   Windows identity returns empty value for Azure application

 

In windows azure web role solution logged in user information cannot be fetched using HttpContext.Current.User.Identity. As in cloud based projects HttpContext.Current.User.Identity.Name will be fetched as empty string. In order to achieve the windows authentication functionality ACS needs to be integrated.

11.   Use ACS integration with https service endpoint

While deploying to the cloud environment it is advisable to use the https endpoint along with a signed certificate. Otherwise there is a huge possibility of facing cryptographic exception on runtime, based on the machine configuration.

12.   During ACS integration IClaimsIndentity cannot be invoked in Application_Start Event 

During ACS implementation in case the Name claim process using IdentityModel  is invoked within the Application_Start event, it can lead to the following exception. Unable to cast object of type 'System.Security.Principal.GenericIdentity' to type 'Microsoft.IdentityModel.Claims.IClaimsIdentity'. In order to handle this all the authentication mechanism should be place under either Session_Start or Application_BeginRequest event.

 13.   Few important web config settings for ACS integration

Following web config settings are mandatory in order to achieve a successful ACS integration

<httpRuntime requestValidationMode="2.0" /> --Under System.web

<validation validateIntegratedModeConfiguration="false" /> --Under System.webserver

 14.   WEB.Config should not be in read only mode while running the application on local environment.

  • Issue: If we try to run the cloud solution when the web.config file is in readonly mode we will get the following error.
  • In SDK 1.3 to simplify the use of ASP.NET, the Windows Azure environment automatically configures the ASP.NET machine key on a per-site basis using the site’s web.config file.  The automatically-supplied machine key is identical for all instances of a given site, but is different in all other cases (across deployments, etc.).

    • Resolution: In the SDK 1.3 release, this error occurs in the Windows Azure compute emulator when the web.config file is marked as read-only. The error does not occur when deploying to Windows Azure in the cloud, because file attributes are reset in any cloud deployment, thus making the web.config file writable will resolve the above exception. Note that the compute emulator does not copy the site’s content during execution.