The below article was prepared based on the Azure SDK 1.8.
Why we use Windows Azure
Azure and cloud platforms are about saving money. Instead of buying and operating an entire data center for yourself, you purchase a slice of data center and share in the cost of its operation.
Currently supports:
- .Net
- Java
- Ruby on Rails
- PHP
Migration is not Free
You can't put an existing application on top of Windows Azure. You must first make some changes to your existing application.
Backup is not there
You can't take a backup of your application in the live environment. Backups are still your responsibility.
Logging in and Debugging require some code
Once you host your application in the production environment, you can't get a good view of what is happening in the production environment. But Azure provides standard log and diagnostic data you want. However you must code and configure your application to request and capture the data.
Data Migration
Where and how to retrieve our application data? The best answer is SQL Azure. SQL Azure is a sub-component of Windows Azure. SQL Azure is fully based on SQL Server 2008 R2, whereas migrating existing data from SQL Server 2008 to SQL Azure is not so easy. But CodePlex provides tools to migrate our local data to SQL Azure and vice versa is also possible.
You can find this tool : http://sqlazuremw.codeplex.com/.
ASP.Net Session State
Many ASP.Net applications use session state to track the state of the user's behavior.
Default ASP.Net supports an INProc state or State Server or SQL Server, but Windows Azure doesn't support INProc mode.
Configuration
Many web applications rely on using the Web.Config to store runtime configuration, this is a handy and secure place to store your configuration details (like database connection strings and so on).
When you deploy your application to Windows Azure your package is deployed to your web role instance as a read only mode, so none of the files can be changed at runtime. If you want to change anything after the deployment then that should be treated as a re-deployment. So you are unable to edit any files in the production environment.
In Windows Azure we have the following two configuration files:
- ServiceConfiguration.cscfg
- ServiceDefinition.csdef
FileSystem Use
Many web applications read and write to the file system. This is a problem in the cloud because your code is running in a stateless environment and could be destroyed and recreated at any time. This is the stateless nature, the local disk is not available for use.
You only use the file system for temporary storage, for that Windows Azure provides a local disk on the server for temporary use. The following are the configuration details to request the local files system for temporary usage. You need to fill in these details in the csdef file.
- <LocalResources>
- <LocalStorage name=”TempStore” sizeinMB=”100” clearonRoleRecycle=”True”/>
- <LocalResources>
In the code behind:
- LocalResource localCache = RoleEnvironment.GetLocalResource("TempUploads");
- string localCacheRootDirectory = localCache.RootPath
Your second option is to dynamically create a Virtual Hard Disk (VHD) and mount it for your application for the IO operations. For that you must modify many things from your existing application.
A Drive page is a BLOB formatted as a Fixed NTFS VHD between 16 MB to 1TB.
A VM can dynamically mount up to 16 drives
A Page Blob can only be mounted by only one VM at a time for read/write access.
Please refer to http://www.codeproject.com/KB/azure/wa_drives_webrole_any_web.aspx
SQL AzureMicrosoft SQL Azure is a sub component of Windows Azure and its extend SQL Server capabilities to the cloud. SQL Azure offers a relational database service called Microsoft SQL Azure Database. Once you have an Azure account using Windows you can log into the Azure portal and land at the following page. Using this web page you are able to create a database and modify some settings about the database. But you can drill down to the table, row and column level. The next picture will list the same features, entirely developed by Silverlight.
Migrating an existing database into SQL Azure
SQL Azure is built on top of SQL Server 2008, so for that you need to migrate the entire database into SQL Server 2008. From SQL Server 2008 we need to migrate into SQL Azure, for that we have an automatic migration tool available in Codeplex.
You can download the tool from : http://sqlazuremw.codeplex.com/
SQL Azure Migration Wizard
The SQL Azure Migration Wizard migrates an existing SQL 2005 & 2008 database into SQL Azure. The better usage of this tool is when migrating itself we are able to determine migration compatibility issues, that is the major benefit of this tool. Basically it's a command line application.
The SQL Migration Wizard gives the option to analyze and generate scripts and migrate data via BCP.
- SQL Server to SQL Azure
- SQL Azure to SQL Server
- SQL Azure to SQL Azure
The following is another way we must move our db into SQL Azure.
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
Step 10
Once these scripts are generated, open SQL Server 2008 edition and connect to the SQL Azure Server using Live credentials then execute the following scripts. This is shown in following pictures.
Step 1
Step 2
You will get the preceding error the first time when connecting to the SQL Azure database. For that you must add your IP address into the SQL Azure live portal. The following picture shows that.
Unsupported statements in SQL Azure
SQL Azure doesn't support the following SQL statements. When migrating our existing database we must concentrate on these things also. It lists many more things but I chose the frequently used SQL statements.
- Bulk Insert
- Contains
- Containstable
- DBCC Commands
- Select into clause
- OpenXml
- OpenRowSet
- OpenQuery
- OpenDataSource
- Kill
- Grant/Revoke/Deny commands
For more unsupported SQL statements refer to: MSDN