<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
        <title>Wade Wegner</title>
        <description>Wade Wegner - </description>
        <link>/rss.xml</link>
        <lastBuildDate>Mon, 05 Feb 2018 14:18:19 +0000</lastBuildDate>
        <pubDate>Mon, 05 Feb 2018 14:18:19 +0000</pubDate>
        <ttl>1800</ttl>


        <item>
                <title>Build a Native Mobile App Using Salesforce DX and the Mobile SDK</title>
                <description>&lt;p&gt;This week I had the opportunity to demo how developers can combine project-based app development with Salesforce DX, the Salesforce CLI, Scratch Orgs, and the Mobile SDK to make – at least, in my humble opinion – a pretty compelling native app dev experience with Salesforce. In this post I’ll share some of the things I did with the hope that, after you look at it, you’ll want to try it out too.&lt;/p&gt;

&lt;h3 id=&quot;setup-the-cli-plugin-for-the-mobile-sdk&quot;&gt;Setup the CLI Plugin for the Mobile SDK&lt;/h3&gt;

&lt;p&gt;Did you know the Salesforce Mobile team created a CLI plugin? Oh yes they did!&lt;/p&gt;

&lt;p&gt;To install it, run the following command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx plugins:install sfdx-mobilesdk-plugin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now if you run &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx mobilesdk --help&lt;/code&gt; you’ll see all the SDK commands are available.&lt;/p&gt;

&lt;p&gt;In case you’re wondering, these commands are no different than the &lt;code class=&quot;highlighter-rouge&quot;&gt;forceios&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;forcedriod&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;forcehybrid&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;forcereact&lt;/code&gt; commands. This plugin is simply a wrapper to include all these commands in a single CLI. A big improvement, in my opinion.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Note: If you’re interested in learning details about the mobile SDK, I suggest you take a look at the &lt;a href=&quot;https://trailhead.salesforce.com/en/trails/mobile_sdk_intro&quot;&gt;Develop with Mobile SDK&lt;/a&gt; Trail. I’m not going to get into details about how it operates and how to set it up. These modules can do a much better job.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;setup-your-workspace&quot;&gt;Setup Your Workspace&lt;/h3&gt;

&lt;p&gt;Lots of ways you can approach this. Here’s my recommendation:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;myproject/
├── force
└── mobile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Yes, looks simple. Don’t worry, there will be more folders.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;force&lt;/code&gt; will contain our Salesforce DX project and all the associated source and metadata. &lt;code class=&quot;highlighter-rouge&quot;&gt;mobile&lt;/code&gt; will contain our mobile application and all the files generated by the Mobile SDK.&lt;/p&gt;

&lt;p&gt;So, start off by creating &lt;code class=&quot;highlighter-rouge&quot;&gt;myproject&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mkdir myproject &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;myproject
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, you might as well initialize it as a git repo. Yes, that’s right – a single git repo for both your mobile app and your Salesforce project.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git init
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git remote add origin &amp;lt;yourremote&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, let’s create the Salesforce DX project. The first time I tried this out, I did everything manually: created my project, then my scratch org, created the connected app, grabbed the data, and so forth. But if you know anything about me, I’m a lazy developer. Which means I hate to do the same thing more than once. Consequently, I created a script that not only setup my Salesforce DX project for me, but also outputs all the values I’m going to need to connect the mobile app to my Scratch Org for development.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;To use the script below, grab my CLI plugin which allows you to create Connected Apps through the CLI: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx plugins:install sfdx-waw-plugin&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here’s a script you can use. Create a file like &lt;code class=&quot;highlighter-rouge&quot;&gt;setup.sh&lt;/code&gt; (and make it executable &lt;code class=&quot;highlighter-rouge&quot;&gt;chmod +x setup.sh&lt;/code&gt;) and add the following to it:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# set the callback URL&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;callbackUrl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sfdx://success&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# create force project&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;project&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;sfdx force:project:create &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; force&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# open folder&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;force

&lt;span class=&quot;c&quot;&gt;# create a scratch org&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;org&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;sfdx force:org:create &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; config/project-scratch-def.json&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# Create a connected app&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;connectedApp&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;sfdx waw:connectedapp:create &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$callbackUrl&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; wade.wegner@gmail.com &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; mobile &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; mobile &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; mobile &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; Api,Web,RefreshToken&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;consumerKey&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;connectedApp&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; .oauthConfig.consumerKey&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Consumer Key: &quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$consumerKey&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# generate a password&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;sfdx force:user:password:generate&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# get values&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;sfdx force:org:display &lt;span class=&quot;nt&quot;&gt;--json&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; .result&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; .password&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; .username&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;instanceUrl&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;result&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; | jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; .instanceUrl&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# echo values&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Username: &quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$username&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Password: &quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Instance URL: &quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$instanceUrl&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Callback URL: &quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$callbackUrl&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# return to root&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then, run it:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./setup.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Boom! Neat, right? You’re output should be something like …&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;./setup.sh
Consumer Key: &amp;lt;snip&amp;gt;
Callback URL: sfdx://success
Username:     test-ppvviujleloj@demo_company.net
Password:     &lt;span class=&quot;k&quot;&gt;**********&lt;/span&gt;
Instance URL: https://mello-yellow-999-dev-ed.cs90.my.salesforce.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;… which contains everything you need to connect with your mobile app.&lt;/p&gt;

&lt;p&gt;Speaking of which, let’s create that mobile app.&lt;/p&gt;

&lt;h3 id=&quot;create-your-mobile-app-with-the-mobile-sdk&quot;&gt;Create Your Mobile App with the Mobile SDK&lt;/h3&gt;

&lt;p&gt;This step is pretty easy thanks to all the hard work done by the Salesforce Mobile SDK team. Make sure you’re in the &lt;code class=&quot;highlighter-rouge&quot;&gt;myproject&lt;/code&gt; folder and run the following CLI command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx mobilesdk:reactnative:create
    &lt;span class=&quot;nt&quot;&gt;--platform&lt;/span&gt; ios
    &lt;span class=&quot;nt&quot;&gt;--appname&lt;/span&gt; demo1
    &lt;span class=&quot;nt&quot;&gt;--packagename&lt;/span&gt; com.wadewegner.demo1
    &lt;span class=&quot;nt&quot;&gt;--organization&lt;/span&gt; WadeWegner.com
    &lt;span class=&quot;nt&quot;&gt;--outputdir&lt;/span&gt; mobile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Of course, you likely want to change some of those values. But you get the idea.&lt;/p&gt;

&lt;p&gt;That will create everything you need to build and run the native mobile applications. Additionally, the SDK includes a bunch of useful stuff to get you going fast (e.g. some simple pages, wiring up auth, etc).&lt;/p&gt;

&lt;p&gt;Okay, now let’s wire it together!&lt;/p&gt;

&lt;h3 id=&quot;update-the-mobile-app-to-use-your-scratch-org&quot;&gt;Update the Mobile App to Use Your Scratch Org&lt;/h3&gt;

&lt;p&gt;Remember the info we echo’d to the console above? It’s time to use it!&lt;/p&gt;

&lt;p&gt;Open up Xcode (of course, if you targeted a different platform, use the right tool). You’ll want to open the Xcode workspace (not the project) in Xcode. You’ll find it at &lt;code class=&quot;highlighter-rouge&quot;&gt;myproject/mobile/ios/demo1.xcworkspace&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Open the &lt;code class=&quot;highlighter-rouge&quot;&gt;AppDelegate.m&lt;/code&gt; file and update the &lt;code class=&quot;highlighter-rouge&quot;&gt;RemoteAccessConsumerKey&lt;/code&gt; to use the &lt;strong&gt;Consumer Key&lt;/strong&gt; from above and &lt;code class=&quot;highlighter-rouge&quot;&gt;OAuthRedirectURI&lt;/code&gt; to use the &lt;strong&gt;Callback URL&lt;/strong&gt; from above. (Why we use different names for all these things I’ll never know.)&lt;/p&gt;

&lt;p&gt;That’s it for the code! Now, run the app.&lt;/p&gt;

&lt;p&gt;Before we launch the mobile app in Xcode, and if you created a React Native app like I did above, be sure to run &lt;code class=&quot;highlighter-rouge&quot;&gt;npm start&lt;/code&gt; in the &lt;code class=&quot;highlighter-rouge&quot;&gt;myproject/mobile&lt;/code&gt; folder. This ensures you have all the React “stuff” running for your app.&lt;/p&gt;

&lt;p&gt;Okay – now you can run the app in Xcode.&lt;/p&gt;

&lt;h3 id=&quot;log-into-the-mobile-app&quot;&gt;Log Into the Mobile App&lt;/h3&gt;

&lt;p&gt;Let’s go ahead and log into the mobile app and see it in action!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;On the login screen, click “Use Custom Domain”.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/35710831-8a82348c-076e-11e8-9894-c6c2121cb92b.png&quot; width=&quot;200&quot; alt=&quot;image&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Paste in the &lt;strong&gt;Instance URL&lt;/strong&gt; we echo’d above (be sure you don’t copy in the &lt;code class=&quot;highlighter-rouge&quot;&gt;https://&lt;/code&gt; as it won’t remove it.)&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/35710869-b3626b9c-076e-11e8-82fd-52a84cbae230.png&quot; width=&quot;200&quot; alt=&quot;image&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Then type (or copy) the username and password.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/35710893-d4fd09c4-076e-11e8-9099-113ca98456e2.png&quot; width=&quot;200&quot; alt=&quot;image&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click the Allow button to use the Connected App for API access.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/35710910-e7c80edc-076e-11e8-9c9b-9bc742c747fb.png&quot; width=&quot;200&quot; alt=&quot;image&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And presto, your mobile app is working against your scratch org!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/35710925-f78a27a6-076e-11e8-8b20-b85e8952f97a.png&quot; width=&quot;200&quot; alt=&quot;image&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Pretty neat!&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;I hope this has demonstrated that Salesforce DX, and all the tools that comes with it, is a compelling way to combine Salesforce with native mobile apps built using the Mobile SDK. I think it’s good, but I think we can do even better! I’m hoping to get the CLI plugin (and SDK) updated such that those values we echo’d from the script can be injected into the template (via the CLI command) such that it doesn’t require any code updates. Wouldn’t that be sweet?&lt;/p&gt;

&lt;p&gt;I hope this helps, and let me know if you have additional ideas on improvement! You can find me on Twitter @WadeWegner.&lt;/p&gt;
</description>
                <link>/2018/02/mobile-sdk-with-salesforce-dx/</link>
                <guid>/2018/02/mobile-sdk-with-salesforce-dx</guid>
                <pubDate>Thu, 01 Feb 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Authenticate to your Scratch Orgs using the OAuth 2.0 JWT Bearer Flow</title>
                <description>&lt;p&gt;A different, if not more accurate or better, name for this blog post could be “Authenticate to a Scratch Org You Didn’t Create and Whose Password You Don’t Know.” I even went out to Twitter to ask for help and, well, &lt;a href=&quot;https://twitter.com/britishboyindc&quot;&gt;Peter Churchill&lt;/a&gt; did not disappoint:&lt;/p&gt;

&lt;center&gt;&lt;blockquote class=&quot;twitter-tweet&quot; data-conversation=&quot;none&quot; data-lang=&quot;en&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;&amp;quot;I used JWT Bearer Flow with my Scratch Orgs and Dev Hub - you won&amp;#39;t believe what happened next!&amp;quot;&lt;/p&gt;&amp;mdash; Peter Churchill (@britishboyindc) &lt;a href=&quot;https://twitter.com/britishboyindc/status/958702877475790848?ref_src=twsrc%5Etfw&quot;&gt;January 31, 2018&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;&lt;/center&gt;

&lt;p&gt;But, as you can see, I went the boring and conservative route. Naming things, even blog posts, is hard. Anyway …&lt;/p&gt;

&lt;p&gt;One of my more popular blog posts recently is &lt;a href=&quot;http://www.wadewegner.com/2017/04/using-the-oauth-2-jwt-bearer-flow-to-support-the-salesforcedx-cli/&quot;&gt;Using the OAuth 2.0 JWT Bearer Flow to Support the Salesforce DX CLI&lt;/a&gt;. Not only is JWT Bearer Flow a powerful capability for automating continuous integration (you’re not using usernames and passwords, are you?), but setting it up is rather complex and the blog post details the required steps as simply as possible. In this post, I want to build the capability of the JWT Bearer Flow and introduce a capability of the Dev Hub that makes it easier for you to authenticate to newly created Scratch Orgs, even when you’re not on the machine that initially created the scratch org.&lt;/p&gt;

&lt;p&gt;Consider, if you will, the following: you have a script that automates these steps every morning:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Creates 50 new scratch orgs (possibly with different scratch org configuration settings).&lt;/li&gt;
  &lt;li&gt;Installs 3rd party packages that are used/required.&lt;/li&gt;
  &lt;li&gt;Pushes unpackaged source/metadata required (e.g. custom objects).&lt;/li&gt;
  &lt;li&gt;Assigns permsets.&lt;/li&gt;
  &lt;li&gt;Imports sample data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This isn’t a fictional scenario, as there are a number of ISVs and customers already doing this today as a way to bootstrap environments. But, invariably, the next question is: how do I let a developer, or separate CI system, authenticate to the newly created scratch org?&lt;/p&gt;

&lt;p&gt;Turns out, you can setup a Connected App in your Dev Hub to support the JWT OAuth flow that you can then use to authenticate to your scratch org. That’s right, you don’t have to create the Connected App in the scratch org itself (which is good, as you can’t automate it). Using the Connected App in the Dev Hub, you can use the same certificate key and &lt;code class=&quot;highlighter-rouge&quot;&gt;force:auth:jwt:grant&lt;/code&gt; command to authenticate directly to a scratch org.&lt;/p&gt;

&lt;p&gt;As I said, this is a powerful capability for CI systems that create scratch orgs and then need to auth into them but don’t have access to access token stored in &lt;code class=&quot;highlighter-rouge&quot;&gt;~/.sfdx&lt;/code&gt; during the scratch org creation process.&lt;/p&gt;

&lt;p&gt;Without further ado, let’s go started.&lt;/p&gt;

&lt;h3 id=&quot;create-the-certificate--private-key&quot;&gt;Create the certificate &amp;amp; private key&lt;/h3&gt;

&lt;p&gt;The first step is to create the certificate and private key you’re going to use. I prefer to do this in a place that’s both secure and not related to any specific project I’m working on. This way I can make everything work independent of my current project.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/ &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; mkdir .certs &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; .certs

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl genrsa &lt;span class=&quot;nt&quot;&gt;-des3&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-passout&lt;/span&gt; pass:x &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.pass.key 2048

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl rsa &lt;span class=&quot;nt&quot;&gt;-passin&lt;/span&gt; pass:x &lt;span class=&quot;nt&quot;&gt;-in&lt;/span&gt; server.pass.key &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.key

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;rm server.pass.key

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl req &lt;span class=&quot;nt&quot;&gt;-new&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-key&lt;/span&gt; server.key &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.csr

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;openssl x509 &lt;span class=&quot;nt&quot;&gt;-req&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sha256&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-days&lt;/span&gt; 365 &lt;span class=&quot;nt&quot;&gt;-in&lt;/span&gt; server.csr &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;-signkey&lt;/span&gt; server.key &lt;span class=&quot;nt&quot;&gt;-out&lt;/span&gt; server.crt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When finished, you’ll have the files you need later in the process. And, while I have these files setup to use locally, it’s entirely likely you’ll want to put them on a server to make them more accessible. It’s also not uncommon to encrypt them and use them with systems like Travis CI (see our &lt;a href=&quot;https://trailhead.salesforce.com/trails/sfdx_get_started/modules/sfdx_travis_ci&quot;&gt;Continuous Integration Using Salesforce DX&lt;/a&gt; Trailhead module for details).&lt;/p&gt;

&lt;h3 id=&quot;create-the-connected-app&quot;&gt;Create the Connected App&lt;/h3&gt;

&lt;p&gt;We’re going to use a Connected App in our Dev Hub org. This is part of the magic. By having this Connected App in our Dev Hub and setup with JWT Grant, we can use this flow with all of the Scratch Orgs we create.&lt;/p&gt;

&lt;p&gt;To make things easier, I like to use my CLI plugin: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx-waw-plugin&lt;/code&gt; (feel free to contribute here: &lt;a href=&quot;https://github.com/wadewegner/sfdx-waw-plugin&quot;&gt;https://github.com/wadewegner/sfdx-waw-plugin&lt;/a&gt;). It includes commands for creating the Connected App (and minimizes the manual steps).&lt;/p&gt;

&lt;p&gt;Install the &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx-waw-plugin&lt;/code&gt; to and look at the command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx plugins:install sfdx-waw-plugin

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx waw:connectedapp:create &lt;span class=&quot;nt&quot;&gt;--help&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You’ll want to run this command against your Dev Hub; I’ve aliased mine as &lt;code class=&quot;highlighter-rouge&quot;&gt;HubOrg&lt;/code&gt; (not sure why).&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx waw:connectedapp:create &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; http://localhost:1717/OauthRedirect 
    &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;YOUR_EMAIL_ADDRESS] 
    &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; Basic,Api,Web,RefreshToken 
    &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; jwtrulz 
    &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; HubOrg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When you run this command it will output information.&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&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;s2&quot;&gt;&quot;fullName&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;jwtrulz&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;s2&quot;&gt;&quot;contactEmail&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;wade.wegner@salesforce.com&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;s2&quot;&gt;&quot;description&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;generated by waw:connectedapp:create&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;s2&quot;&gt;&quot;label&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;jwtrulz&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;s2&quot;&gt;&quot;oauthConfig&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;s2&quot;&gt;&quot;callbackUrl&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;http://localhost:1717/OauthRedirect&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;s2&quot;&gt;&quot;consumerKey&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[YOUR_CONSUMER_KEY]&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;s2&quot;&gt;&quot;scopes&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;s2&quot;&gt;&quot;Basic&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;s2&quot;&gt;&quot;Api&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;s2&quot;&gt;&quot;Web&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;s2&quot;&gt;&quot;RefreshToken&quot;&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;s2&quot;&gt;&quot;consumerSecret&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[YOUR_CONSUMER_SECRET]&quot;&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;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Grab both the &lt;code class=&quot;highlighter-rouge&quot;&gt;consumerKey&lt;/code&gt; and the &lt;code class=&quot;highlighter-rouge&quot;&gt;consumerSecret&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now we’re going to open our Dev Hub so that we can finish setting up the JWT Bearer Flow. (As I mentioned before, you can’t automate all of this through our APIs today.)&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx force:org:open &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; HubOrg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We’re going to complete the setup of the Connected App. (Unfortunately, there aren’t any APIs exposed to assist you in this process).&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Open &lt;strong&gt;App Manager&lt;/strong&gt;, find your Connected App.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;strong&gt;Edit&lt;/strong&gt;. Turn on &lt;strong&gt;Use digital signatures&lt;/strong&gt; and choose your &lt;strong&gt;server.crt&lt;/strong&gt;.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/35624777-d75b3892-0644-11e8-89c2-4aa83e18d50b.png&quot; alt=&quot;Use Digital Signatures&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;strong&gt;Manage&lt;/strong&gt; then &lt;strong&gt;Edit Policies&lt;/strong&gt;. Update &lt;strong&gt;Permitted Users&lt;/strong&gt;.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/35624805-ef677694-0644-11e8-9f66-40050f404cea.png&quot; alt=&quot;Edit Policies&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;strong&gt;Manage Profiles&lt;/strong&gt; or &lt;strong&gt;Managed Permission Sets&lt;/strong&gt; and add your profile or permset.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you need a refresher for any of these steps, see my blog post &lt;a href=&quot;http://www.wadewegner.com/2017/04/using-the-oauth-2-jwt-bearer-flow-to-support-the-salesforcedx-cli/&quot;&gt;Using the OAuth 2.0 JWT Bearer Flow to Support the Salesforce DX CLI&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;log-into-your-dev-hub-with-jwtgrant&quot;&gt;Log into your Dev Hub with &lt;code class=&quot;highlighter-rouge&quot;&gt;jwt:grant&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;For this to work, you’ll want to log into your Dev Hub using &lt;code class=&quot;highlighter-rouge&quot;&gt;force:auth:jwt:grant&lt;/code&gt;, not &lt;code class=&quot;highlighter-rouge&quot;&gt;force:auth:web:login&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx force:auth:jwt:grant &lt;span class=&quot;nt&quot;&gt;--clientid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;YOUR_CONSUMER_KEY] &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;YOUR_DEVHUB_LOGIN] &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--jwtkeyfile&lt;/span&gt; ~/.certs/server.key &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--setdefaultdevhubusername&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; HubOrg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You should see something like:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Successfully authorized YOUR_DEVHUB_LOGIN] with org ID [YOUR_ORG_ID].&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s worth noting that this step is required. If you’re not logged into your Dev Hub using &lt;code class=&quot;highlighter-rouge&quot;&gt;jwt:grant&lt;/code&gt; then the rest of the magic won’t work.&lt;/p&gt;

&lt;h3 id=&quot;create-a-new-scratch-org-and-login-with-jwtgrant&quot;&gt;Create a new scratch org and login with &lt;code class=&quot;highlighter-rouge&quot;&gt;jwt:grant&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;Okay, now it’s time for the payoff! Go ahead and create a new scratch org:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx force:project:create &lt;span class=&quot;nt&quot;&gt;-n&lt;/span&gt; jwtrulz &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;jwtrulz

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx force:org:create &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; config/project-scratch-def.json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Copy down the username to the newly screated scratch org. Let’s pretend it’s &lt;code class=&quot;highlighter-rouge&quot;&gt;test-qyczf1ot1p6j@wade.wegner_company.net&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, we want to demonstrate that you can authenticate into the scratch org using the JWT Grant flow and the certificate – nothing else. If you’re doing this on your machine, and you want to guarantee that you’re not cheating, you can delete the JSON file that’s storing the creds for the newly created scratch org: &lt;code class=&quot;highlighter-rouge&quot;&gt;rm ~/.sfdx/test-qyczf1ot1p6j@wade.wegner_company.net.json&lt;/code&gt;. Not necessary, but it’ll help prove I’m not pulling the wool over your eyes.&lt;/p&gt;

&lt;p&gt;Are you ready? Okay, let’s login to your scratch org with the &lt;code class=&quot;highlighter-rouge&quot;&gt;jwt:grant&lt;/code&gt; command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx force:auth:jwt:grant &lt;span class=&quot;nt&quot;&gt;--clientid&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;YOUR_CONSUMER_KEY] &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;YOUR_SCRATCHORG_USERNAME] &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--jwtkeyfile&lt;/span&gt; ~/.certs/server.key &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--instanceurl&lt;/span&gt; https://test.salesforce.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You should see:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Successfully authorized YOUR_SCRATCHORG_USERNAME] with org ID [YOUR_SCRATCHORG_ID].&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;BOOM!&lt;/p&gt;

