<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Keerat Singh</title>
    <description>A development blog with experiences and helpful tutorials for the latest and greatest technologies.</description>
    <link>http://localhost:4000/</link>
    <atom:link href="http://localhost:4000/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sat, 03 Feb 2018 21:03:08 -0800</pubDate>
    <lastBuildDate>Sat, 03 Feb 2018 21:03:08 -0800</lastBuildDate>
    <generator>Jekyll v3.6.2</generator>
    
      <item>
        <title>Working with Azure Storage Blobs using .Net Core</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Azure Storage&lt;/code&gt; is cloud service that provides storage which is fully maintained by Microsoft and is highly scalable, available and robust. Azure storage comprises mainly of Blob, File, Table and Queue storage, however, the following article discusses only &lt;code class=&quot;highlighter-rouge&quot;&gt;block blobs&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;pre-requisites&quot;&gt;Pre-Requisites&lt;/h2&gt;
&lt;h3 id=&quot;microsoft-azure-storage-account&quot;&gt;Microsoft Azure Storage Account&lt;/h3&gt;
&lt;p&gt;Make sure you have created a &lt;code class=&quot;highlighter-rouge&quot;&gt;Storage Account&lt;/code&gt; on Azure portal, we will be needing the Access Keys to access the Storage Account.
The same can also be done locally using an Azure Storage Emulator if you don’t have an Azure Subscription.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2018-02-03-working-with-azure-storage-blobs/create_azure_storage_account.jpg&quot; alt=&quot;Create Azure Storage Account&quot; /&gt;
    &lt;figcaption&gt;Create Azure Storage Account&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;p&gt;You can find both access keys and connection strings under the &lt;code class=&quot;highlighter-rouge&quot;&gt;Access Keys&lt;/code&gt; section. I would suggest copying one of the connection strings and using it in your application.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2018-02-03-working-with-azure-storage-blobs/connection_string_azure_storage_account.jpg&quot; alt=&quot;Connection String Azure Storage Account&quot; /&gt;
    &lt;figcaption&gt;Connection String Azure Storage Account&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h3 id=&quot;install-microsoftwindowsazureconfigurationmanager-nuget-package&quot;&gt;Install Microsoft.WindowsAzure.ConfigurationManager NuGet Package&lt;/h3&gt;
&lt;p&gt;Make sure you have added the &lt;code class=&quot;highlighter-rouge&quot;&gt;Microsoft.WindowsAzure.ConfigurationManager&lt;/code&gt; NuGet Package to your project.
To add the pacakge Go to &lt;code class=&quot;highlighter-rouge&quot;&gt;Tools&lt;/code&gt; &amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Nuget Package Manager&lt;/code&gt; &amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Package Manager Console&lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;Install-Package Microsoft.WindowsAzure.ConfigurationManager&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/PM_Console.jpg&quot; alt=&quot;Install Microsoft.WindowsAzure.ConfigurationManager&quot; /&gt;
    &lt;figcaption&gt;Install Microsoft.WindowsAzure.ConfigurationManager&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;storage-account-architecture&quot;&gt;Storage Account Architecture&lt;/h2&gt;
&lt;p&gt;This is what the high-level view of the Storage Account looks like. Storage Account is the first point of access. Each storage account contains various containers, and each container is further comprised of blobs and each blob can either be an append, block or page blobs.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2018-02-03-working-with-azure-storage-blobs/blob_architecture.jpg&quot; alt=&quot;Storage Account Architechture&quot; /&gt;
    &lt;figcaption&gt;Storage Account Architechture&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;create-container&quot;&gt;Create Container&lt;/h2&gt;
&lt;p&gt;To create a container we first need to get the reference to the storage account, using the storage account reference we then create a blob client which is
a client-side representation of blob storage.
An important thing to note is that the &lt;code class=&quot;highlighter-rouge&quot;&gt;name of the container must always be lowercase&lt;/code&gt; as per container naming rules.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Get Reference to the storage account using the connection string&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudStorageAccount&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storageAccount&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;CloudStorageAccount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_strStorageConnection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Create a client side representation of Azure Blob storage&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlobClient&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobClient&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;storageAccount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;CreateCloudBlobClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Get Container reference&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlobContainer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobContainer&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetContainerReference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;containerName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// We can also use CreateIfNotExistsAsync method, however it doesn't convey the information if the container&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// already exists. CreateAsync on the other hand throws an exception if the container already exists.&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;CreateAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;upload-blob&quot;&gt;Upload Blob&lt;/h2&gt;
&lt;p&gt;We upload the blob from a file using the container reference created previously via the &lt;code class=&quot;highlighter-rouge&quot;&gt;UploadFromFileAsync&lt;/code&gt; method of the &lt;code class=&quot;highlighter-rouge&quot;&gt;CloudBlockBlob&lt;/code&gt; class, the blob gets overwritten by the uploaded blob if a blob with the same name already exists in the container.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Get Blob reference using the container reference previously created&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlockBlob&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blockBlob&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetBlockBlobReference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blobName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Upload BlockBlob&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blockBlob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;UploadFromFileAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blobPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;download-blob&quot;&gt;Download Blob&lt;/h2&gt;
&lt;p&gt;We download the blob to a file using the container reference created previously via the &lt;code class=&quot;highlighter-rouge&quot;&gt;DownloadToFileAsync&lt;/code&gt; method of the &lt;code class=&quot;highlighter-rouge&quot;&gt;CloudBlockBlob&lt;/code&gt; class, the blob gets overwritten by the downloaded blob if a blob with the same name already exists.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Get Blob reference using the container reference previously created&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlockBlob&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blockBlob&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetBlockBlobReference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blobName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Download Blob&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blockBlob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;DownloadToFileAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blobPath&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;FileMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;delete-blob&quot;&gt;Delete Blob&lt;/h2&gt;
&lt;p&gt;Delete blob operation is also performed using the container reference created previously using the &lt;code class=&quot;highlighter-rouge&quot;&gt;DeleteAsync&lt;/code&gt; method of the &lt;code class=&quot;highlighter-rouge&quot;&gt;CloudBlockBlob&lt;/code&gt; class.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Get Blob reference using the container reference previously created&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlockBlob&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blockBlob&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetBlockBlobReference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blobName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Delete Blob&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blockBlob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;DeleteAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;copy-blob&quot;&gt;Copy Blob&lt;/h2&gt;
&lt;p&gt;In order to copy the blobs, we need reference for both the source and destination container. The same can be obtained using the &lt;code class=&quot;highlighter-rouge&quot;&gt;GetContainerReference&lt;/code&gt; method.
If you want to copy the blob within the same container, the reference for source and destination container will be same. The copy operation takes place using the &lt;code class=&quot;highlighter-rouge&quot;&gt;StartCopyAsync&lt;/code&gt; method of &lt;code class=&quot;highlighter-rouge&quot;&gt;CloudBlockBlob&lt;/code&gt; class&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Get the source container reference to copy the blob from&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlobContainer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fromCloudBlobContainer&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;CreateContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blobClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fromContainerName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetAwaiter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Get the source blob reference&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlockBlob&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fromBlockBlob&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fromCloudBlobContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetBlockBlobReference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fromBlobName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Get the destination container reference to copy the blob to&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlobContainer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;toCloudBlobContainer&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;CreateContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;blobClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;toContainerName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetAwaiter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Get the destination blob reference&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlockBlob&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;toBlockBlob&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;toCloudBlobContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetBlockBlobReference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;toBlobName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Copy the blob&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;toBlockBlob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;StartCopyAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fromBlockBlob&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AbsoluteUri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;list-blobs&quot;&gt;List Blobs&lt;/h2&gt;
&lt;p&gt;To list all the blobs in a container, we call the &lt;code class=&quot;highlighter-rouge&quot;&gt;ListBlobsSegmentedAsync&lt;/code&gt; method of &lt;code class=&quot;highlighter-rouge&quot;&gt;CloudBlobContainer&lt;/code&gt; class. The result is returned as a result segment containing a collection of blob items. We call the &lt;code class=&quot;highlighter-rouge&quot;&gt;ListBlobsSegmentedAsync&lt;/code&gt; method until the &lt;code class=&quot;highlighter-rouge&quot;&gt;BlobContinuationToken&lt;/code&gt; is null.
The continuation token is returned as null when there are no more blobs to be returned.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt; &lt;span class=&quot;c1&quot;&gt;// Get Container reference&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;CloudBlobContainer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobContainer&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetContainerReference&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;containerName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IListBlobItem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lstBlobs&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;List&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IListBlobItem&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;();&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;BlobContinuationToken&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;continuationToken&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Get the list of blobs in the container and store them into a list&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;BlobResultSegment&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resultSegment&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;blobContainer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ListBlobsSegmentedAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;continuationToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Update continuation token&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;continuationToken&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resultSegment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ContinuationToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Add Blobs to the list&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;lstBlobs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;AddRange&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;resultSegment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;source-code&quot;&gt;Source Code&lt;/h2&gt;
&lt;p&gt;You can find the &lt;code class=&quot;highlighter-rouge&quot;&gt;source code&lt;/code&gt; at Github &lt;a href=&quot;https://github.com/keeratsingh/AzureStorageBlobs&quot;&gt;AzureStorageBlobs&lt;/a&gt; repository as &lt;code class=&quot;highlighter-rouge&quot;&gt;.Net Core&lt;/code&gt; solution.&lt;/p&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;There are many other operations that can be performed on azure storage blobs, which are not covered in this post, I would encourage you to explore more about them.
If you have any questions or concerns, feel free to leave a comment.&lt;/p&gt;

</description>
        <pubDate>Sat, 03 Feb 2018 02:56:00 -0800</pubDate>
        <link>http://localhost:4000/blog/2018/working-with-azure-storage-blobs/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2018/working-with-azure-storage-blobs/</guid>
        
        
        <category>Microsoft</category>
        
        <category>Azure,</category>
        
        <category>Azure</category>
        
        <category>Storage</category>
        
      </item>
    
      <item>
        <title>Using Microsoft Azure Entity Linking Cognitive API</title>
        <description>&lt;h2 id=&quot;microsoft-cognitive-services&quot;&gt;Microsoft Cognitive Services&lt;/h2&gt;
&lt;p&gt;Microsoft Cognitive Services, formerly known as &lt;code class=&quot;highlighter-rouge&quot;&gt;Project Oxford&lt;/code&gt; are a set of APIs, SDKs and services available to developers to make their applications more intelligent, engaging and discoverable. These services let you build apps with powerful algorithms to see, hear, speak, understand and interpret using natural methods of communication, with just a few lines of code. Microsoft Cognitive Services enable the developers to easily add intelligent features such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Emotion and video detection&lt;/li&gt;
  &lt;li&gt;Facial, speech and vision recognition&lt;/li&gt;
  &lt;li&gt;Speech and language understanding&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;microsoft-entity-linking-intelligence-service-api&quot;&gt;Microsoft Entity Linking Intelligence Service API&lt;/h2&gt;
