<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Welcome to Saurabh Kirtani's blog!</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/saurabhkirtani/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/saurabhkirtani/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:27:19 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Game development: Getting started guide with Unity</title>
      <link>https://docs.microsoft.com/archive/blogs/saurabhkirtani/game-development-getting-started-guide-with-unity</link>
      <pubDate>Thu, 19 May 2016 05:01:28 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Kirtani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/saurabhkirtani/?p=176</guid>
      <description><![CDATA[At multiple occasions, I encounter developers who want to get started with game development. As is...]]></description>
      <content:encoded><![CDATA[<p>At multiple occasions, I encounter developers who want to get started with game development. As is the case, a lot of them love Unity when I tell them about it. So, here’s a getting started guide for anyone looking to get started with Unity.  <p>&nbsp; <h4>Get to know the Unity IDE:</h4> <p>This is the environment you will work mostly in. Spend some time getting to know it better.  <p><a href="https://msdnshared.blob.core.windows.net/media/2016/05/unity-ide.png"><img title="unity ide" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="unity ide" src="https://msdnshared.blob.core.windows.net/media/2016/05/unity-ide_thumb.png" width="614" height="329"></a>  <p>Here, you can see the Scene view, Game view, Hierarchy, Project, Inspector and other toolbars. You can change the current layout of these multiple windows by choosing from the Layout dropdown at the top right. Unity has given a good short description of each of these in their official video. <a href="https://unity3d.com/learn/tutorials/modules/beginner/editor/interface-overview?playlist=17090" target="_blank">Head over here</a>. Remember, everything in Unity will be built in multiple scenes. A Scene file is akin to a unique level in your game. <a href="https://docs.unity3d.com/Manual/CreatingScenes.html" target="_blank">Head over here</a> to learn more. Here I have 2 scenes – 001 and 002. <p><a href="https://msdnshared.blob.core.windows.net/media/2016/05/scene.png"><img title="scene" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="scene" src="https://msdnshared.blob.core.windows.net/media/2016/05/scene_thumb.png" width="244" height="102"></a>  <h4>&nbsp;</h4> <h4>Some terminology in Unity:</h4> <p>Learn these terms to get started – <a href="https://unity3d.com/learn/tutorials/modules/beginner/editor/game-objects-and-components?playlist=17090" target="_blank">GameObjects and Components</a>, <a href="https://unity3d.com/learn/tutorials/modules/beginner/editor/prefabs-concept-usage?playlist=17090" target="_blank">Prefabs</a>, <a href="https://unity3d.com/learn/tutorials/modules/beginner/graphics/textures" target="_blank">Textures</a> , <a href="https://unity3d.com/learn/tutorials/modules/beginner/2d/sprite-type" target="_blank">Sprites</a>, <a href="https://unity3d.com/learn/tutorials/modules/intermediate/layers?playlist=17090" target="_blank">Layers</a>.  <p>&nbsp; <h4>Adding Physics to objects is easy:</h4> <p>Unity has 3D and 2D physics and animation systems built into it - which means adding physics and animations to objects is easy. Usually, you will use 2 Physics components on your character/environment: <br>(i) something which gives mass and allows objects to be under influence of gravity (RigidBody/RigidBody2D) – and if you’re giving a body mass, you would want it to interact with the environment, or want it to walk on the surface – hence, you need the body and the environment to interact with each other through a collision <em>(even if you just want a character to walk on a floor, you need to ensure that the character and the floor are colliding with each other)</em>. This collider is the 2<sup>nd</sup> part <br>(ii) A collider which tells Unity the region to detect collisions (for example, a Box collider 2D)  <p>For collisions that shouldn’t use physics engine, like picking up a coin – you can use something called isTrigger in the Unity IDE to mark it that way.  <p>&nbsp; <h4>Changes made to a game view do NOT persist: </h4> <p>This is something that new game developers on Unity need to remember very well. Usually, we make changes when the game is in Play mode (when you click the Play sign). However, any change made to the Scene view in Play mode will not persist once you stop the game – hence, all the changes will be lost. Stop the game, make the changes to the scene and you’re good to go. I’ve seen some developers who change the color of the Unity editor background to a complete contrast when the game is in play mode, just so that they know that they are NOT supposed to make the changes to the Scene at that time.  <p>&nbsp; <h4>Build for multiple platforms using Unity:</h4> <p>This is the utility of using Unity – you can target multiple platforms like iOS, Android, Windows 10 devices, Virtual Reality and Augmented Reality platforms like Microsoft Hololens and Oculus VR, Console gaming platforms like Xbox One and PS4, Smart TV and WebGL.  <p>&nbsp; <h4>Use the Asset store:</h4> <p>It’s a store consisting of a lot of free and commercial assets that you can use in your Unity project, which have been built by the Unity team and the community around Unity. You can find and download textures, animations, project examples, etc on the store. You can access the Asset store from within Unity by going to Windows -&gt; Asset Store. It will ask you to create a free user account on your first visit.  <p>&nbsp; <h4>Use these resources to learn on Unity:</h4> <p>If you’re starting with Unity, it may seem to be a lot to digest on your first visit. However, there are excellent resources to learn more, supported by an active community, which can help you in building your first game:  <p>o Unity official documentation is an excellent source to learn features of Unity. They have short videos to explain particular concepts of Unity. Head over here: <a href="https://unity3d.com/learn">https://unity3d.com/learn</a>  <p>o Free course on Unity: <a href="https://mva.microsoft.com/training-courses/developing-2d-3d-games-with-unity-for-windows-jump-start">https://mva.microsoft.com/training-courses/developing-2d-3d-games-with-unity-for-windows-jump-start</a> (Especially Module 2 - where you can build your first 2D game. Scripts and assets for this module are here: <a href="https://github.com/TobiahZ/10th-Planet">https://github.com/TobiahZ/10th-Planet</a>)  <p>o <a href="https://aka.ms/codelabs">https://aka.ms/codelabs</a>  <p>o <a href="https://channel9.msdn.com/coding4fun/blog/Learning-Unity-3D">https://channel9.msdn.com/coding4fun/blog/Learning-Unity-3D</a>  <p>o <a href="https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Build-A-Unity-Game-Part-1">https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Build-A-Unity-Game-Part-1</a>  <p>o Courses on Pluralsight like this: <a href="https://www.pluralsight.com/courses/introduction-game-development-unity">https://www.pluralsight.com/courses/introduction-game-development-unity</a> (requires Pluralsight subscription)  <p>&nbsp; <p>Have fun building games!  <p>Until next time,  <p>Saurabh Kirtani  <p><a href="https://twitter.com/saurabhkirtani" target="_blank">@saurabhkirtani</a>]]></content:encoded>
    </item>
    <item>
      <title>Microsoft Bot Framework: Welcoming the bots!</title>
      <link>https://docs.microsoft.com/archive/blogs/saurabhkirtani/microsoft-bot-framework-welcoming-the-bots</link>
      <pubDate>Tue, 03 May 2016 14:40:16 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Kirtani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/saurabhkirtani/?p=135</guid>
      <description><![CDATA[Interacting via bots has been around for some time now, and it’s finding its takers day-by-day. The...]]></description>
      <content:encoded><![CDATA[Interacting via bots has been around for some time now, and it’s finding its takers day-by-day. The bots are available across the messaging channels we’re already using – like Skype, Facebook Messenger, Telegram, etc. and this is one of the primary reasons for their increase in popularity. As a business owner, you could easily target the platforms your users are already on, to interact with them directly. Some bots are easy – like the one in ‘getting started’ <a href="https://docs.botframework.com/connector/getstarted/" target="_blank">guide</a>, and some are complex – like the <a href="https://github.com/Microsoft/BotBuilder/tree/master/CSharp/Samples/PizzaBot" target="_blank">Pizza bot</a> which was shown on the main Build stage.

We launched a new platform – the Bot Framework at Build 2016. It’s our first step towards building and connecting Bots across popular messaging services and mainstreaming ‘<strong>Conversations as a Platform</strong>’. At its core, the Bot Framework has 3 components:
<ol>
	<li>Bot Connector</li>
	<li>Bot Builder SDKs</li>
	<li>Bot Directory</li>
</ol>
Bot Connector lets you connect your bot <em>(the one which you have already, or the one you will build using the Bot Builder SDK)</em> to popular messaging services like Skype, Telegram, Slack, Facebook Messenger, GroupMe, text message, Office 365 email, web chat control, or your custom client (using Direct Line). There is a simple process to configure and register your bot in the bot framework portal and you’re good to go.

Bot Builder SDKs are open-sourced SDKs available for C# and Node.js, which help you build great bots.

Bot Directory is a public directory of all the bots registered through the Bot Connector – note that the directory is not available just yet – it will come soon. Once it is live, users will have one place to discover and add bots to the messaging platform of their choice. As of today, a <a href="https://bots.botframework.com/" target="_blank">few bots</a> from Build are available.

I recently played with the Bot Framework and published the bot to Telegram – I was amazed by how easy it was to get started with building a bot. Here is the process I followed:
<ul>
	<li>Follow the steps on <a href="https://docs.botframework.com/connector/getstarted/">https://docs.botframework.com/connector/getstarted/</a></li>
	<li>Publish the bot to Telegram – configuration steps are given when you sign in to the Bot Framework portal, register your bot and add the channel as Telegram.</li>
</ul>
That’s it! Give this bot a try on your Telegram app. Open the app and search for <strong>@botframework_bot </strong><em>(Or directly go here from your mobile browser <a href="https://telegram.me/botframework_bot">https://telegram.me/botframework_bot</a>)</em><strong>. </strong>Send some data to the bot and it will return the number of characters. This is a simple bot, but usually, defining the logic of your bot is the most complex part in the entire process.

One thing to note about the Bot Framework is that it does not give you a way for user authentication within the bot (as of today). It means if you want to retrieve information about the user by asking for his username and password for a particular service – you can’t do that directly in the interaction with the bot within the current messaging platform. This is how you can do it for now:
<ol>
	<li>Generate an authentication URL and send it to your user via the bot. Ask him to login to the service using the URL.</li>
	<li>Once the user logs in, set up the server so that it would receive the result of that authentication (your API for the bot is now aware of the result) and if successful, you can show the relevant data to the user through the bot.</li>
</ol>
&nbsp;

The <strong>Bot Directory</strong> currently has some bots published from Build. The list is available at <a href="https://bots.botframework.com/">https://bots.botframework.com/</a>. One of the bots among them was MurphyBot – which you can add to Skype and ask interesting ‘What If’ questions. Here's an interesting reply:

[caption id="attachment_145" align="alignleft" width="919"]<a href="https://msdnshared.blob.core.windows.net/media/2016/05/bot1.png"><img class="wp-image-145 size-full" src="https://msdnshared.blob.core.windows.net/media/2016/05/bot1.png" alt="What if I was Virat Kohli?" width="919" height="401" /></a> Murphy Bot[/caption]

&nbsp;

Looks good, doesn’t it? I am sure Virat would agree.

Have fun with bots :)

Until next time,
Saurabh Kirtani
Twitter: <a href="https://twitter.com/saurabhkirtani" target="_blank">@saurabhkirtani</a>]]></content:encoded>
    </item>
    <item>
      <title>It’s time to //Build/!</title>
      <link>https://docs.microsoft.com/archive/blogs/saurabhkirtani/its-time-to-build</link>
      <pubDate>Tue, 05 Apr 2016 15:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Kirtani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/saurabhkirtani/?p=131</guid>
      <description><![CDATA[It’s amazing how technology has been transforming our lives. Sit back for a moment and think about...]]></description>
      <content:encoded><![CDATA[<p align="justify">It’s amazing how technology has been transforming our lives. Sit back for a moment and think about it – how you yourself have been impacted by the numerous tech innovations. And yet, there is something new to always explore – something fascinating, that can help people achieve more.</p> <p align="justify">With so many developers building ‘what’s next’, Microsoft showcased to the developers what it’s been doing behind its office doors at its annual conference – Build 2016.</p> <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/2016/04/image147.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2016/04/image_thumb132.png" width="296" height="199"></a></p> <p align="justify">This conference was spread across 3 days from 30 March – 1 April in San Francisco. The keynote on the first day focused on personal computing driven by Windows. The second day’s keynote focused on how we are building the intelligent cloud with Azure and how customers are using it in production. In addition, we talked about how Office 365 is helping improve productivity all the time. In this blog, I’ll cover some announcements made on the first day.</p> <p align="justify">Windows 10 is being actively used by over 270 million people – think it over, that’s huge! And still we have time to achieve our 1 Billion goal. We announced about a major update coming to Windows 10 – the <b>Anniversary Update</b> coming this summer for free. There was a special callout, deservedly so, to all the Windows Insiders, who have been instrumental in giving us feedback and shaping our roadmap for Windows 10. These are the folks who’ve opted in to receive preview builds and give us feedback to shape the future of Windows. If you’re interested to join this program and help us build for the future, head over to <a href="https://insider.windows.com/">https://insider.windows.com/</a>.</p> <p align="justify">Coming to the Anniversary Update, here are a few important updates:</p> <ul> <li> <div align="justify">Windows Hello (our biometric authentication to log-on to devices) will be available to be used as an authentication mechanism for Windows apps and all the supporting websites running on Microsoft Edge. So you can log in to such websites using your face, or fingerprint! </div> <li> <div align="justify">Introduction of <b>Windows Ink</b> – an all-new experience which attempts to make writing on a device just as writing on a paper, maybe better. This is already integrated into apps like Maps, Office and Microsoft Edge. So, with Windows Ink, you can use the virtual ruler: </div></li></ul> <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/2016/04/clip_image0026.jpg"><img title="clip_image002" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2016/04/clip_image002_thumb6.jpg" width="244" height="180"></a></p> <p align="justify">... or, simply use your pen to delete sentences from Word. Just cross them using Ink and the sentences will be gone.</p> <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/2016/04/clip_image0044.jpg"><img title="clip_image004" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="clip_image004" src="https://msdnshared.blob.core.windows.net/media/2016/04/clip_image004_thumb4.jpg" width="249" height="165"></a></p> <p align="justify"><a href="https://blogs.windows.com/windowsexperience/2016/03/30/the-future-of-pen-windows-ink/" target="_blank">Head over here</a> to learn more.</p> <p align="justify">- We released <b>Visual Studio 2015 Update 2</b> and the <b>Anniversary SDK preview</b>. This includes some exciting new features like Action Center in the cloud (so, as an example, you can now dismiss notifications on one device and they will be dismissed on all your synced devices), App Extensions (Microsoft Edge uses this technology for its own extensions – that’s a news too), improved background execution of apps, etc. <a href="https://blogs.windows.com/buildingapps/2016/03/30/windows-10-anniversary-sdk-is-bringing-exciting-opportunities-to-developers/" target="_blank">Head over here</a> to learn more.</p> <p align="justify">- We wanted to make Windows as a home for your development. To make this one step closer, <strong>the Bash shell is coming to Windows!</strong> This was among the biggest announcements we made. Native Ubuntu Linux binaries running on Windows through a new Windows subsystem. This was made possible because of our partnership with Canonical. The developers will be able to download the Bash shell from the Windows Store. So, all the developers who wanted more support for relevant command line tools, you’ve got this on Windows with Bash! And all of this is made possible because of ‘your’ feedback on <a href="https://wpdev.uservoice.com/" target="_blank">uservoice</a>. Check out this <a href="https://channel9.msdn.com/Events/Build/2016/P488" target="_blank">Build session here</a> to learn more.</p> <p align="justify">- There’s good news for all the Win32 and .NET developers who are looking to convert their desktop app to a UWP app (using Project Centennial). We shipped a <b>desktop app converter</b> which will help in the process. The code continues to run with minimal changes. This is our way of making it easy to bring <b>16+ million</b> Win32/.NET apps to the Universal Windows Platform. <a href="https://developer.microsoft.com/en-us/windows/bridges/desktop" target="_blank">Head over here</a> to see how you can use it.</p> <p align="justify">- With Windows 10 Anniversary update, background music and Cortana is coming to Xbox One. So, Cortana can now become your gaming assistant! Support for multiple GPUs is also arriving! We launched <b>Xbox Dev Mode</b>, where you can convert your retail Xbox One to be a developer kit. <a href="https://news.xbox.com/2016/03/30/xbox-at-build-2016/" target="_blank">Head over here</a> for all details.</p> <p align="justify">- We already have nearly 1000 apps using voice commands with Cortana. Now, you can <b>integrate actions within your apps</b> to drive more engagement. <a href="https://developer.microsoft.com/en-us/Cortana" target="_blank">Head over here</a> to request access to beta.</p> <p align="justify"><b>- Microsoft Hololens Development Edition is now shipping</b> to developers! We showed off another cool demo of Hololens on stage.</p> <p align="justify">[embed]https://www.youtube.com/watch?v=mM1P41qeVGs[/embed]</p> <p align="justify">So folks, this was a short recap of some of the announcements made on Build Day 1 with relevant links to get started. Next up will be a discussion on ‘Conversations as a Platform’ – where we will talk about the possibilities that can exist with <strong>bots</strong>. Stay tuned.</p> <p align="justify">Until next time,</p> <p align="justify">Saurabh Kirtani</p> <p align="justify"><a href="https://twitter.com/saurabhkirtani" target="_blank">@saurabhkirtani</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Responsive images on the web: how to build with srcset, sizes and picture</title>
      <link>https://docs.microsoft.com/archive/blogs/saurabhkirtani/responsive-images-on-the-web-how-to-build-with-srcset-sizes-and-picture</link>
      <pubDate>Tue, 24 Nov 2015 00:30:00 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Kirtani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/saurabhkirtani/2015/11/24/responsive-images-on-the-web-how-to-build-with-srcset-sizes-and-picture/</guid>
      <description><![CDATA[I recently wrote an article on how to use responsive images on the web, using srcset, sizes and...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small;">I recently wrote an article on how to use responsive images on the web, using srcset, sizes and picture. Responsive images are now supported by lots of browsers, including Microsoft Edge (starting Windows Insider Build 10547), and it is highly recommended to start using them on your website, if you haven&rsquo;t yet.&nbsp;This is how the article begins:<br /><br /></span></p>
<p style="padding-left: 30px;"><span style="font-size: small;"><em>In this connected world where people have a variety of devices, ensuring your website works seamlessly across all of them is a need, not an option. Your website views won&rsquo;t come from a single resolution device, or a single form-factor. To cater to all of them, your website needs to be responsive.</em></span><br /><br /><span style="font-size: small;"><em>If you&rsquo;re familiar with responsive web design (RWD), you probably know the intricacies that come with a responsive design (and how Bootstrap solves a lot of them!). An important part &hellip; <a href="https://www.codeproject.com/Articles/1053341/Responsive-Images-on-the-Web-How-to-build-with-src">read more</a> </em></span></p>
<p><span style="font-size: small;"><br />The article was published on <a href="https://www.codeproject.com/Articles/1053341/Responsive-Images-on-the-Web-How-to-build-with-src">CodeProject</a> and <a href="https://www.sitepoint.com/how-to-build-responsive-images-with-srcset/">SitePoint</a>. Feel free to read through it, including some self-made stick figures towards the end ;).</span></p>
<p><span style="font-size: small;">Also, reach out to me on Twitter <a href="https://twitter.com/saurabhkirtani">@saurabhkirtani</a> to discuss more on the topic.</span></p>
<p><span style="font-size: small;">Until next time,<br />Saurabh Kirtani</span></p>]]></content:encoded>
    </item>
    <item>
      <title>My experience of the conference: Open Source India 2015</title>
      <link>https://docs.microsoft.com/archive/blogs/saurabhkirtani/my-experience-of-the-conference-open-source-india-2015</link>
      <pubDate>Sun, 22 Nov 2015 23:40:00 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Kirtani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/saurabhkirtani/2015/11/22/my-experience-of-the-conference-open-source-india-2015/</guid>
      <description><![CDATA[Hello,I wanted to share my experience of a conference which I was recently a part of :&nbsp;Open...]]></description>
      <content:encoded><![CDATA[<p>Hello,<br /><br />I wanted to share my experience of a conference which I was recently a part of :&nbsp;Open Source India (aka OSI Days) - and as the name suggests, this is a conference where the open source enthusiasts come together, and discuss ideas and knowledge with each other. Check out their website (<a href="https://www.osidays.com">www.osidays.com</a>) to know much more.<br /><br />I was wearing&nbsp;three hats at the conference - of an attendee, a speaker, and a proctor for some HOLs. And what a power-packed two days it were!<br /><br />My talk was on IoT &ndash; the topic was &lsquo;Build your IoT solutions powered by Python and cloud&rsquo;, and&nbsp;the abstract can be found <a title="here" href="https://osidays.com/osidays/speaker-lineup/saurabh-kirtani/">here</a>. I took the Sparkfun weather shield and captured the temperature, humidity and the light level in the room. I accessed this data on the serial monitor of the Arduino Uno, and sent this to Raspberry Pi 2. Once this data was captured, I showed how it was possible to push the data to Azure (Events Hub) from Raspberry Pi 2 (running Raspbian) using Python. Once this data was captured, we then saw how to use Stream Analytics to start analyzing the data coming in real-time from Events Hub. All in all &ndash; a quick demo of how you can get started with building IoT solutions. I hope the attendees found it useful. The session was probably recorded and I will update the blog with the link once the video is up. Also, feel free to join <a href="https://www.facebook.com/groups/IoTCommunity/">this</a> group to discuss more on IoT.<br /><br />Most of my time was spent at the Microsoft booth. Here, we had some hands-on-labs for the attendees on Open Source technologies running on Azure, including Linux VMs on Azure, PHP web apps, Machine Learning, Stream Analytics, etc on Azure. There was not a single time when there wasn&rsquo;t a queue waiting to get inside the lab room &ndash; throughout the two days! This meant that I and my team had two good field days :). We saw people getting excited on running Machine Learning on Azure, SSH into a Linux VM hosted on Azure, create a Logic App connecting SaaS&nbsp;services,&nbsp;or even hosting a website. They saw hands-on how cloud can help them in their journey, and we hope this helped them realize the value of cloud.<br /><br />As an attendee, I got to attend some portion of a few sessions, and was impressed by the content being presented.&nbsp;All in all, we had a good two days interacting with open source enthusiasts.</p>
<p>Until next time,<br />Saurabh Kirtani<br /><br />Feel free to reach out to me on Twitter <a title="@saurabhkirtani" href="https://twitter.com/saurabhkirtani">@saurabhkirtani</a> to discuss anything&nbsp;about this blog.</p>]]></content:encoded>
    </item>
    <item>
      <title>My encounter with Redis Cache: getting inside session management using Azure Redis Cache.</title>
      <link>https://docs.microsoft.com/archive/blogs/saurabhkirtani/my-encounter-with-redis-cache-getting-inside-session-management-using-azure-redis-cache</link>
      <pubDate>Thu, 16 Jul 2015 02:35:00 GMT</pubDate>
      <dc:creator><![CDATA[Saurabh Kirtani]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/saurabhkirtani/2015/07/16/my-encounter-with-redis-cache-getting-inside-session-management-using-azure-redis-cache/</guid>
      <description><![CDATA[What is caching? There are some cool examples of caching in our day-to-day life. You keep milk in...]]></description>
      <content:encoded><![CDATA[<p>What is caching? There are some cool examples of caching in our day-to-day life. You keep milk in the refrigerator so that you don&rsquo;t need to go to the market every time you want to drink it &ndash; this is caching. You keep coins in your pocket so that you don&rsquo;t have to go to the ATM every time you have to spend cash &ndash; this is caching. In our technology world, we have different types of caching too.<br /><br />Redis. This is probably the most popular caching service around. And guess what, companies like Twitter, GitHub, StackOverflow, Instagram, Snapchat, Flickr are already using it in some form or the other. With all of this going around, why not take a quick lap and have a look at one small application of Redis?<br /><br />For the readers who are getting started, Redis is an open-source advanced key-value cache and store. The special thing about Redis is that the keys in Redis can contain not just strings, but hashes, lists, sets, etc. Their official website (<a href="https://redis.io/">redis.io</a>) has a ton of information if you want to read more. As some of you may know, Redis is a managed service on Azure. What this means is, Azure will give you ready-to-use features and services of Redis and you can plug-and-play them into your application. You get access to a secure, dedicated Redis cache and this is accessible from any application within Azure. <br /><br />In this blog, we are going to see a scenario&nbsp;where Redis can manage sessions for us. First of all, to setup Redis, we have some excellent resources in our official documentation. Just do a quick brief of it if you haven&rsquo;t already <a href="https://azure.microsoft.com/en-in/documentation/articles/cache-dotnet-how-to-use-azure-redis-cache/#_get-started-with-azure-redis-cache">here</a>. There&rsquo;s also an ASP.NET Session state provider for Azure Redis cache. It&rsquo;s very well documented <a href="https://msdn.microsoft.com/en-us/library/azure/dn690522.aspx">here</a>. <br />Let&rsquo;s take a look at what happens within the cache once the session variables are stored. For this demo, I&rsquo;m using a simple web page to start a session and display the person&rsquo;s name. The first page looks like:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/1200.p1.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/1200.p1.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/1200.p1.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/1200.p1.JPG" alt="" border="0" /></a></p>
<p>The first line displays the session ID, which is randomly generated by ASP.NET.</p>
<p>I&rsquo;ve edited my web.config to tell my application to use Azure Redis cache to store session variables. These are the few lines of code to be added:</p>
<pre class="scroll"><span style="font-size: small;"><code class="csharp">&lt;sessionState mode="Custom" customProvider="MySessionStateStore" timeout="10"&gt;<br /> &lt;providers&gt;<br /> &lt;add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="&lt;Enter your Azure Redis Cache endpoint here&gt;.redis.cache.windows.net" accessKey="&lt;Enter your access key here&gt;" /&gt;<br /> &lt;/providers&gt;<br /> &lt;/sessionState&gt;</code></span></pre>
<p>(Timeout has been set to 10 min for this demo)</p>
<p><br />The code behind for the first page (which I have simply named hello.aspx) is:</p>
<pre class="scroll"><span style="font-size: small;"><code class="cplusplus">protected void Page_Load(object sender, EventArgs e)<br /> {<br /> Label1.Text= Session.SessionID; // Displays the session ID.<br /> string name = Session["name"] as string;<br /> if (name != null)<br /> Response.Redirect("welcome.aspx");<br /> }<br /> <br /> protected void nameText_TextChanged(object sender, EventArgs e) //Method to be called when we enter the name in the textbox<br /> {<br /> Session["name"] = TextBox1.Text; //We store the name in the session variable Session[&ldquo;name&rdquo;]<br /> }<br /> <br /> protected void enterButton_Click(object sender, EventArgs e) //Method to be called when we click the Enter button<br /> {<br /> string name = Session["name"] as string;<br /> if (name != null)<br /> { <br /> Label2.Text = "Welcome " + name;<br /> Response.Redirect("welcome.aspx");<br /> }<br /> else<br /> Label2.Text = "Nothing entered";<br /> }<br /> </code></span></pre>
<p>This is a straightforward piece of code. As the web page loads, I initiate my connection to Azure Redis cache through Azure client. This is achieved by using azure-cli.exe in admin mode. Have a look at <a href="https://azure.microsoft.com/blog/2014/06/04/lap-around-azure-redis-cache-preview/">this</a> and&nbsp;<a href="https://msopentech.com/opentech-projects/redis/">this</a> to know how it&rsquo;s done. <br />Once this setup is done, we set two keys &ndash; key1 and key2 and view them. So, currently, there are 2 key-value pairs in the cache. (all the commands used here are very well documented on redis.io)</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/4314.p2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/4314.p2.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/4314.p2.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/4314.p2.png" alt="" border="0" /></a></p>
<p>Now, as soon as I enter my name and press Enter, the welcome page loads up.<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/5355.p3.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/5355.p3.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/5355.p3.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/5355.p3.JPG" alt="" border="0" /></a></p>
<p>&nbsp;</p>
<p>The cache is now populated with a new key-value pair:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/2134.p4.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/2134.p4.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/2134.p4.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/2134.p4.JPG" alt="" border="0" /></a></p>
<p>Let&rsquo;s see what this new entry is made of. To find out the type of key, I just enter a simple Redis command &ndash; <em>type &lt;key name&gt;</em></p>
<p><em><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/8838.p5.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/8838.p5.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/8838.p5.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/8838.p5.JPG" alt="" border="0" /></a></em></p>
<p>And this comes out as a hash type! A hash holds field-value pairs.</p>
<p>Let&rsquo;s play around with some hash commands now.</p>
<ul>
<li>hkeys: This displays all the field names in the hash stored at the key we mention.<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/0474.p6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/0474.p6.png"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/0474.p6.png" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/0474.p6.png" alt="" border="0" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/2043.p6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/2043.p6.png"><br /></a>
<p>As it shows, we only have one field right now, which is the &ldquo;name&rdquo;. If you go back to the code behind (hello.aspx), we had initiated Session[&ldquo;name&rdquo;] &ndash; this is where the field comes from.</p>
</li>
<li>
<p>hget: Let&rsquo;s try to get the value associated with this field. The command used for that is hget.<br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/7827.p7.JPG" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/7827.p7.JPG"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/7827.p7.JPG" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/7827.p7.JPG" alt="" border="0" /></a><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/72/06/3718.p7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-72-06/3718.p7.png"><br /></a>And something familiar comes up &ndash; the name we entered is stored in the value of this field.</p>
</li>
</ul>
<p>&nbsp;</p>
<p>Once 10 minutes are over, the session is completed (we had set the timeout as 10) and now if we try to refresh the Welcome page, it redirects to the home page.</p>
<p><br />This pretty much sums up the small application of Redis cache.</p>
<p>So, to summarize,</p>
<ul>
<li>Session variables are stored in a hash type.</li>
<li>The key is of type string. The value of that key is of type hash which has field-value pairs.</li>
<li>The field holds the parameters we had passed during programming (say we stored the name in session[&ldquo;name&rdquo;] - the field holds the string &ldquo;name&rdquo;). The value of that field holds the name we had passed through the website in the textbox for name.</li>
</ul>
<p>Hope you guys had fun reading this!</p>
<p><br />Until next time,<br />Saurabh Kirtani<br /><a href="https://twitter.com/saurabhkirtani">@saurabhkirtani</a></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
  </channel>
</rss>