Saturday, October 10, 2009

How to access SQL Azure from SQL Management Studio

It now more than a month Microsoft announced CTP of SQL Azure… SQL Azure a service to host full RDBMS database on Cloud. currently this service is available as CTP, so have very limited access and less features, but still it is a SQL server running there at cloud and very soon we can expect all SQL server features on SQL Azure.

Today when i started working on it, the best thing i found in it is, “you can access SQL Azure from your machine using your favorite SQL IDE tool, i.e.  “SQL Server Management Studio 2008”.

But very first time when i tried to access it, i got a nice error but thanks to my friend Jacob, he redirected to me to a site where that author mentioned a small but funny trick to use it.

so what i did -

I simply open SQL Server management studio 2008 from start menu, I entered full server name as “servername.ctp.database.windows.net”, my login name and password. and said connect. a simple and standard process which we follow every time to access SQL Server database.

Capture

this Error saying “Invalid Object name sys.configurations. (Microsoft SQL Server Error: 208)”

now how to connect to SQL Azure, i asked one of my friend Jacob who is a SQL MVP, and thanks to him he redirected me to a nice site where athlete gave one funny trick to make it work.

basically what you have to do is when you start SQL Server Management studio it prompt you a Connect to Server Windows (like this)

 Capture2

Now don’t Enter SQL Azure server name and login details here… simply say cancel

Capture3

and now say “New Query” it will again open a similar windows like previous one. now click on option button.

Now at login tab enter full server name, then select authentication type as SQL Authentication as SQL Azure only support SQL authentication and the Enter you login and password.

 Capture4

after this move to connection Properties Tab and Enter Database name which you created at SLQ Azure portal http://sql.azure.com

Please note this is important to enter this name as, SQL Azure don't allow you to connect  Server, it allow you to connect to Database.

Capture5

after your enter database name them simply click “connect”

if everything goes right then you will prompted with following error message

“Unable to apply connection settings, The detailed error message is “ANSI_NULLS” is not a recognized SET option.

Capture6

don't worry about this error, simply click “OK” .

Now you are ready to run your queries. try and Enjoy SQL Azure.

Friday, October 09, 2009

SQL Azure Explorer Add-in for VS2010

New version (0.1.1) of SQL Azure Explorer, an Add-in for VS2010 has been released with better UI performance

you can download new build at http://sqlazureexplorer.codeplex.com/

some of features mentioned on CodePlex site about SQL Azure Explore

  • SQL Azure Explorer which contains:
    • Databases
    • Tables with columns
    • Views with columns
    • Stored procs with parameters
    • Functions with parameters
  • Context menues for:
    • Open Sql Editor Window
    • Select Top 100 Rows
    • Script as CREATE for all tables, views, stored procs and functions
  • SQL Editor Window with built in:
    • SQL Execute
    • Off line parser
    • Script formatter

Thursday, October 08, 2009

New Sysinternals Tool - Disk2VHD

Today a new Sysinternals tool is announced, called as Disk2vhd, that simplifies the migration of physical systems into virtual machines (p2v).

Disk2vhd is a utility that creates VHD (Virtual Hard Disk - Microsoft’s Virtual Machine disk format) versions of physical disks for use in Microsoft Virtual PC or Microsoft Hyper-V virtual machines (VMs). The difference between Disk2vhd and other physical-to-virtual tools is that you can run Disk2vhd on a system that’s online.

ee656415_Disk2vhd_01r(en-us,MSDN_10)

Download Disk2vsd V1.0

to know more about this tool visit SysInternals site at http://technet.microsoft.com/en-us/sysinternals/ee656415.aspx

Wednesday, October 07, 2009

How to send Email on Windows Azure Application

Today during “TechStart Windows Azure Training Program” session I got a question about sending Emails from Windows Azure Application.
I was expecting that Windows Azure itself provide a SMTP relay and i could easily send email using SmtpClient Class but after checking Azure documentation, I found that unfortunately it does not support it, now what, how to send email from Azure application… ?
As almost all outbound ports are open on windows azure (including 25), so this can be a good news for us.. we can use external SMTP to send email.
also another good news is after March CTP Windows Azure offers the option of running the code in your Web and worker roles under full trust. (To enable full trust, simply add the enableNativeCodeExecution attribute to your role in the Service Definition file and set the attribute value to true)
e.g.
<WebRole name="WebRole" enableNativeCodeExecution="true">
so i guess now we are ready to send an Email from our Azure application…
Standard code which we use to send email in our ASP.NET using SmtpClient class applications works fine with Windows Azure Application.
so Open Visual Studio, create a Cloude Service Applications and add a WebRole to it. now on design a Page which will accept a TO address and a body of your message, and a send button :), now copy paste following code to Button click event, replace the credential details with actual credentials and Test it.

SmtpClient myClient;
MailMessage myMessage;

myClient = new SmtpClient("mysmtp.cognitioninfotech.com", 25);
myClient.Credentials = new NetworkCredential("myAlert@cognitioninfotech.com", "mypassword");
myMessage = new MailMessage(new MailAddress("myAlert@cognitioninfotech.com"), new MailAddress(txtTo.Text));
myMessage.Body = txtMessage.Text;
myMessage.Subject = "Test Email";

try
{
    myClient.Send(myMessage);
    lblstatus.Text = "Sent";
}

catch (Exception ex)
{
    lblstatus.Text = ex.ToString();
}