<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ariel Neisen &#187; On-the-cloud services</title>
	<atom:link href="http://blogs.southworks.net/aneisen/category/on-the-cloud-services/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.southworks.net/aneisen</link>
	<description></description>
	<lastBuildDate>Tue, 29 Jul 2008 16:57:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using SQL Server Data Services</title>
		<link>http://blogs.southworks.net/aneisen/2008/07/29/using-ssds/</link>
		<comments>http://blogs.southworks.net/aneisen/2008/07/29/using-ssds/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 16:42:06 +0000</pubDate>
		<dc:creator>aneisen</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[On-the-cloud services]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/aneisen/?p=11</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/aneisen/2008/07/29/using-ssds/" class="more-link">read more<img src="http://blogs.southworks.net/aneisen/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://blogs.southworks.net/aneisen/2008/07/29/a-first-glance-at-sql-server-data-services/" target="_blank">my previous post</a> I&#8217;ve presented my first impressions of SQL Server Data Services. Now it&#8217;s time to start coding. In this post, I&#8217;ll show how to use the basic operations from SSDS.</p>
<h3>Getting started</h3>
<p>Remember that SSDS is a service provided by Microsoft. So, the first step is creating an account. You can register here: <a href="http://www.microsoft.com/sql/dataservices/default.mspx">http://www.microsoft.com/sql/dataservices/default.mspx</a></p>
<p>After receiving the confirmation you&#8217;ll be able to access the services.</p>
<h3>Adding the service reference</h3>
<p>In order to use the SSDS instance, we need to add a reference to the SOAP service. The URL is <a title="http://data.beta.mssds.com/soap/v1?wsdl" href="http://data.beta.mssds.com/soap/v1?wsdl">http://data.beta.mssds.com/soap/v1?wsdl</a>. Remember that this is a beta instance, so the URL can be changed in any moment.</p>
<h3>Creating entities</h3>
<p>SSDS has a defined structure: authorities, containers and entities. Then, we need to create those entities in order to use the service.</p>
<h4>Creating the proxy</h4>
<p>When creating the proxy, you should only submit the client credentials.</p>
<p>Note: Sitka is SSDS&#8217; codename.</p>
<div>
<pre style="padding-right: 0px;padding-left: 0px;font-size: 8pt;padding-bottom: 0px;margin: 0em;width: 100%;color: black;padding-top: 0px;font-family: consolas, 'Courier New', courier, monospace"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> SitkaSoapServiceClient GetProxy()
{
    SitkaSoapServiceClient proxy = <span style="color: #0000ff">new</span> SitkaSoapServiceClient(<span style="color: #006080">"SitkaSoapEndpoint"</span>);
    proxy.ClientCredentials.UserName.UserName = <span style="color: #006080">"---"</span>; <span style="color: #008000">//TODO: Add username</span>
    proxy.ClientCredentials.UserName.Password = <span style="color: #006080">"----"</span>; <span style="color: #008000">//TODO: Add password</span>
    <span style="color: #0000ff">return</span> proxy;
}</pre>
</div>
<h4>Creating authorities</h4>
<p>Creating an authority is just a simple call to the service. In this case the Scope will be empty, because we&#8217;re creating a new one.</p>
<div>
<pre style="padding-right: 0px;padding-left: 0px;font-size: 8pt;padding-bottom: 0px;margin: 0em;width: 100%;color: black;padding-top: 0px;font-family: consolas, 'Courier New', courier, monospace"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Authority CreateAuthority(<span style="color: #0000ff">string</span> id)
{
    Scope scope = <span style="color: #0000ff">new</span> Scope();
    Authority authority = <span style="color: #0000ff">new</span> Authority();
    authority.Id = id;
    GetProxy().Create(scope, authority);

    <span style="color: #0000ff">return</span> authority;
}</pre>
</div>
<p> </p>
<h4>Creating containers</h4>
<p>Creating a container is very similar to creating an authority. The only difference is that now the container is going to be scoped to an authority, so we need to specify that in the Scope.</p>
<div>
<pre style="padding-right: 0px;padding-left: 0px;font-size: 8pt;padding-bottom: 0px;margin: 0em;width: 100%;color: black;padding-top: 0px;font-family: consolas, 'Courier New', courier, monospace"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Container CreateContainer(<span style="color: #0000ff">string</span> id, Authority authority)
{
    Scope scope = <span style="color: #0000ff">new</span> Scope();
    scope.AuthorityId = authority.Id;
    Container container = <span style="color: #0000ff">new</span> Container();
    container.Id = id;
    GetProxy().Create(scope, container);

    <span style="color: #0000ff">return</span> container;
}</pre>
</div>
<p> </p>
<h4>Creating entities</h4>
<p>Now we&#8217;re all set to add entities to our container. Given that the model is very flexible, in order to create entities we only need to provide the id and the values.</p>
<p>Note that the entity will be scoped to an authority and a container.</p>
<div>
<pre style="padding-right: 0px;padding-left: 0px;font-size: 8pt;padding-bottom: 0px;margin: 0em;width: 100%;color: black;padding-top: 0px;font-family: consolas, 'Courier New', courier, monospace"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Entity CreateEntity(<span style="color: #0000ff">string</span> id, Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">object</span>&gt; values,
        Authority authority, Container container)
{
    Entity entity = <span style="color: #0000ff">new</span> Entity();
    entity.Kind = <span style="color: #006080">"default"</span>; <span style="color: #008000">//Optional metadata</span>
    entity.Id = id;
    entity.Properties = <span style="color: #0000ff">new</span> Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">object</span>&gt;(values);
    SitkaSoapServiceClient proxy = GetProxy();
    Scope scope = <span style="color: #0000ff">new</span> Scope();
    scope.AuthorityId = authority.Id;
    scope.ContainerId = container.Id;
    proxy.Create(scope, entity);

    <span style="color: #0000ff">return</span> entity;
}</pre>
</div>
<p> </p>
<h3>Querying entities</h3>
<p>Taking into account that the queries are text-based, querying over entities is just a call to the service.</p>
<div>
<pre style="padding-right: 0px;padding-left: 0px;font-size: 8pt;padding-bottom: 0px;margin: 0em;width: 100%;color: black;padding-top: 0px;font-family: consolas, 'Courier New', courier, monospace"><span style="color: #0000ff">public</span> <span style="color: #0000ff">static</span> Entity[] Query(<span style="color: #0000ff">string</span> query, Authority authority, Container container)
{
    SitkaSoapServiceClient proxy = GetProxy();
    Scope scope = <span style="color: #0000ff">new</span> Scope();
    scope.AuthorityId = authority.Id;
    scope.ContainerId = container.Id;

    <span style="color: #0000ff">return</span> proxy.Query(scope, query);
}</pre>
</div>
<p> </p>
<h3>Putting all together</h3>
<p>That&#8217;s it. We have our data layer implemented without having an SQL server. We&#8217;re just using an on-the-cloud service and we don&#8217;t have to worry about deploying, maintenance, etc.</p>
<p>Putting all together, we can use the methods defined in this post like this:</p>
<div>
<pre style="padding-right: 0px;padding-left: 0px;font-size: 8pt;padding-bottom: 0px;margin: 0em;width: 100%;color: black;padding-top: 0px;font-family: consolas, 'Courier New', courier, monospace"><span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> SSDSSample()
{
    <span style="color: #008000">// Creating authority</span>
    Authority authority = CreateAuthority(<span style="color: #006080">"testauthority"</span>);
    <span style="color: #008000">// Creating container</span>
    Container container = CreateContainer(<span style="color: #006080">"testauthority_container"</span>, authority);

    <span style="color: #008000">// Adding entities</span>
    <span style="color: #0000ff">for</span> (<span style="color: #0000ff">int</span> i = 0; i &lt; 10; i++)
    {
        Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">object</span>&gt; props = <span style="color: #0000ff">new</span> Dictionary&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">object</span>&gt;(3) {
                {<span style="color: #006080">"name"</span>, <span style="color: #006080">"name"</span> + i}, {<span style="color: #006080">"address"</span>, <span style="color: #006080">"address"</span> + i}, {<span style="color: #006080">"tel"</span>, <span style="color: #006080">"tel"</span> + i}};
        CreateEntity(<span style="color: #006080">"person"</span> + i, props, authority, container);
    }

    <span style="color: #008000">// Querying entities</span>
    Entity[] retrievedEntities = Query(<span style="color: #006080">"from e in entities select e"</span>, authority, container);
    <span style="color: #0000ff">foreach</span> (Entity entity <span style="color: #0000ff">in</span> retrievedEntities)
    {
        Console.WriteLine(entity.Id);
        <span style="color: #0000ff">foreach</span> (KeyValuePair&lt;<span style="color: #0000ff">string</span>, <span style="color: #0000ff">object</span>&gt; val <span style="color: #0000ff">in</span> entity.Properties)
        {
            Console.WriteLine(val.Key + <span style="color: #006080">": "</span> + val.Value.ToString());
        }
        Console.WriteLine();
    }
    Console.ReadKey();
}</pre>
</div>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A first glance at SQL Server Data Services</title>
		<link>http://blogs.southworks.net/aneisen/2008/07/29/a-first-glance-at-sql-server-data-services/</link>
		<comments>http://blogs.southworks.net/aneisen/2008/07/29/a-first-glance-at-sql-server-data-services/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 12:26:43 +0000</pubDate>
		<dc:creator>aneisen</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[On-the-cloud services]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://blogs.southworks.net/aneisen/2008/07/29/a-first-glance-at-sql-server-data-services/</guid>
		<description><![CDATA[... <a href="http://blogs.southworks.net/aneisen/2008/07/29/a-first-glance-at-sql-server-data-services/" class="more-link">read more<img src="http://blogs.southworks.net/aneisen/wp-content/themes/southworks/assets/img/arrow-blue.png" width="12" height="12" alt="" /></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been researching one of Microsoft&#8217;s newest services: <a href="http://www.microsoft.com/sql/dataservices/default.mspx" target="_blank">SQL Server Data Services</a> (aka SSDS). In this post I will present my first impressions about this technology.</p>
<p>&#160;</p>
<h3>Motivation</h3>
<p>The motivation of this service is to provide a scalable data storage and query processor utility &quot;on the cloud&quot;. Using this approach, the costs of infrastructure and support decreases, since that responsibility relies on Microsoft and not in the software provider.</p>
<p>Besides, more and more new Web applications need to save less complex data, with a high service level agreement (SLA).</p>
<p>&#160;</p>
<h3>Implementation</h3>
<p>SSDS is built on the SQL Server technology, using the <a href="http://en.wikipedia.org/wiki/SOAP" target="_blank">SOAP</a> and <a href="http://en.wikipedia.org/wiki/REST" target="_blank">REST</a> communication protocols. Some of the features are:</p>
<ul>
<li><em>No schema</em>. Since the data model is flexible, we now can have heterogeneous entities (serialization becomes more complex). </li>
<li><em>Pay-as-you-grow model</em>. The space used can grow as you need it. </li>
<li><em>SLA</em> covering high availability, performance and redundancy. </li>
<li><em>Easy to develop</em>. In order to use the data we only need to call the appropriate Web Service. </li>
<li>The <em>queries</em> are text-based with a <a href="http://msdn.microsoft.com/en-us/netframework/aa904594.aspx" target="_blank">C# LINQ</a> pattern. </li>
</ul>
<p>The organization model is really simple:</p>
<ul>
<li><strong>Customers</strong> are the organizations that are using the SSDS. Customers have many <em>Accounts</em>. </li>
<li><strong>Accounts</strong> are the billing entities. An account has <em>authorities </em>assigned. </li>
<li><strong>Authorities</strong> are the ones that organize the data <em>containers</em>. It defines the location and security policies of its containers. </li>
<li><strong>Containers</strong> are the scope for the <em>entity</em> storage and query. For example, each employee may have a container with its personal data. </li>
<li><strong>Entities</strong> are the storage unit of SSDS, for example the employee&#8217;s education information. </li>
</ul>
<h3>Conclusion</h3>
<p>I think that this service has a lot of potential. With the growth of Web2.0 and social applications, we need a way of deploying small applications with a reliable data access. Obviously is very expensive to deploy and maintain a data base server, so having that service on-the-cloud is a very interesting alternative. </p>
<p>From the technical point of view, the no-schema structure is very interesting. Still, I guess that it can have a negative impact in the serialization process.</p>
<p>On the other hand, this service is still in working process, so we&#8217;ll be awaiting for new features to come.</p>
]]></content:encoded>
			<wfw:commentRss></wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