&lt;p&gt;Yes, this is the kind of stuff that I really enjoy. And I know there are a few of you out there who dig this too.&lt;/p&gt;

&lt;p&gt;I hope you’ve found this post helpful! It will definitely provide new and powerful ways for you to automate your continuous integration systems and provide more flexible ways for you to design some of your automation.&lt;/p&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;
</description>
                <link>/2018/01/jwt-oauth-with-scratch-orgs/</link>
                <guid>/2018/01/jwt-oauth-with-scratch-orgs</guid>
                <pubDate>Wed, 31 Jan 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Using Salesforce DX with Trailhead</title>
                <description>&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/34568070-75637fae-f119-11e7-8551-9b036a9d7fd2.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As you’ve likely seen on Twitter, I’ve really gotten into &lt;a href=&quot;trailhead.com&quot;&gt;Trailhead&lt;/a&gt; these past few months. In particular, the Superbadges. I not only enjoy the challenge of working through the project, but regularly discover I don’t know nearly as much as I think I do. There’s a ton of useful and practical information in Trailead just waiting for us all to discover.&lt;/p&gt;

&lt;p&gt;Of course, I have other motivations for doing Trailhead. I find it’s an amazing way to validate various workflows with &lt;a href=&quot;https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm&quot;&gt;Salesforce DX&lt;/a&gt;. I’ve logged at least a dozen bugs or feature requests based on trying to get something in Trailhead to work with various things, such as the Salesforce CLI, Scratch Orgs, source synch, or continuous integration.&lt;/p&gt;

&lt;p&gt;Numerous people have asked me to share my workflow and tips for getting started. So, please pardon the more tutorial-style post as I write this all out. Also, before you get started, be sure to review the &lt;a href=&quot;https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm&quot;&gt;Salesforce DX Setup Guide&lt;/a&gt; to ensure you have everything all set!&lt;/p&gt;

&lt;p&gt;You’ll find the following in this post:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Logging into your Trailhead playground org in the CLI&lt;/li&gt;
  &lt;li&gt;Creating a project &amp;amp; scratch org&lt;/li&gt;
  &lt;li&gt;Completing the challenge and pulling your source&lt;/li&gt;
  &lt;li&gt;Deploying source to your TPO to verify&lt;/li&gt;
  &lt;li&gt;Installing required packages&lt;/li&gt;
  &lt;li&gt;Exporting and importing data&lt;/li&gt;
  &lt;li&gt;Executing anonymous Apex&lt;/li&gt;
  &lt;li&gt;Opening up a Lightning App&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I thought it’d be good to use the &lt;a href=&quot;https://trailhead.salesforce.com/projects/quickstart-devzone-app&quot;&gt;Quick Start: Build Your First App&lt;/a&gt; project as the example for this tutorial.&lt;/p&gt;

&lt;h3 id=&quot;step-1-log-into-your-tpo-using-the-cli&quot;&gt;Step 1: Log into your TPO using the CLI&lt;/h3&gt;

&lt;p&gt;The first thing you’ll want to do is log into your trailhead playground org (TPO) using the &lt;a href=&quot;https://developer.salesforce.com/tools/sfdxcli&quot;&gt;Salesforce CLI&lt;/a&gt;. Doing this will allow you to target your TPO and deploy your metadata to pass challenges.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Reset your TPO password. You’ll find all the information in the &lt;a href=&quot;https://trailhead.salesforce.com/modules/trailhead_playground_management/units/get-your-trailhead-playground-username-and-password&quot;&gt;Get Your Trailhead Playground Usernamd and Password&lt;/a&gt; module. You have to do this because Trailhead created the TPO for you and you they set the password.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Log into your TPO using your username &amp;amp; password: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:auth:web:login -a tpo&lt;/code&gt;. Notice we’ve aliased it &lt;code class=&quot;highlighter-rouge&quot;&gt;tpo&lt;/code&gt; so that it’s easier to target in the future. Once done, you can test this by opening up your TPO with &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:org:open -u tpo&lt;/code&gt; and it’ll pop right up. Note: you’ll likely end up having more than one TPO, so a good practice would be to give it an alias that’s specific to your task.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Okay, that completes the initial setup. Now it’s time to dig in.&lt;/p&gt;

&lt;h3 id=&quot;step-2-create-a-project--scratch-org&quot;&gt;Step 2: Create a project &amp;amp; scratch org&lt;/h3&gt;

&lt;p&gt;I like to create a new project for each trail/project/superbadge. This lets me keep all the required source in a place where it’s easy to re-use and also allows me to easily push to a version control system (VCS). (You’re using VCS, right?)&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Create a project. For this quick start, I’d do: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:project:create -n trailblazerapp&lt;/code&gt;. This will create a new directory with all the requisite files for using Salesforce DX.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Depending on the challenge, you may want/need to change the default scratch org configuration file. Take a look at &lt;a href=&quot;https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_scratch_orgs_def_file.htm&quot;&gt;the docs&lt;/a&gt; to see if there’s anything you want to do.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Create your scratch org. This assumes you already have your Dev Hub setup and ready to go (if not, &lt;a href=&quot;https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_enable_devhub.htm&quot;&gt;look here&lt;/a&gt;). I do something like &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:org:create -s -f config/project-scratch-def.json&lt;/code&gt;. This not only creates the scratch org, but &lt;code class=&quot;highlighter-rouge&quot;&gt;-s&lt;/code&gt; makes it the default for the project, meaning all other commands I invoke will default to this scratch org.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;step-3-complete-the-challenge-in-the-scratch-org-and-pull-the-source&quot;&gt;Step 3: Complete the challenge in the scratch org and pull the source&lt;/h3&gt;

&lt;p&gt;You’ll see that the &lt;a href=&quot;https://trailhead.salesforce.com/projects/quickstart-devzone-app/steps/devzone-app-1&quot;&gt;Create the Trailblazer App&lt;/a&gt; module has you complete a number of steps. You’ll want to do all of this in the scratch org, not your TPO. Then, when you’ve completed the steps, you can pull it all out of the scratch org so that you have a local copy of all your changes.&lt;/p&gt;

&lt;p&gt;This is the eye-opening moment for most people when they start using Salesforce DX. It’s really simple to make changes in your scratch org then externalize them out of the org.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Open your scratch org: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:org:open&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Complete all the steps required for the challenge.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Pull the changes: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:source:pull&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now you’ll see you’ll see your source in the &lt;code class=&quot;highlighter-rouge&quot;&gt;force-app/main/default&lt;/code&gt; folder:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/746259/34566625-fc9a041c-f113-11e7-868f-f06ed147bdbd.png&quot; alt=&quot;image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you haven’t done so before, poke around and take a look. This is what metadata looks like!&lt;/p&gt;

&lt;h3 id=&quot;step-4-deploy-to-your-tpo-and-verify&quot;&gt;Step 4: Deploy to your TPO and verify&lt;/h3&gt;

&lt;p&gt;At this point, you’re ready to verify you completed the challenge. But the metadata isn’t yet in your TPO. No problem, all the MDAPI commands are available in the CLI. And, since we already logged into your TPO, it’s really simple to deploy it.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Convert your source into the MDAPI format. Simple: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:source:convert -d mdapiout&lt;/code&gt;. This will create a new folder called &lt;code class=&quot;highlighter-rouge&quot;&gt;mdapiout&lt;/code&gt;. If you look in it, it will look similar to your source, but there are subtle differences. You can learn about &lt;a href=&quot;https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_source_file_format.htm&quot;&gt;source file format&lt;/a&gt;, and it’s benefits, in the docs.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Now, deploy the metadata into your TPO with &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:mdapi:deploy -d mdapiout --wait 100 -u tpo&lt;/code&gt;. Notice we’ve targeted the &lt;code class=&quot;highlighter-rouge&quot;&gt;mdapiout&lt;/code&gt; folder, we’re using &lt;code class=&quot;highlighter-rouge&quot;&gt;--wait&lt;/code&gt; so that it’s synchronous and with &lt;code class=&quot;highlighter-rouge&quot;&gt;-u&lt;/code&gt; we’ve targeted our TPO.&lt;/p&gt;

    &lt;p&gt;You’ll see something like:&lt;/p&gt;

    &lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx force:mdapi:deploy &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; mdapiout &lt;span class=&quot;nt&quot;&gt;--wait&lt;/span&gt; 100 &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; tpo
 9185 bytes written to /var/folders/9t/rvzqw72n7jj03c4pccmq3vrj7b3gyz/T/mdapiout.zip using 44.179ms
 Deploying /var/folders/9t/rvzqw72n7jj03c4pccmq3vrj7b3gyz/T/mdapiout.zip...

 &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; Status
 Status:  Pending
 jobid:  0Af4100001aS6FLCA0
 Component errors:  0
 Components deployed:  0
 Components total:  0
 Tests errors:  0
 Tests completed:  0
 Tests total:  0
 Check only: &lt;span class=&quot;nb&quot;&gt;false

 &lt;/span&gt;Deployment finished &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;9000ms

 &lt;span class=&quot;o&quot;&gt;===&lt;/span&gt; Result
 Status:  Succeeded
 jobid:  0Af4100001aS6FLCA0
 Completed:  2018-01-04T14:02:11.000Z
 Component errors:  0
 Components deployed:  11
 Components total:  11
 Tests errors:  0
 Tests completed:  0
 Tests total:  0
 Check only: &lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;And that’s it!&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click the &lt;code class=&quot;highlighter-rouge&quot;&gt;Verify&lt;/code&gt; button. If you completed everything successfully, you’ll pass. If it fails, you have a few options:&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;Update your source, test in scratch org, and re-deploy. In most cases, this will work.&lt;/li&gt;
      &lt;li&gt;Maybe you defined the schema for a custom object wrong? You might need to manually (or automatically) delete it in the TPO before you re-deploy.&lt;/li&gt;
      &lt;li&gt;When all else fails, create a new TPO. It’s free and not too hard.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Two important notes:&lt;/p&gt;

&lt;h4 id=&quot;profiles-are-messy-and-need-clean-up&quot;&gt;Profiles are messy and need clean-up&lt;/h4&gt;

&lt;p&gt;Let’s face it, they are. It’s better to use permission sets if you can. But, you’ll notice that when you create schema or do just about anything else, it updates profiles. Did you notice them when you pulled them out of the scratch org?&lt;/p&gt;

&lt;p&gt;Often times, when you pull from the scratch org, you’ll pull profiles that don’t exist in your target org. This happens. When it does, simply remove the unwanted profiles from your source (not the MDAPI format) and convert it again into MDAPI format. A tip, shared by SFDX engineer &lt;a href=&quot;https://twitter.com/gmurnock__c&quot;&gt;George Murnock&lt;/a&gt; and platform architect &lt;a href=&quot;https://twitter.com/MShaneMc/status/948991161389273090&quot;&gt;Shane McLaughlin&lt;/a&gt;, is to include &lt;code class=&quot;highlighter-rouge&quot;&gt;**profiles&lt;/code&gt; to your &lt;code class=&quot;highlighter-rouge&quot;&gt;.forceignore&lt;/code&gt; file. This will force you to use permsets.&lt;/p&gt;

&lt;p&gt;Ideally, try to avoid profiles. Sadly, since they’re so pervasive, Trailhead often assumes (and even checks) for the existence of the profile, so sometimes you can’t avoid it.&lt;/p&gt;

&lt;h4 id=&quot;script-this-step-to-make-it-easier&quot;&gt;Script this step to make it easier&lt;/h4&gt;

&lt;p&gt;I’ve created an alias that makes it really easy to deploy to my TPO.&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;mdd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'function _blah(){ sfdx force:source:convert -d mdapiout &amp;amp;&amp;amp; /
  sfdx force:mdapi:deploy -d mdapiout --wait 100 -u $1 &amp;amp;&amp;amp; rm -rf mdapiout };_blah'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With this alias, I can convert, deploy, and clean all with one command: &lt;code class=&quot;highlighter-rouge&quot;&gt;mdd tpo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Definitely a lot easier!&lt;/p&gt;

&lt;h3 id=&quot;additional-things-to-know&quot;&gt;Additional things to know&lt;/h3&gt;

&lt;p&gt;Certain modules will require you to do additional things.&lt;/p&gt;

&lt;h4 id=&quot;installing-required-packages&quot;&gt;Installing required packages&lt;/h4&gt;

&lt;p&gt;As pointed out by &lt;a href=&quot;https://twitter.com/SNUGSFBay/status/948927117248491520&quot;&gt;Bonny Hinners&lt;/a&gt;, there are times when you need to install some dependencies (typically via an unmanaged package but possibly through a labs app too) into your TPO to complete a challenge. This can give you custom objects and other metadata you’ll use within the challenge. You’ll need to do the same thing with your scratch org.&lt;/p&gt;

&lt;p&gt;A good example is the &lt;a href=&quot;https://trailhead.salesforce.com/en/super_badges/superbadge_apex&quot;&gt;Apex Specialist Superbadge&lt;/a&gt;. Notice that the pre-work includes an unmanaged package you need to install.&lt;/p&gt;

&lt;p&gt;No problem, we can install this unmanaged package in the scratch org. Then, any changes we make, even if these changes are made against metadata that comes from the package, will get pulled out.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Figure out the package ID. Usually this is pretty simple, if not transparent. Notice the URL for the unmanaged package: &lt;code class=&quot;highlighter-rouge&quot;&gt;https://login.salesforce.com/packaging/installPackage.apexp?p0=04t36000000i5UM&lt;/code&gt;. An ID that starts with &lt;code class=&quot;highlighter-rouge&quot;&gt;04t&lt;/code&gt; is a package. Copy this package ID.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Create your scratch org the normal way we highlighted above.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install the package into your scratch org: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:package:install -i 04t36000000i5UM --wait 100&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it! Now all the required schema and dependencies are in your scratch org.&lt;/p&gt;

&lt;h4 id=&quot;exporting-and-importing-data&quot;&gt;Exporting and importing data&lt;/h4&gt;

&lt;p&gt;A few of the challenges will verify that you’ve created data in the TPO. Now, of course you could open the TPO and manually enter the data it’s looking for. But where’s the fun in that? Instead, do it in your scratch org, export it, and then import it into your TPO.&lt;/p&gt;

&lt;p&gt;This is a great way to discover some of the useful data import/export commands in the CLI.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Open your scratch org and enter your data. Yes, you can do this through other tools, but let’s face it: the app you’ve built is likely the best interface for creating your data.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Use the CLI to write a query that will grab the data you added: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:data:soql:query -q &quot;SELECT Waypoint_Name__c FROM Waypoints__c&quot;&lt;/code&gt;. Ensure you get the data you’re expecting.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Export to JSON files and store in your project (other developers on your team will appreciate you doing this; trust me): &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:data:tree:export -q &quot;SELECT Waypoint_Name__c FROM Waypoints__c&quot; -p -d data&lt;/code&gt;. Notice it’s the same query as before. Also, we’re using a plan definition file and exporting it into the &lt;code class=&quot;highlighter-rouge&quot;&gt;data&lt;/code&gt; folder.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Now, import the data into your TPO: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:data:tree:import -p data/Waypoint__c-plan.json -u tpo&lt;/code&gt;. This will create the records in our TPO without you having to do it manually.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pretty slick.&lt;/p&gt;

&lt;h4 id=&quot;executing-anonymous-apex-code&quot;&gt;Executing anonymous Apex code&lt;/h4&gt;

&lt;p&gt;There are some things that either don’t fit into the model of source push/pull (e.g. connected apps) or will require you to take a different approach to updating in the org. So, get ready to bust out some anonymous Apex!&lt;/p&gt;

&lt;p&gt;Here’s what I do:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;I create a folder called &lt;code class=&quot;highlighter-rouge&quot;&gt;scripts&lt;/code&gt;. This is where I’ll create my Apex scripts.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Create a file with an &lt;code class=&quot;highlighter-rouge&quot;&gt;.apex&lt;/code&gt; extension in the &lt;code class=&quot;highlighter-rouge&quot;&gt;scripts&lt;/code&gt; folder. Need to create a scheduled job? Call it &lt;code class=&quot;highlighter-rouge&quot;&gt;scheduledjob.apex&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Write your code. Example:&lt;/p&gt;

    &lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &lt;span class=&quot;n&quot;&gt;System&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;schedule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WarehouseCallout&lt;/span&gt;&lt;span class=&quot;sc&quot;&gt;','&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; 
     &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;WarehouseSyncSchedule&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Execute the script against your scratch org to test: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:apex:execute -f scripts/scheduledjob.apex&lt;/code&gt;. Note: sometimes to get this right, you’ll want to create a new scratch org to try again. I’ve gone through many iterations sometimes until I finally get it working the way I want.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Execute the script against your TPO: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:apex:execute -f scripts/servicetoken.apex -u tpo&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Notice how easy that is? And, even better, it’s completely repeatable!&lt;/p&gt;

&lt;h4 id=&quot;opening-up-a-lightning-app&quot;&gt;Opening up a Lightning App&lt;/h4&gt;