&lt;p&gt;This API is part of the broader set of APIs provided as part of &lt;code class=&quot;highlighter-rouge&quot;&gt;Microsoft Cognitive Services&lt;/code&gt; APIs. This API is designed to help developers with tasks related to &lt;code class=&quot;highlighter-rouge&quot;&gt;Entity Linking&lt;/code&gt;. One of the challenges while working with Natural Language Processing is recognizing the context of a particular word within a paragraph/sentence, a word might be used differently in different contexts. For example, in the case where “times” is a named entity, it still may refer to two separately distinguishable entities, such as “The New York Times” or “Times Square”. Given a specific paragraph the &lt;code class=&quot;highlighter-rouge&quot;&gt;Entity Linking Intelligence Service&lt;/code&gt; will recognize and identify each separate entity based on its context.&lt;/p&gt;

&lt;h2 id=&quot;install-microsoftprojectoxfordentitylinking-package&quot;&gt;Install Microsoft.ProjectOxford.EntityLinking Package&lt;/h2&gt;
&lt;p&gt;Make sure you have added the &lt;code class=&quot;highlighter-rouge&quot;&gt;Microsoft.ProjectOxford.EntityLinking&lt;/code&gt; NuGet Package to your project.
To add the pacakge Go to &lt;code class=&quot;highlighter-rouge&quot;&gt;Tools&lt;/code&gt; &amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Nuget Package Manager&lt;/code&gt; &amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Package Manager Console&lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-html&quot; data-lang=&quot;html&quot;&gt;Install-Package Microsoft.ProjectOxford.EntityLinking&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/PM_Console.jpg&quot; alt=&quot;Install Microsoft.Identity.Client Pacakge&quot; /&gt;
    &lt;figcaption&gt;Install Microsoft.ProjectOxford.EntityLinking Pacakge&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h2 id=&quot;get-an-api-subscription-key&quot;&gt;Get an API Subscription Key&lt;/h2&gt;
&lt;p&gt;A subscription to Entity Linking Intelligence Service API is required to use the service. A sign up may be required if don’t already have an account.
To get a subscription key you can visit the link below and follow the steps below.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Goto &lt;a href=&quot;https://azure.microsoft.com/en-us/try/cognitive-services/?api=entity-linking-intelligence-service&quot;&gt;Try Cognitive Services&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Click &lt;code class=&quot;highlighter-rouge&quot;&gt;Get API Key&lt;/code&gt;, Read and Agree to Microsoft Cognitive Services Terms.&lt;/li&gt;
  &lt;li&gt;Sign-in using your preferred account.&lt;/li&gt;
  &lt;li&gt;Once Signed-in you will be redirected to a web page as seen below in the screenshot below.&lt;/li&gt;
  &lt;li&gt;Save this information and either of the keys can be used to call the API Service.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-08-26-using-microsoft-azure-entity-linking-cognitive-api/API_Subcription_Key.jpg&quot; alt=&quot;API Subscription Key&quot; /&gt;
    &lt;figcaption&gt;API Subscription Key&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;creating-an-entitylinkingserviceclient-object&quot;&gt;Creating an EntityLinkingServiceClient object&lt;/h2&gt;
&lt;p&gt;The very first step is to create an object of the class &lt;code class=&quot;highlighter-rouge&quot;&gt;EntityLinkingServiceClient&lt;/code&gt;, there are various overloaded constructors that can be used to instantiate the object, however, we will use the version that takes only one argument as input, i.e. an API &lt;code class=&quot;highlighter-rouge&quot;&gt;Subscription Key&lt;/code&gt;.
This is the same subscription key that was generated in Step 1.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;EntityLinkingServiceClient&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clientApplication&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;clientApplication&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;EntityLinkingServiceClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Enter your Subscription Key here&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;calling-the-microsoft-azure-entity-linking-cognitive-api&quot;&gt;Calling the Microsoft Azure Entity Linking Cognitive API&lt;/h2&gt;
&lt;p&gt;Once we have the service client initialized, the next step is to call the &lt;code class=&quot;highlighter-rouge&quot;&gt;LinkAsync&lt;/code&gt; method. Along with the text, you want to identify entities from, you can also specify a specific word within that text that you want to be entity linked. However, if you specify a specific word, you will also have to specify the location of the specific word in the given text.
This method takes the following arguments:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Task&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EntityLink&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;]&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;LinkAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;selection&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;text&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Text that is supplied to the service to separate the entities from.&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;selection&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Specific word within the text you want to be entity linked&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;offset&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// position of the specific word offset by the number of character within the given text.&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;In a case where only one argument, the input text is specified, then the service tries to recognize and identify all the entities as seen in the code below.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linkResponse&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clientApplication&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;LinkAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;txtRequest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;display-entity-linking-api-response&quot;&gt;Display Entity Linking API Response&lt;/h2&gt;
&lt;p&gt;The response from the method &lt;code class=&quot;highlighter-rouge&quot;&gt;LinkAsync&lt;/code&gt; call is returned in the form of an array of objects of the type &lt;code class=&quot;highlighter-rouge&quot;&gt;EntityLink&lt;/code&gt;. 
The objects in the array are traversed one by one, serialized and formatted into JSON format.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linkResponse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// Serialize and format the response into JSON.&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;resultJSON&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;JsonConvert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;SerializeObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;\n&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;We also use a &lt;code class=&quot;highlighter-rouge&quot;&gt;LINQ&lt;/code&gt; query to retrieve the WikipediaID from each Entity, these IDs are then displayed accordingly.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Retrieve Wikipedia IDs for all the Entities.&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;resultEnitites&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Join&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;\n&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linkResponse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Select&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WikipediaID&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-08-26-using-microsoft-azure-entity-linking-cognitive-api/display_entity_api_response.jpg&quot; alt=&quot;Display Entity Linking API response&quot; /&gt;
    &lt;figcaption&gt;Display Entity Linking API response&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;source-code&quot;&gt;Source Code&lt;/h2&gt;
&lt;p&gt;You can find the &lt;strong&gt;source code&lt;/strong&gt; at Github &lt;a href=&quot;https://github.com/keeratsingh/AzureEntityLinkingCognitiveApi&quot;&gt;AzureEntityLinkingCognitiveApi&lt;/a&gt; repository as &lt;code class=&quot;highlighter-rouge&quot;&gt;Visual Studio 2017&lt;/code&gt; solution.&lt;/p&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;This is a very brief introduction to get you started using the Microsoft Azure Entity Linking Cognitive API. The same method can be improvised upon and used to connect to other Cognitive APIs. If you have any questions or concerns, feel free to leave a comment.&lt;/p&gt;

</description>
        <pubDate>Sat, 26 Aug 2017 09:15:00 -0700</pubDate>
        <link>http://localhost:4000/blog/2017/using-microsoft-azure-entity-linking-cognitive-api/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2017/using-microsoft-azure-entity-linking-cognitive-api/</guid>
        
        
        <category>Microsoft</category>
        
        <category>Azure,</category>
        
        <category>Cognitive</category>
        
        <category>Services</category>
        
      </item>
    
      <item>
        <title>Authenticating Microsoft Account using Microsoft Authentication Library (MSAL)</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;Microsoft recently revealed the new Graph APIs at the recent MS Build 2017. These APIs provide a single unified endpoint to access different Microsoft Products, which means you no longer have to deal with different methods of authentication across different platforms.
An exciting addition to this is the new and updated Microsoft Authentication Library (MSAL), which is conveniently available across .Net, iOS, Android, and JavaScript.
This consolidated library will be used to authenticate both Microsoft personal and Azure AD School and work accounts.&lt;/p&gt;

&lt;p&gt;In order to access Microsoft Graph functionality, the first step is to authenticate and get the &lt;code class=&quot;highlighter-rouge&quot;&gt;access token&lt;/code&gt; using &lt;code class=&quot;highlighter-rouge&quot;&gt;MSAL&lt;/code&gt;, which will be discuss in this tutorial.&lt;/p&gt;

&lt;h1 id=&quot;pre-requisites&quot;&gt;Pre-Requisites&lt;/h1&gt;

&lt;h2 id=&quot;install-microsoftidentityclient-package&quot;&gt;Install Microsoft.Identity.Client Package&lt;/h2&gt;
&lt;p&gt;Make sure you have added the &lt;code class=&quot;highlighter-rouge&quot;&gt;Microsoft.Identity.Client&lt;/code&gt; Nuget Package to your project.
To add the pacakge Go to &lt;code class=&quot;highlighter-rouge&quot;&gt;Tools&lt;/code&gt; &amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Nuget Package Manager&lt;/code&gt; &amp;gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Package Manager Console&lt;/code&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Install&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Package&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Microsoft&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Identity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Client&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Pre&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/PM_Console.jpg&quot; alt=&quot;Install Microsoft.Identity.Client Package&quot; /&gt;
    &lt;figcaption&gt;Install Microsoft.Identity.Client Pacakge&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;register-your-application-to-get-client-id&quot;&gt;Register your application to get Client Id&lt;/h2&gt;
&lt;p&gt;Make sure you register your application at the Microsoft Application Registration Portal and make a note of the Client id / Application Id.
This Client Id will be required later when authenticating the user account.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;https&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;//apps.dev.microsoft.com/portal/register-app&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/microsoft_application_registration_portal_1.png&quot; alt=&quot;Register your application&quot; /&gt;
    &lt;figcaption&gt;Register your application&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/microsoft_application_registration_portal_2.png&quot; alt=&quot;Note the Client Id/Application Id&quot; /&gt;
    &lt;figcaption&gt;Note the Client Id/Application Id&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;1-request-token&quot;&gt;1. Request Token&lt;/h2&gt;
&lt;p&gt;The very first step is to request a token. Once authenticated, the requesting application receives a token, which further can be used to query Microsoft Graph API.
This token is used to access certain resources, such as user’s information, send emails, read OneNote notebooks and many other protected resources.
We use the AcquireTokenAsync method to acquire the token interactively, as it displays the user sign-in window as seen below.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;    &lt;span class=&quot;c1&quot;&gt;//Set the scope&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_Scopes&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;User.Read&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;PublicClientApplication&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clientApplication&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;PublicClientApplication&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_ClientID&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;authResult&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clientApplication&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;AcquireTokenAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_Scopes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/request_token_sign-in.jpg&quot; alt=&quot;Interactive Sign-In&quot; /&gt;
    &lt;figcaption&gt;Interactive Sign-In&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/request_token_scopes.jpg&quot; alt=&quot;Allow permission for requested Scopes&quot; /&gt;
    &lt;figcaption&gt;Allow permission for requested Scopes&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;2-receive-and-parse-token&quot;&gt;2. Receive and Parse Token&lt;/h2&gt;
&lt;p&gt;AcquireTokenAsync method returns an object of class &lt;code class=&quot;highlighter-rouge&quot;&gt;AuthenticationResult&lt;/code&gt;, which is stored in the variable authResult.
The actual token is stored in the &lt;code class=&quot;highlighter-rouge&quot;&gt;authResult.AccessToken&lt;/code&gt; property.
We check if the object returned by the function call AcquireTokenAsync is not null and then parse the object and display it accordingly.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;authResult&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;DisplayParseAuthResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;authResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SendGetRequest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;authResult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AccessToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nf&quot;&gt;DisplayAPIResponse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;3-send-get-request-with-token&quot;&gt;3. Send GET Request with token&lt;/h2&gt;
&lt;p&gt;Once the token is received, we send a GET request attaching the access token as a header using the &lt;code class=&quot;highlighter-rouge&quot;&gt;HttpClient&lt;/code&gt; class.
The GET request is sent to the &lt;code class=&quot;highlighter-rouge&quot;&gt;https://graph.microsoft.com/v1.0/me&lt;/code&gt; Graph API Endpoint.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;//Set the API Endpoint&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_GraphAPIEndpoint&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;https://graph.microsoft.com/v1.0/me&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;HttpClient&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;httpClient&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;HttpClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;httpClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DefaultRequestHeaders&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Authorization&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;Bearer &quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_AccessToken&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Uri&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;GraphAPIEndpointUri&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_GraphAPIEndpoint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;4-display-graph-api-response&quot;&gt;4. Display Graph API Response&lt;/h2&gt;

