It was a great opportunity to talk about SQL Azure to SQL User group Singapore. In a nutshell, SQL Azure is SQL database as service that is hosted on the Microsoft cloud platform.
In the talk, I started my presentation with overview idea of cloud computing, introducing Azure Service Platform, and finally deep dive on more detail on SQL Azure.
As usual, rather than showing presentation slide, I also showed the audience 4 demos including:
| Connecting and administering SQL Azure |
Migrating to SQL Azure |
| Spatial support in SQL Azure |
Introducing Houston Silverlight version of SQL Azure management tools |
There are a few photos taken as followings.
Finally, you can download my presentation slide here.
This is the fourth post of Migrating ASP.NET Application to Windows Azure series. As usual, I encourage you to check out the rest of my posts before reading this post:
1. Right click on the cloud service project and select Publish…
2. VS will need a few seconds to compile and package your application into 2 files: [name].cspkg and ServiceConfiguration.cscfg.
[name].cspkg is a package file that contains all of your source codes, dll, and contents file. ServiceConfiguration.cscfg is the configuration file that define our cloud service project. Before uploading it to Windows Azure, it’s possible for us to do some changes on the ServiceConfiguration.cscfg by opening it up with any text editor.
At the end, it will also open up a browser page that refer to Windows Azure Developer Portal and also open up a windows explorer that navigating to the location of your package files.
3. Assuming that you have an account and have sign in to Azure Developer Portal, the next step is to select the project. Do note that, it’s possible for one account to have more than one project, as you see in my example here:
To proceed, I’ll select my MSDNAzure11July2010 project. Of course you can name of the project when performing subscription process.
4. When you have selected the project, the next step is about the service. If you’ve created the service before,you’ll see a list of available service. To avoid any confusion,I’ve cleared all of my existing services. Click on New Service link to create the new service.
You will see two type of service available:
Since in the previous demo, I didn’t use any storage account, I am not going to create the Storage Account service. Instead, I’ll select the Hosted Service.
5. The next step is to enter the Service Label as well as the Description (which is actually optional).
I enter Personal Service as my Service Label and some description that explain what the service is all about. Click on Next button to proceed.
6. On the next step, we are prompted to enter the Hosted Service URL as well as Affinity Group.
Windows Azure will provide us a URL domain with suffix .cloudapp.net. All we need to do is to ensure that the public service name must be globally unique. Note that, it’s possible for us to set our desired custom domain in provider such as GoDaddy or DynaDot. In the example, I’ll enter welypersonal as the public service name.
Next step is about setting the Region and Affinity Group. Affinity Group allows Windows Azure to place our hosted service with other service (storage or any other hosted service) in one place to enable the better performance and connectivity. If your service is hosted with association to any other service, you will need to consider creating an Affinity Group, then subsequently the region. Otherwise, we can just proceed to set the region. Currently, there’s 6 available region to be chosen as following. It’s believe that Microsoft will continue to invest more data center in the future.
Since my application is not associated with others, I’ll choose not to use any Affinity Group. Furthermore, I’ll select SouthEastAsia as my region. Click on the Create button when you are ready to go.
7. After a few seconds, you will be seeing the following screen. Yeah, this is to deploy your application to Windows Azure. Note that, Azure provide you both Staging and Production version to deploy. You can first deploy to staging environment. When everything is going well, then promote it to Production. However, even though staging environment, the charge will be still applied BOTH because in principle, you still use Windows Azure’s resource
.
8. Assuming we want to deploy to the staging environment first. The subsequent step is to deploy the package. To do that, click on Deploy… button. It then will bring you to another page. Upload the application package .cskpg file as well as configuration settings .cscfg file.
At the operation system settings, you can select the guest OS version of Windows Azure. Note that, there’re few release of Windows Azure Guest OS. You can then enter the deployment label to note down the version of your deployment. Click on Deploy button when everything is ready.
It may take sometime to deploy the package depends on the size of you’re the deployment package.
9. A few moments later, you will see the following screen
The screen indicates that your application is now deployed but on suspended status. Take a look at the WARNING section above that remind you about the charge. Right, it will still charge you even though your application is suspended. So make sure you delete the deployment to avoid the charge when not needed anymore.
The next step is to enable the service. To do that, simply click on Run button.
10. After a few moment, you probably see the status become Initializing and later Busy.
What actually happened is Windows Azure is allocating our deployment on appropriate machine that satisfy the load of each physical machine. Additionally, if you set your instance to more than 1, it manages the load balancing mechanism so that when the load increases, Windows Azure will intelligently load balance your application.
11. After a few minutes, if you see the status become Ready like the following, that’s great. It means your application has been successfully deployed. Congratulation! You may want to click on the URL to test it. You will see the ugly name of my URL like mine. That’s actually apply when we use the staging version of the deployment. The URL will be change into more friendly one as what we’ve defined before when we promote it to production.
However, sometimes it may not be successful as you will probably see the status keep stuck at Initializing – Busy – Stopping. I recommend you to check out MSDN Forum or MSDN library to work out from the troubleshooting.
12. If your application runs well at staging, you may want to promote it to production by clicking on this
button. Click on Yes if there’s prompt to ensure we want to promote it to production environment. After a few moment, we are happy to see the following screen that indicates our successful deployment.
Take a look and click also at the friendly-name URL to see the result.
Alright, I’ll keep the website active for a few weeks / months. If you find that it doesn’t work anymore and you want to explore about it, please let me know by sending me an email at wely_live@live.com. I would be happy to help you
.
See you!
This is the third post of Migrating ASP.NET Application to Windows Azure series. You are encourage to read my first post about Preparing the ASP.NET Application and the second post about Preparing SQL Azure Database if you have not do so. Without further due, let’s get started.
Before conversion, do note that web role is actually ASP.NET web application++, not ASP.NET website. If you are not sure about the difference, please go through the following blogs and discussion about that:
The ++ that I’ve mentioned before is some additional files as well as minor changes as following:
<system.diagnostics>
<trace>
<listeners>
<add type=”Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ name=”AzureDiagnostics”>
<filter type=”"/>
</add>
</listeners>
</trace>
</system.diagnostics>
This section of the code enable us to perform Windows Azure diagnostic monitoring by injecting the trace listener. I encourage you to read this reference to learn more about Windows Azure diagnostic.
Alright, now let’s get our hand dirty to convert the core application.
I’ll continue the steps that are done in the first post here. We have 3 projects in our solution: namely the Website personal, CloudServicePersonal,and PersonalWebRole.
1. As we need to align our webrole with the website personal content,we need to delete the unused files in default WebRole project. On the WebRole project “PersonalWebRole”, delete the default.aspx and web.config file. Note that, if we want to implement the diagnostic, we’ll need to manually add those diagnostic section later on.
2. Next step is to copy the entire content of the website personal to the PersonalWebrole. Block all of the content from personal website and drag it to PersonalWebRole. Alternately, you can do so by copy the website personal and paste it on the PersonalWebRole.
If it prompts for merge folders, check “Apply to all items” and select “Yes” to merge.
3. Remembering that ASP.NET Web Role is based on ASP.NET Web application, not web site, we will need to convert the aspx files to web application so that it contains the .designer.cs file. To do that, right click on the PersonalWebRole and select Convert to Web Application.
4. You may delete your personal website as we don’t need to use it anymore.
5. Try to build the solution to check if any error occurs.
6. As hosting your application on Windows Azure is somehow different with traditional web application, we’ll need to examine the code whether they are all valid.
Some example of invalid code could be found in App_CodePhotoManager.cs, ListUploadDirectory() method since it tries to get the detail directory info of “upload” folder. Comment this method.
We’ll also need to comment any other code that call that method such as AdminPhoto.aspx.
In some case where you really need the similar functionality, of course you’ll need to modify it as required to be ready to run on Azure. For example, If your ASP.NET Website allow people to upload and store the file on file system, you will want to implement similar feature using Azure Storage Blob. I’ll talk about those stuff on the further post if possible
.
Updated on 8 Sept 2010: Please refer this link where I’ve implemented similar functionality for bulk upload
7. Run the web role on the development fabric by pressing F5 or Run. Development Fabric is the local simulation environment of Windows Azure hat implements things like load balancing, etc. Make sure that your website is running well on development fabric first before deploy it to real Windows Azure environment.
8. Try to log-in with the credential to see whether it’s running well.
9. Congratulation if you’ve done at this step. It means that you have successfully converted your web site to Windows Azure web role, as well as have successfully connected it to SQL Azure.
But wait, you are not done yet! Why? Running well on development fabric, doesn’t mean it will run well on Windows Azure
.
No worries, in next post, I’ll show you how to deploy it to Windows Azure and solve each problem if there’s any issue arise.
See you!
This is the second post of Migrating ASP.NET Application to Windows Azure series. In the first post, I’ve show you in preparation of website to be migrated. Now, let’s prepare the database for that.
If you notice the App_Data of the personal website, you will see the Personal.mdf file which is the database of the application.
However, by noticing the web.config file, there is also another database called aspnetdb.mdf. This database will be automatically created when we open-up the ASP.NET Administration portal. To do that, click on ASP.NET Configuration button to open up the web site administration tool.
I believe most of you are familiar with ASP.NET administrator tool. As it, I won’t go into the details of how to create roles and users. But in this example, create 2 roles (Administrators and Guests) and 1 user (admin).
When you are done, try to refresh the App_Data folder and you will see that the new aspnetdb.mdf file was created.
Since we are going to host our application on Windows Azure, it’s impossible to keep our database on our local storage. As it, we’ll need to export our database to the cloud database service,the SQL Azure.
1. The first step is to prepare the SQL Azure database. To do that,go to http://sql.azure.com. I assume you have got the SQL Azure account in this step. Click on the project name and it will bring you to your server administration as shown below.
You will notice that some info above such as my server name, admin user, as well as server location which I’ve defined it earlier.
2. The next step is to create the database. To do that, click on the Create Database button and fill in the name (I name it PERSONAL). You may also want to specify the edition of your database (whether Web or Business) as well as the maximum size for your database. Click Create when you are ready.
Immediately, you will see the new created database.
3. Now the we’ll need to connect to the SQL Azure database from client. To do that, open up the SQL Server 2008 R2 Management Studio. (You’ll need to use the R2 version since the ability to connect to SQL Azure). Enter the server name as you could seen from your server administration, eg: [server name].database.windows.net. Subsequently enter your username and password as authentication. Click on option, and type the database name that you’ve been created just name (PERSONAL).
If anything goes well, you should see as following screenshot.
4. Now you are connected with the SQL Azure database, the Personal. The next step is to create tables and other objects from the on-premise database. Remembering that we have 2 database on local server, aspnetdb and personal. Now we are going to prepare the script of these two database. To do that, . Login to the your local database engine with your admin credential. I would recommend you to copy the mdf and ldf file of your database (in this sample aspnetdb and personal) to the SQL Server data folder in order to simplify the attach process.
Next, attached your database mdf file. Moreover, I rename the database to personal and aspnetdb from the long fullname. If everything goes well, you will see the following database in the explorer like mine.
5. The next step is to generate the script of each database. To do that, right click on the personal database and select Task – Generate Script.
I’ll select the script entire database objects on the “Choose Object” step.
6. On the Set Scripting Options steps, click on Advanced button. Modify the following properties:
- Types of data scripts : Schema and data.
- Script use database: false
Click OK to close the “Advanced scripting options”
Subsequently, Select “Save to file” and locate the file to your preferred location. (in this example, I save it to my documentsscripts.sql
Click Next and Next, Finish to finished.
7. Do note that the script that has been generated is not SQL-Azure-ready! It means that we’ll need to modify it first so that could be successfully compatible with SQL Azure. Thanks to community folks who have been developing the SQL Azure Migration Wizard to simplify the task. Download and open up the Migration Wizard.
Select Analyze Only (as we’ll do the migration manually) and TSQL file as the input. Click on Next to proceed.
8. You will notice that in the Result Summary, some of the sections are marked with these comments –~ CREATE DATABASE is not supported in current version of SQL Azure
From the Object Explorer, select our cloud database “Personal”. Click on New Query button. As the new query editor comes up. Just copy and paste all of the script from SQL Azure Migration Wizard to SQL Server Management Studio. For each block with those comment, delete it.
Run it immediately. If anything goes well, you will see the result as following.
![]()
9. Repeat step 4 to 8 with database aspnetdb. Do note that although the source comes from two database, we are only targeted to one destination on SQL Azure for simplicity purpose.
When you run the aspnetdb query, you might find the problem as below on the [aspnet_Membership_GetNumberOfUsersOnline] stored procedured. This is caused the SP uses nolock keyword which are deprecated features in SQL Server 2008 R2. To solve it, just delete the (NOLOCK) keyword.
10. If everything goes well, when you refresh the cloud personal database, you will see the tables and stored procedure are all there.
It means that we’ve successfully export our on-premise database to the cloud.
11. Now, to test whether the database is successfully created, we can connect our personal starter kit website to use SQL Azure database. To do that, modify connection string section in the web.config file as following.
<add name=”Personal” connectionString=”server=[server_name].database.windows.net;database=personal;uid=[username];pwd=[password]” providerName=”System.Data.SqlClient”/>
<add name=”LocalSqlServer” connectionString=”server=[server_name].database.windows.net;database=personal;uid=[username];pwd=[password]“/>
12. Run our ASP.NET website and see whether it is successfully connected.
In the next post, I’ll show you how to migrate our ASP.NET website to ASP.NET Web role.
Stay tuned.
In this series of blogs, I will write about the step by step of migrating an ASP.NET application to Windows Azure. As the example, I”ll use a simple Personal Website Starter Kit. Recently, I just notice that Microsoft have replaced that version with another which doesn”t have database engine. As it, I suggest you to download the older version from here.
(I assume you”ve successfully installed the Windows Azure Tools for Visual Studio. If you haven”t done so, go and download it here. At the time this article is written, the version of the VS Tools for Azure is 1.2 – June 2010)
Without further due, let”s start the migration:
1. Download and Install Personal Starter Kit
2. Having done the first step, start an empty solution in Visual Studio. I call it CloudPersonalSite.
3. Next, right click on the blank solution, select Add – New Project.
4. You may choose you preferred language (In this example,I”ll use C#),then select Cloud on the project types. Select Windows Azure Cloud Service as the template. Ultimately, fill-in the project name with CloudServicePersonal.
5. As immediate, the New Cloud Service Project will pop-up and ask you for the roles in your project. By default, there are 4 roles available. I”ll choose ASP.NET Web Role and rename it to PersonalWebRole.
6. As soon as you click OK, Visual Studio will generate 2 projects for you. The first one is CloudServicePersonal which is your Windows Azure Cloud Service Project. The second one is the ASP.NET Web Role called PersonalWebRole. Do note that the ASP.NET Web Role is basically an ordinary ASP.NET Web Application Project (NOT ASP.NET WEBSITE) with some modification on web.config files as well as the new added file called WebRole.cs / WebRole.vb.
7. The next step is to create the personal web site based on the installed template. To do that, right click on the project and select Add – New Website. Select Personal Web Site Starter Kit as the template and name the website WebSitePersonal.
8. Since the template is actually created with .NET 2.0, Visual Studio will now prompt us whether to migrate it to .NET 3.5. To do that, click YES button.
You will now see the default page of the personal website, the welcome.html if you have successfully completed those steps above.
In the next post, I”ll continue to write how to convert the web site to be ready on the Web Role. And then, we”ll migrate our on-premise database to SQL Azure as well.
Stay tuned!

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void
Life
Earth
Wind « Default
Water
Fire
Light 