&lt;p&gt;In many of the modules you’ll create a lightning app as a test harness called &lt;code class=&quot;highlighter-rouge&quot;&gt;harnessApp.app&lt;/code&gt; (see &lt;a href=&quot;https://trailhead.salesforce.com/modules/lex_dev_lc_basics/units/lex_dev_lc_basics_create&quot;&gt;Create and Edit Lightning Components&lt;/a&gt; for an example). This test harness is used to test the Lightning Components as you create them. Super helpful!&lt;/p&gt;

&lt;p&gt;Now, Trailhead assumes you’re doing your development in the Developer Console. If you’re using Salesforce DX, how do you easily open &lt;code class=&quot;highlighter-rouge&quot;&gt;harnessApp.app&lt;/code&gt; to test your component? Well, the CLI let’s you target a specific page:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sfdx force:org:open &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; c/harnessApp.app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This will directly open your &lt;code class=&quot;highlighter-rouge&quot;&gt;harnessApp.app&lt;/code&gt; in the browser, without even having to login. Pretty cool, right?&lt;/p&gt;

&lt;p&gt;Of course, if you want to test it in your TPO, just add your alias (e.g. &lt;code class=&quot;highlighter-rouge&quot;&gt;-u tpo&lt;/code&gt;).&lt;/p&gt;

&lt;h3 id=&quot;wrap-it-up&quot;&gt;Wrap it up&lt;/h3&gt;

&lt;p&gt;That’s pretty much it! You can do this over and over again. The best part is, as I mentioned, you can setup version control and push all your source.&lt;/p&gt;

&lt;p&gt;In your project, it’s as simple as the following:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git init
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git remote add origin git@github.com:wadewegner/th-trailblazerapp.git
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git add &lt;span class=&quot;nt&quot;&gt;-A&lt;/span&gt;
&lt;span class=&quot;nv&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;It works&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git push origin master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And then you’ll have a nice repo of your code to refer to in the future: &lt;a href=&quot;https://github.com/wadewegner/th-trailblazerapp&quot;&gt;https://github.com/wadewegner/th-trailblazerapp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope this helps!&lt;/p&gt;

&lt;p&gt;P.S. Thanks to George Murnock for literally finding (and pointing out) hundreds of typos.&lt;/p&gt;
</description>
                <link>/2018/01/using-salesforce-dx-with-trailhead/</link>
                <guid>/2018/01/using-salesforce-dx-with-trailhead</guid>
                <pubDate>Tue, 02 Jan 2018 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Deploy to Salesforce DX</title>
                <description>&lt;p&gt;If you’re a Salesforce developer, it’s likely you’ve heard us talk about &lt;a href=&quot;https://developer.salesforce.com/platform/dx&quot;&gt;Salesforce DX&lt;/a&gt; these past months. (If not, you’re missing out and you should checkout the &lt;a href=&quot;https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm&quot;&gt;official documentation&lt;/a&gt;.) Since TrailheaDX, everyone has been able to use the new tools and services we’ve made available as part of the Salesforce DX beta. Personally, I’ve thoroughly enjoyed building all kinds of plugins for the Salesforce CLI.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;My primary plugin with lots of functionality: &lt;a href=&quot;https://github.com/wadewegner/sfdx-waw-plugin&quot;&gt;https://github.com/wadewegner/sfdx-waw-plugin&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Generate code snippets from templates: &lt;a href=&quot;https://github.com/wadewegner/sfdx-code-gen&quot;&gt;https://github.com/wadewegner/sfdx-code-gen&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Convert WSDL to Apex: &lt;a href=&quot;https://github.com/wadewegner/sfdx-wsdl2apex-plugin0&quot;&gt;https://github.com/wadewegner/sfdx-wsdl2apex-plugin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of our top goals has been to make deployment incredibly easy. With the Salesforce CLI, deploying your source is as easy as typing &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:source:push&lt;/code&gt; and, within a few moments, your Scratch Org is refreshed with the latest source. This has proved immensely popular with developers looking for better development experiences.&lt;/p&gt;

&lt;p&gt;Yet, during the beta, we’ve seen a number of use cases for providing the ability to deploy source into a Scratch Org directly from a source control repository like Github:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;You want to quickly try out the latest and greatest from a &lt;a href=&quot;https://twitter.com/ccoenraets&quot;&gt;Christophe Coenraets&lt;/a&gt; or &lt;a href=&quot;https://twitter.com/muenzpraeger&quot;&gt;René Winkelmeyer&lt;/a&gt; blog post. (You know you do!)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You’re not able to access a machine where you can install the Salesforce CLI. (Maybe you’re at a conference?)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Laziness. (It’s okay, it happens to me too.)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Regardless of the reasons, a few of us agree and thought it worth doing something about it.&lt;/p&gt;

&lt;p&gt;Without further ado, I’m &lt;strong&gt;pleased to introduce &lt;a href=&quot;https://deploy-to-sfdx.com&quot;&gt;Deploy to Salesforce DX&lt;/a&gt;&lt;/strong&gt;, an open-source and community-driven tool for automating Salesforce DX deployments from public repositories to Scratch Orgs.&lt;/p&gt;

&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;

&lt;p&gt;I started working on this tool a couple months ago. When I began, there were a few blocking issues that prevented it from working. Many thanks to &lt;a href=&quot;https://twitter.com/amphro&quot;&gt;Thomas Dvornik&lt;/a&gt;, one of the lead engineers on the Salesforce CLI team, who added the ability to use access tokens minted from a separate Web Server OAuth flow to authenticate to the Dev Hub. (More on this in a future blog post, as it’s an incredibly useful feature.)&lt;/p&gt;

&lt;p&gt;Additionally, the first few iterations of this tool significantly lacked polish and simplicity. Without the amazing UX design and development work of &lt;a href=&quot;https://twitter.com/benjisnyder&quot;&gt;Ben Snyder&lt;/a&gt; this tool would be an ugly mess.&lt;/p&gt;

&lt;p&gt;Last, but not least, I’m grateful for the contribution from &lt;a href=&quot;https://twitter.com/andyinthecloud&quot;&gt;Andrew Fawcett&lt;/a&gt;. As the official owner of the “Deploy to Salesforce” button, it pleases me that he found it worthwhile to contribute some useful code to this project, and I’m hopeful that he (and others) continue to contribute.&lt;/p&gt;

&lt;p&gt;What’s the end game for &lt;strong&gt;Deploy to Salesforce DX&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;That’s a good question. I’m as curious as you. This started off as a project to see if it was possible. I had numerous questions. Can this run on Heroku? &lt;em&gt;(Yes, in fact it can, powered by the &lt;a href=&quot;https://github.com/wadewegner/salesforce-cli-buildpack&quot;&gt;salesforce-cli-buildpack&lt;/a&gt;; more on this in another post!)&lt;/em&gt; Can we orchestrate a Salesforce DX deployment in one click? &lt;em&gt;(Yes, look at the .salesforcedx.yaml file to see the instructions.)&lt;/em&gt; How hard is it to invoke the CLI itself from code? &lt;em&gt;(Turns out, it’s not too bad!)&lt;/em&gt; Ultimately, my goal with &lt;strong&gt;Deploy to Salesforce DX&lt;/strong&gt; is to show what’s possible. If it serves nothing more than to let people know all the crazy/awesome things you can do with Salesforce DX, I’ll consider it a success.&lt;/p&gt;

&lt;p&gt;I have fully open-source this application, so you can see how it works. Andy and I have already started putting together a set of feature requirements, so feel free to &lt;a href=&quot;https://github.com/wadewegner/deploy-to-sfdx/issues&quot;&gt;contribute your own&lt;/a&gt;. I’d also love it if you contributed, so feel free to fork and send me a pull request.&lt;/p&gt;

&lt;h2 id=&quot;try-it-out&quot;&gt;Try it out&lt;/h2&gt;

&lt;p&gt;The website itself explains how to get started, to head on over to &lt;a href=&quot;https://deploy-to-sfdx.com/&quot;&gt;https://deploy-to-sfdx.com/&lt;/a&gt;. There are also a few Github repositories out there that already support the tool:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/forcedotcom/sfdx-dreamhouse&quot;&gt;https://github.com/forcedotcom/sfdx-dreamhouse&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/forcedotcom/sfdx-simple&quot;&gt;https://github.com/forcedotcom/sfdx-simple&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ccoenraets/northern-trail&quot;&gt;https://github.com/ccoenraets/northern-trail&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/muenzpraeger/salesforce-einstein-platform-apex&quot;&gt;https://github.com/muenzpraeger/salesforce-einstein-platform-apex&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Want to add this to your own Github repository? Please do! It’s as easy as adding the following tag to your repositories repo:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[![Deploy](https://deploy-to-sfdx.com/dist/assets/images/DeployToSFDX.svg)](https://deploy-to-sfdx.com/)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That will give you a lovely button that users can click on to deploy your source directly into one of their Scratch Orgs.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://deploy-to-sfdx.com/dist/assets/images/DeployToSFDX.svg&quot; alt=&quot;Deploy&quot; title=&quot;Deploy&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you want to further customize your deployment, you can add a &lt;code class=&quot;highlighter-rouge&quot;&gt;.salesforcedx.yaml&lt;/code&gt; file in your repo. It’ll look something like this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;scratch-org-def: config/project-scratch-def.json
assign-permset: false
run-apex-tests: true
delete-scratch-org: false
show-scratch-org-url: true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This instructs the service to perform additional or custom activities. Definitely useful if you’ve got a Lightning app or you want to run a set of tests.&lt;/p&gt;

&lt;h2 id=&quot;word-of-warning&quot;&gt;Word of warning&lt;/h2&gt;

&lt;p&gt;Before I close, I want to remind everyone that this is not an official Salesforce service or tool. While I am a Salesforce employee, I’ve built this service on the side. I don’t offer any official support, although I will do my very best to &lt;a href=&quot;https://github.com/wadewegner/deploy-to-sfdx/issues&quot;&gt;respond to issues&lt;/a&gt;. Since the tool only interacts with Scratch Orgs, the risk is minimal. That said, consider yourself warned.&lt;/p&gt;

&lt;p&gt;I hope you find this tool useful. It was a lot of fun to build. Thanks again to all the individuals who helped along the way!&lt;/p&gt;
</description>
                <link>/2017/09/deploy-to-salesforce-dx/</link>
                <guid>/2017/09/deploy-to-salesforce-dx</guid>
                <pubDate>Wed, 13 Sep 2017 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Use Workbench with your Scratch Org</title>
                <description>&lt;p&gt;The &lt;a href=&quot;https://workbench.developerforce.com&quot;&gt;Salesforce Workbench&lt;/a&gt; is a powerful set of tools for developers and admins to use with their org. You can easily describe, query, manipulate, and migrate data and metadata through the web browser, using a combination of Partner, Bulk, REST, Streaming, Metadata, and Tooling APIs. It’s completely &lt;a href=&quot;https://github.com/ryanbrainard/forceworkbench&quot;&gt;open-sourced on Github&lt;/a&gt; by Ryan Brainard (&lt;a href=&quot;https://twitter.com/ryanbrainard&quot;&gt;@RyanBrainard&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;And if all of this isn’t enough to convince you of its value, I can almost guarantee that Josh Kaplan (&lt;a href=&quot;https://twitter.com/joshsfdc&quot;&gt;@JoshSfdx&lt;/a&gt;) is playing around in Workbench right now!&lt;/p&gt;

&lt;p class=&quot;center&quot;&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/25318133/f82383cc-283c-11e7-9887-26c89e9ce32a.jpeg&quot; alt=&quot;Josh Kaplan approves&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Recently, I found the need to use the Workbench while working on a side project. Of course, I’m using Salesforce DX and scratch orgs. Scratch orgs provide the perfect environment to quickly development my app and, when I’m done, I delete it. I also use the new source synchronization capabilities to externalize all my source so I can easily commit it in a Github repository.&lt;/p&gt;

&lt;p&gt;If you’re one of our Salesforce DX pilot participants, you might be asking yourself: uh, how are you able to use your Scratch org with Workbench when you don’t know your scratch org password, it’s my domain, and it’s not running on production? Well, I’m glad you asked! And not to fear, there are two commands in the Salesforce CLI you can use to make this work!&lt;/p&gt;

&lt;p&gt;First, assuming you’re in your project workspace, we’re going to run the command &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:user:password:generate&lt;/code&gt; to generate a random password. If you’re not in your project workspace, you use the &lt;code class=&quot;highlighter-rouge&quot;&gt;targetusername&lt;/code&gt; (or &lt;code class=&quot;highlighter-rouge&quot;&gt;-u&lt;/code&gt;) to specify the scratch org (and consequently the user).&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt; sfdx force:user:password:generate

Successfully set the password &quot;XXXXXXXX&quot; for user 
scratchorgXXXXXXXXXXXXXX@wade.wegnercompany.com. You can see the password
again by running &quot;force:org:display&quot;.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now you know the password! What’s more, it’s encrypted and stored locally, so running &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:org:display&lt;/code&gt; will remind you of the password if you forget it.&lt;/p&gt;

&lt;p&gt;Second, you’ll need to know the “my domain” used with the scratch org. This is also generated randomly when the scratch org is created. To get it, you run the same command, &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:org:display&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Key              Value
───────────────  ───────────────────────────────────────────────────────────
Access Token     XXXXXXXXX...
Client Id        SalesforceDevelopmentExperience
Created Date     2017-04-23
Dev Hub Id       XXXXXXXXX...
Edition          Developer Edition
Expiration Date  2017-05-01
Id               XXXXXXXXX...
Instance Url     https://dream-business-XXXX-dev-ed.cs70.my.salesforce.com
Password         XXXXXXXX
Scratch Org      true
Username         scratchorgXXXXXXXXXXXXXX@wade.wegnercompany.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As you can see, this command includes all kinds of useful information.&lt;/p&gt;

&lt;p&gt;Now, armed with this information, it’s easy to log into the Workbench.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Change the &lt;strong&gt;Environment&lt;/strong&gt; to &lt;code class=&quot;highlighter-rouge&quot;&gt;Sandbox&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;strong&gt;I agree to the terms of service&lt;/strong&gt;.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/25318071/74bed640-283b-11e7-8021-a6a60fb13ae0.png&quot; alt=&quot;Workbench&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;strong&gt;Login with Salesforce&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;strong&gt;Use Custom Domain&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Paste your &lt;strong&gt;Instance Url&lt;/strong&gt; into the &lt;strong&gt;Custom Domain&lt;/strong&gt; box and click &lt;strong&gt;Continue&lt;/strong&gt;.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/25318084/d9dd2450-283b-11e7-8a12-501838b32dde.png&quot; alt=&quot;Custom Domain&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Paste your &lt;strong&gt;Username&lt;/strong&gt; and &lt;strong&gt;Password&lt;/strong&gt; in the box, and click &lt;strong&gt;Log In to Sandbox&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Voilà! You’re using Workbench with your Scratch Org.&lt;/p&gt;

&lt;p&gt;Of course, these two commands enable all kinds of other useful scenarios, not just logging into the Workbench. Please explore their use and try them out yourself.&lt;/p&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;
</description>
                <link>/2017/04/use-workbench-with-your-scratch-org/</link>
                <guid>/2017/04/use-workbench-with-your-scratch-org</guid>
                <pubDate>Sun, 23 Apr 2017 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Show the Salesforce DX Org Config in your Bash Prompt</title>
                <description>&lt;p&gt;Using the capabilities of Salesforce DX you can enable some neat tricks. Such as displaying your org configuration in your Bash prompt:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/content/2017/04/08/bash.gif&quot; alt=&quot;Bash&quot; /&gt;&lt;/p&gt;

&lt;p&gt;But, first, a little background …&lt;/p&gt;

&lt;p&gt;The Salesforce DX CLI provides some powerful capabilities for tracking your Salesforce org. When you login with &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:auth:web:login&lt;/code&gt; (&lt;code class=&quot;highlighter-rouge&quot;&gt;-a &amp;lt;alias&amp;gt;&lt;/code&gt; lets you alias the org) your credentials are encrypted and stored locally. When running subsequent commands, you can append &lt;code class=&quot;highlighter-rouge&quot;&gt;-u &amp;lt;username|alias&amp;gt;&lt;/code&gt; to the command to target an org. Since the CLI stores the refresh token, it can generate a new access token automatically.&lt;/p&gt;

&lt;p&gt;Two additional things you should understand are:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;The dev hub org vs the default org&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Global vs local orgs&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The dev hub org is the production org you esignate as the hub to track all of your scratch orgs. (In the future the dev hub will do more.) Some of the CLI commands (i.e. &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:org:create&lt;/code&gt;) run against the dev hub org. The default org is the org all other commands run against (i.e. &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:apex:execute&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;The Salesforce DX CLI lets you set global orgs for the dev hub and your default org. This means that when you run the commands without &lt;code class=&quot;highlighter-rouge&quot;&gt;-u&lt;/code&gt; it will target those global orgs. That is, unless your local workspace has specified a local dev hub org or default org, in which case it will use the local orgs. You can set defaults using &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:config:set&lt;/code&gt; or when you create a scratch org using &lt;code class=&quot;highlighter-rouge&quot;&gt;-s&lt;/code&gt; (i.e. &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:org:create -s&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;While these capabilities are powerful, it can be difficult to keep track which org your currently tracking.&lt;/p&gt;

&lt;p&gt;To solve this, I’ve updated my &lt;code class=&quot;highlighter-rouge&quot;&gt;.bash_profile&lt;/code&gt; to display the dev hub org and default org. If it doesn’t find a local org for the workspace it will display the global org.&lt;/p&gt;

&lt;p&gt;Here’s the &lt;code class=&quot;highlighter-rouge&quot;&gt;.bash_profile&lt;/code&gt; code:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/2c9339618983c9b40cc58b03d700e2b9.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;It’s not 100% perfect, but it’s extremely useful. Now, the same information could be determine with &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:config:list&lt;/code&gt; with the advantage that it’s 100% accurate (my script isn’t accurate in workspace subdirectories, for example), but there’s still some latency we need to workout of the CLI. When that latency is resolved I’ll update to use that command.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: this script uses files directly that, frankly, you shouldn’t use. Note that we may change these files at any point. Please do not base anything important on these files directly. Instead, use the CLI.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I hope you find this useful!&lt;/p&gt;

&lt;p&gt;Special thanks to &lt;a href=&quot;https://twitter.com/cwallatx&quot;&gt;Chris Wall (@cwallatx)&lt;/a&gt;, an amazing architect and developer on the Salesforce DX team, for the inspiration!&lt;/p&gt;
</description>
                <link>/2017/04/show-the-salesforce-dx-org-config-in-your-bash-profile/</link>
                <guid>/2017/04/show-the-salesforce-dx-org-config-in-your-bash-profile</guid>
                <pubDate>Sat, 08 Apr 2017 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Using the OAuth 2.0 JWT Bearer Flow to Support the Salesforce DX CLI</title>
                <description>&lt;p&gt;The Salesforce DX (SFDX) CLI makes it easy to run commands as a developer. It also makes it really easy to create scripts that facilitate automation. A great example is the following tweet from Pat Patterson:&lt;/p&gt;

&lt;center&gt;&lt;blockquote class=&quot;twitter-tweet&quot; data-lang=&quot;en&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;&lt;a href=&quot;https://twitter.com/hashtag/SalesforceDX?src=hash&quot;&gt;#SalesforceDX&lt;/a&gt; is awesome! I can create a scratch org for testing from a bash script. Great job, &lt;a href=&quot;https://twitter.com/WadeWegner&quot;&gt;@WadeWegner&lt;/a&gt; &amp;amp; team! &lt;a href=&quot;https://t.co/Nu3yI2UQH0&quot;&gt;pic.twitter.com/Nu3yI2UQH0&lt;/a&gt;&lt;/p&gt;&amp;mdash; Pat Patterson (@metadaddy) &lt;a href=&quot;https://twitter.com/metadaddy/status/846893287495512064&quot;&gt;March 29, 2017&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;&lt;/center&gt;

&lt;p&gt;The praise for SFDX is awesome. Thanks, Pat. But that’s not my purpose for sharing. This script does some awesome stuff. But notice the first command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sfdx force:auth:jwt:grant &lt;span class=&quot;nt&quot;&gt;--clientid&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CLIENT_ID&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--jwtkeyfile&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JWT_KEY_FILE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--username&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HUB_USERNAME&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--setdefaultdevhubusername&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This command logs into the developer hub using only the client ID, the username, and the JWT key file; it doesn’t require you to interactively login. This is important when you want your scripts to run automatically. For this to work, your local SFDX workspace (i.e. client-side) needs a private key for signing the JWT bearer token payload. The server-side needs a Connected App containing a certificate generated from that private key.&lt;/p&gt;

&lt;p&gt;The key to the use of the JWT bearer flow is that it supports the RSA SHA256 algorithm, which uses an uploaded certificate as the signing secret. This gives us the ability to authenticate the CLI without having to interactively login. Perfect for automated builds and scripting. Read the Salesforce documentation for more details on the &lt;a href=&quot;https://help.salesforce.com/articleView?id=remoteaccess_oauth_jwt_flow.htm&amp;amp;type=0&quot;&gt;OAuth 2.0 JWT Bearer Token Flow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this post, we’ll create both the key and the certificate, as well as setup the Connected App to facilitate the &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx force:auth:jwt:grant&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;[Update 4/6/17: you can now install my plugin (&lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx plugins:install sfdx-oss-plugin&lt;/code&gt;) and run the command &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx wadewegner:connectedapp:create -u &amp;lt;username|alias&amp;gt; -n &amp;lt;name&amp;gt; -r&lt;/code&gt; to get through step #5. You’ll still need to complete steps #6 and #7.]&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Follow &lt;a href=&quot;https://devcenter.heroku.com/articles/ssl-certificate-self&quot;&gt;these instructions&lt;/a&gt; to generate a private key and a certificate signing request. The resulting &lt;code class=&quot;highlighter-rouge&quot;&gt;server.key&lt;/code&gt; file contains your private key, and we’re going to use that as input when signing the JWT bearer token payload.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Execute the &lt;a href=&quot;https://devcenter.heroku.com/articles/ssl-certificate-self#generate-ssl-certificate&quot;&gt;subsequent instructions&lt;/a&gt; to generate a self-signed SSL certificate.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Log into your &lt;strong&gt;Developer Hub&lt;/strong&gt;, and navigate to &lt;strong&gt;Setup&lt;/strong&gt;.  Go to &lt;strong&gt;App Manager&lt;/strong&gt;, then click the &lt;strong&gt;New Connected App&lt;/strong&gt; button on the upper-left. (You’re using the Lightning Experience, right?)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Create a new Connected App with information and click &lt;strong&gt;Save&lt;/strong&gt;. Ensure you do the following:&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;
        &lt;p&gt;Set the &lt;strong&gt;Callback URL&lt;/strong&gt; to: &lt;code class=&quot;highlighter-rouge&quot;&gt;http://localhost:1717/OauthRedirect&lt;/code&gt;&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Check &lt;strong&gt;Use digital signatures&lt;/strong&gt; and upload your &lt;code class=&quot;highlighter-rouge&quot;&gt;server.crt&lt;/code&gt; certificate.&lt;/p&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Add the following &lt;strong&gt;OAuth Scopes&lt;/strong&gt;: &lt;code class=&quot;highlighter-rouge&quot;&gt;basic&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;api&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;web&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;refresh_token&lt;/code&gt;&lt;/p&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Save your &lt;strong&gt;Consumer Key&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click the &lt;strong&gt;Manage&lt;/strong&gt; button, then &lt;strong&gt;Edit Policies&lt;/strong&gt;. Under the OAuth policies subsection, change the &lt;strong&gt;Permitted Users&lt;/strong&gt; combo box to be &lt;code class=&quot;highlighter-rouge&quot;&gt;Admin approved users are pre-authorized&lt;/code&gt;. Then click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Click &lt;strong&gt;Manage Profiles&lt;/strong&gt; OR &lt;strong&gt;Manage Permission Sets&lt;/strong&gt;, and select the profiles and/or perm sets that should be allowed to be pre-authorized to use this Connected App. (For perm sets, create a perm set without any particular permissions, assign it your user, then assign that perm set to the connected app.) Then click &lt;strong&gt;Save&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When this is setup correctly, running the command will look like the following:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sfdx force:auth:jwt:grant &lt;span class=&quot;nt&quot;&gt;--clientid&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;CLIENT_ID&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--jwtkeyfile&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JWT_KEY_FILE&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--username&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HUB_USERNAME&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;--setdefaultdevhubusername&lt;/span&gt;

Successfully authorized &amp;lt;USERNAME&amp;gt; with org id 00D460000001PSmEAM
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can see this in action in a &lt;a href=&quot;https://travis-ci.org/wadewegner/sfdx-travisci&quot;&gt;sample Travis CI&lt;/a&gt; build I have setup for &lt;a href=&quot;https://github.com/wadewegner/sfdx-travisci&quot;&gt;https://github.com/wadewegner/sfdx-travisci&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope this post helps! Special thanks to &lt;a href=&quot;https://twitter.com/gmurnock__c&quot;&gt;George Murnock (gmurnock__c)&lt;/a&gt; for putting together a really helpful document that is the basis of this post.&lt;/p&gt;
</description>
                <link>/2017/04/using-the-oauth-2-jwt-bearer-flow-to-support-the-salesforcedx-cli/</link>
                <guid>/2017/04/using-the-oauth-2-jwt-bearer-flow-to-support-the-salesforcedx-cli</guid>
                <pubDate>Mon, 03 Apr 2017 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Creating a Plugin for the Salesforce CLI</title>
                <description>&lt;p&gt;&lt;em&gt;This post is valid for the Salesforce DX (SFDX) pilot. Please note that details may change and I’ll do my best to update accordingly.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Recently I highlighted a neat way to &lt;a href=&quot;http://www.wadewegner.com/2017/03/salesforce-dx-strike/&quot;&gt;use open source software with Salesforce DX&lt;/a&gt;. Since then I’ve used Appiphony’s custom base components many, many times in demos and apps I’ve built.&lt;/p&gt;

&lt;p&gt;It didn’t take long for me to get tired of removing the Git details when pulling the OSS from Github. So I created &lt;a href=&quot;https://github.com/wadewegner/sfdx-oss-plugin&quot;&gt;sfdx-oss-plugin&lt;/a&gt;. With this command, you can run &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx wadewegner:source:oss -r wadewegner/Strike-Components -p .&lt;/code&gt; to grab all the source listed in the &lt;a href=&quot;https://github.com/wadewegner/Strike-Components/blob/master/sfdx-oss-manifest.json&quot;&gt;SFDX oss manifest&lt;/a&gt; into whatever directory you specify. It also makes it really easy to create a SFDX oss manifest file with the command &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx wadewegner:source:create -p .&lt;/code&gt;, which creates the JSON file for everything in the specified path.&lt;/p&gt;

&lt;p&gt;Pretty nifty, eh? To try it out:&lt;/p&gt;

&lt;p&gt;1) Install the SDFX CLI.&lt;/p&gt;

&lt;p&gt;2) Clone the repo: &lt;code class=&quot;highlighter-rouge&quot;&gt;git clone git@github.com:wadewegner/sfdx-oss-plugin.git&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Install npm modules: &lt;code class=&quot;highlighter-rouge&quot;&gt;npm install&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4) Link the plugin: &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx plugins:link .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;(Perhaps I’ll publish this at somepoint.)&lt;/p&gt;

&lt;p&gt;This highlights one of the advantages building our Salesforce CLI on the Heroku CLI. Not only do we get to take advantage of frequent updates (both for features and security) of the Heroku CLI, but we can also take advantage of plugin extensibility.&lt;/p&gt;

&lt;p&gt;For the most part, building a plugin for the Salesforce CLI is exactly the same as &lt;a href=&quot;https://devcenter.heroku.com/articles/developing-cli-plugins&quot;&gt;building a plugin for the Heroku CLI&lt;/a&gt;. I think you’ll find &lt;a href=&quot;https://github.com/wadewegner/sfdx-oss-plugin&quot;&gt;sfdx-oss-plugin&lt;/a&gt; a very good reference.&lt;/p&gt;

&lt;p&gt;One significant change we’ve made is the introduction of a namespace. You can see it on &lt;a href=&quot;https://github.com/wadewegner/sfdx-oss-plugin/blob/master/index.js#L16&quot;&gt;index.js#L16&lt;/a&gt; and in the following sample:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;exports.namespace = {
    name: 'wadewegner',
    description: 'commands from Wade Wegner'
};
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This organizes all the commands in my plugin under &lt;code class=&quot;highlighter-rouge&quot;&gt;sfdx wadewegner&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Overtime, things will change. I’ll be sure to update this post accordingly.&lt;/p&gt;