&lt;p&gt;The response from the Graph API call is returned in the form of &lt;code class=&quot;highlighter-rouge&quot;&gt;HttpResponseMessage&lt;/code&gt; object. We then serialize the HTTP content to a string using the &lt;code class=&quot;highlighter-rouge&quot;&gt;ReadAsStringAsync&lt;/code&gt; method. This string is then displayed on the UI.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;HttpResponseMessage&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;httpClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GraphAPIEndpointUri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;content&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ReadAsStringAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-05-14-authentication-using-msal/display_token_http_response.jpg&quot; alt=&quot;Display Token and Graphi API response&quot; /&gt;
    &lt;figcaption&gt;Display Token and Graph API resposne&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;source-code&quot;&gt;Source Code&lt;/h2&gt;
&lt;p&gt;You can find the &lt;strong&gt;source code&lt;/strong&gt; at Github &lt;a href=&quot;https://github.com/keeratsingh/MSALAuthentication&quot;&gt;MSALAuthentication repo&lt;/a&gt; along with the &lt;code class=&quot;highlighter-rouge&quot;&gt;Visual Studio 2017&lt;/code&gt; solution.&lt;/p&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;This is a very brief introduction to get you started using the MSAL and calling the Graph API. You can use the token received for further calls to the Graph API, as long as the token is in the header of the GET request.
If you have any questions or concerns, feel free to leave a comment.&lt;/p&gt;

</description>
        <pubDate>Sun, 14 May 2017 13:15:00 -0700</pubDate>
        <link>http://localhost:4000/blog/2017/authentication-using-msal/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2017/authentication-using-msal/</guid>
        
        
        <category>Microsoft</category>
        
        <category>Graph,</category>
        
        <category>UWP</category>
        
      </item>
    
      <item>
        <title>Adding appointments to Windows 10 Calendar using C#</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;Working different shifts? Having trouble updating the Windows 10 Calendar with repetitive tasks? I had the same issue, so I decided to make it
as less painful as possible. :)
This blog post is a result of my laziness to update calendar everytime I encounter a new weekly schedule.
This program reads the data from a text/csv file and updates the calendar, based on the appointments in the file.&lt;/p&gt;

&lt;h2 id=&quot;picking-a-file-using-fileopenpicker-class&quot;&gt;Picking a File using FileOpenPicker class&lt;/h2&gt;
&lt;p&gt;The first step is to choose a file that contains the appointments in particular format. I chose the format Subject,Date,StartTime,Duration as comma separated values.&lt;br /&gt;
This is what my csv file looks like.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;Subject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;StartTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Duration&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Test1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;16&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;04&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2017&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;00&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;8.5&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Test2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;24&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;04&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2017&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;00&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;reading-from-the-chosen-file&quot;&gt;Reading from the chosen file&lt;/h2&gt;
&lt;p&gt;I used the &lt;code class=&quot;highlighter-rouge&quot;&gt;FileIO.ReadLinesAsync&lt;/code&gt; method to read from the file and store them into an enumerable list of the type string. Once the appointments are stored
in a list, the items in the list are read one by and each item is split based on the delimiter.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Store contents of the file into an enumerable List.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;IList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;lines&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;FileIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ReadLinesAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Split the contents of the line based on the delimiter&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;appointmentDetails&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chDelimiter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-04-14-adding-appointments-to-windows10-calendar-using-c-sharp/windows_chosen_file.jpg&quot; alt=&quot;Choose file using FileOpenPicker&quot; /&gt;
    &lt;figcaption&gt;Choose file using FileOpenPicker&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;initializing-the-appointment-object&quot;&gt;Initializing the Appointment object&lt;/h2&gt;
&lt;p&gt;Windows 10 SDK provides an API &lt;code class=&quot;highlighter-rouge&quot;&gt;Windows.ApplicationModel.Appointments&lt;/code&gt;, through which we can manage appointments.
Once the item in the list is split based on the delimiter, respective properties of the initialized &lt;code class=&quot;highlighter-rouge&quot;&gt;Appointment&lt;/code&gt; object are set based on the values in the file.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Create a new Appointment object&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;Appointment&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;appointment&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Appointment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Expected format of string: Subject,Date,StartTime,Duration&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;appointment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Subject&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;appointmentDetails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;DateTime&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dateTime&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ParseExact&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;{0} {1}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;appointmentDetails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;appointmentDetails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]),&lt;/span&gt; 
                                        &lt;span class=&quot;s&quot;&gt;&quot;dd-MM-yyyy HH:mm&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
                                        &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Globalization&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CultureInfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;InvariantCulture&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;DateTimeOffset&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;startTime&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;DateTimeOffset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;appointment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;StartTime&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;startTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;appointment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Duration&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TimeSpan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;FromHours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;float&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;appointmentDetails&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]));&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;appointment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Reminder&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TimeSpan&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;FromHours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;adding-appointment-to-the-calendar&quot;&gt;Adding appointment to the calendar&lt;/h2&gt;
&lt;p&gt;Once the required properties of the Appointment object are set, we will invoke the method Windows.ApplicationModel.Appointments.&lt;code class=&quot;highlighter-rouge&quot;&gt;AppointmentManager.ShowAddAppointmentAsync&lt;/code&gt;,
with the following parameters:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Appointment&lt;/code&gt; object: This object contains the information regarding the appointment being added.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Rect&lt;/code&gt; object: As per &lt;a href=&quot;https://msdn.microsoft.com/en-us/microsoft-r/windows.applicationmodel.appointments.appointmentstore.showaddappointmentasync&quot;&gt;MSDN documentation&lt;/a&gt; &lt;code class=&quot;highlighter-rouge&quot;&gt;Rect&lt;/code&gt; is the rectangular area of user selection (for example, pressing a button), around which the operating system displays the Add Appointment UI, not within that rectangular area. For example, if an app uses a button to show the Rect, pass the Rect of the button so the Add Appointment UI displays around the button, not overlapping it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When this method call concludes, it returns a string object containing the appointment identifier, which is used when updating or removing an appointment.
If the return string is empty, it means that the appointment was not added.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;appointmentId&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AppointmentManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ShowAddAppointmentAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;appointment&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-04-14-adding-appointments-to-windows10-calendar-using-c-sharp/windows_add_to_calendar.jpg&quot; alt=&quot;add appointment to calendar&quot; /&gt;
    &lt;figcaption&gt;Appointment UI&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;appointment-added&quot;&gt;Appointment added&lt;/h2&gt;
&lt;p&gt;Once the appointment is confirmed via the Add Appointment UI, it gets added to the calendar app. Do keep in mind that you have to have an outlook account setup on windows phone for this to work. In case of Windows 10 on desktop this is not the case.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2017-04-14-adding-appointments-to-windows10-calendar-using-c-sharp/windows_appointment_added.jpg&quot; alt=&quot;Appointments added to the calendar&quot; /&gt;
    &lt;figcaption&gt;Appointments added to the calendar&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;Once you have everything setup, you just have to edit the file and you are just one click away from adding all the appointments.
If you have any questions or concerns, feel free to leave a comment.&lt;/p&gt;

</description>
        <pubDate>Fri, 14 Apr 2017 13:15:00 -0700</pubDate>
        <link>http://localhost:4000/blog/2017/adding-appointments-to-windows10-calendar-using-c-sharp/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2017/adding-appointments-to-windows10-calendar-using-c-sharp/</guid>
        
        
        <category>Windows</category>
        
        <category>10,</category>
        
        <category>UWP</category>
        
      </item>
    
      <item>
        <title>Setting up docker on Mac,Windows,Linux and Azure VM</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;Containers have been around for a while, however, Docker has made the use of the container technology simple.
If you are new to Docker and container technology just like me, Docker has well &lt;a href=&quot;https://docs.docker.com/engine/understanding-docker/&quot;&gt;detailed documentation&lt;/a&gt; to start with.
I was pretty curious on what all the fuss about containers was, therefore I started looking into container technology.
Since Docker is available on many different platforms, I thought it would be appropriate to discuss as to how to setup Docker on different platforms.
I will not be going into the detail of what containers are and how Docker works, this is more of how to tutorial, and me sharing my experience of setting up docker on 
Mac,Windows,Linux, and Azure VM.&lt;br /&gt;
Docker runs natively on Linux systems and uses a virtualized docker environment on Windows and Mac, I will exlore native Docker Containers on Windows in the near future.
I will be using Docker for Mac and Windows, rather than using Docker Toolbox, details of which will be discussed further in the article.&lt;/p&gt;

&lt;h2 id=&quot;download-docker-engine&quot;&gt;Download Docker Engine&lt;/h2&gt;
&lt;h3&gt;Mac&lt;/h3&gt;
&lt;p&gt;Docker can be setup on Mac either using Docker Toolbox or Docker for Mac. The key difference between the two is that the former 
uses VirutalBox to setup a VM to host the Docker environment and the latter is a native application that makes use of xhyve to virtualize 
the Docker environment, which is pretty lightweight as compared to an actual VM.&lt;br /&gt;
Docker for Mac requires Hypervisor to be supported by the operation system and is, therefore, applicable mostly to the newer version of Mac OS.
A detailed comparison can be found at the &lt;a href=&quot;https://docs.docker.com/docker-for-mac/docker-toolbox/&quot;&gt;Docker website&lt;/a&gt;. 
Downloading is pretty straight forward, and you can download the official version &lt;a href=&quot;https://download.docker.com/mac/stable/Docker.dmg&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Windows&lt;/h3&gt;
&lt;p&gt;Similar to Mac, Docker can be setup on Windows in two ways, either using Docker Toolbox or Docker for Windows. 
Since Docker Engine uses some Linux-specific features, therefore the former creates a VM using VirtualBox and attaches it to the host Windows machine. 
This VM then hosts the Docker environment required by the Windows system.
The latter uses Hyper-V to virtualize the Docker enviornment.
You can download Docker for Windows from &lt;a href=&quot;https://download.docker.com/win/stable/InstallDocker.msi&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Linux(uBuntu)&lt;/h3&gt;
&lt;p&gt;Since Docker Engine runs natively on Linux, therefore it can be installed directly by installing the docker-engine package from apt-get. Docker is supported across
various Linux distributions, however, I will be discussing setting up on Ubuntu.&lt;/p&gt;
&lt;h3&gt;Azure VM(Docker on Ubuntu)&lt;/h3&gt;
&lt;p&gt;Setting up Docker on Azure is easiest, thanks to a pre-existing template on Azure called &lt;code class=&quot;highlighter-rouge&quot;&gt;Docker on Ubuntu Server&lt;/code&gt;. Docker on Ubuntu Server
template deploys a Ubuntu Server 16.04 LTS VM and then automatically installs Docker Engine on the VM.
The terminal on this machine can be accessed via ssh using putty on windows, for linux/mac native terminal works.&lt;/p&gt;

