Fetching name of all tables in Windows Azure Storage

To list all the table name from Windows Azure storage account, you need to call ListTable() function of CloudTableClient class. To start with first you need to add below namespaces.

image

Then create a storage account as below,

clip_image001

Make sure to put your own connection string to azure storage to parse. Next you need to create instance of table client

clip_image003

Once tableclient is created you can list all the tables by making call to ListTables() method.

clip_image004

For your reference full source code to fetch all the tables name from Windows Azure Storage account is given below,


using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure;
namespace ConsoleClient
{
class Program
{
static void Main(string[] args)
{

string connectionString = "DefaultEndpointsProtocol=https;AccountName=abc;AccountKey=jsjdsfjgdsfj09===";
var TablesName = GetTablesNameForAzureSubscription(connectionString);
foreach (var r in TablesName)
{
Console.WriteLine(r.ToString());
}
Console.ReadKey(true);
}

private static List<string> GetTablesNameForAzureSubscription(string connectionString)
{
CloudStorageAccount account =CloudStorageAccount
.Parse(connectionString);

CloudTableClient tableClient = new CloudTableClient
(account.TableEndpoint.ToString(),
account.Credentials);

var result = tableClient.ListTables();

return result.ToList();
}

&nbsp;

On running of above code you should be getting the table name listed for the account mentioned in connection string. In this case I have three tables listed to the account as below,

clip_image001[6]

In this way you can list all the tables name from Windows Azure Storage Account. I hope this post is useful. Thanks for reading  Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Code to make call in Windows Phone 7

Launchers are used to perform task provided by phone operating system. Making Call is feature of Windows phone operating system and can be used by Launcher API. PhoneCallTask launcher is used to call. This launcher class is defined as below,

image

 

To work with PhoneCallTask, first you need to add namespace of Microsoft.Phone.Task

image

Then create instance of PhoneCallTask.

image

Next you need to set values properties to make the call. To make the call you need to set below properties