&lt;p&gt;I hope you’ve found this post useful and that you’re enjoying the Salesforce DX pilot! To add yourself to the Salesforce DX pilot waitlist, enter your info here: &lt;a href=&quot;http://go.pardot.com/l/27572/2017-01-23/6gh89x&quot;&gt;http://go.pardot.com/l/27572/2017-01-23/6gh89x&lt;/a&gt;&lt;/p&gt;
</description>
                <link>/2017/03/creating-a-plugin-for-the-sf-cli/</link>
                <guid>/2017/03/creating-a-plugin-for-the-sf-cli</guid>
                <pubDate>Fri, 31 Mar 2017 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Salesforce DX Strike</title>
                <description>&lt;p&gt;Like many people at Salesforce and in the community, I was really excited and impressed to see &lt;a href=&quot;http://www.lightningstrike.io/&quot;&gt;Lightning Strike by Appiphony&lt;/a&gt;. Not to take away from the remarkable tool they built to visually explore and configure Lightning components, I was most excited by the custom Lightning Components they built and released to the community through their &lt;a href=&quot;https://github.com/appiphony/Strike-Components&quot;&gt;Github repository Strike-Components&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Immediately I wanted to try these components out myself. And fortunate, using Salesforce DX, it’s really quite easy.&lt;/p&gt;

&lt;p&gt;Here’s a Gist showing the commands I ran to quickly pull these open source Lightning components into my Salesforce DX workspace and push into my scratch org.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/d156fe0e86971fac23d17977cc99374b.js&quot;&gt;&lt;/script&gt;

&lt;p&gt;I think this is a great example of how Salesforce developers can quickly take advantage of open source software.&lt;/p&gt;

&lt;p&gt;In fact, this has me thinking that there’s more we can do as part of Salesforce DX to make this even easier. Stay tuned for more updates!&lt;/p&gt;
</description>
                <link>/2017/03/salesforce-dx-strike/</link>
                <guid>/2017/03/salesforce-dx-strike</guid>
                <pubDate>Tue, 07 Mar 2017 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Salesforce DX Pilot Demos</title>
                <description>&lt;p&gt;We’re so excited to have recently launched the Salesforce DX pilot. Our teams have been hard at work on Salesforce DX, and it’s tremendously exciting to have so many of you using the tools and trying out an entirely new way to build applications on the Salesforce platform.&lt;/p&gt;

&lt;p&gt;I thought it would be helpful to share with everyone the demos from the Salesforce DX pilot kickoff webinar. This is cut directly from the webinar, so apologies for any rough edges.&lt;/p&gt;

&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/TFe0bthtYP4?ecver=1&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;If you have any questions, please ask me &lt;a href=&quot;https://twitter.com/wadewegner&quot;&gt;@WadeWegner&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To add yourself to the Salesforce Pilot waitlist, enter your info here: &lt;a href=&quot;http://go.pardot.com/l/27572/2017-01-23/6gh89x&quot;&gt;http://go.pardot.com/l/27572/2017-01-23/6gh89x&lt;/a&gt;&lt;/p&gt;
</description>
                <link>/2017/02/salesforce-dx-pilot-demos/</link>
                <guid>/2017/02/salesforce-dx-pilot-demos</guid>
                <pubDate>Mon, 27 Feb 2017 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Creating a Go Site Extension and Resource Template for Azure</title>
                <description>&lt;p&gt;The New Year is a good time to set goals for yourself. I’ve challenged myself this year to explore and ship some apps using the Go language, which is likely no surprise given my recent posts on &lt;a href=&quot;http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/&quot;&gt;setting up Go on Windows&lt;/a&gt; and &lt;a href=&quot;http://www.wadewegner.com/2014/12/4-simple-steps-to-run-go-language-in-azure-websites/&quot;&gt;running Go on Azure Websites&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As part of my initial explorations, I used Azure Websites to host my Go web apps. The last post I wrote showed my first &lt;a href=&quot;http://www.wadewegner.com/2014/12/4-simple-steps-to-run-go-language-in-azure-websites/&quot;&gt;Go prototype on Azure Websites&lt;/a&gt;. While useful as a prototype, it’s arguably not the most straightforward way to go about building and deploying your Go web app. The principal issue is that the Go runtime is not available by default on Azure Websites; we have to configure the website to use downloaded Go binaries. While my first prototype works, Azure has two capabilities you’ve likely never heard of which can help simplify and automate: Site Extensions and the Azure Resource Manager.&lt;/p&gt;

&lt;p&gt;So, what did I do? I created a &lt;a href=&quot;https://www.siteextensions.net/packages/golang/&quot;&gt;site extension for Go&lt;/a&gt; and wrote a &lt;a href=&quot;https://github.com/wadewegner/azure-go-lang-site-extension/blob/master/scripts/Template.json&quot;&gt;resource template&lt;/a&gt; and &lt;a href=&quot;https://github.com/wadewegner/azure-go-lang-site-extension/blob/master/scripts/Deploy.ps1&quot;&gt;PowerShell script&lt;/a&gt; for deploying an Azure Website that installs the site extention. You can find everything in my &lt;a href=&quot;https://github.com/wadewegner/azure-go-lang-site-extension&quot;&gt;azure-go-lang-site-extension&lt;/a&gt; respository on Github.&lt;/p&gt;

&lt;p&gt;Let’s see how it works.&lt;/p&gt;

&lt;h3 id=&quot;create-the-site-extension&quot;&gt;Create the Site Extension&lt;/h3&gt;

&lt;p&gt;Site Extensions are exactly what the name suggests and provide ways to extend your Azure Website. You create a NuGet package with your code and config, package it up, deploy it to &lt;a href=&quot;https://www.siteextensions.net/&quot;&gt;https://www.siteextensions.net/&lt;/a&gt; (actually, any NuGet feed), and later you can apply these packages to your Azure Website. For additional details, please see the &lt;a href=&quot;http://azure.microsoft.com/blog/2014/06/20/azure-web-sites-extensions/&quot;&gt;Azure Web Site Extensions&lt;/a&gt; blog post and the &lt;a href=&quot;https://github.com/projectkudu/kudu/wiki/Azure-Site-Extensions&quot;&gt;Azure Site Extensions wiki&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I used two important capabilities to get Go setup in the Azure Website: install/uninstall scripts and XML Document Transformation (XDT).&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bat&quot; data-lang=&quot;bat&quot;&gt;IF NOT EXIST &quot;%WEBROOT_PATH%server.go&quot; (&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	cp server.go %WEBROOT_PATH%&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;)&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;IF NOT EXIST &quot;%WEBROOT_PATH%go1.4.windows-386.zip&quot; (&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	cd /D %WEBROOT_PATH%&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	curl -O https://storage.googleapis.com/golang/go1.4.windows-386.zip&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	start unzip -o go1.4.windows-386.zip -d .&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;)&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;First, I wrote an install script called &lt;code class=&quot;highlighter-rouge&quot;&gt;install.cmd&lt;/code&gt; which performs the following tasks:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Copies the &lt;code class=&quot;highlighter-rouge&quot;&gt;server.go&lt;/code&gt; file into the webroot. This is the file that serves the HTTP responses and the same one I used in my prototype.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Downloads the Go SDK using curl.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Unzips the Go SDK.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Unzipping the Go SDK can take several minutes. Today, this causes issues when trying to install the site extension from the Azure Portal and the Azure Resource Manager, as it will timeout, throw an error, and continue to retry until it ultimately fails. Consequently, I use the command &lt;code class=&quot;highlighter-rouge&quot;&gt;start&lt;/code&gt; to run the unzip operation asynchronously, allowing the &lt;code class=&quot;highlighter-rouge&quot;&gt;install.cmd&lt;/code&gt; execution to return and not causing a timeout error. While this solves the problem it is not ideal for if the instance is restarted during the process of unzipping the SDK it could leave us in a faulted state. This is likely a short term issue and I’ll update this post when it is resolved.&lt;/p&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;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xmlns:xdt=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;http://schemas.microsoft.com/XML-Document-Transform&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt; &lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;location&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;%XDT_SITENAME%&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Locator=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Match(path)&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.webServer&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;handlers&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;InsertIfMissing&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;httpplatformhandler&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;*&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;verb=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;*&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;modules=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;httpPlatformHandler&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;resourceType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Unspecified&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;InsertIfMissing&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/handlers&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;httpPlatform&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;processPath=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;d:\home\site\wwwroot\go\bin\go.exe&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;                    &lt;span class=&quot;na&quot;&gt;arguments=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;run d:\home\site\wwwroot\server.go&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;                    &lt;span class=&quot;na&quot;&gt;startupTimeLimit=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;60&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;InsertIfMissing&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;environmentVariables&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;span class=&quot;nt&quot;&gt;&amp;lt;environmentVariable&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;GOROOT&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;d:\home\site\wwwroot\go&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;xdt:Transform=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;InsertIfMissing&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/environmentVariables&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;span class=&quot;nt&quot;&gt;&amp;lt;/httpPlatform&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.webServer&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/location&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Next, I wrote an XML document transform for the &lt;code class=&quot;highlighter-rouge&quot;&gt;applicationHost.Config&lt;/code&gt; file to tell IIS to use our Go binaries for responding to web requests. After the site extension is installed and the first web request is processed, the &lt;code class=&quot;highlighter-rouge&quot;&gt;applicationHost.config&lt;/code&gt; file is updated to include the additional configuration details. It’s important to point out the &lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;location&amp;gt; ... &amp;lt;location&amp;gt;&lt;/code&gt; element, as this ensures our changes only apply to the correct website; otherwise, anything hosted on this machine is affected.&lt;/p&gt;

&lt;p&gt;If you have questions on this configuration information, see my earlier post on &lt;a href=&quot;http://www.wadewegner.com/2014/12/4-simple-steps-to-run-go-language-in-azure-websites/&quot;&gt;setting up Go on Azure websites&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Packaging all of this into a site extension is pretty easy as it’s based on NuGet. I first created a &lt;a href=&quot;https://github.com/wadewegner/azure-go-lang-site-extension/blob/master/GoLang.nuspec&quot;&gt;Nuspec file&lt;/a&gt; to describe the package and then a &lt;a href=&quot;https://github.com/wadewegner/azure-go-lang-site-extension/blob/master/build.cmd&quot;&gt;build script&lt;/a&gt; which uses NuGet to create the package. The result is a NuPkg which I then upload to &lt;a href=&quot;https://www.siteextensions.net/&quot;&gt;https://www.siteextensions.net/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At this point you can log into the &lt;a href=&quot;http://portal.azure.com/&quot;&gt;Azure Portal&lt;/a&gt;, create an Azure Website (or use an existing one), and install the Site Extension. Load your website blade and scroll down until you see the &lt;code class=&quot;highlighter-rouge&quot;&gt;Extensions&lt;/code&gt; tile.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5613696/8d0ec790-94a5-11e4-9907-4f505b18bcf9.png&quot; alt=&quot;zeroextensions&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Through the extensions blade you can browse available Site Extensions. You’ll find &lt;code class=&quot;highlighter-rouge&quot;&gt;Go Lang for Azure Websites&lt;/code&gt;. Install it, and you’ll see it listed as one of your site extensions.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5613717/e0e28e06-94a5-11e4-9b25-72d1eb5579f5.png&quot; alt=&quot;installedextension&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Wait a few minutes and click the &lt;code class=&quot;highlighter-rouge&quot;&gt;Browse&lt;/code&gt; link; you now have a Go web app running in Azure Websites. Not too bad! Of course, we can make the last step of creating the Azure Website and installing the Site Extension easier with the Azure Resource Manager.&lt;/p&gt;