&lt;h2 id=&quot;installing-docker&quot;&gt;Installing Docker&lt;/h2&gt;
&lt;h3&gt;Mac&lt;/h3&gt;
&lt;p&gt;Installing Docker on Mac is fairly standard and simple, once you have downloaded the dmg package, you can double-click the package file 
to mount dmg file. Then drag and drop Docker.app into the Applications folder as seen below.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/install-docker-on-mac1.jpg&quot; alt=&quot;Installing Docker on Mac&quot; /&gt;
    &lt;figcaption&gt;Installing Docker on Mac&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;p&gt;Once you have successfully installed Docker.app, run the application. If everything goes well, you can see a whale icon pop up in the status bar
citing that Docker is now up and running.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/install-docker-on-mac2.jpg&quot; alt=&quot;Successful installation&quot; /&gt;
    &lt;figcaption&gt;Successful installation&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h3&gt;Windows&lt;/h3&gt;
&lt;p&gt;To install Docker on Windows, make sure Hyper-V is supported and enabled. If Hyper-V is not enabled, you can follow this tutorial to &lt;a href=&quot;https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/quick_start/walkthrough_install&quot;&gt;enable Hyper-V&lt;/a&gt; on Windows 10.
Also, virtualization should be enabled on the operating system for Docker to work.
Once you have both Hyper-V and virtualization enabled, run the msi installer that you downloaded, follow the instructions to install Docker and at the last dialog box tick option
&lt;code class=&quot;highlighter-rouge&quot;&gt;Launch Docker&lt;/code&gt;. If everything goes well, you should see a whale icon in the taskbar, which means Docker is running and ready to use.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/install-docker-on-windows.jpg&quot; alt=&quot;Installing Docker on Windows&quot; /&gt;
     &lt;figcaption&gt;Installing Docker on Windows&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;h3&gt;Linux(uBuntu)&lt;/h3&gt;
&lt;p&gt;Since the Docker Engine is supported natively on Linux, therefore I can just install docker by running a simple script from the official Docker website. I installed Docker on Ubuntu, it is supported
across many flavors of Linux. Docker on Linux can be installed using respective native package managers, however, I chose to install Docker using &lt;code class=&quot;highlighter-rouge&quot;&gt;curl&lt;/code&gt;.
You will need sudo permissions to install Docker, therefore make sure you have &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo&lt;/code&gt; privileges. Once you make sure curl is installed, you can fetch the latest Docker package as shown below.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;which curl  
curl &lt;span class=&quot;nt&quot;&gt;-fsSL&lt;/span&gt; https://get.docker.com/ | sh&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3&gt;Azure VM(Docker on Ubuntu)&lt;/h3&gt;
&lt;p&gt;Docker installation is probably the easiest on Azure, since you can provision a VM with Docker pre-installed.
To provision, a new Ubuntu VM with Docker pre-installed follow the instructions below.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;- Click the + icon to add a new resource. 
- Choose Virtual Machines.
- Search &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;Docker on Ubuntu Server&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
- Configure your server and provision it.
- Once the server is provisioned, SSH into the server using an SSH client like putty.
- You will find the Docker Engine already installed.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/Docker-On-Azure.jpg&quot; alt=&quot;Docker-On-Azure&quot; /&gt;
    &lt;figcaption&gt;Installing Docker on Azure&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;verifying-docker-installation&quot;&gt;Verifying Docker installation&lt;/h2&gt;
&lt;p&gt;In order to verify Docker installation on each platform execute &lt;code class=&quot;highlighter-rouge&quot;&gt;docker info&lt;/code&gt; to see information regarding kernel version, a number of containers and images.
&lt;code class=&quot;highlighter-rouge&quot;&gt;docker version&lt;/code&gt; displays all the information regarding the version of the Client and the Server, you can even format the string into JSON format.&lt;/p&gt;

&lt;h3&gt;Mac&lt;/h3&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/verify-docker-install-mac.jpg&quot; alt=&quot;Verify Docker installation on Mac&quot; /&gt;
    &lt;figcaption&gt;Verify Docker installation on Mac&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h3&gt;Windows&lt;/h3&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/verify-docker-install-windows.jpg&quot; alt=&quot;Verify Docker installation on Windows&quot; /&gt;
    &lt;figcaption&gt;Verify Docker installation on Windows&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;h3&gt;Linux(uBuntu)&lt;/h3&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/verify-docker-install-linux.jpg&quot; alt=&quot;Verify Docker installation on Linux&quot; /&gt;
    &lt;figcaption&gt;Verify Docker installation on Linux(uBuntu)&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h3&gt;Azure VM(Docker on Ubuntu)&lt;/h3&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/verify-docker-install-azure.jpg&quot; alt=&quot;Verify Docker installation on Azure VM&quot; /&gt;
    &lt;figcaption&gt;Verify Docker installation on Azure VM(Docker on Ubuntu)&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;running-hello-world-image&quot;&gt;Running hello-world image&lt;/h2&gt;
&lt;p&gt;Execute the &lt;code class=&quot;highlighter-rouge&quot;&gt;docker run&lt;/code&gt; command to run the image &lt;code class=&quot;highlighter-rouge&quot;&gt;hello-world&lt;/code&gt; in the container. This image is an example of minimal dockerization. You can find more images at &lt;a href=&quot;https://hub.docker.com/explore/&quot;&gt;docker explore&lt;/a&gt;.
Run the command &lt;code class=&quot;highlighter-rouge&quot;&gt;docker ps -a&lt;/code&gt; to list all containers, both running and stopped.&lt;/p&gt;
&lt;h3&gt;Mac&lt;/h3&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/running-hello-world-mac.jpg&quot; alt=&quot;Running hello world on Mac&quot; /&gt;
    &lt;figcaption&gt;Running hello world on Mac&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;h3&gt;Windows&lt;/h3&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/running-hello-world-windows.jpg&quot; alt=&quot;Running hello world on Windows&quot; /&gt;
    &lt;figcaption&gt;Running hello world on Windows&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;h3&gt;Linux(uBuntu)&lt;/h3&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/running-hello-world-linux.jpg&quot; alt=&quot;Running hello world on Linux(uBuntu)&quot; /&gt;
    &lt;figcaption&gt;Running hello world on Linux(uBuntu)&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;h3&gt;Azure VM(Docker on Ubuntu)&lt;/h3&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-25-setting-up-docker-on-mac-windows-linux-azure/running-hello-world-azure.jpg&quot; alt=&quot;Running hello world on Azure VM&quot; /&gt;
    &lt;figcaption&gt;Running hello world on Azure VM(Docker on Ubuntu)&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;Docker is supported mostly on all the popular platforms and setting up docker is pretty straight-forward and easy. 
This was just an introduction on how to setup and verify docker on various platforms. If you have any questions or concerns, feel free to leave a comment.&lt;/p&gt;

</description>
        <pubDate>Sun, 06 Nov 2016 10:05:00 -0800</pubDate>
        <link>http://localhost:4000/blog/2016/setting-up-docker-on-mac-windows-linux-azure/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2016/setting-up-docker-on-mac-windows-linux-azure/</guid>
        
        
        <category>Docker,Containers</category>
        
      </item>
    
      <item>
        <title>Customizing Microsoft Band using Band SDK and UWP</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;This idea was on the back burner for quite a while, and I never had the time to pursue this, until last week. I finally sat down and developed a Microsoft Band customization app,
that helps you take advantage of the Band SDK and customize the &lt;code class=&quot;highlighter-rouge&quot;&gt;BandTheme&lt;/code&gt;. I know the &lt;strong&gt;Microsoft Health&lt;/strong&gt; app allows you to customize the BandTheme using various styles, however, I felt
it was &lt;strong&gt;limited in terms of granular customization&lt;/strong&gt;, which inspired me to develop this app that helps you to customize each and every &lt;code class=&quot;highlighter-rouge&quot;&gt;Band Color&lt;/code&gt; class individually.
Another thing I felt the Microsoft Health app &lt;strong&gt;lacked in terms of Band personalization&lt;/strong&gt; was the visual UI that helped the user interpret how the theme actually
affected the Band Tiles. This UWP application actually helps the user have a better understanding of the components of the Band being customized.&lt;br /&gt;
This post will help you guide through the &lt;code class=&quot;highlighter-rouge&quot;&gt;Band SDK&lt;/code&gt; functions used to retrieve and update the BandTheme. 
There are 8 color classes that exist on the Band, however, only &lt;strong&gt;6 of the 8 can be customized&lt;/strong&gt; using the Band SDK.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;err&quot;&gt;•&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Base&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;•&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;High&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Contrast&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;•&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Lowlight&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;•&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Highlight&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;•&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Muted&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;•&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Secondary&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;h3&gt;Installing Nuget package Microsoft.Band&lt;/h3&gt;
&lt;p&gt;We need to install the NuGet package Microsoft.Band, in order to have the BandSDK capabilities.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Right click on the Project you want to add the package to.&lt;/li&gt;
  &lt;li&gt;Choose &lt;code class=&quot;highlighter-rouge&quot;&gt;Manage NuGet Packages...&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Seach for package called &lt;code class=&quot;highlighter-rouge&quot;&gt;Band&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Install package &lt;code class=&quot;highlighter-rouge&quot;&gt;Microsoft.Band&lt;/code&gt; by Microsoft Corporation.
&lt;br /&gt;
&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Manage_Nuget.jpg&quot; alt=&quot;Installing Microsoft.Band package&quot; /&gt;
    &lt;figcaption&gt;Installing Microsoft.Band package&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;h3&gt;Enabling Bluetooth capability&lt;/h3&gt;
&lt;p&gt;We need to enable the Bluetooth capability of the UWP application, in order to allow the app to connect to the Microsoft band via Bluetooth.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Right click on the &lt;code class=&quot;highlighter-rouge&quot;&gt;Package.appxmanifest&lt;/code&gt; and click open&lt;/li&gt;
  &lt;li&gt;Go to &lt;code class=&quot;highlighter-rouge&quot;&gt;Capabilities&lt;/code&gt; tab.&lt;/li&gt;
  &lt;li&gt;Check the option &lt;code class=&quot;highlighter-rouge&quot;&gt;Bluetooth&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Save Package.appxmanifest.
&lt;br /&gt;
&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Bluetooth_Capability.jpg&quot; alt=&quot;Enabling Bluetooth capability&quot; /&gt;
    &lt;figcaption&gt;Enabling Bluetooth capability&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;connecting-to-the-band&quot;&gt;Connecting to the Band&lt;/h2&gt;
&lt;p&gt;The initial step is to connect to a paired Band to the device on which your application is running. 
We use the &lt;code class=&quot;highlighter-rouge&quot;&gt;BandClientManager&lt;/code&gt; to get a list of paired Bands and connect to the first Band.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Get the list of paired Bands&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairedBands&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BandClientManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Instance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetBandsAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Connect to the first Band&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;band&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pairedBands&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;FirstOrDefault&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Connect to the Band and get a new BandClient object&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;bandClient&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;BandClientManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Instance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ConnectAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;band&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Connecting_to_the_Band.jpg&quot; alt=&quot;Connecting to Microsoft Band&quot; /&gt;
    &lt;figcaption&gt;Connecting to Microsoft Band&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;retrieving-the-band-theme&quot;&gt;Retrieving the Band Theme&lt;/h2&gt;