  • PhoneNumber
  • DisplayName

So first set PhoneNumber property as below,

image

And DisplayName as below,

image

Last step you need to launch making call application provided by operating system. You can show that as below,

image

If you put all code together and want to make a call on click event of button then full code will be as below,

 


using System.Windows;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace Day6
{
public partial class MainPage : PhoneApplicationPage
{

public MainPage()
{
InitializeComponent();
}

private void btnCall_Click(object sender, RoutedEventArgs e)

{
PhoneCallTask callTask = new  PhoneCallTask();
callTask.PhoneNumber = "999999";
callTask.DisplayName = "debugMode";
callTask.Show();

}

}
}

&nbsp;

When you run above code you will get application running as below,

image

When you click on Call button, you will next screen as below for confirmation to call.

image

After choosing Call you will get usual Windows Phone 7 Call screen as below,

image

If you want you can very much end call, turn on speaker, mute hold or add call. I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

What is wrong with the Partition Key value?

If you are trying to insert Partition Key and Row Key values as below image then very likely you will encounter DataServiceRequestException.

clip_image001

You cannot have below special characters as value of Partition Key and Row Key.

clip_image002

Let us say you have a table called School and you are trying to insert entity in that table using below code.

clip_image004

You are adding an entity as below,

clip_image005

When you run to add an entity you will get exception as below,

clip_image007

In above code if you notice Partition Key Value is

clip_image008

So while adding an entity makes sure, you are not using four special characters in value of Row Key and Partition Key. I hope this post is useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

I UNLOCK JOY Program : Great opportunity for Developers and Students

Browse to official site

image

What is this Program all about?

At the recent Mobile Developer Summit which took place on November 2, 2011 at Bangalore Microsoft announced the details of the developer programme for Windows Mobile in India with I unlock Joy, a unique Application Development and Submission Program, where technology professionals and students get an opportunity to develop applications and showcase creativity.

There are three categories of program,

image

Browse to official site

Student

I UNLOCK JOY STUDENT

image

 

STUDENT CATEGORY

Calling on the community to be a part of the initiative, the “I unlock Joy” programme is customized to unfold their innovative and creative best and become among the select first few proud owners of the Windows Phone. Program for students will begin on December 18, 2011 and conclude on March 30 2012

How?

image

You get

clip_image001

Rules

clip_image002

Developer

I UNLOCK JOY DEVELOPERS

image

 

SUBMIT & WIN CATEGORY

A registered participant submits THREE qualified Windows Phone Application in the Marketplace and gets a chance to win a Windows Phone. In this category, the Applications must be distinct and of non-trivial utility value for the Application User. A “Spam” or close replicas of existing Windows Phone Applications are disqualified.

PORT 2 APPS & WIN CATEGORY

A registered participant submitting TWO qualified Windows Phone Applications in the Marketplace which are ported from existing Android or iPhone Applications get to win a Windows Phone.

This for developers has started from November 1, 2011 and will continue till June 30, 2012

 

WOMEN SPECIAL CATEGORY

A first of its kind in the developer space. The first 100 registered Woman Developers who submit ONE (1) qualified Windows Phone Application each in the Marketplace qualify to win a Windows Phone each. The applications can be based on Entertainment, Fashion, Leisure, Sports, Recreation or Travel themes.

Why are you waiting  ? go and grab Smile 

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

Unpacking Book Authored and Autographed by Pinal Dave

It was month of July, when I was in flight with Pinal Dave sir from Bangalore to Kolkata. Both we were travelling to present in Kolkata community tech days.

Pinal Dave sir in flight to Kolkata

clip_image001

I consider him as my one of the inspiration. Hence I was asking many questions to him related to blogs, presenting, community and taking me further as blogger. In discussion I popped to him, “Sir when you are going to author a book? “ He replied with smile “would you read if I will write a book? “ I replied “Who won’t read sir? “, with his humble voice and kind smile he told me that day that he was working on authoring. To my surprise in last 3 months his two books got published and I always wonder how much he works? In recent time he authored below two books along with continuity of his daily blog posts.

clip_image002

When his first book got published, I gave him a call to congratulate. In that call, I requested him to send me copy of his book with his signature on book. Because I always wanted to keep book autographed and authored by him with myself for motivation and inspiration. He agreed to send. Today afternoon I got this awesome gift from him. Below are few pic of book sent by him.

clip_image003

clip_image004

clip_image005

If you want to know more about these books, please refer below blog post written by Pinal Dave sir himself on his blog.

Flipkart Amazon

SQLAuthority News – Book Signing Event – SQLPASS 2011 Event Log

SQLAuthority News – SQL Server Wait Stats – eBook to Download on Kindle – Answer to FREE PDF Download Request

I would take this opportunity to thanks Pinal Dave sir for all his support to community and his inspirational persona.

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

List valid Data Center Locations for a Subscription using Windows Azure Management API

Windows Azure Management API enables you to manage Azure subscription through codes. In this post, I will show, how could you list valid datacenter locations available for given subscription using Windows Azure Management API?

Windows Azure Management API is REST based API and allows you to perform almost all management level tasks with Azure subscription.

Any client making call to Azure portal using Management API has to authenticate itself before making call. Authenticating being done between Azure portal and client calling REST based Azure Management API through the certificates.

Read here to create certificate for Azure subscription

Read here to upload certificate

Video on Creating and Uploading Certificate for Windows Azure

Very first let us create a class representing Locations. There is property representing location name.

image

Essentially you need to perform below steps,

You need to create a web request to below URL. Provide desired subscription Id to fetch the locations. After subscription you need to add locations to get all the locations for given subscription

image

While making request you need to make sure you are calling the correct version and adding the cross ponding pfx certificate of your subscription level certificate. To list locations for given subscription header should me either 2010-10-28 or later .

image

abc is password to use PFX certificate

Get the stream and convert response stream in string

image

You will get the XML response in below format,

image

Once XML is there in form of string you need to extract Location name from XML element using LINQ to XML. You can parse location from xml as below

image

On running you should get all the hosted service. For me there is only one hosted service debugmode9 under my Azure subscription.

image

For your reference full source code is as below,


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConsoleClient.ServiceReference1;
using System.Xml.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.IO;

namespace ConsoleClient
{
class Program
{
static void Main(string[] args)
{
var result = GetLocations("-4761-bced-b75fcde0d7e1").ToList();

foreach (var r in result)
{
Console.WriteLine(r.LocationName);
}
Console.ReadKey(true);
}

&nbsp;

private static  List<Location> GetLocations(string SubscriptionId)
{
var request = (HttpWebRequest)WebRequest
.Create("<a href="https://management.core.windows.net/&quot;+SubscriptionId+&quot;/locations">https://management.core.windows.net/"+SubscriptionId+"/locations</a>");

request.Headers.Add("x-ms-version:2010-10-28");
X509Certificate2 certificate =
new X509Certificate2("D:\\debugmodepfx.pfx", "abc");
request.ClientCertificates.Add(certificate);

var response = request.GetResponse().GetResponseStream();
var xmlofResponse = new StreamReader(response).ReadToEnd();
XDocument doc = XDocument.Parse(xmlofResponse);
XElement document = XElement.Parse(xmlofResponse);

XNamespace ns = "<a href="http://schemas.microsoft.com/windowsazure">http://schemas.microsoft.com/windowsazure</a>";
var locations = (from a in document.Descendants(ns + "Location")
select new Location
{
LocationName = a.Element(ns + "Name").Value,
}).ToList();
return locations;

}

public class Location
{
public string LocationName { get; set; }
}

}

&nbsp;

I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.