&lt;h3 id=&quot;create-the-resource-template&quot;&gt;Create the Resource Template&lt;/h3&gt;

&lt;p&gt;The Azure Resource Manager is a relatively new technology that provides a container for managing the lifecycle of Azure resources (called a &lt;a href=&quot;http://azure.microsoft.com/en-us/documentation/articles/azure-preview-portal-using-resource-groups/&quot;&gt;resource group&lt;/a&gt;), a way to describe and execute the deployment and configuration of a set of Azure resources, and a management layer for these resources. As the resource manager is still in preview, documentation is hard to find; particularly for resource templates. To learn more about the resource manager, I recommend you watch &lt;a href=&quot;http://channel9.msdn.com/Events/Build/2014/2-607&quot;&gt;Introduction to Azure Resource Manager&lt;/a&gt; from Build 2014 and read the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/azure/dn790568.aspx&quot;&gt;REST API Reference&lt;/a&gt; and &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/azure/dn835138.aspx&quot;&gt;Template Language&lt;/a&gt; guides.&lt;/p&gt;

&lt;p&gt;The resource template is nothing more than a JSON file that describes the Azure resources we want to deploy; in this case, it’s an Azure Website along with our Go site extension. Let’s look at the template.&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;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;$schema&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;s2&quot;&gt;&quot;http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;contentVersion&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;s2&quot;&gt;&quot;1.0.0.0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;parameters&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;siteName&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;hostingPlanName&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;siteLocation&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sku&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;allowedValues&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Free&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Shared&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Basic&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Standard&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;defaultValue&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;s2&quot;&gt;&quot;Free&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;workerSize&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;string&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;allowedValues&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;defaultValue&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;s2&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;variables&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;goSite&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;s2&quot;&gt;&quot;[parameters('siteName')]&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;resources&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apiVersion&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;s2&quot;&gt;&quot;2014-04-01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&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;s2&quot;&gt;&quot;[parameters('hostingPlanName')]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;Microsoft.Web/serverfarms&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;location&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;s2&quot;&gt;&quot;[parameters('siteLocation')]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;properties&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&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;s2&quot;&gt;&quot;[parameters('hostingPlanName')]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;sku&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;s2&quot;&gt;&quot;[parameters('sku')]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;workerSize&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;s2&quot;&gt;&quot;0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;numberOfWorkers&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;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apiVersion&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;s2&quot;&gt;&quot;2014-04-01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&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;s2&quot;&gt;&quot;[variables('goSite')]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;Microsoft.Web/sites&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;location&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;s2&quot;&gt;&quot;[parameters('siteLocation')]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dependsOn&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;properties&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&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;s2&quot;&gt;&quot;[variables('goSite')]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;webHostingPlan&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;s2&quot;&gt;&quot;[parameters('hostingPlanName')]&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;resources&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apiVersion&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;s2&quot;&gt;&quot;2014-04-01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&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;s2&quot;&gt;&quot;web&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;config&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dependsOn&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;            &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[resourceId('Microsoft.Web/Sites', variables('goSite'))]&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;properties&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;            &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;appSettings&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;br data-jekyll-commonmark-ghpages=&quot;&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;s2&quot;&gt;&quot;Name&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;s2&quot;&gt;&quot;SCM_SITEEXTENSIONS_FEED_URL&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;s2&quot;&gt;&quot;Value&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;s2&quot;&gt;&quot;http://www.siteextensions.net/api/v2/&quot;&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;            &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apiVersion&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;s2&quot;&gt;&quot;2014-04-01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&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;s2&quot;&gt;&quot;GoLang&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;siteextensions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dependsOn&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;            &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[resourceId('Microsoft.Web/Sites', variables('goSite'))]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;            &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[resourceId('Microsoft.Web/Sites/config', variables('goSite'), 'web')]&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;            &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;          &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;properties&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;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&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;I’m not going to attempt to explain this entire template as that’s well beyond the scope of this post. Take a look at this &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/azure/dn835138.aspx&quot;&gt;guide on the template language&lt;/a&gt; if you want to learn more.&lt;/p&gt;

&lt;p&gt;For our purposes, I want to highlight the last section:&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;err&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;apiVersion&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;s2&quot;&gt;&quot;2014-04-01&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;name&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;s2&quot;&gt;&quot;GoLang&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;type&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;s2&quot;&gt;&quot;siteextensions&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dependsOn&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;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[resourceId('Microsoft.Web/Sites', variables('goSite'))]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;[resourceId('Microsoft.Web/Sites/config', variables('goSite'), 'web')]&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;  &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;properties&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;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Here we tell the resource manager that we want the &lt;code class=&quot;highlighter-rouge&quot;&gt;GoLang&lt;/code&gt; site extension installed into our Azure Website. Simple but effective.&lt;/p&gt;

&lt;p&gt;To execute this template, use PowerShell. I wrote a script which makes this pretty simple.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-powershell&quot; data-lang=&quot;powershell&quot;&gt;&lt;span class=&quot;k&quot;&gt;Switch&lt;/span&gt;-AzureMode -Name AzureResourceManager&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$subName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOURSUBSCRIPTIONNAME&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$userName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOURORGIDUSERNAME&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$securePassword&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ConvertTo-SecureString&lt;/span&gt; -String &lt;span class=&quot;s2&quot;&gt;&quot;YOURPASSWORD&quot;&lt;/span&gt; -AsPlainText -Force&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;YOURRESOURCEGROUPNAME&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$location&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;West US&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$templateFile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Template.json&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$siteName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$name&lt;/span&gt; + &lt;span class=&quot;s2&quot;&gt;&quot;Site&quot;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$hostingPlanName&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$name&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nv&quot;&gt;$cred&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;New-Object &lt;/span&gt;System.Management.Automation.PSCredential&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$userName&lt;/span&gt;, &lt;span class=&quot;nv&quot;&gt;$securePassword&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;Add-AzureAccount -Credential &lt;span class=&quot;nv&quot;&gt;$cred&lt;/span&gt; &lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;nb&quot;&gt;Select&lt;/span&gt;-AzureSubscription -SubscriptionName &lt;span class=&quot;nv&quot;&gt;$subName&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;New-AzureResourceGroup -Name &lt;span class=&quot;nv&quot;&gt;$name&lt;/span&gt; -Location &lt;span class=&quot;nv&quot;&gt;$location&lt;/span&gt; -TemplateFile &lt;span class=&quot;nv&quot;&gt;$templateFile&lt;/span&gt; -siteName &lt;span class=&quot;nv&quot;&gt;$siteName&lt;/span&gt; -hostingPlanName &lt;span class=&quot;nv&quot;&gt;$hostingPlanName&lt;/span&gt; -siteLocation &lt;span class=&quot;nv&quot;&gt;$location&lt;/span&gt; -Force&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt; &lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;&lt;span class=&quot;k&quot;&gt;Switch&lt;/span&gt;-AzureMode -Name AzureServiceManagement&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;When you run this command it will create a resource group and run the resource template, resulting in a new Azure Website with our site extension installed.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5613872/dc0c8f7e-94a7-11e4-8313-a00b174f3daf.png&quot; alt=&quot;psoutput&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The parameters &lt;code class=&quot;highlighter-rouge&quot;&gt;siteName&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;hostingPlanName&lt;/code&gt;, and &lt;code class=&quot;highlighter-rouge&quot;&gt;siteLocation&lt;/code&gt; are all defined within the resource template. For documentation on the &lt;code class=&quot;highlighter-rouge&quot;&gt;New-AzureResourceGroup&lt;/code&gt; syntax you can review the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dn654594.aspx&quot;&gt;MSDN documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And that’s it, my friends. The end result is an Azure Website you can use to start playing around with Go.&lt;/p&gt;

&lt;p&gt;There’s a lot of stuff to think about in this blog post. While my goal here was to make it easy to setup Go inside Azure Websites, I hope you see this as an example of how you can take advantage of Site Extensions and the Azure Resource Manager to do some amazing things in Azure.&lt;/p&gt;

&lt;p&gt;Special thanks to &lt;a href=&quot;https://twitter.com/davidebbo&quot;&gt;David Ebbo&lt;/a&gt; for his help when creating the site extension!&lt;/p&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;
</description>
                <link>/2015/01/creating-a-go-site-extension-and-resource-template-for-azure/</link>
                <guid>/2015/01/creating-a-go-site-extension-and-resource-template-for-azure</guid>
                <pubDate>Mon, 05 Jan 2015 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>4 Simple Steps to Run Go Language in Azure Websites</title>
                <description>&lt;p&gt;A few weeks ago I wrote a GoLang web app and wanted to find a good place to host it. Given I work with the team that builds Azure Websites, it seemed only fitting to host it in Azure Websites. Turns out, it works great! However, there aren’t any resources available that walk you through the steps. Consequently, I wrote the following tutorial.&lt;/p&gt;

&lt;p&gt;(Incidentally, if you want to start to use Go Language and run Windows you’ll want to review my post &lt;a href=&quot;http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/&quot;&gt;Easy Go Programming Setup for Windows&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;Is this the absolutely authority on running Go Language in Azure Websites? No, but it works. I plan to publish a few more articles on more complex scenarios in the future.&lt;/p&gt;

&lt;h3 id=&quot;4-simple-steps&quot;&gt;4 Simple Steps&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Create your Azure Website in the &lt;a href=&quot;https://portal.azure.com&quot;&gt;Azure Portal&lt;/a&gt;. Without a doubt the easiest step.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Download and unzip the Go executables. In the Azure Portal select your website blade and scroll down until you see the &lt;code class=&quot;highlighter-rouge&quot;&gt;Console&lt;/code&gt; tile.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5574198/146ffd92-8f76-11e4-9975-f9e4cd51b9fe.png&quot; alt=&quot;Open Console on the Azure websites blade&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;In the console to the right, type the following commands:&lt;/p&gt;

    &lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;curl -O https://storage.googleapis.com/golang/go1.4.windows-386.zip &lt;/code&gt;&lt;/p&gt;

    &lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;unzip go1.4.windows-386.zip &lt;/code&gt;&lt;/p&gt;

    &lt;p&gt;You should see the following:&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5574286/0ac47f78-8f78-11e4-91c3-1a5f4a6540ae.png&quot; alt=&quot;unzipped&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;Be patient with the console as these two operations may take a few moments. It’s purposefully simple.&lt;/p&gt;

    &lt;p&gt;Note: I’m not sure why it returns &lt;code class=&quot;highlighter-rouge&quot;&gt;Bad Request&lt;/code&gt; but so far it doesn’t seem to cause any issues.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Create a &lt;code class=&quot;highlighter-rouge&quot;&gt;server.go&lt;/code&gt; file in the &lt;code class=&quot;highlighter-rouge&quot;&gt;wwwroot&lt;/code&gt; folder. This is a super simple Go file which will reply for any resource on the website.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-go&quot; data-lang=&quot;go&quot;&gt;&lt;span class=&quot;k&quot;&gt;package&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;fmt&quot;&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;net/http&quot;&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;os&quot;&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ResponseWriter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Fprintf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;w&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;You just browsed page (if blank you're at the root): %s&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;URL&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Path&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;o&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;func&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;main&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HandleFunc&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;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;handler&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ListenAndServe&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;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Getenv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;HTTP&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\_&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;PLATFORM&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\_&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;PORT&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;x&quot;&gt; &lt;/span&gt;&lt;span class=&quot;no&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;x&quot;&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&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;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;As a convenience, feel free to use `curl` and download this directly from [my public gist](https://gist.github.com/wadewegner/52a925a7b1607a48d796). Otherwise, you should consider using Kudu or git to get your files into your Azure Website.

`curl -L http://bit.ly/1xtYNRU --output server.go`

Once downloaded, type `type server.go` to confirm you grabbed everything correctly.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;Create a &lt;code class=&quot;highlighter-rouge&quot;&gt;Web.Config&lt;/code&gt; file in the &lt;code class=&quot;highlighter-rouge&quot;&gt;wwwroot&lt;/code&gt; folder. We will use the &lt;code class=&quot;highlighter-rouge&quot;&gt;httpPlatformHandler&lt;/code&gt; simpilar to &lt;a href=&quot;http://azure.microsoft.com/en-us/documentation/articles/web-sites-java-custom-upload/&quot;&gt;running Tomcat in Azure Websites&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&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;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	&lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;span class=&quot;nt&quot;&gt;&amp;lt;system.webServer&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	        &lt;span class=&quot;nt&quot;&gt;&amp;lt;handlers&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	            &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;httpplatformhandler&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;path=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;\*&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;verb=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;\*&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;modules=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;httpPlatformHandler&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;resourceType=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Unspecified&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/handlers&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	        &lt;span class=&quot;nt&quot;&gt;&amp;lt;httpPlatform&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;processPath=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;d:\home\site\wwwroot\go\bin\go.exe&quot;&lt;/span&gt; &lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	                      &lt;span class=&quot;na&quot;&gt;arguments=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;run d:\home\site\wwwroot\server.go&quot;&lt;/span&gt; &lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	                      &lt;span class=&quot;na&quot;&gt;startupTimeLimit=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;60&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	            &lt;span class=&quot;nt&quot;&gt;&amp;lt;environmentVariables&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	              &lt;span class=&quot;nt&quot;&gt;&amp;lt;environmentVariable&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;GOROOT&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;d:\home\site\wwwroot\go&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	            &lt;span class=&quot;nt&quot;&gt;&amp;lt;/environmentVariables&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	        &lt;span class=&quot;nt&quot;&gt;&amp;lt;/httpPlatform&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/system.webServer&amp;gt;&lt;/span&gt;&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;	&lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Again, you can use the following curl command to download the `Web.Config` file:

`curl -L http://bit.ly/1wx4JFY --output Web.Config`
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That is it! You can now browse to your Azure Website and see it in action.&lt;/p&gt;

&lt;p&gt;For now, try it out here: &lt;a href=&quot;http://golang.azurewebsites.net/hello&quot;&gt;http://golang.azurewebsites.net/hello&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Is there more we can do here? Absolutely, and I intend to cover some additional topics in future posts. However, for now, it feels good knowing that we can push our Go Language code to Azure Websites.&lt;/p&gt;

&lt;p&gt;Special thanks to &lt;a href=&quot;https://twitter.com/ranjithtweeets&quot;&gt;Ranjith Mukkai Ramachandra&lt;/a&gt; for his help and answering all my questions quickly and thoroughly!&lt;/p&gt;
</description>
                <link>/2014/12/4-simple-steps-to-run-go-language-in-azure-websites/</link>
                <guid>/2014/12/4-simple-steps-to-run-go-language-in-azure-websites</guid>
                <pubDate>Mon, 29 Dec 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Easy Go Programming Setup for Windows</title>
                <description>&lt;p&gt;I’ve had to do this more than once recently, so I figured I’d document the simple steps for setting up the Go programming language on Windows. Most of this is simple and straightforward. The only tricky part I found is setting up your GOPATH, which defines a convention for storing and building Go code you write and acquire from open source code repositories.&lt;/p&gt;

&lt;h3 id=&quot;5-simple-steps&quot;&gt;5 Simple Steps&lt;/h3&gt;

&lt;p&gt;Follow these five simple steps to install Go.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Make sure you have both Git &lt;a href=&quot;http://git-scm.com/download/win&quot;&gt;download&lt;/a&gt; and Mercurial &lt;a href=&quot;http://mercurial.selenic.com/wiki/Download&quot;&gt;download&lt;/a&gt; installed. With Go programming you’ll make heavy use of open source repositories.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Download&lt;/strong&gt; and &lt;strong&gt;install&lt;/strong&gt; the latest 64-bit Go MSI distributable (which sets most of the environmental variables for you). &lt;a href=&quot;https://golang.org/dl/&quot;&gt;https://golang.org/dl/&lt;/a&gt;&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536386/184c0a8c-8a4e-11e4-828c-dd3320fbdd41.png&quot; alt=&quot;go1-4-windows-amd64-msi&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;To make things simple, use the default installation path at &lt;code class=&quot;highlighter-rouge&quot;&gt;C:\Go&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Ensure the &lt;strong&gt;Go binaries&lt;/strong&gt; (found in &lt;code class=&quot;highlighter-rouge&quot;&gt;C:\Go\bin&lt;/code&gt;) are in your &lt;code class=&quot;highlighter-rouge&quot;&gt;Path&lt;/code&gt; system environment variables. To check click &lt;code class=&quot;highlighter-rouge&quot;&gt;System&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;Advanced system settings&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;Environment Variables...&lt;/code&gt; and open &lt;code class=&quot;highlighter-rouge&quot;&gt;Path&lt;/code&gt; under &lt;code class=&quot;highlighter-rouge&quot;&gt;System variables&lt;/code&gt;:&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536474/965ff18a-8a4f-11e4-853f-aede7735a6fd.png&quot; alt=&quot;gopath&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;An easy way to confirm is to open the command line and type &lt;code class=&quot;highlighter-rouge&quot;&gt;go version&lt;/code&gt;:&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536483/e51af5c2-8a4f-11e4-8b7f-dddcf0a32548.png&quot; alt=&quot;gopathcmd&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Setup your &lt;strong&gt;Go workspace&lt;/strong&gt;. This consists of three folders at the root:&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; bin/
 pkg/
 src/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;I create a &lt;code class=&quot;highlighter-rouge&quot;&gt;C:\Projects\Go&lt;/code&gt; folder as my root Go workspace:&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536646/909c8c06-8a52-11e4-8cb0-1ba9b5077f8a.png&quot; alt=&quot;goworkspace&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Create the &lt;strong&gt;GOPATH environment variable&lt;/strong&gt; and reference your Go workspace path. To add, click &lt;code class=&quot;highlighter-rouge&quot;&gt;System&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;Advanced system settings&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;Environment Variables...&lt;/code&gt; and click &lt;code class=&quot;highlighter-rouge&quot;&gt;New...&lt;/code&gt; under &lt;code class=&quot;highlighter-rouge&quot;&gt;System variables&lt;/code&gt;:&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536717/6ef223da-8a53-11e4-96bf-3cbbd9acf589.png&quot; alt=&quot;gopathenvvar&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;Set the variable name to &lt;code class=&quot;highlighter-rouge&quot;&gt;GOPATH&lt;/code&gt; and value to your Go workspace path (e.g. &lt;code class=&quot;highlighter-rouge&quot;&gt;C:\Projects\Go&lt;/code&gt;):&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536757/feb28c94-8a53-11e4-9bf4-02728abe34e5.png&quot; alt=&quot;gopathvalue&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;You can quickly check to ensure your path has been set by opening the command line and typing &lt;code class=&quot;highlighter-rouge&quot;&gt;echo %GOPATH%&lt;/code&gt; and check the output:&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536824/39de5004-8a55-11e4-8140-ee39858cc1f4.png&quot; alt=&quot;gopathecho&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And that’s all it takes! You’re ready to get started.&lt;/p&gt;

&lt;h3 id=&quot;verify&quot;&gt;Verify&lt;/h3&gt;

&lt;p&gt;Want to quickly test and ensure this is all working as expected? Open the command line and type the following:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bat&quot; data-lang=&quot;bat&quot;&gt;go get github.com/golang/example/hello&lt;br data-jekyll-commonmark-ghpages=&quot;&quot; /&gt;%GOPATH%/bin/hello&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;You should see the output as “Hello, Go examples!” (refreshingly, not your typical hello world):&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/5536857/ad39c088-8a55-11e4-9080-c87d62ca55c8.png&quot; alt=&quot;gohelloworld&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;
</description>
                <link>/2014/12/easy-go-programming-setup-for-windows/</link>
                <guid>/2014/12/easy-go-programming-setup-for-windows</guid>
                <pubDate>Tue, 23 Dec 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Build a Windows 8 App for Salesforce With No Code Using Project Siena</title>
                <description>&lt;p&gt;Microsoft Project Siena (Beta) is a tool that allows a business user (i.e. non-developer) to quickly building rich business applications for Windows 8. You can learn all about the tool on the &lt;a href=&quot;http://www.microsoft.com/en-us/projectsiena/default.aspx&quot;&gt;Microsoft Project Siena web site&lt;/a&gt; and by watching a set of tutorials on the &lt;a href=&quot;http://channel9.msdn.com/Blogs/Microsoft-Project-Siena&quot;&gt;Microsoft Project Siena (Beta) Channel 9 Blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Having recently left Salesforce to join Microsoft, I was curious about how to build a Project Siena app that integrated into Salesforce. Project Siena uses the Web Application Description Language, or WADL, to connect to 3rd party SaaS services. WADL is an open web standard that is for REST what WSDL is for SOAP, meaning it describes the service resources and relationships.&lt;/p&gt;

&lt;p&gt;The release of the &lt;a href=&quot;http://gallery.technet.microsoft.com/WADL-Generator-for-Siena-cc311ee9&quot;&gt;WADL Generator for Project Siena (Alpha)&lt;/a&gt; makes the &lt;a href=&quot;http://social.technet.microsoft.com/wiki/contents/articles/23838.project-siena-creating-a-wadl-configuration-file.aspx&quot;&gt;generation of the WADL file&lt;/a&gt; extremely easy.&lt;/p&gt;

&lt;p&gt;Here’s a video that shows how a developer can define the relationship with Salesforce and create a WADL file that a business user can use within a Project Siena application.&lt;/p&gt;

&lt;p&gt;(Watch in full screen for the best experience.)&lt;/p&gt;

&lt;iframe src=&quot;http://channel9.msdn.com/Blogs/Wade-Wegner-s-Channel-9-Blog/Create-a-Windows-8-App-with-Salesforce-Data-Using-Project-Siena/player?h=450&amp;amp;w=800&quot; style=&quot;height:450px;width:800px;&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;There are a few reasons I think this is pretty compelling:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;I like the separations of concerns. The developer can setup the integration with Salesforce (or any REST API) and define functions used by a business user.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;WADL is an open web standard used by many companies, not just Microsoft.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Once in Project Siena, you don’t have to worry about setting up authentication or configuring authorization to the 3rd party SaaS provider. It’s already been done and the settings exist in the WADL file.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The business user has a very rich and interact experience when building the application. As the demo shows, even interacting with a REST API, and seeing the results, is possible at design time.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;All the business user really has to care about are controls &amp;amp; functions. (And perhaps a little bit of “Excel-like” coding.)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I think this is only the tip of the iceburg. Take a look at the other &lt;a href=&quot;http://channel9.msdn.com/Blogs/Microsoft-Project-Siena&quot;&gt;Project Siena tutorials&lt;/a&gt; to get more ideas about how you can use Project Siena to build applications.&lt;/p&gt;
</description>
                <link>/2014/08/build-a-windows-8-app-for-salesforce-with-no-code-using-project-siena/</link>
                <guid>/2014/08/build-a-windows-8-app-for-salesforce-with-no-code-using-project-siena</guid>
                <pubDate>Thu, 07 Aug 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Create an iBeacon Transmitter with the Raspberry Pi</title>
                <description>&lt;p&gt;iBeacon is the Apple trademark for a low-powered, low-cost transmitter that can notify nearby iOS 7 devices of its presence. It uses Bluetooth Low Energy (BLE), also called Bluetooth Smart, technology to transmit an advertisement that includes a universally unique identifier (UUID). Android devices can receive iBeacon advertisements and, fortunately for those of us who like to hack around, it doesn’t take too much work to setup a Raspberry Pi to emit iBeacon advertisements.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/3030868/149b9a9a-e046-11e3-9014-1138428103fe.jpg&quot; alt=&quot;Raspberry Pi transmitting as an iBeacon&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Why would you want to do this? Well, if the act of configuring a Raspberry Pi itself isn’t enough of a reward, consider some of the following use cases:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Host a digital scavenger hunt by placing iBeacons with different clues scattered around a conference.&lt;/li&gt;
  &lt;li&gt;Customize retail offers based on your location in a store and proximity to certain products.&lt;/li&gt;
  &lt;li&gt;Alert you while you sit at a bar enjoying your favorite craft beer when someone rides off with your bicycle outside.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I particularly enjoy the last use case. Simply tag your bag with a BLE transmitter and then, if it leaves the proximity/region, get alerted!&lt;/p&gt;

&lt;p&gt;If you look around the Internet you’ll find hundreds of additional use cases and ideas. The point is, this is cool technology with a lot of different applications and uses.&lt;/p&gt;

&lt;p&gt;In this post we’re going to look at how you can start to play around with this using that universal toy for the hacker: the Raspberry Pi.&lt;/p&gt;

&lt;h2 id=&quot;required-hardware&quot;&gt;Required Hardware&lt;/h2&gt;

&lt;p&gt;Here’s the hardware I use. You don’t have to purchase from &lt;a href=&quot;http://www.adafruit.com&quot;&gt;Adafruit&lt;/a&gt;, but to have the best results I’d recommend you try to get the same hardware I used; otherwise your mileage may vary.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/998&quot;&gt;Raspberry Pi Model B 512MB RAM&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/102&quot;&gt;SD/MicroSD Memory Card (4 GB SDHC)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/1327&quot;&gt;Bluetooth 4.0 USB Module (v2.1 Back-Compatible)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/501&quot;&gt;5V 1A (1000mA) USB port power supply&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/592&quot;&gt;USB cable - A/MicroB&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.adafruit.com/products/814&quot;&gt;Miniature WiFi (802.11b/g/n) Module&lt;/a&gt; (optional)&lt;/li&gt;
  &lt;li&gt;Raspberry Pi Case (optional)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The WiFi and Pi Case are optional but I strongly encourage you to get them. They’ll make your life a lot easier.&lt;/p&gt;

&lt;h2 id=&quot;setup-the-raspberry-pi-as-an-ibeacon-transmitter&quot;&gt;Setup the Raspberry Pi as an iBeacon Transmitter&lt;/h2&gt;

&lt;p&gt;Over the past week I’ve had to setup and configure numerous Raspberry Pi’s as iBeacons. Yes, there are a lot of tutorials, but sadly none worked perfectly for me. As so often happens when you’re on the bleeding edge, things change and instructions stagnate. Additionally, I think some of the tutorials are simply wrong or poorly document the process.&lt;/p&gt;

&lt;p&gt;Here are the steps I’ve taken to, repeatedly, get Raspberry Pi’s setup as iBeacon transmitters. If you follow these instructions with the above hardware I’m reasonably confident you can get this up and running with no problems.&lt;/p&gt;

&lt;h3 id=&quot;step-1-download-an-operating-system-image&quot;&gt;Step 1: Download an Operating System Image&lt;/h3&gt;

&lt;p&gt;There are numerous OS images you can use with the Raspberry Pi. I chose to use the &lt;strong&gt;Raspbian Debian Wheezy&lt;/strong&gt; image. The steps below work on the &lt;strong&gt;2014-01-07&lt;/strong&gt; release.&lt;/p&gt;

&lt;p&gt;Download the image from the official downloads page: &lt;a href=&quot;http://www.raspberrypi.org/downloads/&quot;&gt;http://www.raspberrypi.org/downloads/&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;step-2-write-the-image-to-the-sd-card&quot;&gt;Step 2: Write the Image to the SD Card&lt;/h3&gt;

&lt;p&gt;There are &lt;a href=&quot;http://www.raspberrypi.org/documentation/installation/installing-images/README.md&quot;&gt;numerous tutorials&lt;/a&gt; available for this step.&lt;/p&gt;

&lt;p&gt;If you’re using a Mac I recommend Ray Viljoen’s &lt;a href=&quot;https://github.com/RayViljoen/Raspberry-PI-SD-Installer-OS-X&quot;&gt;Raspberry PI SD Installer OS X&lt;/a&gt; script. Works great.&lt;/p&gt;

&lt;h3 id=&quot;step-3-connect-to-the-raspberry-pi&quot;&gt;Step 3: Connect to the Raspberry Pi&lt;/h3&gt;

&lt;p&gt;Again, you have numerous options for connecting to the device. I personally like to use the &lt;a href=&quot;https://learn.adafruit.com/adafruits-raspberry-pi-lesson-5-using-a-console-cable?view=all&quot;&gt;Console Cable&lt;/a&gt; to connect directly from my Mac but you can also connect with Ethernet &amp;amp; SSH or connect a monitor and keyboard.&lt;/p&gt;

&lt;p&gt;It’s worth noting that your default user name is &lt;code class=&quot;highlighter-rouge&quot;&gt;pi&lt;/code&gt; and password is &lt;code class=&quot;highlighter-rouge&quot;&gt;raspberry&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;step-4-initial-device-configuration&quot;&gt;Step 4: Initial Device Configuration&lt;/h3&gt;

&lt;p&gt;Once you connect to the device you should first configure a few settings. Run &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo raspi-config&lt;/code&gt; and complete the following six steps.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Choose &lt;strong&gt;Expand Filesystem&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;You should &lt;strong&gt;Change User Password&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;Choose &lt;strong&gt;Internationalisation Options&lt;/strong&gt; then &lt;strong&gt;I1 Change Locale&lt;/strong&gt;. I removed the existing setting and chose &lt;strong&gt;enUS.UTF-8 UTF-8&lt;/strong&gt;.&lt;/li&gt;
  &lt;li&gt;Choose &lt;strong&gt;Internationalisation Options&lt;/strong&gt; then &lt;strong&gt;I2 Change Timezone&lt;/strong&gt;. Set accordingly.&lt;/li&gt;
  &lt;li&gt;Choose &lt;strong&gt;Advanced Options&lt;/strong&gt; then &lt;strong&gt;A2 Hostname&lt;/strong&gt;. Choose something unique.&lt;/li&gt;
  &lt;li&gt;Choose &lt;strong&gt;Advanced Options&lt;/strong&gt; then &lt;strong&gt;A4 SSH&lt;/strong&gt;. It’s likely enabled already but you may as well make sure.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Reboot the Raspberry Pi (&lt;code class=&quot;highlighter-rouge&quot;&gt;sudo shutdown -r now&lt;/code&gt;) and reconnect.&lt;/p&gt;

&lt;h3 id=&quot;step-5-setup-wifi-optional&quot;&gt;Step 5: Setup WiFi (Optional)&lt;/h3&gt;

&lt;p&gt;While not absolutely necessary, I always setup WiFi on my Raspberry Pi so that it doesn’t require Ethernet or a console cable for me to connect via SSH. When you have a lot of devices this is particularly important.&lt;/p&gt;

&lt;p&gt;I use the &lt;a href=&quot;https://www.adafruit.com/products/814&quot;&gt;Miniature WifFi (802.11b/g/n) Module&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You’ll need to update your &lt;code class=&quot;highlighter-rouge&quot;&gt;interfaces&lt;/code&gt; so that your WiFi connects to your wireless router. Run &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo nano /etc/network/interfaces&lt;/code&gt; (or whatever editor you want to use) and update accordingly.&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;auto lo
 
iface lo inet loopback
iface eth0 inet dhcp
 
allow-hotplug wlan0
auto wlan0
 
iface wlan0 inet dhcp
  wpa-ssid &quot;ssid&quot;
  wpa-psk &quot;password&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Be sure to set your own &lt;strong&gt;ssid&lt;/strong&gt; and &lt;strong&gt;password&lt;/strong&gt; values (and yes, capitalization matters).&lt;/p&gt;

&lt;p&gt;If you’re connected over Ethernet you’ll likely want to restart with &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo shutdown -r now&lt;/code&gt; but if you’re using your Console Cable you can simply restart the networking with &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo /etc/init.d/networking restart&lt;/code&gt;. If you then run &lt;code class=&quot;highlighter-rouge&quot;&gt;ifconfig&lt;/code&gt; you should see you now have an IP address. At this point I typically start connecting using SSH.&lt;/p&gt;

&lt;h3 id=&quot;step-6-install-required-libraries&quot;&gt;Step 6: Install Required Libraries&lt;/h3&gt;

&lt;p&gt;There are a number of open source libraries and tools used in order to send the iBeacon data from the Raspberry Pi. Install the following libraries:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install libusb-dev 
sudo apt-get install libdbus-1-dev 
sudo apt-get install libglib2.0-dev --fix-missing
sudo apt-get install libudev-dev 
sudo apt-get install libical-dev
sudo apt-get install libreadline-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This only takes a few minutes.&lt;/p&gt;

&lt;h3 id=&quot;step-7-download-make--install-bluez-library&quot;&gt;Step 7: Download, Make, &amp;amp; Install BlueZ Library&lt;/h3&gt;

&lt;p&gt;The BlueZ libraries provide support for the core Bluetooth layers and protocols. We have to download, make, and then install the libraries. Run the following commands sequentially:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo mkdir bluez
cd bluez
sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.18.tar.gz
sudo gunzip bluez-5.18.tar.gz
sudo tar xvf bluez-5.18.tar
cd bluez-5.18
sudo ./configure --disable-systemd
sudo make
sudo make install
sudo shutdown -r now
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;highlighter-rouge&quot;&gt;sudo make&lt;/code&gt; command can take a long time to complete. Just let it run. As long as you’ve followed these instructions exactly as I’ve described it should complete without any problem.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/3031070/26af888e-e048-11e3-85af-5b6fafa16335.png&quot; alt=&quot;makestep&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Congratulations. You’ve successfully setup your Raspberry Pi to act as an iBeacon transmitter. Of course, it’s not yet transmitting a signal so let’s set that up now.&lt;/p&gt;

&lt;h2 id=&quot;setup-the-raspberry-pi-as-an-ibeacon-transmitter-1&quot;&gt;Setup the Raspberry Pi as an iBeacon Transmitter&lt;/h2&gt;

&lt;p&gt;At this point we need to start transmitting a signal. Here’s where, depending on what you’re looking to accomplish, you may decide to take a different path. For me, I want my Raspberry Pi iBeacon to do the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Initialize and broadcast a signal.&lt;/li&gt;
  &lt;li&gt;Advertise itself but don’t allow connections.&lt;/li&gt;
  &lt;li&gt;Broadcast a unique transmission but let me have more than one identifiable iBeacons.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The broadcast has three important identifiers:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;proximityUUID&lt;/code&gt;: a unique UUID that distinguishes your iBeacons from other iBeacons.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;major&lt;/code&gt;: used to group related sets of iBeacons.&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;minor&lt;/code&gt;: used to identify a iBeacon within a group.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What’s nice about the Raspberry Pi as a iBeacon is you can choose all these values yourself. Perhaps the easiest way to generate a UUID is to run the following command:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;python -c 'import sys,uuid;sys.stdout.write(uuid.uuid4().hex)'|pbcopy &amp;amp;&amp;amp; pbpaste &amp;amp;&amp;amp; echo&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should get a value such as 636f3f8f64914bee95f7d8cc64a863b5 as the output. This is a 128-bit UUID that our app will use to look for our iBeacon.&lt;/p&gt;

&lt;p&gt;Okay, let’s reconnect (if needed) to our Raspberry Pi and run the following commands:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd bluez/bluez-5.18
sudo tools/hciconfig hci0 up
sudo tools/hciconfig hci0 leadv 3
sudo tools/hciconfig hci0 noscan
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, run &lt;code class=&quot;highlighter-rouge&quot;&gt;tools/hciconfig&lt;/code&gt; and confirm it’s up and running. Your output should look similar to this:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;hci0:	Type: BR/EDR  Bus: USB
		BD Address: 00:1A:7D:DA:71:13  ACL MTU: 310:10  SCO MTU: 64:8
		UP RUNNING 
		RX bytes:1136 acl:0 sco:0 events:61 errors:0
		TX bytes:855 acl:0 sco:0 commands:61 errors:0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It’s now time use the &lt;code class=&quot;highlighter-rouge&quot;&gt;hcitool&lt;/code&gt; to configure the transmission to use our UUID. Additionally, for this initial device, we’re going to set the &lt;code class=&quot;highlighter-rouge&quot;&gt;major&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;minor&lt;/code&gt; values as 0 by attaching &lt;code class=&quot;highlighter-rouge&quot;&gt;00 00 00 00&lt;/code&gt; to the end of our UUID. Finally, the last byte we’ll add is the &lt;code class=&quot;highlighter-rouge&quot;&gt;RSSI&lt;/code&gt; value of &lt;code class=&quot;highlighter-rouge&quot;&gt;C8&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The command should look like the following:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 00 00 C8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You might be wondering about some of the other values. Well, the whole thing breaks down like this:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Setup the add packet flags:&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  1E
  02 		# Number of bytes that follow in first AD structure
  01  	# Flags AD type
  1A  	# Flags value 0x1A = 000011010  
            bit 0 (OFF) LE Limited Discoverable Mode
            bit 1 (ON) LE General Discoverable Mode
            bit 2 (OFF) BR/EDR Not Supported
            bit 3 (ON) Simultaneous LE and BR/EDR to Same Device Capable (controller)
            bit 4 (ON) Simultaneous LE and BR/EDR to Same Device Capable (Host)
  1A  	# Number of bytes that follow in second (and last) AD structure
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Define vendor specific values:&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  FF 		# Manufacturer specific data AD type
  4C 00 	# Company identifier code (0x004C == Apple)
  02 		# Byte 0 of iBeacon advertisement indicator
  15 		# Byte 1 of iBeacon advertisement indicator
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Our specific UUID values:&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 # our iBeacon proximity uuid
  00 00 	# Major 
  00 00 	# Minor 
  C8 00 	# Calibrated Tx power
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run the command. Congrats, you’re broadcasting!&lt;/p&gt;

&lt;h2 id=&quot;detect-your-ibeacon-signal&quot;&gt;Detect Your iBeacon Signal&lt;/h2&gt;

&lt;p&gt;In a later post I’ll show you how to write your own iOS application to detect iBeacon signals. For now, let’s grab a free application to find our signal.&lt;/p&gt;

&lt;p&gt;For an iOS device I recommend &lt;strong&gt;Locate iBeacon&lt;/strong&gt;. It’s easy to use. I don’t have an Android, but I’m sure there are many out there.&lt;/p&gt;

&lt;p&gt;When you open the app first select &lt;strong&gt;iBeacon Transmitter&lt;/strong&gt; and hit the &lt;strong&gt;+&lt;/strong&gt; symbol/button to configure our Raspberry Pi iBeacon.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Name&lt;/code&gt;: Choose a unique name&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Proximity UUID&lt;/code&gt;: 636f3f8f-6491-4bee-95f7-d8cc64a863b5 (must he a hex version of our UUID)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Major&lt;/code&gt;: 0&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Minor&lt;/code&gt;: 0&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Power&lt;/code&gt;: (leave blank)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Save these values, then select the &lt;strong&gt;Locate iBeacons&lt;/strong&gt; button. You should see your iBeacon!&lt;/p&gt;

&lt;table style=&quot;margin-bottom:10px;&quot;&gt;&lt;tr&gt;&lt;td style=&quot;padding-right:5px;&quot;&gt;
&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/3030919/956ab73c-e046-11e3-9682-c00043149c67.png&quot; alt=&quot;Authorize&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;
&lt;/td&gt;&lt;td style=&quot;padding-right:5px;&quot;&gt;
&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/3030922/98ed92e4-e046-11e3-848b-e9cd98157e45.png&quot; alt=&quot;Authorize&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;
&lt;/td&gt;&lt;td&gt;
&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/3030923/9c220620-e046-11e3-816f-d05624b5e676.png&quot; alt=&quot;Authorize&quot; style=&quot;border-style: solid;border-width:1px;border-color:#767676;&quot; /&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;Of course, if you have more than one Raspberry Pi, you can get them both to broadcast. Follow the instructions above except change the &lt;code class=&quot;highlighter-rouge&quot;&gt;mino&lt;/code&gt; value to 1 (01 00 in hex):&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 63 6F 3F 8F 64 91 4B EE 95 F7 D8 CC 64 A8 63 B5 00 00 01 00 C8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pretty awesome!&lt;/p&gt;

&lt;p&gt;I hope you’ve found this article on configuring a Raspberry Pi as an iBeacon transmitter useful! If you have questions or issues please feel free to leave a comment.&lt;/p&gt;
</description>
                <link>/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi/</link>
                <guid>/2014/05/create-an-ibeacon-transmitter-with-the-raspberry-pi</guid>
                <pubDate>Tue, 20 May 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Salesforce Did What? How We Built the Salesforce Toolkits for .NET</title>
                <description>&lt;p&gt;I had the great pleasure this week to speak at &lt;a href=&quot;http://northamerica.msteched.com/&quot;&gt;TechEd North America 2014&lt;/a&gt; on how we built the &lt;a href=&quot;http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;&gt;Salesforce Toolkits for .NET&lt;/a&gt;. It was a blast, and I wouldn’t be surprised if I was the first Salesforce employee to speak at TechEd. Many thanks to my friends at Microsoft for the opportunity.&lt;/p&gt;

&lt;p&gt;Here is the &lt;a href=&quot;http://channel9.msdn.com/Events/TechEd/NorthAmerica/2014/DEV-B308&quot;&gt;video recording of the talk&lt;/a&gt; on Channel 9:&lt;/p&gt;

&lt;iframe src=&quot;http://channel9.msdn.com/Events/TechEd/NorthAmerica/2014/DEV-B308/player?h=405&amp;amp;w=720&amp;amp;format=html5&quot; style=&quot;height:405px;width:720px;&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;The highlight of the talk for me was that, rather than explain through slides, I built a brand new SDK during the talk and committed it live to &lt;a href=&quot;https://github.com/wadewegner/TechEd14SDK&quot;&gt;Github in this repository&lt;/a&gt;. Take a look at the repository and use whatever your find valuable!&lt;/p&gt;

&lt;p&gt;While I gave a quick overview of the toolkits and SDKs we built for Salesforce, the focus of the talk was on &lt;em&gt;how&lt;/em&gt; they were built. Consequently, I broke the talk into different segments and focused on the following items:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Segment 1&lt;/strong&gt;: Create a new project with authentication capabilities.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Portable class libraries&lt;/li&gt;
  &lt;li&gt;Extensibility&lt;/li&gt;
  &lt;li&gt;Async/Await&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Segment 2&lt;/strong&gt;: Create tests to validate our new library.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Functional tests&lt;/li&gt;
  &lt;li&gt;Unit tests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Segment 3&lt;/strong&gt;: Allow our library to run with Mono.NET on non-Windows platforms.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Mono.NET &amp;amp; Xamarin&lt;/li&gt;
  &lt;li&gt;Continuous integration with Travis CI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Segment 4&lt;/strong&gt;: Extend our library with additional functionality for developers.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Anonymous types&lt;/li&gt;
  &lt;li&gt;Dynamics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Segment 5&lt;/strong&gt;: Package and deploy our library.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;NuGet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Segment 6&lt;/strong&gt;: How to grow community involvement with our project.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Community&lt;/li&gt;
  &lt;li&gt;Licenses&lt;/li&gt;
  &lt;li&gt;Issues, features, and bugs in Github&lt;/li&gt;
  &lt;li&gt;Pull requests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope you find this presentation valuable! I had a blast and thoroughly enjoyed it.&lt;/p&gt;
</description>
                <link>/2014/05/salesforce-did-what-how-we-built-the-salesforce-toolkits-for-net/</link>
                <guid>/2014/05/salesforce-did-what-how-we-built-the-salesforce-toolkits-for-net</guid>
                <pubDate>Thu, 15 May 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Uploading an Attachment to Salesforce with the SOAP and REST APIs</title>
                <description>&lt;p&gt;Earlier today a colleague asked me if I had an example of using Python to create an attachment in Salesforce. I didn’t, but that didn’t stop me from creating a couple. Sadly, our documentation here isn’t the greatest. You can look at the &lt;a href=&quot;http://www.salesforce.com/us/developer/docs/api_rest/Content/dome_sobject_insert_update_blob.htm&quot;&gt;Insert or Update Blob Data&lt;/a&gt; for the REST API or &lt;a href=&quot;http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_attachment.htm&quot;&gt;Attachment&lt;/a&gt; for our SOAP API. If you’re like me, neither document is good enough; I had to continue to dig around to figure out exactly what I needed.&lt;/p&gt;

&lt;p&gt;Nevertheless, I got it working. I’d like to share with you two examples: uploading attachments with the REST API and uploading attachments with the SOAP API. For both examples I will use Python.&lt;/p&gt;

&lt;p&gt;Why Python?&lt;/p&gt;

&lt;p&gt;Well, not only is it fun, but I think Python is also remarkably easy to read. It shouldn’t be too much work for you to adjust to your language of choice.&lt;/p&gt;

&lt;p&gt;A few things worth nothing before we go to far:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;You will need to &lt;code class=&quot;highlighter-rouge&quot;&gt;base64&lt;/code&gt; encode your file.&lt;/li&gt;
  &lt;li&gt;An attachment &lt;em&gt;attaches&lt;/em&gt; to an object in Salesforce (i.e. Account, Contact, etc.). You’ll need to know the &lt;code class=&quot;highlighter-rouge&quot;&gt;Id&lt;/code&gt; (called the &lt;code class=&quot;highlighter-rouge&quot;&gt;ParentId&lt;/code&gt;) to which you want to attach.&lt;/li&gt;
  &lt;li&gt;Python has some great libraries that I’m going to use. This has the added benefit of keeping the code really simple and focused on the task of uploading the attachment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without further ado …&lt;/p&gt;

&lt;h4 id=&quot;python-and-attachments-with-the-rest-api&quot;&gt;Python and Attachments with the REST API&lt;/h4&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/df609a495df2e4bd7a07.js?file=upload_rest.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;To run this script you’ll need to do the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create a &lt;code class=&quot;highlighter-rouge&quot;&gt;text.txt&lt;/code&gt; file in the same directory as the Python script.&lt;/li&gt;
  &lt;li&gt;Add your user name, password, and security token.&lt;/li&gt;
  &lt;li&gt;Install &lt;code class=&quot;highlighter-rouge&quot;&gt;simple_salesforce&lt;/code&gt; with &lt;code class=&quot;highlighter-rouge&quot;&gt;pip install simple_salesforce&lt;/code&gt;. I recommend you first use &lt;a href=&quot;https://pypi.python.org/pypi/virtualenv&quot;&gt;virtualenv&lt;/a&gt; to manage your environment.&lt;/li&gt;
  &lt;li&gt;Update the &lt;code class=&quot;highlighter-rouge&quot;&gt;instance&lt;/code&gt; value (or extract it from the login info).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is pretty straightforward. &lt;a href=&quot;https://pypi.python.org/pypi/simple-salesforce/&quot;&gt;simple_salesforce&lt;/a&gt; is great when you want to quickly work with the REST API.&lt;/p&gt;

&lt;h4 id=&quot;python-and-attachments-with-the-soap-api&quot;&gt;Python and Attachments with the SOAP API&lt;/h4&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/df609a495df2e4bd7a07.js?file=upload_soap.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;To run this script you’ll need to do the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Create a &lt;code class=&quot;highlighter-rouge&quot;&gt;text.txt&lt;/code&gt; file in the same directory as the Python script.&lt;/li&gt;
  &lt;li&gt;Add your user name, password, and security token.&lt;/li&gt;
  &lt;li&gt;Install &lt;code class=&quot;highlighter-rouge&quot;&gt;beatbox&lt;/code&gt; with &lt;code class=&quot;highlighter-rouge&quot;&gt;pip install beatbox&lt;/code&gt;. I recommend you first use &lt;a href=&quot;https://pypi.python.org/pypi/virtualenv&quot;&gt;virtualenv&lt;/a&gt; to manage your environment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Again, this code is pretty straightforward. &lt;a href=&quot;https://pypi.python.org/pypi/beatbox/20.0&quot;&gt;beatbox&lt;/a&gt; is a fantastic way to interact with the SOAP API.&lt;/p&gt;

&lt;p&gt;It’s likely over time I’ll learn more that I should add to this post. For now, I’ll leave it as it is; hopefully someone finds it useful.&lt;/p&gt;

&lt;p&gt;Enjoy!&lt;/p&gt;
</description>
                <link>/2014/05/uploading-an-attachment-to-salesforce-with-the-soap-and-rest-apis/</link>
                <guid>/2014/05/uploading-an-attachment-to-salesforce-with-the-soap-and-rest-apis</guid>
                <pubDate>Thu, 01 May 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Update Records with Python and the Salesforce Bulk API</title>
                <description>&lt;p&gt;It’s time to take a little break from .NET and enjoy the many different programming languages you can use when integrating to the Salesforce1 Platform. But first, a public service announcement from &lt;a href=&quot;http://twitter.com/smarx&quot;&gt;Steve Marx&lt;/a&gt;:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/38c6752f76e6970c935d.js?file=steve.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;This week a colleague of mine asked me if I could help him by writing a script to update data he has in Salesforce (okay, he asked me weeks ago, and I only got to it yesterday). In this particular case, he is tracking articles that are written by different members of our team and includes fields such as date published, published url, as well as the # of tweets, likes, and LinkedIn shares. Each week he’s able to use Salesforce to produce dashboards and reports that demonstrate how well (or poorly) articles are doing. The complication was that all the social stats (i.e. # of tweets, likes, and shares) were aggregated manually.&lt;/p&gt;

&lt;p&gt;A perfect opportunity for scripting, no?&lt;/p&gt;

&lt;p&gt;It’s really not that difficult. All three of these particular services provide a simple API that returns a JSON package with the counts we need. For example, let’s say I want to see counts/shares for my post announcing the &lt;a href=&quot;http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;&gt;Salesforce Toolkits for .NET&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For Twitter, create the URL &lt;a href=&quot;https://cdn.api.twitter.com/1/urls/count.json?url=http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;&gt;https://cdn.api.twitter.com/1/urls/count.json?url=http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&lt;/a&gt; and parse the following JSON:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{
	&quot;count&quot; : 144,
	&quot;url&quot; : &quot;http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For Facebook, create the URL &lt;a href=&quot;http://graph.facebook.com/http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;&gt;http://graph.facebook.com/http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&lt;/a&gt; and parse the following JSON:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{
	&quot;id&quot;: &quot;http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;,
	&quot;shares&quot;: 28
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For LinkedIn, create the URL: &lt;a href=&quot;http://www.linkedin.com/countserv/count/share?url=http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;&gt;http://www.linkedin.com/countserv/count/share?url=http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&lt;/a&gt; and parse the following JSON:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;IN.Tags.Share.handleCount({
	&quot;count&quot;:18,
	&quot;fCnt&quot;:&quot;18&quot;,
	&quot;fCntPlusOne&quot;:&quot;19&quot;,
	&quot;url&quot;:&quot;http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Pretty simple, right?&lt;/p&gt;

&lt;p&gt;So, now the challenge is using this information to update all the records in Salesforce. Let me quickly describe to you the two approaches I took. The first was fast and simple, but long term has some complications. The second took longer to create but ultimately provides the soundest approach.&lt;/p&gt;

&lt;h4 id=&quot;approach-1-using-the-salesforce-rest-api&quot;&gt;Approach 1: Using the Salesforce REST API&lt;/h4&gt;

&lt;p&gt;I started with this approach. Basically, logged in using the Username-Password authentication flow, grabbed my access token, performed a SOQL query to get all the records with published URLs, looped through them, and then issues an update via the REST API with the proper social counts. Pretty simple.&lt;/p&gt;

&lt;p&gt;The problem with this approach is that, eventually, I’m going to hit my &lt;a href=&quot;http://help.salesforce.com/apex/HTViewHelpDoc?id=integrate_api_rate_limiting.htm&quot;&gt;REST API limits&lt;/a&gt;. Not only is my query an API call, but so too is every update. The plan is for this script to run many times throughout the day. It won’t take too long for me to hit the limit.&lt;/p&gt;

&lt;p&gt;Although it is a simple and elegant solution, ultimately it won’t work.&lt;/p&gt;

&lt;h4 id=&quot;approach-2-using-the-salesforce-bulk-api&quot;&gt;Approach 2: Using the Salesforce Bulk API&lt;/h4&gt;

&lt;p&gt;As you’ll see, this approach is a lot more involved. However, it’s also rock solid and designed to beyond the scenarios supported by the REST API.&lt;/p&gt;

&lt;p&gt;The Bulk API is optimized for loading or deleting large sets of data. You can use it to query, insert, update, upsert, or delete a large number of records asynchronously by submitting batches which are processed in the background by Salesforce.&lt;/p&gt;

&lt;p&gt;The easiest way to use Bulk API is to enable it for processing records in Data Loader using CSV files. This avoids the need to write your own client application. However, you can also send it XML, which avoids having to construct or generate CSV files; perfect, in my opinion, for our scenario.&lt;/p&gt;

&lt;p&gt;Okay, enough talk. Let’s jump into the code.&lt;/p&gt;

&lt;h4 id=&quot;solution&quot;&gt;Solution&lt;/h4&gt;

&lt;p&gt;To go really deep with the Bulk API, I recommend you review the &lt;a href=&quot;https://www.salesforce.com/us/developer/docs/api_asynch/&quot;&gt;Bulk API Developers Guide&lt;/a&gt; and watch the &lt;a href=&quot;https://developer.salesforce.com/en/events/webinars/bulk-api?d=70130000000lWwX&quot;&gt;Fast Parallel Data Loading with the Bulk API&lt;/a&gt; presentation from &lt;a href=&quot;http://twitter.com/sbob909&quot;&gt;Steve Bobrowski&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://twitter.com/sfdcsregan&quot;&gt;Sean Regan&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are, roughly, four steps involved in using the Bulk API:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Logging in.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Creating a job.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Adding a batch. (Or multiple batches.)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Closing the job (thereby starting it).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To facilitate these steps I created a file called &lt;code class=&quot;highlighter-rouge&quot;&gt;async.py&lt;/code&gt; that had the four following methods.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/38c6752f76e6970c935d.js?file=login.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;You can see that this method does the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It constructs an XML string that includes the user name and password.&lt;/li&gt;
  &lt;li&gt;Defines some heads; in particular it includes the &lt;code class=&quot;highlighter-rouge&quot;&gt;SOAPAction&lt;/code&gt; of &lt;code class=&quot;highlighter-rouge&quot;&gt;login&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;A &lt;code class=&quot;highlighter-rouge&quot;&gt;requests&lt;/code&gt; post is made to the URL, passing the headers and the encoded data.&lt;/li&gt;
  &lt;li&gt;It returns the response to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pretty simple and nothing surprising.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/38c6752f76e6970c935d.js?file=createJob.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;A few things worth noting here:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We pass in the &lt;code class=&quot;highlighter-rouge&quot;&gt;instance&lt;/code&gt; which we derive from the login response. This is used to call against the correct Salesforce datacenter.&lt;/li&gt;
  &lt;li&gt;To successfully communicate with the API we need to validate ourselves with the &lt;code class=&quot;highlighter-rouge&quot;&gt;sessionId&lt;/code&gt;, which was returned in the login response. This value is used in the header &lt;code class=&quot;highlighter-rouge&quot;&gt;X-SFDC-Session&lt;/code&gt; to validate us against the API.&lt;/li&gt;
  &lt;li&gt;To create the job we have to specify an &lt;code class=&quot;highlighter-rouge&quot;&gt;operation&lt;/code&gt;, i.e. &lt;code class=&quot;highlighter-rouge&quot;&gt;insert&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;update&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;upsert&lt;/code&gt;, and so on.&lt;/li&gt;
  &lt;li&gt;We pass in the &lt;code class=&quot;highlighter-rouge&quot;&gt;object&lt;/code&gt; we’re working with. For example, we’re using a custom object called &lt;code class=&quot;highlighter-rouge&quot;&gt;Byline__c&lt;/code&gt;, so that’s what we’ll pass in.&lt;/li&gt;
  &lt;li&gt;There are two &lt;code class=&quot;highlighter-rouge&quot;&gt;contentType&lt;/code&gt; values: CSV and XML. We need to specify which one we’re using.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates the job. Next we have to add a batch.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/38c6752f76e6970c935d.js?file=addBatch.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;This is likely the most important, and undocumented, step - particularly when using XML.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You will need to construct an XML string that includes all the objects you want to manipulate.&lt;/li&gt;
  &lt;li&gt;For the purposes of this method I found it easier to create an &lt;code class=&quot;highlighter-rouge&quot;&gt;objects&lt;/code&gt; parameter on &lt;code class=&quot;highlighter-rouge&quot;&gt;addBatch&lt;/code&gt; and pass it in. We’ll walk through this in detail shortly.&lt;/li&gt;
  &lt;li&gt;Notice too that the url now includes the &lt;code class=&quot;highlighter-rouge&quot;&gt;jobId&lt;/code&gt; that was returned from the &lt;code class=&quot;highlighter-rouge&quot;&gt;createJob&lt;/code&gt; response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lastly we close the job.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/38c6752f76e6970c935d.js?file=closeJob.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;As you can see, this is a pretty simple operation.&lt;/p&gt;

&lt;p&gt;Before we pull it all together, let’s look at one more method I’ve created to facilitate the Bulk API operation. The reason I didn’t include this method above is you’ll see it’s very specific to the particular use case; i.e. we’re looping through a lot of data and constructing the &lt;code class=&quot;highlighter-rouge&quot;&gt;object&lt;/code&gt; data we’ll eventually pass into the &lt;code class=&quot;highlighter-rouge&quot;&gt;addBatch&lt;/code&gt; method.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/38c6752f76e6970c935d.js?file=createObjectXml.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;Okay, there’s a bit going on here. Once you look, though, you’ll see that it’s not too complex.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The first thing to point out is that I’m using a library called &lt;code class=&quot;highlighter-rouge&quot;&gt;simple_salesforce&lt;/code&gt; that provides a set of methods for interacting with the Salesforce REST API. Yes, I’m combining SOAP and REST APIs!&lt;/li&gt;
  &lt;li&gt;I perform a &lt;code class=&quot;highlighter-rouge&quot;&gt;SOQL&lt;/code&gt; query to get the records that have a published link. This is returned as a Python dictionary from the &lt;code class=&quot;highlighter-rouge&quot;&gt;query_all&lt;/code&gt; method.&lt;/li&gt;
  &lt;li&gt;Since it’s a dictionary I can easily get all the records and iterate through them all.&lt;/li&gt;
  &lt;li&gt;Using the URLs I identified above, I use &lt;code class=&quot;highlighter-rouge&quot;&gt;requests&lt;/code&gt; to call each of the URLs to get the JSON responses. It’s then simple to pull out the &lt;code class=&quot;highlighter-rouge&quot;&gt;count&lt;/code&gt; or &lt;code class=&quot;highlighter-rouge&quot;&gt;shares&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Lastly, we add the data we pulled from the JSON responses and add it to the &lt;code class=&quot;highlighter-rouge&quot;&gt;objectXml&lt;/code&gt; string that is ultimately returned. It’s worth noting that the &lt;code class=&quot;highlighter-rouge&quot;&gt;Id&lt;/code&gt; value is required; everything else added to this object is updated in Salesforce.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pretty simple!&lt;/p&gt;

&lt;p&gt;Okay, let’s pull this all together.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/38c6752f76e6970c935d.js?file=script.py&quot;&gt;&lt;/script&gt;

&lt;p&gt;As you can see, we’re simply calling our methods and evaluating the responses to get data that we pass into other methods.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Get the &lt;code class=&quot;highlighter-rouge&quot;&gt;sessionId&lt;/code&gt; from the &lt;code class=&quot;highlighter-rouge&quot;&gt;login&lt;/code&gt;. You could also grab the &lt;code class=&quot;highlighter-rouge&quot;&gt;instance&lt;/code&gt; here with a simple regex.&lt;/li&gt;
  &lt;li&gt;Create a job and grab the &lt;code class=&quot;highlighter-rouge&quot;&gt;jobId&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Create the &lt;code class=&quot;highlighter-rouge&quot;&gt;objectXml&lt;/code&gt; data and pass it into &lt;code class=&quot;highlighter-rouge&quot;&gt;addBatch&lt;/code&gt; to create the batch.&lt;/li&gt;
  &lt;li&gt;Close the batch, which starts the execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let’s look at the job execution. Login into Salesforce and click &lt;strong&gt;Setup&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Jobs&lt;/strong&gt;, and &lt;strong&gt;Bulk Data Load Jobs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://cloud.githubusercontent.com/assets/746259/2848136/99fcd1ba-d0b8-11e3-8594-ef30b283ae10.png&quot; alt=&quot;Jobs&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You can click the individual job to see the full details.&lt;/p&gt;

&lt;p&gt;And that’s a wrap! I hope this helps explain the process so that, when you attempt to do something like this yourself, it won’t take you as long as it took me.&lt;/p&gt;
</description>
                <link>/2014/04/update-records-with-python-and-the-salesforce-bulk-api/</link>
                <guid>/2014/04/update-records-with-python-and-the-salesforce-bulk-api</guid>
                <pubDate>Wed, 30 Apr 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Announcing the Salesforce Accelerators for Windows Store Apps</title>
                <description>&lt;p&gt;Yesterday I was pleased to announce the &lt;a href=&quot;http://www.wadewegner.com/2014/04/Announcing-the-Windows-Phone-8-Accelerators-for-Salesforce/&quot;&gt;Salesforce Accelerators for Windows Phone 8 Apps&lt;/a&gt;. Today I’m excited to tell you about the &lt;strong&gt;Salesforce Accelerators for Windows Store Apps&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nuget.org/packages/DeveloperForce.Windows8.Login/&quot;&gt;DeveloperForce.Windows8.Login&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nuget.org/packages/DeveloperForce.Windows8.Samples.Accounts/&quot;&gt;DeveloperForce.Windows8.Samples.Accounts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These accelerators exist to make it easier for you to get started building Windows 8 store apps and work directly with the &lt;a href=&quot;http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;&gt;Salesforce Toolkits for .NET&lt;/a&gt;. Take a look at this short video to see just how easy it is to get started.&lt;/p&gt;

&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;//www.youtube.com/embed/WnSSJxm9KI0&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;Let’s look in greater detail at how all of this works.&lt;/p&gt;

&lt;h3 id=&quot;using-the-developerforcewindows8login-nuget&quot;&gt;Using the DeveloperForce.Windows8.Login NuGet&lt;/h3&gt;

&lt;p&gt;Using the &lt;a href=&quot;&quot;&gt;DeveloperForce.Windows8.Login&lt;/a&gt; NuGet is pretty straightforward and only involves a few steps.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Setup a &lt;strong&gt;Connected App&lt;/strong&gt; in Salesforce (&lt;a href=&quot;https://help.salesforce.com/HTViewHelpDoc?id=connected_app_create.htm&amp;amp;language=en_US&quot;&gt;instructions here&lt;/a&gt;). Be sure to &lt;strong&gt;Enable OAuth Settings&lt;/strong&gt;, at least choose &lt;strong&gt;Full access (full)&lt;/strong&gt; and set the &lt;strong&gt;Callback URL&lt;/strong&gt; to &lt;span class=&quot;inline-code&quot;&gt;sfdc://success&lt;/span&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install the NuGet Package via the command line …&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; Install-Package DeveloperForce.Windows8.Login
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;… or using &lt;strong&gt;Manage NuGet Packages&lt;/strong&gt; in Visual Studio. When you install this NuGet package you also get the &lt;strong&gt;DeveloperForce.Force&lt;/strong&gt; and &lt;strong&gt;DeveloperForce.Common&lt;/strong&gt; NuGet packages, which are defined as dependencies.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open &lt;strong&gt;MainPage_SFDC.xaml.cs&lt;/strong&gt; and change the &lt;span class=&quot;inline-code&quot;&gt;ConsumerKey&lt;/span&gt; value to the one specified by your &lt;strong&gt;Connected App&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open &lt;strong&gt;MainPage.xaml.cs&lt;/strong&gt; wire up the &lt;span class=&quot;inline-code&quot;&gt;Page_Loaded&lt;/span&gt; event. (You can also do this from the designer, as shown in the video.)&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11298871.js?file=MainPage.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Make the &lt;span class=&quot;inline-code&quot;&gt;MainPage_Loaded&lt;/span&gt; asynchronous and call the &lt;span class=&quot;inline-code&quot;&gt;GetAccessToken&lt;/span&gt; method.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11298871.js?file=MainPage_Loaded.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Run the application.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As you can see, using the NuGet is quite simple and takes away the guess work and trouble of setting up the user login experience. Nevertheless, it’s worth noting a few things about how it all works.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;App_SFDC.xaml.cs&lt;/strong&gt; is a partial class that extends the functionality of &lt;span class=&quot;inline-code&quot;&gt;App&lt;/span&gt; by defining three public properties: &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt;, &lt;span class=&quot;inline-code&quot;&gt;RefreshToken&lt;/span&gt;, and &lt;span class=&quot;inline-code&quot;&gt;InstanceUrl&lt;/span&gt;. These values are returned to us and set after the user logs in. Having these as public properties gives us the ability to share these around the app so that we can use them when making subsequent REST API calls.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11298871.js?file=App_SFDC.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;MainPage_SFDC.xaml.cs&lt;/strong&gt; is a partial class that extends the default &lt;strong&gt;MainPage.xaml.cs&lt;/strong&gt; through the &lt;span class=&quot;inline-code&quot;&gt;GetAccessToken&lt;/span&gt; method. It contains all the logic for interacting with the &lt;span class=&quot;inline-code&quot;&gt;WebAuthenticationBroker&lt;/span&gt; which manages the authentication process for Windows Store Apps.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The &lt;span class=&quot;inline-code&quot;&gt;GetAccessToken&lt;/span&gt; method first creates a set of URIs for the login process. It then initiates the &lt;span class=&quot;inline-code&quot;&gt;WebAuthenticationBroker&lt;/span&gt; process by calling &lt;span class=&quot;inline-code&quot;&gt;AuthenticateAsync&lt;/span&gt;. If the response comes back as a success the response URI is decoded and the &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt;, &lt;span class=&quot;inline-code&quot;&gt;RefreshToken&lt;/span&gt;, and &lt;span class=&quot;inline-code&quot;&gt;InstanceUrl&lt;/span&gt; values are specified in the &lt;span class=&quot;inline-code&quot;&gt;app&lt;/span&gt; variable.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11298871.js?file=GetAccessToken.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Once the login process completes the &lt;strong&gt;MainPage.xaml&lt;/strong&gt; is loaded.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s all it takes. After you login you’ll be back on a blank &lt;strong&gt;MainPage.xaml&lt;/strong&gt; but you’ll have your &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt; available to use when calling the Salesforce1 Platform REST APIs, which is a great transition to the &lt;strong&gt;DeveloperForce.Windows8.Samples.Accounts&lt;/strong&gt; NuGet package accelerator.&lt;/p&gt;

&lt;h3 id=&quot;using-the-developerforcewindows8samplesaccounts-nuget&quot;&gt;Using the DeveloperForce.Windows8.Samples.Accounts NuGet&lt;/h3&gt;

&lt;p&gt;An access token is worthless if you don’t do anything with it.&lt;/p&gt;

&lt;p&gt;Using the &lt;a href=&quot;https://www.nuget.org/packages/DeveloperForce.Windows8.Samples.Accounts/&quot;&gt;DeveloperForce.Windows8.Samples.Accounts&lt;/a&gt; NuGet makes it easy to create a page where you can query and view your account information. It is designed to demonstrate how to use the access token and instance url retrieved during the login process.&lt;/p&gt;

&lt;p&gt;To use this NuGet, just follow these quick steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Install the NuGet Package via the command line …&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; Install-Package DeveloperForce.Windows8.Samples.Accounts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;… or using &lt;strong&gt;Manage NuGet Packages&lt;/strong&gt; in Visual Studio.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;After calling &lt;span class=&quot;inline-code&quot;&gt;GetAccessToken&lt;/span&gt; navigate the user to the newly added &lt;strong&gt;AccountsPage.xaml&lt;/strong&gt;.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11298871.js?file=AccountsPage.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it! Now run it and see it in action.&lt;/p&gt;

&lt;p&gt;As with the previous accelerator, it will help if you know a few things about how this works. Here’s the code that makes it function.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/11298871.js?file=Page_Loaded_AccountsPage.cs&quot;&gt;&lt;/script&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;You can see that we first set our &lt;span class=&quot;inline-code&quot;&gt;app&lt;/span&gt; variables so that we can get values like &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt; and &lt;span class=&quot;inline-code&quot;&gt;InstanceUrl&lt;/span&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Next we create an instance of the &lt;span class=&quot;inline-code&quot;&gt;ForceClient&lt;/span&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;We perform an asynchronous query using a simple SOQL select statement.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Lastly, we take the records and bind them to an accounts grid on the page.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s as simple as that!&lt;/p&gt;

&lt;p&gt;It is my hope that these accelerators help get you over the initial hurdles that exist when building new applications that integrate with Salesforce. As always, if you have additional ideas (or find bugs!) you can open a &lt;a href=&quot;https://github.com/developerforce/Force.com-Toolkit-for-NET/issues&quot;&gt;new issue on Github&lt;/a&gt; or (if you’re so inclinded) take a tab at it yourself and &lt;a href=&quot;http://help.github.com/send-pull-requests/&quot;&gt;send me a pull request&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;
</description>
                <link>/2014/04/announcing-the-salesforce-accelerators-for-windows-store-apps/</link>
                <guid>/2014/04/announcing-the-salesforce-accelerators-for-windows-store-apps</guid>
                <pubDate>Fri, 25 Apr 2014 00:00:00 +0000</pubDate>
        </item>

        <item>
                <title>Announcing the Salesforce Accelerators for Windows Phone 8 Apps</title>
                <description>&lt;p&gt;I am pleased to announce the &lt;strong&gt;Salesforce Accelerators for Windows Phone 8 Apps&lt;/strong&gt;, a set of assets designed to make it easier to create new applications using the Salesforce Toolkits for .NET:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nuget.org/packages/DeveloperForce.Windows8.Login/&quot;&gt;DeveloperForce.WindowsPhone8.Login&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nuget.org/packages/DeveloperForce.WindowsPhone8.Samples.Accounts/&quot;&gt;DeveloperForce.WindowsPhone8.Samples.Accounts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;a href=&quot;http://www.wadewegner.com/2014/01/announcing-the-salesforce-toolkits-for-net/&quot;&gt;Salesforce Toolkits for .NET&lt;/a&gt;, released earlier this year, allow you to interact with the Force.com and Chatter REST APIs using native .NET code on multiple platforms and devices. Many developers and companies have already benefited from these libraries and have built new ASP.NET web applications, Windows Phone 8 apps, and even Windows 8 store apps.&lt;/p&gt;

&lt;p&gt;Nevertheless, one of the requests I kept receiving was to create additional tools and samples that make it easier to get started; little &lt;em&gt;nuggets&lt;/em&gt; of code that &lt;em&gt;accelerate&lt;/em&gt; the process. These accelerators are the answer to those requests and deliver functionality through small, composable NuGet packages.&lt;/p&gt;

&lt;p&gt;This short video shows how quick and easy it is to build a Windows Phone 8 app that connects to Salesforce.&lt;/p&gt;

&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;//www.youtube.com/embed/i-vYcyZL9Yo&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;p&gt;Let’s dig a little deeper and look at exactly what is happening.&lt;/p&gt;

&lt;h3 id=&quot;using-the-developerforcewindowsphone8login-nuget&quot;&gt;Using the DeveloperForce.WindowsPhone8.Login NuGet&lt;/h3&gt;

&lt;p&gt;Using the &lt;a href=&quot;https://www.nuget.org/packages/DeveloperForce.WindowsPhone8.Login/&quot;&gt;DeveloperForce.WindowsPhone8.Login&lt;/a&gt; NuGet is pretty straightforward and only involves a few steps.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Setup a &lt;strong&gt;Connected App&lt;/strong&gt; in Salesforce (&lt;a href=&quot;https://help.salesforce.com/HTViewHelpDoc?id=connected_app_create.htm&amp;amp;language=en_US&quot;&gt;instructions here&lt;/a&gt;). Be sure to &lt;strong&gt;Enable OAuth Settings&lt;/strong&gt;, at least choose &lt;strong&gt;Full access (full)&lt;/strong&gt; and set the &lt;strong&gt;Callback URL&lt;/strong&gt; to &lt;span class=&quot;inline-code&quot;&gt;sfdc://success&lt;/span&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install the NuGet Package via the command line …&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; Install-Package DeveloperForce.WindowsPhone8.Login
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;… or using &lt;strong&gt;Manage NuGet Packages&lt;/strong&gt; in Visual Studio. When you install this NuGet package you also get the &lt;strong&gt;DeveloperForce.Force&lt;/strong&gt; and &lt;strong&gt;DeveloperForce.Common&lt;/strong&gt; NuGet packages, which are defined as dependencies.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Set &lt;strong&gt;LoginPage.xaml&lt;/strong&gt; (installed with the NuGet) as the default page by changing &lt;strong&gt;Navigation Page&lt;/strong&gt; in &lt;strong&gt;WMAppManifest.xml&lt;/strong&gt; to &lt;span class=&quot;inline-code&quot;&gt;Pages\LoginPage.xaml&lt;/span&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Open &lt;strong&gt;Pages\LoginPage.xaml.cs&lt;/strong&gt; and change the &lt;span class=&quot;inline-code&quot;&gt;ConsumerKey&lt;/span&gt; value to the one specified by your &lt;strong&gt;Connected App&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Run the application.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As you can see, using the NuGet is quite simple and takes away the guess work and trouble of setting up the user login experience. Nevertheless, it’s worth noting a few things about how it all works.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;App_SFDC.xaml.cs&lt;/strong&gt; is a partial class that extends the functionality of &lt;span class=&quot;inline-code&quot;&gt;App&lt;/span&gt; by defining three public properties: &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt;, &lt;span class=&quot;inline-code&quot;&gt;RefreshToken&lt;/span&gt;, and &lt;span class=&quot;inline-code&quot;&gt;InstanceUrl&lt;/span&gt;. These values are returned to us and set after the user logs in. Having these as public properties gives us the ability to share these around the app so that we can use them when making subsequent REST API calls.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11270012.js?file=properties.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The &lt;strong&gt;LoginPage.xaml&lt;/strong&gt; has a &lt;span class=&quot;inline-code&quot;&gt;WebBrowser&lt;/span&gt; control. The user will log into Salesforce from within this control.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11270012.js?file=WebBrowser&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;There is a set of constants defined at the top of the &lt;strong&gt;LoginPage.xaml.cs&lt;/strong&gt;: &lt;span class=&quot;inline-code&quot;&gt;AuthorizationEndpointUrl&lt;/span&gt;, &lt;span class=&quot;inline-code&quot;&gt;ConsumerKey&lt;/span&gt;, &lt;span class=&quot;inline-code&quot;&gt;CallbackUrl&lt;/span&gt;, and &lt;span class=&quot;inline-code&quot;&gt;ApiVersion&lt;/span&gt;. The only value you must change is &lt;span class=&quot;inline-code&quot;&gt;ConsumerKey&lt;/span&gt; as by default it is set to nonsense.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The &lt;span class=&quot;inline-code&quot;&gt;LoginPage&lt;/span&gt; constructor enables scripts on the &lt;span class=&quot;inline-code&quot;&gt;WebBrowser&lt;/span&gt; control. This is required for the login process to work.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The &lt;span class=&quot;inline-code&quot;&gt;OnNavigatedTo&lt;/span&gt; event fires when the user is navigated to the login page. It constructs a URL to the Salesforce login page (using a helper from the &lt;strong&gt;DeveloperForce.Common&lt;/strong&gt; NuGet) and then navigates the &lt;span class=&quot;inline-code&quot;&gt;WebBrowser&lt;/span&gt; control to the page. This is where the user logs in and authorizes the application.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11270012.js?file=OnNavigatedTo.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;After the user logs in the &lt;span class=&quot;inline-code&quot;&gt;WebBrowser_Navigating&lt;/span&gt; method is fired. If the return URI has the “sfdc://success” callback URI then we know that the login has been successful. The returned querystring contains the &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt;, &lt;span class=&quot;inline-code&quot;&gt;RefreshToken&lt;/span&gt;, and &lt;span class=&quot;inline-code&quot;&gt;InstanceUrl&lt;/span&gt;; these values are grabbed and stored as global variables.&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11270012.js?file=WebBrowser_Navigating.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Lastly, the user is redirected back to the &lt;strong&gt;MainPage.xaml&lt;/strong&gt; after a successful login. (Which you can see on line 18 in the code snippet above.)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s all it takes. After you login you’ll be back on a blank &lt;strong&gt;MainPage.xaml&lt;/strong&gt; but you’ll have your &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt; available to use when calling the Salesforce1 Platform REST APIs, which is a great transition to the &lt;strong&gt;DeveloperForce.WindowsPhone8.Samples.Accounts&lt;/strong&gt; NuGet package accelerator.&lt;/p&gt;

&lt;h3 id=&quot;using-the-developerforcewindowsphone8samplesaccounts-nuget&quot;&gt;Using the DeveloperForce.WindowsPhone8.Samples.Accounts NuGet&lt;/h3&gt;

&lt;p&gt;An access token is worthless if you don’t do anything with it.&lt;/p&gt;

&lt;p&gt;Using the &lt;a href=&quot;https://www.nuget.org/packages/DeveloperForce.WindowsPhone8.Samples.Accounts/&quot;&gt;DeveloperForce.WindowsPhone8.Samples.Accounts&lt;/a&gt; NuGet makes it easy to create a page where you can query and view your account information. It is designed to demonstrate how to use the access token and instance url retrieved during the login process.&lt;/p&gt;

&lt;p&gt;To use this NuGet, just follow these quick steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Install the NuGet Package via the command line …&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; Install-Package DeveloperForce.WindowsPhone8.Samples.Accounts
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;… or using &lt;strong&gt;Manage NuGet Packages&lt;/strong&gt; in Visual Studio.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Instead of navigating the user to the &lt;strong&gt;MainPage.xaml&lt;/strong&gt; after logging in, navigate them to &lt;strong&gt;Pages\AccountsPage.xaml&lt;/strong&gt;. In the &lt;span class=&quot;inline-code&quot;&gt;WebBrowser_Navigating&lt;/span&gt; event on &lt;strong&gt;LoginPage.xaml.cs&lt;/strong&gt; change URI as follows:&lt;/p&gt;

    &lt;script src=&quot;https://gist.github.com/wadewegner/11270012.js?file=accountspage.cs&quot;&gt;&lt;/script&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it! Now run it and see it in action.&lt;/p&gt;

&lt;p&gt;As with the previous accelerator, it will help if you know a few things about how this works. Here’s the code that makes it function.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/wadewegner/11270012.js?file=PhoneApplicationPage_Loaded.cs&quot;&gt;&lt;/script&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;You can see that we first ensure we have the &lt;span class=&quot;inline-code&quot;&gt;InstanceUrl&lt;/span&gt; and &lt;span class=&quot;inline-code&quot;&gt;AccessToken&lt;/span&gt; variables available.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Next we create an instance of the &lt;span class=&quot;inline-code&quot;&gt;ForceClient&lt;/span&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;We perform an asynchronous query using a simple SOQL select statement.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Lastly, we take the records and bind them to an accounts list on the page.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s as simple as that!&lt;/p&gt;

&lt;p&gt;It is my hope that these accelerators help get you over the initial hurdles that exist when building new applications that integrate with Salesforce. As always, if you have additional ideas (or find bugs!) you can open a &lt;a href=&quot;https://github.com/developerforce/Force.com-Toolkit-for-NET/issues&quot;&gt;new issue on Github&lt;/a&gt; or (if you’re so inclinded) take a tab at it yourself and &lt;a href=&quot;http://help.github.com/send-pull-requests/&quot;&gt;send me a pull request&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;
</description>
                <link>/2014/04/Announcing-the-Windows-Phone-8-Accelerators-for-Salesforce/</link>
                <guid>/2014/04/Announcing-the-Windows-Phone-8-Accelerators-for-Salesforce</guid>
                <pubDate>Thu, 24 Apr 2014 00:00:00 +0000</pubDate>
        </item>


</channel>
</rss>