&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;PersonalizationManager&lt;/code&gt; allows us to retrieve the color classes currently being used on the Band device using the &lt;code class=&quot;highlighter-rouge&quot;&gt;BandTheme&lt;/code&gt; class.
The Band Theme is retrieved using the &lt;code class=&quot;highlighter-rouge&quot;&gt;GetThemeAsync&lt;/code&gt; method and stored into an object of the BandTheme class.
After the theme is retrieved, the UI is updated respectively, by converting the &lt;code class=&quot;highlighter-rouge&quot;&gt;BandColor&lt;/code&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;SolidColorBrush&lt;/code&gt; and updating the &lt;code class=&quot;highlighter-rouge&quot;&gt;Fill&lt;/code&gt; property of the ellipse.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Retrieve theme from the band&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;BandTheme&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bandClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PersonalizationManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetThemeAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Update the UI&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;eBase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Base&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;eHighContrast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HighContrast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;eHighlight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Highlight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;eLowLight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Lowlight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;eMuted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Muted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;eSecondary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SecondaryText&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img class=&quot;postImg&quot; src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Theme_Retrieved.jpg&quot; alt=&quot;Connected and successfully retrieved the BandTheme&quot; /&gt;
    &lt;figcaption&gt;Connected and successfully retrieved the theme&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;personalizing-the-band-theme&quot;&gt;Personalizing the Band Theme&lt;/h2&gt;
&lt;p&gt;The application allows the user to customize all the 6 available Band color classes individually. Your can click on each class to bring out a color dialog box.
This color dialog box gives you the option of either choosing a color from a &lt;strong&gt;predefined list of colors&lt;/strong&gt;, included in the &lt;code class=&quot;highlighter-rouge&quot;&gt;Windows.UI.Colors&lt;/code&gt; or entering a &lt;strong&gt;custom color Hex Code&lt;/strong&gt;.&lt;br /&gt;
Each Band color class has its own row and the application UI reflects how each Band color class affects the Microsoft Band UI.&lt;/p&gt;
&lt;h3&gt;Choosing color from ComboBox&lt;/h3&gt;
&lt;p&gt;Currently, there are &lt;strong&gt;141 colors&lt;/strong&gt; to choose from &lt;code class=&quot;highlighter-rouge&quot;&gt;Windows.UI.Colors&lt;/code&gt;, since the list is dynamically generated at runtime, 
any new colors added to Windows.UI.Colors will be added to the &lt;code class=&quot;highlighter-rouge&quot;&gt;ComboBox&lt;/code&gt; automatically.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Personalizing_2a_1.jpg&quot; alt=&quot;Choosing color using ComboBox&quot; /&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Personalizing_2a_2.jpg&quot; alt=&quot;Choosing color using ComboBox&quot; /&gt;
     &lt;figcaption&gt;Choosing color using ComboBox&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h3&gt;Entering a Custom color hex value&lt;/h3&gt;
&lt;p&gt;You can also define a custom color, using the hex value of the color. You can use your favorite program to get the hex value or use this wonderful site that I really like 
&lt;a href=&quot;http://www.color-hex.com&quot;&gt;hex-color&lt;/a&gt;. The hex code can be entered with or without the # symbol.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Personalizing_2b_1.jpg&quot; alt=&quot;Choosing color using hex value&quot; /&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Personalizing_2b_2.jpg&quot; alt=&quot;Choosing color using hex value&quot; /&gt;
     &lt;figcaption&gt;Choosing color using hex value&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;uploading-the-band-theme&quot;&gt;Uploading the Band Theme&lt;/h2&gt;
&lt;p&gt;Once you have customized the UWP application UI, we need to upload the theme to the connected Band device. We do that by clicking the &lt;strong&gt;accept icon&lt;/strong&gt;, which
calls the &lt;code class=&quot;highlighter-rouge&quot;&gt;SetThemeAsync&lt;/code&gt; method. We create a new &lt;code class=&quot;highlighter-rouge&quot;&gt;BandTheme&lt;/code&gt; object using the color values set by the user and then call the SetThemeAsync, with the BandTheme
object as the argument. A message is displayed on the UI once the BandTheme is uploaded successfully.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Convert user customizations into Band theme.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;BandTheme&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;BandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Base&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eBase&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToBandColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;HighContrast&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eHighContrast&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToBandColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Lowlight&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eLowLight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToBandColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Highlight&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eHighlight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToBandColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Muted&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eMuted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToBandColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;SecondaryText&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SolidColorBrush&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;eSecondary&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fill&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Color&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToBandColor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(),&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// Update Band with the theme.&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bandClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PersonalizationManager&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;SetThemeAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bandTheme&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Upload_Theme_1.jpg&quot; alt=&quot;Uploading theme to Band&quot; /&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Upload_Theme_2.jpg&quot; alt=&quot;Upload completed&quot; /&gt;
    &lt;figcaption&gt;Uploading theme to Microsoft Band&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;screenshots-on-microsoft-band-2&quot;&gt;Screenshots on Microsoft Band 2&lt;/h2&gt;
&lt;div class=&quot;postImg&quot;&gt;
&lt;figure&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Band_1.jpg&quot; alt=&quot;Band Screenshot 1&quot; /&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Band_2.jpg&quot; alt=&quot;Band Screenshot 2&quot; /&gt;
    &lt;img src=&quot;/images/posts/2016-09-07-customizing-microsoft-band-using-band-sdk-uwp/Band_3.jpg&quot; alt=&quot;Band Screenshot 3&quot; /&gt;
    &lt;figcaption&gt;Screenshots on Microsoft Band 2&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;/div&gt;

&lt;h2 id=&quot;video-walkthrough&quot;&gt;Video Walkthrough&lt;/h2&gt;
&lt;p&gt;Here is video Tutorial on how to use the app. It goes through all the steps, such as retrieving, customizing and uploading the theme.
It also covers the cancel button, in case you want to discard your changes.&lt;/p&gt;
&lt;div class=&quot;postImg&quot;&gt;
    &lt;iframe width=&quot;100%&quot; height=&quot;500&quot; src=&quot;https://www.youtube.com/embed/mONhqsVWKks&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;source-code&quot;&gt;Source Code&lt;/h2&gt;
&lt;p&gt;You can find the &lt;strong&gt;source code&lt;/strong&gt; at Github &lt;a href=&quot;https://github.com/keeratsingh/bandManager&quot;&gt;bandManager repo&lt;/a&gt; along with the &lt;code class=&quot;highlighter-rouge&quot;&gt;Visual Studio 2015&lt;/code&gt; solution.&lt;/p&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;This UWP application is very basic demonstration of using the &lt;strong&gt;Microsoft Band SDK&lt;/strong&gt; to interact and personalize the Band. A lot more things can be done with the SDK, such as subscribe to sensors 
and use the data from the sensors, or update the &lt;strong&gt;MeTile&lt;/strong&gt;. This is application does not use the &lt;code class=&quot;highlighter-rouge&quot;&gt;RelativePanel&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;VisualState&lt;/code&gt; class to make the application dynamically 
adjust to the screen size, since that was not the motive of this app.
If you still face any problems or have any questions, feel free to leave a comment and I will be happy to help. Cheers :)&lt;/p&gt;

</description>
        <pubDate>Sat, 10 Sep 2016 14:05:00 -0700</pubDate>
        <link>http://localhost:4000/blog/2016/customizing-microsoft-band-using-band-sdk-uwp/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2016/customizing-microsoft-band-using-band-sdk-uwp/</guid>
        
        
        <category>UWP,Band</category>
        
      </item>
    
      <item>
        <title>Font icons in UWP using Segoe MDL2 and Segoe UI</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;While developing a UWP app to customize the Microsoft Band, I realized, there was no way to retrieve icons from the default band tiles, therefore 
I decided to go the old way of displaying icons, that is using images. Now, since it is a &lt;strong&gt;Universal Platform Application&lt;/strong&gt;, it is expected to work across many different windows 10 platforms and screen sizes.
One solution is to use an image file as an icon, which is pretty common, however, the image gets pixelated when the image and the screen size increases.
We can use different icon files for different screen sizes, however, it is too much of hassle.  &lt;br /&gt;
An easier solution I found is to use font icons, already predefined in the fonts &lt;strong&gt;Segoe MDL2 Assets and Segoe UI Symbol&lt;/strong&gt;, the best part is you can bind the font size 
to a particular value, depending upon the screen size everything else is taken care of. Another benefit of using font icons is that, in case you change the theme from light to dark, 
the icons are updated as well, depending on the theme.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Segoe MDL2 Assets&lt;/strong&gt; is a Windows 10 font that replaces Windows 8/8.1 font &lt;strong&gt;Segoe UI Symbols&lt;/strong&gt;. Some of the &lt;strong&gt;Segoe MDL2 Assets&lt;/strong&gt; icons are also available through 
&lt;code class=&quot;highlighter-pygments&quot;&gt;Symbol Enumeration&lt;/code&gt;, which I will discuss in this post as well. 
For list of symbols, available refer to this MSDN article &lt;a href=&quot;https://msdn.microsoft.com/en-us/windows/uwp/style/segoe-ui-symbol-font&quot;&gt;Segoe MDL2 icons&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;using-textblock&quot;&gt;Using TextBlock&lt;/h2&gt;
&lt;p&gt;TextBlock is a FrameworkElement control that is used to display small amounts of text. We set the &lt;code class=&quot;highlighter-pygments&quot;&gt;Text&lt;/code&gt; property of the &lt;code class=&quot;highlighter-pygments&quot;&gt;TextBlock&lt;/code&gt; 
control to the Unicode Value of the symbol we want to use. In our example below we have different symbols as the &lt;code class=&quot;highlighter-pygments&quot;&gt;Text&lt;/code&gt; property.&lt;/p&gt;
&lt;h3&gt;Using Segoe MDL2 Assets&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;TextBlock&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Text=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&amp;amp;#xEB52; &amp;amp;#xEB51; &amp;amp;#xEB68;&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;FontFamily=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Segoe MDL2 Assets&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3&gt;Using Segoe UI Symbols&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt; &lt;span class=&quot;nt&quot;&gt;&amp;lt;TextBlock&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Text=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&amp;amp;#xE200; &amp;amp;#xE1D6; &amp;amp;#xE181;&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;FontFamily=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Segoe UI Symbol&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;using-fonticon&quot;&gt;Using FontIcon&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;highlighter-pygments&quot;&gt;FontIcon&lt;/code&gt; is a generalized version of &lt;code class=&quot;highlighter-pygments&quot;&gt;SymbolIcon&lt;/code&gt;, that inherits from &lt;code class=&quot;highlighter-pygments&quot;&gt;IconElement&lt;/code&gt; class. 
It is pretty similar to the &lt;code class=&quot;highlighter-pygments&quot;&gt;TextBlock&lt;/code&gt; control, 
however, we set the &lt;code class=&quot;highlighter-pygments&quot;&gt;Glyph&lt;/code&gt; property instead of &lt;code class=&quot;highlighter-pygments&quot;&gt;Text&lt;/code&gt; property in the case of &lt;code class=&quot;highlighter-pygments&quot;&gt;FontIcon&lt;/code&gt; control. 
Instead of using a predefined set of symbols from &lt;strong&gt;Segoe MDL2 Assets&lt;/strong&gt;, you can specify the Unicode value and choose from the list of available icons.
You can even specify a different font, such as &lt;strong&gt;Segoe UI Symbols&lt;/strong&gt; and specify respective Unicode value.&lt;/p&gt;
&lt;h3&gt;Using Segoe MDL2 Assets&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;FontIcon&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Glyph=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&amp;amp;#xEB52; &amp;amp;#xEB51;  &amp;amp;#xEB68;&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;FontFamily=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Segoe MDL2 Assets&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3&gt;Using Segoe UI Symbols&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;FontIcon&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Glyph=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&amp;amp;#xE200; &amp;amp;#xE1D6; &amp;amp;#xE181;&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;FontFamily=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Segoe UI Symbol&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;using-symbolicon&quot;&gt;Using SymbolIcon&lt;/h2&gt;
&lt;p&gt;Both the &lt;code class=&quot;highlighter-pygments&quot;&gt;SymbolIcon&lt;/code&gt; and &lt;code class=&quot;highlighter-pygments&quot;&gt;FontIcon&lt;/code&gt; inherit from the same class &lt;code class=&quot;highlighter-pygments&quot;&gt;IconElement&lt;/code&gt;, 
however &lt;code class=&quot;highlighter-pygments&quot;&gt;SymbolIcon&lt;/code&gt; is constrained to a predefined set of Segoe MDL2 icons.&lt;/p&gt;
&lt;h3&gt;Using Segoe MDL2 Assets&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;SymbolIcon&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Symbol=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Favorite&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;SymbolIcon&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Symbol=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Camera&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;SymbolIcon&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Symbol=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Mail&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;display-font-icons-using-c&quot;&gt;Display font icons using C#&lt;/h2&gt;
&lt;p&gt;Font icons can also be displayed very easily using &lt;code class=&quot;highlighter-pygments&quot;&gt;C#&lt;/code&gt; by updating the respective code behind file.
Just update the respective &lt;code class=&quot;highlighter-pygments&quot;&gt;Gylph&lt;/code&gt; or &lt;code class=&quot;highlighter-pygments&quot;&gt;Text&lt;/code&gt; property of the control you want to display the font icons in.
The only difference in C# is that the Unicode value is escaped differently using ‘\u’.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;n&quot;&gt;FontIconCS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Glyph&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;\uE1D0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;txtFontIconCS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Text&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;\uE1D0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;icons-in-action&quot;&gt;Icons in action&lt;/h2&gt;
&lt;p&gt;This is how &lt;strong&gt;Segoe MDL2&lt;/strong&gt; and &lt;strong&gt;Segoe UI&lt;/strong&gt; font icons look on a UWP app.&lt;br /&gt;
&lt;img src=&quot;/images/posts/2016-09-05-using-font-icons-uwp-segoe-mdl2/FontIcons.jpg&quot; alt=&quot;Windows 10 UWP Font Icons Segoe MDL2 Segoe UI&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;source-code&quot;&gt;Source Code&lt;/h2&gt;
&lt;p&gt;You can find the &lt;strong&gt;source code&lt;/strong&gt; at Github &lt;a href=&quot;https://github.com/keeratsingh/FontIcons&quot;&gt;fontIcons repo&lt;/a&gt; along with the &lt;code class=&quot;highlighter-rouge&quot;&gt;Visual Studio 2015&lt;/code&gt; solution.&lt;/p&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;The best part about font icons is that you don’t have to worry about pixelated icons anymore. :)&lt;br /&gt;
If you still face any problems or have any questions, feel free to leave a comment and I will be happy to help. Cheers :)&lt;/p&gt;

</description>
        <pubDate>Mon, 05 Sep 2016 05:50:52 -0700</pubDate>
        <link>http://localhost:4000/blog/2016/using-font-icons-uwp-segoe-mdl2/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2016/using-font-icons-uwp-segoe-mdl2/</guid>
        
        
        <category>UWP</category>
        
      </item>
    
      <item>
        <title>Get Bing Image of the Day using C# UWP Application</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Bing Image of the Day&lt;/strong&gt; has become quite popular over the years, it comprises of essentially the most spectacular user-submitted images from all over the world 
which have been showcased on the Bing homepage for the past 5 years. I have absolutely loved the &lt;strong&gt;Bing Wallpaper&lt;/strong&gt; of the day part of the Bing desktop 
application. &lt;strong&gt;Bing desktop&lt;/strong&gt; app changes your wallpaper every day to Bing Image of the Day, which is pretty cool and gives you a peace of mind without 
having to change the wallpaper every day manually. The somewhat similar concept has been used in &lt;strong&gt;Windows Phone&lt;/strong&gt; as well, where you can set 
the lock screen to the Bing Image of the Day.&lt;/p&gt;

&lt;p&gt;I was so interested in the idea that I wanted to &lt;strong&gt;try out myself&lt;/strong&gt; building an app to retrieve the Bing Image. I knew once I could retrieve the image, 
I had &lt;strong&gt;numerous possibilities&lt;/strong&gt; going forward. I could save it and change my desktop after a certain duration of my choice, or set it as my lock screen 
just as a desktop wallpaper, you get my point, the key here is to get the Bing Image of the Day.&lt;/p&gt;

&lt;p&gt;Fortunately, Bing has a &lt;code class=&quot;highlighter-rouge&quot;&gt;REST API&lt;/code&gt; to retrieve a &lt;code class=&quot;highlighter-rouge&quot;&gt;JSON&lt;/code&gt; string which contains the &lt;strong&gt;URL to 
the Bing Image&lt;/strong&gt;, which we will be making use of. 
That is the easy part, now the hard part is to parse and retrieve the URL from the JSON string. I will be discussing in detail the &lt;strong&gt;different methods&lt;/strong&gt; that can be used for 
parsing and how they can be used to extract the &lt;strong&gt;Bing Image URL&lt;/strong&gt;.&lt;/p&gt;

&lt;h2 id=&quot;step-1-retrieve-the-json-string&quot;&gt;Step 1. Retrieve the JSON string&lt;/h2&gt;
&lt;p&gt;The first step is to retrieve the &lt;strong&gt;JSON&lt;/strong&gt; string from the &lt;strong&gt;Bing REST API&lt;/strong&gt; endpoint. 
We retrieve the string using an &lt;code class=&quot;highlighter-rouge&quot;&gt;HttpClient&lt;/code&gt;,we have an option of using &lt;code class=&quot;highlighter-rouge&quot;&gt;Windows.Web.Http&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;System.Net.Http&lt;/code&gt; namespace. &lt;br /&gt;
I prefer to choose Windows.Web.Http.HttpClient for the simple reason that the System.Net.Http.HttpClient might get &lt;strong&gt;deprecated&lt;/strong&gt; over time. Another reason is that 
&lt;strong&gt;System.Net.Http.HttpClient supports only .Net Languages&lt;/strong&gt;, whereas Windows.Web.Http.HttpClient was written with the aim of &lt;strong&gt;consolidating all the 
HTTP APIs&lt;/strong&gt; for different Windows Application Languages, and therefore it supports all the Windows Store 
application languages. For the avid readers &lt;a href=&quot;https://blogs.windows.com/buildingapps/2015/11/23/demystifying-httpclient-apis-in-the-universal-windows-platform/&quot;&gt;here&lt;/a&gt; is a &lt;strong&gt;detailed comparison&lt;/strong&gt; between the two.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// We can specify the region we want for the Bing Image of the Day.&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strRegion&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;en-US&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strBingImageURL&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Format&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://www.bing.com/HPImageArchive.aspx?format=js&amp;amp;idx=0&amp;amp;n={0}&amp;amp;mkt={1}&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_numOfImages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strRegion&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;strJSONString&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;HttpClient&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;HttpClient&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Using an Async call makes sure the app is responsive during the time the response is fetched.&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// GetAsync sends an Async GET request to the Specified URI.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;HttpResponseMessage&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;strBingImageURL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Content property get or sets the content of a HTTP response message. &lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// ReadAsStringAsync is a method of the HttpContent which asynchronously &lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// reads the content of the HTTP Response and returns as a string.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;strJSONString&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;await&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ReadAsStringAsync&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-2-parse-the-json-string&quot;&gt;Step 2. Parse the JSON string&lt;/h2&gt;
&lt;p&gt;Now we can parse the retrieved JSON string using 3 methods&lt;br /&gt;
• Using &lt;code class=&quot;highlighter-rouge&quot;&gt;Windows.Data.Json&lt;/code&gt; (&lt;em&gt;Native Way&lt;/em&gt;)&lt;br /&gt;
• Using &lt;code class=&quot;highlighter-rouge&quot;&gt;LINQ-to-JSON&lt;/code&gt; API’s JObject from &lt;code class=&quot;highlighter-rouge&quot;&gt;JSON.NET&lt;/code&gt; (&lt;em&gt;Newtonsoft&lt;/em&gt;)  &lt;br /&gt;
• Using &lt;code class=&quot;highlighter-rouge&quot;&gt;dynamic&lt;/code&gt; object and &lt;code class=&quot;highlighter-rouge&quot;&gt;DeserializeObject&lt;/code&gt; method JSON.NET (&lt;em&gt;Newtonsoft&lt;/em&gt;)&lt;br /&gt;
&lt;strong&gt;JSON.Net&lt;/strong&gt; has existed since long before Windows.Data.Json came into existence, however, Microsoft introduced Windows.Data.Json with &lt;strong&gt;native support&lt;/strong&gt; for parsing JSON.
To use JSON.NET, you need to &lt;strong&gt;add&lt;/strong&gt; the &lt;code class=&quot;highlighter-rouge&quot;&gt;Newtonsoft&lt;/code&gt; Nuget package, which adds an additional library dependency.
I personally prefer the native way, however for the purpose of this app I have discussed both the ways of parsing the JSON string using both &lt;strong&gt;JSON.NET&lt;/strong&gt; and &lt;strong&gt;Windows.Data.Json namespaces&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Retrieved JSON string:&lt;/strong&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;images&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;startdate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20160719&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;fullstartdate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;201607190700&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;enddate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20160720&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/az/hprichbg/rb/NeonMuseum_EN-US8131993872_1920x1080.jpg&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;urlbase&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/az/hprichbg/rb/NeonMuseum_EN-US8131993872&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;copyright&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Neon Museum, Las Vegas, Nevada (© Kerrick James/Getty Images)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;copyrightlink&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://www.bing.com/search?q=neon+museum&amp;amp;form=hpcapt&amp;amp;filters=HpDate:%2220160719_0700%22&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;wp&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hsh&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;96d3e7bbe87ad583a17ef765ed935d8f&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;drk&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;top&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;bot&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:[]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;startdate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20160718&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;fullstartdate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;201607180700&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;enddate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20160719&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/az/hprichbg/rb/DiamondHead_EN-US10119574903_1920x1080.jpg&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;urlbase&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/az/hprichbg/rb/DiamondHead_EN-US10119574903&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;copyright&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Aerial view of Diamond Head, O’ahu, Hawaii (© Biederbick &amp;amp; Rumpf/Offset)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;copyrightlink&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://www.bing.com/search?q=diamond+head+hawaii&amp;amp;form=hpcapt&amp;amp;filters=HpDate:%2220160718_0700%22&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;wp&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hsh&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1aff492416f5e2fcf6e898743154fbda&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;drk&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;top&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;bot&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:[]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;startdate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20160717&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;fullstartdate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;201607170700&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;enddate&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;20160718&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/az/hprichbg/rb/MuizenbergSA_EN-US9176714978_1920x1080.jpg&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;urlbase&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/az/hprichbg/rb/MuizenbergSA_EN-US9176714978&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;copyright&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Beach huts in Muizenberg, South Africa (© Getty Images)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;copyrightlink&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://www.bing.com/search?q=Muizenberg,+South+Africa&amp;amp;form=hpcapt&amp;amp;filters=HpDate:%2220160717_0700%22&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;wp&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hsh&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;8d4bf37f9d61ab103283005264b4b8cb&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;drk&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;top&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;bot&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:[]}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;tooltips&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:{&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;loading&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Loading...&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;previous&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Previous image&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;next&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Next image&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;walle&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;This image is not available to download as wallpaper.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;walls&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Download this image. Use of this image is restricted to wallpaper only.&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2a-parsing-json-string-using-windowsdatajson&quot;&gt;Step 2a. Parsing JSON string using Windows.Data.Json:&lt;/h3&gt;
&lt;p&gt;This Method parses the fetched JSON string and retrieves the Image URLs using &lt;code class=&quot;highlighter-rouge&quot;&gt;Microsoft Windows.Data.Json&lt;/code&gt; class. We use &lt;code class=&quot;highlighter-rouge&quot;&gt;JsonObject&lt;/code&gt; 
that implements an &lt;strong&gt;IMap interface&lt;/strong&gt;, which can help in manipulating the &lt;strong&gt;name/value&lt;/strong&gt; pairs like a &lt;strong&gt;dictionary&lt;/strong&gt;. We use &lt;code class=&quot;highlighter-rouge&quot;&gt;JsonObject.TryParse&lt;/code&gt; 
method to parse the JSON string into a JSON value, it returns a boolean value, indicating success or failure.
The integral part of the retrieval is &lt;code class=&quot;highlighter-rouge&quot;&gt;jsonObject[&quot;images&quot;].GetArray()[i].GetObject()[&quot;url&quot;].GetString()&lt;/code&gt;.
As seen in the above JSON string, we have a root object &lt;code class=&quot;highlighter-rouge&quot;&gt;&quot;images&quot;&lt;/code&gt;, it further has 3 arrays, which are equal to the &lt;strong&gt;number of images&lt;/strong&gt; specified in &lt;strong&gt;Step 1.&lt;/strong&gt;
Each &lt;strong&gt;array&lt;/strong&gt; has an object called &lt;strong&gt;url&lt;/strong&gt;, which is the part of the url to the Bing Image. We retrieve url for each image and store it into a list.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Parse using Windows.Data.Json.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;JsonObject&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jsonObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;boolParsed&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;JsonObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;TryParse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_strRawJSONString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;out&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jsonObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;boolParsed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_numOfImages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;++)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
       &lt;span class=&quot;n&quot;&gt;_lstBingImageURLs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;jsonObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;images&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetArray&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2b-parsing-json-string-using-linq-to-json-apis-jobject&quot;&gt;Step 2b. Parsing JSON string using LINQ-to-JSON API’s JObject:&lt;/h3&gt;
&lt;p&gt;This Method parses the fetched JSON string and retrieves the Image URLs using &lt;code class=&quot;highlighter-rouge&quot;&gt;LINQ-to-JSON&lt;/code&gt; API’s 
&lt;code class=&quot;highlighter-rouge&quot;&gt;JObject&lt;/code&gt; explicitly.We use this method when we &lt;strong&gt;don’t know the JSON structure&lt;/strong&gt;
ahead of time. This method is recommended if only &lt;strong&gt;one or two values&lt;/strong&gt; from the whole JSON string are required.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Parse using LINQ-to-JSON API's JObject explicitly.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;JObject&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jResults&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;JObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Parse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_strRawJSONString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;jResults&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;images&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;_lstBingImageURLs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;url&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2c-parsing-json-string-using-deserializeobject-and-dynamic-object&quot;&gt;Step 2c. Parsing JSON string using DeserializeObject and dynamic object&lt;/h3&gt;
&lt;p&gt;This Method parses the fetched JSON string and retrieves the Image URLs using &lt;code class=&quot;highlighter-rouge&quot;&gt;DeserializeObject&lt;/code&gt; method. 
We use &lt;code class=&quot;highlighter-rouge&quot;&gt;JsonConvert.DeserializeObject&lt;/code&gt; method when &lt;strong&gt;already know the JSON structure&lt;/strong&gt; and the &lt;strong&gt;strongly typed class&lt;/strong&gt; we want to deserialize into. 
We use &lt;code class=&quot;highlighter-rouge&quot;&gt;dynamic&lt;/code&gt; object, as it saves us the trouble of declaring a specific class to hold the JSON object.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;c1&quot;&gt;// Parse using DeserializeObject method.&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_numOfImages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;++)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;_lstBingImageURLs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Convert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ToString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;JsonConvert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DeserializeObject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;dynamic&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_strRawJSONString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)).&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;images&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-3-display-images-on-ui-using-bitmapimage&quot;&gt;Step 3. Display images on UI using BitmapImage&lt;/h2&gt;
&lt;p&gt;Each URL is converted into a Bitmap Image and added into the Stack Panel dynamically to display as an Image Object.
&lt;code class=&quot;highlighter-rouge&quot;&gt;BitmapImage&lt;/code&gt; class inherits from the &lt;code class=&quot;highlighter-rouge&quot;&gt;BitmapSource&lt;/code&gt; class and is specialized 
&lt;code class=&quot;highlighter-rouge&quot;&gt;BitmapSource&lt;/code&gt; that is optimized for loading images using XAML.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_lstBingImageURLs&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// We use the Image control to display an image on the UI.&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Image&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imgbingImage&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;bingURL&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;https://www.bing.com&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;BitmapSource&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imgbingImageSource&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;BitmapImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Uri&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;bingURL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;imgbingImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Source&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;imgbingImageSource&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    
    &lt;span class=&quot;c1&quot;&gt;// Add the Image control to the Stack Panel&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;spImages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Children&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;imgbingImage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;working-windows-10-uwp-app&quot;&gt;Working Windows 10 UWP App&lt;/h2&gt;
&lt;p&gt;Here is the &lt;strong&gt;screenshot&lt;/strong&gt; of the working &lt;strong&gt;Windows 10 UWP&lt;/strong&gt; app, I have hosted the &lt;strong&gt;Visual Studio&lt;/strong&gt; solution file with source code at Github Repository 
&lt;a href=&quot;https://github.com/keeratsingh/bing-Image-JSON&quot;&gt;Bing-Image-JSON&lt;/a&gt; which you can use to &lt;strong&gt;experiment yourself&lt;/strong&gt;.
&lt;img src=&quot;/images/posts/2016-08-19-bing-image-json-csharp-uwp/BIOD.jpg&quot; alt=&quot;Windows 10 UWP Bing Image of the Day&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note:&lt;/h2&gt;
&lt;p&gt;The &lt;strong&gt;source code&lt;/strong&gt; at the &lt;a href=&quot;https://github.com/keeratsingh/bing-Image-JSON&quot;&gt;Github repo&lt;/a&gt; contains the full detailed code, which you can use to experiment and follow along.
If you still face any problems or have any questions, feel free to leave a comment and I will be happy to help. Cheers :)&lt;/p&gt;

</description>
        <pubDate>Sun, 21 Aug 2016 10:27:52 -0700</pubDate>
        <link>http://localhost:4000/blog/2016/bing-image-api-json-csharp-uwp/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2016/bing-image-api-json-csharp-uwp/</guid>
        
        
        <category>UWP,Bing</category>
        
      </item>
    
      <item>
        <title>Setting up a Jekyll blog using Windows 10 Bash and hosting on GitHub Pages</title>
        <description>&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;p&gt;I started on a journey to setup my personal Github.io page and I had no prior experience of &lt;code class=&quot;highlighter-pygments&quot;&gt;Jekyll&lt;/code&gt;, &lt;code class=&quot;highlighter-pygments&quot;&gt;Ruby&lt;/code&gt; or setting up a page on GitHub.
There were some initial hurdles understanding and configuring the blog, but fortunately, I was able to overcome them all and setup my very own personal GitHub.io page :)&lt;/p&gt;

&lt;p&gt;I watched some videos on YouTube, however most of them missed a really important part, the part of setting up Jekyll on windows 10 and compiling the source code into a static website.
Jekyll is not officially supported on windows, but there are workarounds to setup Jekyll on windows, which I will discuss in this post. I figured it would be really helpful for first timers to have a useful guide on how to setup a GitHub.io page using Jekyll on Windows 10.&lt;/p&gt;

&lt;h2 id=&quot;pre-requisites&quot;&gt;Pre-Requisites&lt;/h2&gt;
&lt;p&gt;Before you start, you will need &lt;code class=&quot;highlighter-pygments&quot;&gt;Windows Subsystem for Linux aka Bash&lt;/code&gt; on windows feature enabled. 
If you have no idea on how to get the bash setup, refer to this &lt;a href=&quot;http://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/&quot;&gt;wonderful guide&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;step-1-download-the-theme&quot;&gt;Step 1. Download the Theme&lt;/h2&gt;
&lt;p&gt;After you are done setting up, the next part is choosing a wonderful theme for your blog. Head over to Jekyll Themes to find a theme.
I will be using &lt;a href=&quot;http://jekyllthemes.org/themes/emerald/&quot;&gt;Emerald theme&lt;/a&gt; for our example.
Click the download link to download the zip file containing the source files.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/2016-08-05-setting-up-blog-github-page/1.png&quot; alt=&quot;Theme download location&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, you can go to github.com and download the source code from the GitHub repository &lt;a href=&quot;https://github.com/kingFelix/emerald&quot;&gt;KingFelix/emerald&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/2016-08-05-setting-up-blog-github-page/1a.png&quot; alt=&quot;Theme download location GitHub&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;step-2-setting-up-the-windows-10-environment&quot;&gt;Step 2. Setting up the Windows 10 environment&lt;/h2&gt;
&lt;p&gt;Now we will setup our local environment required to build the source code that we just downloaded on Windows 10.
There are different ways to setup a Jekyll server locally which you can use as desired. The one I found most convenient was installing the packages on the bash shell and 
setting up a Jekyll server on Bash.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/posts/2016-08-05-setting-up-blog-github-page/2.png&quot; alt=&quot;Linux Bash Shell Windows 10&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Extract the zip file and open the bash shell. We need to install &lt;code class=&quot;highlighter-pygments&quot;&gt;ruby&lt;/code&gt; and &lt;code class=&quot;highlighter-pygments&quot;&gt;jekyll&lt;/code&gt; before we do anything. Here are the steps to follow.&lt;/p&gt;

&lt;h3 id=&quot;step-2a-switching-to-root&quot;&gt;Step 2a. Switching to Root&lt;/h3&gt;
&lt;p&gt;We need root permissions to install the packages, else you will get a permission denied error.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2b-installing-gcc-and-make&quot;&gt;Step 2b. Installing gcc and make:&lt;/h3&gt;
&lt;p&gt;Since the ubuntu bash shell is almost empty and has no packages like &lt;code class=&quot;highlighter-pygments&quot;&gt;gcc&lt;/code&gt; and &lt;code class=&quot;highlighter-pygments&quot;&gt;make&lt;/code&gt; installed, we will install gcc and make.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;apt-get update
apt-get install gcc
apt-get install make&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2c-installing-ruby-from-brightbox-recommended-method&quot;&gt;Step 2c. Installing Ruby from Brightbox [Recommended Method]:&lt;/h3&gt;
&lt;p&gt;We will need &lt;code class=&quot;highlighter-pygments&quot;&gt;ruby&lt;/code&gt; and &lt;code class=&quot;highlighter-pygments&quot;&gt;ruby-dev&lt;/code&gt; package to compile and build the Jekyll code and its dependencies. 
The reason why we need &lt;code class=&quot;highlighter-pygments&quot;&gt;ruby-dev&lt;/code&gt; is because some Jekyll dependencies are just source files, which need to be compiled into binaries/executables.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;apt-get install software-properties-common
apt-add-repository ppa:brightbox/ruby-ng
apt-get update
apt-get install ruby2.3 ruby2.3-dev&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2c-installing-ruby-alternate-method&quot;&gt;Step 2c. Installing Ruby [Alternate Method]:&lt;/h3&gt;
&lt;p&gt;Make sure the &lt;code class=&quot;highlighter-pygments&quot;&gt;ruby&lt;/code&gt; version is at least 2.0 as &lt;code class=&quot;highlighter-pygments&quot;&gt;jekyll&lt;/code&gt; requires a minimum &lt;code class=&quot;highlighter-pygments&quot;&gt;ruby&lt;/code&gt; version 2.0. The current latest stable release is 2.3.1.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;apt-get install ruby
apt-get install ruby-dev&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2d-setting-the-ruby-version&quot;&gt;Step 2d. Setting the Ruby version:&lt;/h3&gt;
&lt;p&gt;Just to be sure, change the default Ruby version to 2.3, we can switch the default Ruby version using the &lt;code class=&quot;highlighter-pygments&quot;&gt;ruby-switch&lt;/code&gt; tool.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;apt-get install ruby-switch
ruby-switch &lt;span class=&quot;nt&quot;&gt;--set&lt;/span&gt; ruby2.3
ruby &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2e-installing-bundler&quot;&gt;Step 2e. Installing Bundler:&lt;/h3&gt;
&lt;p&gt;&lt;code class=&quot;highlighter-pygments&quot;&gt;Bundler&lt;/code&gt; is an easy way to track and install the required and dependent gems which will make our life easier, therefore it is a good time now to install bundler.
Once installation completes check the version using the -v flag.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem install bundler
bundler &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-2f-installing-jekyll&quot;&gt;Step 2f. Installing Jekyll:&lt;/h3&gt;
&lt;p&gt;Even though Jekyll is not supported officially on Windows, it is fully supported on Linux, therefore we will take advantage of that. 
To install Jekyll run the following command and it will install all &lt;code class=&quot;highlighter-pygments&quot;&gt;jekyll&lt;/code&gt; and its dependencies. 
Once installation completes check the version using the -v flag.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;gem install jekyll
jekyll &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-3-building-and-serving-website&quot;&gt;Step 3. Building and serving website&lt;/h2&gt;
&lt;p&gt;Extract the zip file you downloaded in step 1 and go to the download location from the bash shell.
All the local drives are present in the &lt;code class=&quot;highlighter-pygments&quot;&gt;/mnt/&lt;/code&gt; folder.&lt;br /&gt;
For example:&lt;br /&gt;
Windows Location: &lt;code class=&quot;highlighter-pygments&quot;&gt;D:\emerald-master\emerald-master&lt;/code&gt; &lt;br /&gt;
Bash Location: &lt;code class=&quot;highlighter-pygments&quot;&gt;/mnt/d/emerald-master/emerald-master &lt;/code&gt; &lt;br /&gt;&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /mnt/d/emerald-master/emerald-master&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-3a-configuring-the-_configyml-file&quot;&gt;Step 3a. Configuring the _config.yml file:&lt;/h3&gt;
&lt;p&gt;Open up any text editor and edit the &lt;code class=&quot;highlighter-pygments&quot;&gt;_config.yml&lt;/code&gt; file before we start building.
Add the following line in the build settings “gems: [jekyll-paginate]”.
&lt;code class=&quot;highlighter-pygments&quot;&gt;jekyll-paginate&lt;/code&gt; is a plugin which helps us in displaying the posts into a smaller list of posts on the main page.
After adding the line your build setting will look something like this.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;c1&quot;&gt;# Build settings&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;baseurl&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/emerald/&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# Change this to your relative path (ex: /blog/), or leave just a /&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;markdown&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;kramdown&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;destination&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;./_site&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;permalink&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/:title&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;paginate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;8&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;paginate_path&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;/page:num/&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;gems&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;jekyll-paginate&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;]&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-3b-building-and-serving-the-website-locally&quot;&gt;Step 3b. Building and serving the website locally:&lt;/h3&gt;
&lt;p&gt;Navigate to the root of your source code folder containing the  &lt;code class=&quot;highlighter-pygments&quot;&gt;_config.yml&lt;/code&gt; to build and serve the website and execute the following command.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;jekyll serve&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Jekyll monitors your source code and regenerates files on the fly by default.
This is termed as watching the source folder for any changes, and in some cases, Jekyll might fail to watch when you try to serve your website.
If you get an error similar to &lt;code class=&quot;highlighter-pygments&quot;&gt;&quot;Error:  Invalid argument - Failed to watch&quot;&lt;/code&gt;,  just execute the following command and would resolve your issue.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;jekyll serve &lt;span class=&quot;nt&quot;&gt;--force_polling&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If in some cases it still fails to watch, just serve the website using the &lt;code class=&quot;highlighter-pygments&quot;&gt;--no-watch&lt;/code&gt; flag, which essentially means you will have to build and serve every time you make a change.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;jekyll serve &lt;span class=&quot;nt&quot;&gt;--no-watch&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;step-3c-opening-the-website-locally&quot;&gt;Step 3c. Opening the website locally:&lt;/h3&gt;
&lt;p&gt;Once the build and serve are completed in step 3b, you should get an output similar to the one given below. There are 3 main elements to look out for&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-pygments&quot;&gt;Configuration file&lt;/code&gt;:  This tells us the configuration file used. Make sure the correct file is used.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-pygments&quot;&gt;Destination&lt;/code&gt;:  This tells us the output folder, in which the source code is built into.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-pygments&quot;&gt;Server address&lt;/code&gt;:  This tells us the local address of the website, which we can use to visit our website hosted on a local server.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Go to the server address &lt;code class=&quot;highlighter-pygments&quot;&gt;http://127.0.0.1:4000/emerald/&lt;/code&gt; to see your website.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;Configuration file: /mnt/d/emerald-master/emerald-master/_config.yml
Source: &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
Destination: ./_site
Incremental build: disabled. Enable with &lt;span class=&quot;nt&quot;&gt;--incremental&lt;/span&gt;
Generating...
                    &lt;span class=&quot;k&quot;&gt;done in &lt;/span&gt;0.744 seconds.
Auto-regeneration: enabled &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'.'&lt;/span&gt;
Configuration file: /mnt/d/emerald-master/emerald-master/_config.yml
Server address: http://127.0.0.1:4000/emerald/
Server running... press ctrl-c to stop.&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-4-hosting-and-uploading-the-website-on-githubio&quot;&gt;Step 4. Hosting and uploading the website on Github.io&lt;/h2&gt;
&lt;p&gt;After you have setup and tested everything locally, the next part is setting up a GitHub repository with the &lt;code class=&quot;highlighter-pygments&quot;&gt;username.github.io&lt;/code&gt;, where username is your username on GitHub. Be very careful to make sure the username is correct, as a mismatching username will not work.  Once a new repository is created online, we will upload the site that we have built locally onto the repository &lt;code class=&quot;highlighter-pygments&quot;&gt;username.github.io&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;step-4a-setup-and-push-your-code-to-github-repo-usernamegithubio&quot;&gt;Step 4a. Setup and push your code to GitHub repo username.github.io:&lt;/h3&gt;
&lt;p&gt;Note the destination folder in step 3c, the default destination folder is &lt;code class=&quot;highlighter-pygments&quot;&gt;_site&lt;/code&gt;.
From your root source folder, navigate into the &lt;code class=&quot;highlighter-pygments&quot;&gt;_site&lt;/code&gt; folder, initialize a new git repository, commit the change and push them to 
repository &lt;code class=&quot;highlighter-pygments&quot;&gt;username.github.io&lt;/code&gt;. GitHub gives the option of hosting your markdown code in the master branch and static website 
code in the gh-pages branch. In our case we will be hosting just the static website code on the master branch, rather than two seperate branches.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;_site/
apt-get install git
git init
git add &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;initial commit&quot;&lt;/span&gt;
git remote add origin https://github.com/username/username.github.io.git
git push &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; origin master&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;step-5-final-check&quot;&gt;Step 5. Final check&lt;/h2&gt;
&lt;p&gt;Once your code is successfully pushed, you can go to the repository settings and confirm everything is working correctly.
&lt;code class=&quot;highlighter-pygments&quot;&gt;https://github.com/username/username.github.io/settings&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Go to &lt;code class=&quot;highlighter-pygments&quot;&gt;https://username.github.io/&lt;/code&gt; to see your website in action.&lt;/p&gt;

&lt;p&gt;Making changes and updating the website:
Repeat step 3b , 3c, 4  and 5
For step 4 repeat only&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;git add &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;initial commit&quot;&lt;/span&gt;
git remote add origin https://github.com/username/username.github.io.git
git push &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; origin master&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;final-note&quot;&gt;Final note&lt;/h2&gt;
&lt;p&gt;If you still face any problems or have any questions, feel free to leave a comment and I will be happy to help. Cheers :)&lt;/p&gt;

&lt;p&gt;Check out the links below for detailed information: &lt;br /&gt;
&lt;a href=&quot;http://daverupert.com/2016/04/jekyll-on-windows-with-bash/&quot;&gt;Jekyll on Bash on Ubuntu on Windows&lt;/a&gt; &lt;br /&gt;
&lt;a href=&quot;http://jekyll-windows.juthilo.com&quot;&gt;Run Jekyll on Windows&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Fri, 05 Aug 2016 14:19:52 -0700</pubDate>
        <link>http://localhost:4000/blog/2016/setup-jekyll-blog-windows-10-bash-host-github-pages/</link>
        <guid isPermaLink="true">http://localhost:4000/blog/2016/setup-jekyll-blog-windows-10-bash-host-github-pages/</guid>
        
        
        <category>GitHub</category>
        
      </item>
    
  </channel>
</rss>
