<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Shweta's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/shwetasblogs/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/feed.xml</link>
    <description>I am a Senior Program Manager with Microsoft, and help partners adopt Azure as their cloud platform.</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:25:13 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Deploying Infrastructure on Azure with Azure Resource Manager &amp; Python SDK.</title>
      <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/deploying-infrastructure-on-azure-with-azure-resource-manager-python-sdk</link>
      <pubDate>Wed, 21 Oct 2015 10:48:06 GMT</pubDate>
      <dc:creator><![CDATA[Shweta Gupta (TE - Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shwetasblogs/2015/10/21/deploying-infrastructure-on-azure-with-azure-resource-manager-python-sdk/</guid>
      <description><![CDATA[Once we have gone through how to authenticate the application with Azure AD through the...]]></description>
      <content:encoded><![CDATA[<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 15" /><meta name="Originator" content="Microsoft Word 15" /><link rel="File-List" href="DeployingwithARM_files/filelist.xml" /><link rel="Edit-Time-Data" href="DeployingwithARM_files/editdata.mso" /><link rel="themeData" href="DeployingwithARM_files/themedata.thmx" /><link rel="colorSchemeMapping" href="DeployingwithARM_files/colorschememapping.xml" />  <div class="WordSection1">   <p class="MsoNormal">Once we have gone through how to authenticate the application with Azure AD through the multi-tenant approach and single tenant approach, in this blog we will look at deploying a VM on a <span class="SpellE">VNet</span>, linked to a storage account. <span class="GramE">Typically</span> when you are looking at automating workloads, you would like to simplify user input as much as possible. </p>    <p class="MsoNormal">This application loads a simple form @ <a href="https://127.0.0.1:8000/deploy">https://127.0.0.1:8000/deploy</a> that takes inputs from the user. This is a simplified sample of course, but in the back-end it could be either creating an ARM template and deploying, which is a preferred route for large scale deployments or deploy single components at a time for small scale/<span class="SpellE">adhoc</span> requirements.</p>    <p class="MsoNormal">We will look at the latter today, and in the coming few days we could look at the template based deployment.</p>    <p class="MsoNormal">You can download and install the latest version of Azure Python SDK with the pip installer:</p>    <p class="MsoNormal"><span style="background: purple; color: white; mso-themecolor: background1; mso-highlight: purple">pip install azure</span> </p>    <p class="MsoNormal">This is the link to view the SDK in detail.</p>    <p class="MsoNormal"><a href="https://github.com/Azure/azure-sdk-for-python"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">https://github.com/Azure/azure-sdk-for-python</span></a><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">Coming back to our application, following is the loading screen, assuming that the user has logged in with their application user name &amp; password.</p>    <p class="MsoNormal">&#160;</p>    <p class="MsoNormal" style="page-break-after: avoid"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/3073.DeploymentScreen1_27689586.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/3073.DeploymentScreen1_5F00_27689586.png"><img title="DeploymentScreen1" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="DeploymentScreen1" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6303.DeploymentScreen1_thumb_0F6745CF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6303.DeploymentScreen1_5F00_thumb_5F00_0F6745CF.png" width="521" height="484" /></a></p>    <p class="MsoCaption">Figure <span style="mso-no-proof: yes">1</span>: Loading screen</p>    <p class="MsoNormal">If we take a look at the deployment option module, <a href="https://github.com/shwetams/arm-samples-py/blob/master/arm_basic_samples/deployment_option/views.py">views.py</a>. The <span class="SpellE"><span class="pl-k1"><span style="font-size: 10pt; font-family: &quot;Helvetica&quot;,sans-serif; line-height: 107%">def</span></span></span><span style="font-size: 10pt; font-family: &quot;Helvetica&quot;,sans-serif; color: #333333; line-height: 107%"> </span><span class="pl-en2"><span style="font-size: 10pt; font-family: &quot;Helvetica&quot;,sans-serif; line-height: 107%">deployment </span></span>method loads the admin settings (which is the <span class="SpellE">client_id</span> &amp; secret of the application registered with the AD it in subscription it is hosted in). </p>    <p class="MsoNormal">When the screen is loaded, we pre-load it with list of regions available today, storage account types and the various VM sizes available. The code has a hard coded else part, which could be replaced by reading from local DB settings.</p>    <p class="MsoNormal">To call any Python SDK function, we need to send two parameters for all the <span class="SpellE">functsions</span>:</p>    <p class="MsoListParagraphCxSpFirst" style="margin-left: 0.75in; text-indent: -0.25in; mso-add-space: auto; mso-list: l0 level1 lfo2"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">1.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span>Access token</p>    <p class="MsoListParagraphCxSpLast" style="margin-left: 0.75in; text-indent: -0.25in; mso-add-space: auto; mso-list: l0 level1 lfo2"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">2.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span>Subscription IDs</p>    <p class="MsoNormal"></p>    <p class="MsoNormal">Since this simply retrieving a standard list we will use the application’s own <span class="SpellE">client_id</span> and secret using the following method.</p>    <p class="MsoNormal">We first extract it from the default Django storage:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">AuthSettings_<span class="GramE">Admin.objects.filter</span></span>(<span class="SpellE">user_id</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Admin&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">).exists(): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">admin_authsettings</span> = <span class="SpellE">AuthSettings_<span class="GramE">Admin.objects.filter</span></span>(<span class="SpellE">user_id</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Admin&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">for</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">admin_auth</span> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">admin_authsettings</span>: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">client_id</span> = <span class="SpellE">admin_<span class="GramE">auth.client</span>_id</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">tenant_id</span>=<span class="SpellE">admin_<span class="GramE">auth.tenant</span>_id</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">subscription_id</span>=<span class="SpellE">admin_<span class="GramE">auth.subscription</span>_id</span> </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">client_secret</span> =<span class="SpellE">admin_<span class="GramE">auth.client</span>_secret</span></span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">Using these we get the access token generated calling the method:</p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">token = get_access_token(tenant_id=tenant_<span class="GramE">id,client</span>_id=client_id,client_secret=client_secret)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal">The method <span class="SpellE"><span class="GramE">get</span>_access_token</span> described below is based on raw REST call, we now have an inbuilt ADL library for Python just released, and will update the article to add that as well in some time:</p>    <p class="MsoNormal">Make sure you <span class="SpellE">urlencode</span> the client secret in the body.</p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">get_access_token</span>(<span class="SpellE">tenant_<span class="GramE">id,client</span>_id,client_secret</span>):<span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">url</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://login.microsoftonline.com/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + <span class="SpellE">tenant_id</span> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/oauth2/token&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">body_data</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;grant_type=client_credentials&amp;resource=https://management.core.windows.net/&amp;</span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">client_id=&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+ <span class="SpellE">client_id</span> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;<span class="SpellE">client_secret</span>=&quot;</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+<span style="mso-spacerun: yes">&#160; </span><span class="SpellE">urllib</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.quote_plus</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE">client_secret</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">#<span class="SpellE">body_data</span> = <span class="SpellE"><span class="GramE">urllib.urlencode</span></span>(<span class="SpellE">body_data_json</span>)</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>headers = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">Content-Type&quot;<span style="color: black">:</span>&quot;application</span>/x-www-form-<span class="SpellE">urlencoded</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">req</span> = Request(method=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;POST<span class="GramE">&quot;<span style="color: black">,<span class="SpellE">url</span></span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">=<span class="SpellE">url,data</span>=<span class="SpellE">body_data</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">req_prepped</span> = <span class="SpellE"><span class="GramE">req.prepare</span></span>() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>s = <span class="GramE">Session(</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = <span class="GramE">Response(</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = <span class="SpellE"><span class="GramE">s.send</span></span>(<span class="SpellE">req_prepped</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span> = {} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (<span class="SpellE"><span class="GramE">res.status</span>_code</span> == 200): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">responseJSON</span> = <span class="SpellE"><span class="GramE">json.loads</span></span>(<span class="SpellE">res.content</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;details<span class="GramE">&quot;<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">responseJSON</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">access_token</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;status<span class="GramE">&quot;<span style="color: black">]=</span></span>&quot;1&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">exp_time</span><span class="GramE">&quot;<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">responseJSON</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">expires_in</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">exp_date</span><span class="GramE">&quot;<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">responseJSON</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">expires_on</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">accessDetails</span><span class="GramE">&quot;<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">responseJSON</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;details<span class="GramE">&quot;<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">str</span>(<span class="SpellE">res.status_code</span>) + <span class="SpellE">str</span>(<span class="SpellE">res.json</span>()) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;status<span class="GramE">&quot;<span style="color: black">]=</span></span>&quot;0&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">access_token_det</span> </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">Once you get the access token, we call the following functions of the SDK to get the list of regions, <span class="SpellE">vm</span> sizes and storage account types:</p>    <p class="MsoNormal">We have added a layer of abstraction between the SDK functions and the Django application. This is to avoid changing the application if the function’s return types change.</p>    <p class="MsoNormal">Please refer to the module <span class="SpellE">arm_framework</span> on this <a href="https://github.com/shwetams/arm-samples-py/blob/master/arm_basic_samples/utilities/arm_framework.py">link</a>.</p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">loc_list</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.get_list_regions</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(token[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;details&quot;</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],<span class="SpellE">subscription</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">pricing_tier</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.get_list_vm_sizes</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(token[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;details&quot;</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],<span class="SpellE">subscription</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">stor_acc_types</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.get_list_storage_types</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(token[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;details&quot;</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],<span class="SpellE">subscription</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">)<span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal">We send all of these as template parameters to the html page. Please look at the template file for details on how it is loaded, it’s typical Django &amp; and <span class="SpellE">javascript</span> code.</p>    <p class="MsoNormal">Now that we have the form loaded, the user can enter the deployment name and everything gets populated.</p>    <p class="MsoNormal">Next step is to <b>Get VM Image list. </b>The Azure Resource Manager provides VM list based on location, and in multi-Step:</p>    <p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; mso-list: l2 level1 lfo3"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">1.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span>Get Publisher</p>    <p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l2 level1 lfo3"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">2.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span>Get Offer for the publisher</p>    <p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; mso-list: l2 level1 lfo3"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">3.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span>Get SKUs for the offer, publisher</p>    <p class="MsoListParagraphCxSpLast" style="text-indent: -0.25in; mso-list: l2 level1 lfo3"><span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"><span style="mso-list: ignore">4.<span style="font: 7pt &quot;Times New Roman&quot;">&#160;&#160;&#160;&#160;&#160;&#160; </span></span></span>Get Versions for the offer, publisher and SKUs</p>    <p class="MsoNormal"></p>    <p class="MsoNormal">The form first loads the list of publisher, it is loading as a raw list which is not a very good way of loading, ideally one must provide a search box and return search results based on that. </p>    <p class="MsoNormal">We use the following function from SDK to load the list of publishers (<span class="SpellE">getvmimagepublishers</span>):</p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">pub_list</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.get_list_vm_<span class="GramE">publishers</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">=<span class="SpellE">acc_token</span>, <span class="SpellE">subscription_id</span>=<span class="SpellE">subscription_id,region_name</span>=<span class="SpellE">region_name</span>)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">Based on the publishers, we call the rest of the functions:</p>    <p class="MsoNormal"><b>Offers: </b></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">offer_list</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.get_list_vm_<span class="GramE">offers</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">=<span class="SpellE">acc_token</span>, subscription_id=subscription_id,region_name=region_name,publisher_name=publisher_name)</span></p>    <p class="MsoNormal"><b><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/0675.DeploymentSelectOffer_77CF985B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/0675.DeploymentSelectOffer_5F00_77CF985B.png"><img title="DeploymentSelectOffer" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="DeploymentSelectOffer" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/0753.DeploymentSelectOffer_thumb_591B3F21.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/0753.DeploymentSelectOffer_5F00_thumb_5F00_591B3F21.png" width="544" height="484" /></a></b></p>    <p class="MsoNormal"><b>SKUs: </b></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">skus_list</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.get_list_vm_<span class="GramE">skus</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">=<span class="SpellE">acc_token</span>, subscription_id=subscription_id,region_name=region_name,publisher_name=publisher_name,</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">offer_name=offer)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/1050.DeploymentSelectSkU_48A2CE26.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/1050.DeploymentSelectSkU_5F00_48A2CE26.png"><img title="DeploymentSelectSkU" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="DeploymentSelectSkU" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/0842.DeploymentSelectSkU_thumb_6134FC27.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/0842.DeploymentSelectSkU_5F00_thumb_5F00_6134FC27.png" width="644" height="338" /></a></span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><b>Versions: </b></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">versions_list</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.get_list_vm_<span class="GramE">versions</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">=<span class="SpellE">acc_token</span>, subscription_id=subscription_id,region_name=region_name,publisher_name=publisher_name,</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">offer_name=offer,sku_name=skus)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><b>Note: You will notice, that for some publishers the version list returns empty. That means that VM image does not exist. While this application doesn’t handle it, you must ideally cater to it by providing appropriate messages.</b></p>    <p class="MsoNormal"><b>Fetch Subscriptions: </b></p>    <p class="MsoNormal">The last bit is to fetch the list of subscriptions that the user initially had entered into settings manually or through the OpenID connect methodology explained earlier. This is done through list stored in the local DB.</p>    <p class="MsoNormal"><b><span style="font-size: 12pt; line-height: 107%; mso-bidi-font-size: 11.0pt">Submit Deployment</span> </b></p>    <p class="MsoNormal">This is the last step of the deployment method. First thing the client determines is whether it is an app-only authentication or user-based authentication. This it does by calling the web method on Django server as shown below in the <a href="https://github.com/shwetams/arm-samples-py/blob/master/arm_basic_samples/deployment_option/templates/deployment_option.html">html template file</a>:</p>    <p class="MsoNormal">If it’s app-only it is very simple, the client sends all the deployment details in a JSON object directly to the server:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>url: </span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'..</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">/<span class="SpellE">authdetails</span>/'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>type: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'POST'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>data: <span class="SpellE">deploymentDetails</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">dataType</span>: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">json</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>headers: <span class="GramE">{ <span style="color: #a31515">&quot;</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">X-<span class="SpellE">CSRFToken</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: <span class="SpellE">getCookie</span>(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">csrftoken</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) }, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>error: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">function</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(e){console.log(<span class="SpellE"><span class="GramE">e.message</span></span>)}, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">function</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (data) { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">deploymentDetails</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_type</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = data[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_type</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">//console.log(data[&quot;<span class="SpellE">auth_type</span>&quot;])</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (data[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_type</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] == </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;A&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">$.ajax</span>({ </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>url: </span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'..</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">/deploy/'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>type: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'post'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>headers: <span class="GramE">{ <span style="color: #a31515">&quot;</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">X-<span class="SpellE">CSRFToken</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: <span class="SpellE">getCookie</span>(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">csrftoken</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) }, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>data: <span class="SpellE">deploymentDetails</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">dataType</span>: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">json</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">function</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (data) { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;#<span class="SpellE">deploy_results</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">).html(<span class="SpellE">JSON.stringify</span>(data)) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;#<span class="SpellE">dep_spinner</span>&quot;</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">).hide</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}) </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">However, if it’s the user-based <span class="GramE">authentication, <span style="mso-spacerun: yes">&#160;</span>the</span> client opens a pop-up with the <span class="SpellE">auth_url</span> that the server returns:</p>    <p class="MsoNormal"></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">var</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">url</span> = data[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_code_url</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>popup = <span class="SpellE"><span class="GramE">window.open</span></span>(<span class="SpellE">url</span>, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;Login&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">, width=300,height=200);</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">This is to get the authorization code that will be used to generate the token.</p>    <p class="MsoNormal">The views.py constructs the <span class="SpellE">auth_code_url</span> using the <span class="SpellE">client_if</span> &amp; <span class="SpellE">tenant_id</span> saved by the user as shown below. </p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">authorize_url</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://login.microsoftonline.com/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + <span class="SpellE">tenant_id</span> +</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/oauth2/<span class="SpellE"><span class="GramE">authorize?client</span>_id</span>=&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+<span class="SpellE">client_id</span>+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;<span class="SpellE">response_type</span>=code&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">auth_response</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_type</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = <span class="SpellE">auth_type</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">auth_response</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_code_url</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = <span class="SpellE">authorize_url</span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">auth_response</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;<span class="SpellE">auth_token</span><span class="GramE">&quot;<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> None</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">The popup window loads the user Azure AD login page. Once the user successfully logs in, it returns the control back to the Django Server as provided in the redirect URI and passes the access code as a query string.</p>    <p class="MsoNormal">This function immediately returns the control back to the template calling it’s <span class="SpellE">get_Access_code</span> function.</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">get_access_code</span>(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">query_string</span> = </span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.META</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;QUERY_STRING&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">code_det</span> = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;code<span class="GramE">&quot;<span style="color: black">:<span class="SpellE">query</span></span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">_string</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">htmlstring</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&lt;html&gt;&lt;head&gt;&lt;/title&gt;&lt;script type='text/javascript'&gt;window.opener.get_access_code(&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.dumps</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(code_det)+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;);window.close();&lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 107%; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> <span class="SpellE">HttpResponse</span>(<span class="SpellE">htmlstring</span>)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal">The <span class="SpellE">javascript</span> function <span class="SpellE">get_access_code</span> is called as described below:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">code_str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> = code[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;code&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">var</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">code_arr</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">code_arr</span> = <span class="SpellE">code_<span class="GramE">str.toString</span></span>().split(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'&amp;'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">code_val</span> = <span class="SpellE">code_<span class="GramE">arr</span></span><span class="GramE">[</span>0].replace(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;code=&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">deploymentDetails</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_code</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = <span class="SpellE">code_val</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="GramE">$.ajax</span>({ </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>url: </span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'..</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">/deploy/'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>type: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'post'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>headers: <span class="GramE">{ <span style="color: #a31515">&quot;</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">X-<span class="SpellE">CSRFToken</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: <span class="SpellE">getCookie</span>(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">csrftoken</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) }, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE"><span class="GramE">data:deploymentDetails</span></span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">dataType</span>:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">json</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">function</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (data) { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;#<span class="SpellE">dep_spinner</span>&quot;</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">).hide</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;#<span class="SpellE">deploy_results</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">).html(<span class="SpellE">JSON.stringify</span>(data)) </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">The function sends the details to the same Django application function <span class="SpellE">create_<span class="GramE">deployment</span></span><span class="GramE">(</span>) as described below:</p>    <p class="MsoNormal">The method gets the access token either directly through the app-only route or using the authorization code: </p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">auth_type</span> == </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;U&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">auth_code</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.POST</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">auth_code</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">token_url</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://login.microsoftonline.com/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + <span class="SpellE">tenant_id</span>+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/oauth2/token&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>body=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;grant_type=authorization_code&amp;code=&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+auth_code+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;redirect_uri=&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+redirect_uri+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;</span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&amp;client_id=&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+client_id+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;client_secret=&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+ </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">urllib</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.quote_plus(client_secret)+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;resource=https://management.core.windows.net/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">headers ={</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">Content-Type&quot;<span style="color: black">:</span>&quot;application</span>/x-www-form-<span class="SpellE">urlencoded</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">req</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(method=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;POST<span class="GramE">&quot;<span style="color: black">,<span class="SpellE">url</span></span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">=<span class="SpellE">token_url,data</span>=body) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">req_prepped</span> = <span class="SpellE"><span class="GramE">req.prepare</span></span>() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>s = </span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Session</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)<span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>res = </span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Response</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>res = <span class="SpellE"><span class="GramE">s.send</span></span>(<span class="SpellE">req_prepped</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">responseJSON</span> = </span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.loads</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE">res.content</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>token = <span class="SpellE">responseJSON</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">access_token</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">token_result</span> = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;POSTURL<span class="GramE">&quot;<span style="color: black">:token</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">_url,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;body&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:body,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;headers&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:headers,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Response&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:responseJSON} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>res = get_access_token(tenant_id=tenant_<span class="GramE">id,client</span>_id=client_id,client_secret=client_secret) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">token_result</span> = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">Response&quot;<span style="color: black">:res</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(res[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;status<span class="GramE">&quot;<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;1&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>token = res[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;details&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>token=None </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">deploymentDetails</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.POST</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">subscription_id</span>=<span class="SpellE">deploymentDetails</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">subscriptionID</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]<span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"></span></p>    <p class="MsoNormal"><b>Create Resource group: </b></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">res_grp_created_status</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_<span class="GramE">fw<span style="color: black">.create</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">_resource_group(access_token=token,subscription_id=subscription_id,resource_group_name=</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;resourceGroupName&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],region=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;location&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">]) </span></p>    <p class="MsoNormal">This sends the details to our abstract layer which in turn calls the Create <span class="SpellE">Vnet</span> function in the Python SDK:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">create_resource_<span class="GramE">group</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>cred = <span class="SpellE"><span class="GramE">SubscriptionCloudCredentials</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_client</span> = <span class="SpellE"><span class="GramE">ResourceManagementClient</span></span><span class="GramE">(</span>cred, <span class="SpellE">user_agent</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">SDKSample</span>/1.0'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_group_params</span> = <span class="SpellE"><span class="GramE">ResourceGroup</span></span><span class="GramE">(</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>location=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>tags<span class="GramE">={</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'RGID'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">result_create</span> = resource_client.resource_<span class="GramE">groups.client</span>.resource_groups.create_or_update(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">resource_group_params</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>success=False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 200: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">elif</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 201: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">result_json</span> = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">success<span class="GramE">&quot;<span style="color: black">:success</span></span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">resource_created&quot;<span style="color: black">:result_create.resource_group.name</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_json</span> </span></p>    <p class="MsoNormal"><b><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160; </span></b></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"><b>Create Virtual Network </b></p>    <p class="MsoNormal">if the resource group gets created successfully, we then create the Virtual Network</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">res_grp_created</span>: </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">vnet_created_status</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_<span class="GramE">fw<span style="color: black">.create</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">_virtual_network(access_token=token,subscription_id=subscription_id,</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">resource_group_name=res_grp_name_created,virtualnetwork_name=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vnetName&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],region=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;location&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">], subnets=<span class="SpellE">None,addresses</span>=<span class="SpellE">None,dns_servers</span>=None)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal">As described in the function below, it is creating a single address space, subnet and <span class="SpellE">dns</span> server</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">create_virtual_<span class="GramE">network</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">virtualnetwork_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subnets</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">=None, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">addresses</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">=None, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">dns_servers</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">=None): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>cred = <span class="SpellE"><span class="GramE">SubscriptionCloudCredentials</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_client</span> = <span class="SpellE"><span class="GramE">ResourceManagementClient</span></span><span class="GramE">(</span>cred, <span class="SpellE">user_agent</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">SDKSample</span>/1.0'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_<span class="GramE">client.providers</span>.register</span>(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">Microsoft.Network</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">network_client</span> = <span class="SpellE">NetworkResourceProviderClient</span>(cred) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">network_parameters</span> = None </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subnets</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> !</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">= None </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">and</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">addresses</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> != None </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">and</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">dns_servers</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> != None): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">addr_space</span> = <span class="SpellE">AddressSpace</span>(<span class="SpellE">address_prefixes</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">addresses</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">dhcp_opts</span> = <span class="SpellE">DhcpOptions</span>(<span class="SpellE">dns_servers</span>=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">dns_servers</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">subnet_det</span> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subnets</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">network_parameters</span> = <span class="SpellE"><span class="GramE">VirtualNetwork</span></span><span class="GramE">(</span>location=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">virtualnetwork_name</span>=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">virtualnetwork_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">address_space</span>= <span class="SpellE">addr_<span class="GramE">space,dhcp</span>_options</span>=<span class="SpellE">dhcp_opts,subnets</span>=<span class="SpellE">subnet_det</span>)<span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="GramE">DefaultNetworkSettings.objects.filter</span>(setting_type_id=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;default&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">).exists(): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">def_settings</span> = <span class="SpellE"><span class="GramE">DefaultNetworkSettings.objects.filter</span></span>(<span class="SpellE">setting_type_id</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;default&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">add_sp</span>=None </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">sb_net_prefix</span>=None </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">sb_net_name</span>=None </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">for</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> ds </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">def_settings</span>: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">add_sp</span> = <span class="SpellE">ds.default_address_space</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">sb_net_prefix</span> = <span class="SpellE">ds.default_address_range</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">sb_net_name</span> = <span class="SpellE">ds.default_subnet_name</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">addr_space</span> = <span class="SpellE">AddressSpace</span>(<span class="SpellE">address_prefixes</span>=[<span class="SpellE">add_sp</span>]) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">subnet_det</span> = [Subnet(name=<span class="SpellE">sb_net_<span class="GramE">name,address</span>_prefix</span>=<span class="SpellE">sb_net_prefix</span>)] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">network_parameters</span> = <span class="SpellE"><span class="GramE">VirtualNetwork</span></span><span class="GramE">(</span>location=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, virtualnetwork_name=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">virtualnetwork_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,address_space=addr_space,dhcp_options=None,</span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">subnets=subnet_det) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>result_create=network_<span class="GramE">client.virtual</span>_networks.create_or_update(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">virtualnetwork_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,network_parameters) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>success=False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 200: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">elif</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 201: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">result_json</span> = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">resource_created</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">virtualnetwork_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;success<span class="GramE">&quot;<span style="color: black">:success</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;subnet_name&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:<span class="SpellE">sb_net_name</span>} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_json</span> </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"><b><span style="mso-spacerun: yes">&#160;</span> </b></p>    <p class="MsoNormal"><b>Create Storage Account </b></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">stor_acc_created_status</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_<span class="GramE">fw<span style="color: black">.create</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">_storage_account(access_token=token,subscription_id=subscription_id,</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">resource_group_name=res_grp_name_created,storage_account_name=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;storageAccountName&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],region=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;location&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],storage_type=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;storageAccountType&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">])</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">Following is the underlying function for creating storage account:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">create_storage_<span class="GramE">account</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">storage_account_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">storage_type</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>cred = <span class="SpellE"><span class="GramE">SubscriptionCloudCredentials</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_client</span> = <span class="SpellE"><span class="GramE">ResourceManagementClient</span></span><span class="GramE">(</span>cred, <span class="SpellE">user_agent</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">SDKSample</span>/1.0'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_<span class="GramE">client.providers</span>.register</span>(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">Microsoft.Storage</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">storage_client</span> = <span class="SpellE"><span class="GramE">StorageManagementClient</span></span><span class="GramE">(</span>cred, <span class="SpellE">user_agent</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">SDKSample</span>/1.0'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">storage_params</span> = <span class="SpellE"><span class="GramE">StorageAccountCreateParameters</span></span><span class="GramE">(</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>location=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">account_type</span>=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">storage_type</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">result_create</span> = storage_<span class="GramE">client.storage</span>_accounts.create(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">storage_account_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,storage_params) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>success=False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 200: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">elif</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 201: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">result_json</span> = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">success<span class="GramE">&quot;<span style="color: black">:success</span></span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;resource_created&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">storage_account_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_json</span> </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"><b>Create Virtual Machine </b></p>    <p class="MsoNormal"><span class="GramE">Finally</span> we call the create Virtual Machine sending the created details.</p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">vm_created_status</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">arm_fw</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.create_virtual_machine(access_token=token,subscription_id=subscription_id,resource_group_name=res_grp_name_</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">created,vm_name=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmName&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],vnet_name=vnet_name_created,subnet_name=subnet_name_created,</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">vm_size=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmPricingTier&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],storage_name=stor_acc_created_name,region=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;location&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],vm_username=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmUserName&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],vm_password=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmPassword&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],publisher=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmPublisher&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],offer=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmOffer&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],sku=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmSKU&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],version=deploymentDetails[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;vmVersion&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">])</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">With underlying function as:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">create_virtual_<span class="GramE">machine</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vnet_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subnet_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_<span class="GramE">size</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,<span style="mso-spacerun: yes">&#160; </span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">storage</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_username</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_password</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">publisher</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">offer</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">sku</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">version</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">interface_name</span>=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">nic</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>cred = <span class="SpellE"><span class="GramE">SubscriptionCloudCredentials</span></span><span class="GramE">(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_client</span> = <span class="SpellE">ResourceManagementClient</span>(cred) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">resource_<span class="GramE">client.providers</span>.register</span>(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">Microsoft.Compute</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">compute_client</span> = <span class="SpellE">ComputeManagementClient</span>(cred) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">hardware_profile</span> = <span class="SpellE">HardwareProfile</span>(<span class="SpellE">virtual_machine_size</span>=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_size</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">os_profile</span> = <span class="SpellE"><span class="GramE">OSProfile</span></span><span class="GramE">(</span><span class="SpellE">computer_name</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">admin_username</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_username</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">admin_password</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_password</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">image_reference</span> = <span class="SpellE"><span class="GramE">ImageReference</span></span><span class="GramE">(</span>publisher=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">publisher</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, offer=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">offer</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">sku</span>=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">sku</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, version=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">version</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">storage_profile</span> = <span class="SpellE"><span class="GramE">StorageProfile</span></span><span class="GramE">(</span><span class="SpellE">os_disk</span>=<span class="SpellE">OSDisk</span>(caching=<span class="SpellE">CachingTypes.none</span>, <span class="SpellE">create_option</span>=<span class="SpellE">DiskCreateOptionTypes.from_image</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;</span><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>name=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">virtual_hard_disk</span>=<span class="SpellE"><span class="GramE">VirtualHardDisk</span></span><span class="GramE">(</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span class="SpellE">uri</span>=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'https://{0<span class="GramE">}.blob.core.windows.net</span>/<span class="SpellE">vhds</span>/{1}.<span class="SpellE">vhd</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.format( </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">torage_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">)</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">), <span class="SpellE">image_reference</span>=<span class="SpellE">image_reference</span>&#160;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160; </span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">nic_reference</span> = create_network_<span class="GramE">interface(</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">access_token</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,interface_name, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vnet_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subnet_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">nw_profile</span> = <span class="SpellE"><span class="GramE">NetworkProfile</span></span><span class="GramE">(</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">network_interfaces</span><span class="GramE">=[</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">NetworkInterfaceReference</span>(<span class="SpellE">reference_uri</span>=<span class="SpellE">nic_reference</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">vm_parameters</span> = <span class="SpellE"><span class="GramE">VirtualMachine</span></span><span class="GramE">(</span>location=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">region</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, name=</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">os_profile</span>=<span class="SpellE">os_profile</span>, <span class="SpellE">hardware_profile</span>= <span class="SpellE">hardware_profile</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">network_profile</span>=<span class="SpellE">nw_profile</span>, <span class="SpellE">storage_profile</span>=<span class="SpellE">storage_profile</span>, <span class="SpellE">image_reference</span>=<span class="SpellE">image_reference</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">result_create</span> = compute_<span class="GramE">client.virtual</span>_machines.create_or_update(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">resource_group_name</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, <span class="SpellE">vm_parameters</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>success=False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 200: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">elif</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_<span class="GramE">create.status</span>_code</span> == 201: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>success = False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span><span class="SpellE">result_json</span> = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">resource_created</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">vm_name</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">success<span class="GramE">&quot;<span style="color: black">:success</span></span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">result_json</span> </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">The application right now returns the names of the created resources as is, one could modify this to show a user friendly message.</p>    <p class="MsoNormal"><b>Refresh Token </b></p>    <p class="MsoNormal">Please note, ideally you should be adding a check to ensure the access token does not expire, and to call the refresh token before it expires.</p> </div>]]></content:encoded>
    </item>
    <item>
      <title>Authentication with Azure AD for Azure Resource Manager with Python – The single tenant app approach</title>
      <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/authentication-with-azure-ad-for-azure-resource-manager-with-python-the-single-tenant-app-approach</link>
      <pubDate>Wed, 21 Oct 2015 10:33:13 GMT</pubDate>
      <dc:creator><![CDATA[Shweta Gupta (TE - Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shwetasblogs/2015/10/21/authentication-with-azure-ad-for-azure-resource-manager-with-python-the-single-tenant-app-approach/</guid>
      <description><![CDATA[This is the Azure Single Tenant application approach where one deploys the application in...]]></description>
      <content:encoded><![CDATA[<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 15" /><meta name="Originator" content="Microsoft Word 15" /><link rel="File-List" href="AuthenticationSingletenant_files/filelist.xml" /><link rel="Edit-Time-Data" href="AuthenticationSingletenant_files/editdata.mso" /><link rel="themeData" href="AuthenticationSingletenant_files/themedata.thmx" /><link rel="colorSchemeMapping" href="AuthenticationSingletenant_files/colorschememapping.xml" />  <div class="WordSection1">   <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">This is the Azure Single Tenant application approach where one deploys the application in their own subscription to manage and automate workloads. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">While the steps to register the application remains same, we need to add the Application as a contributor to the subscription. We have seen that using the REST API in the <a href="https://blogs.msdn.com/b/shwetasblogs/archive/2015/10/21/authentication-with-azure-ad-for-azure-resource-manager-the-multitenant-app-approach.aspx" target="_blank">previous</a> blog post, here we will use Azure CLI command line and certificate based authentication. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">The application can retrieve the <span class="SpellE">Auth</span> code using the Application secret as well, however that may not be the preferred method as you will be storing the secret in the application code/<span class="SpellE">config</span> most likely. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">More details of the client secret based approach <span class="GramE">is</span> present in the following link in the previous blog post. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Let’s assume you have the application registered with your AD, next step will be to give access to the subscription. </span></p>    <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Step 1</span></b><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">: Add the application as Service principal to the subscription </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Please note you could add this to multiple subscriptions that you have the rights to manage. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">On your Linux VM, run the following commands: </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Create a service principal for your </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; background: purple; color: white; line-height: 107%; mso-themecolor: background1; mso-highlight: purple">azure ad <span class="SpellE">sp</span> create &lt;&lt;client ID of the application&gt;&gt;</span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: white; line-height: 107%; mso-themecolor: background1"> </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">This command will return the <span class="SpellE">ObjectID</span> of the application, please make sure you copy this as you will use it for the next step </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">Assign Contributor role to the subscriptions </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; background: purple; color: white; line-height: 107%; mso-themecolor: background1; mso-highlight: purple">azure role assignment <span class="GramE">create</span> –<span class="SpellE">objectId</span> &lt;object ID&gt;-o Contributor -c /subscriptions/{<span class="SpellE">subscriptionId</span>}/</span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"> </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: white; line-height: 107%; mso-themecolor: background1"></span></p>    <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></b></p>    <p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Step 2</span></b><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">: Update the <span class="SpellE"><span class="GramE">manifest.json</span></span> file with the certificate for certificate based authentication: </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">On your Linux VM: </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Create the certificate, public and private key: </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span class="SpellE"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; background: purple; color: white; line-height: 107%; mso-themecolor: background1; mso-highlight: purple">openssl</span></span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; background: purple; color: white; line-height: 107%; mso-themecolor: background1; mso-highlight: purple"> <span class="SpellE">req</span> -x509 -days 3650 -<span class="SpellE">newkey</span> rsa:2048 -<span class="SpellE">keyout</span> <span class="SpellE">azkey.pem</span> -out <span class="SpellE">azcert.pem</span></span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: white; line-height: 107%; mso-themecolor: background1"> </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">This creates two files, the <span class="SpellE">azkey.pem</span> file with the private key and <span class="SpellE">azcert.pem</span> file with the certificate and public key. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Please run the following command to export the certificate thumbprint and Base64 it. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; background: purple; color: white; line-height: 107%; mso-themecolor: background1; mso-highlight: purple">echo $(<span class="SpellE">openssl</span> x509 -in <span class="SpellE">cert.pem</span> -fingerprint -<span class="SpellE">noout</span>) | <span class="SpellE">sed</span> 's/SHA1 Fingerprint=//g' | <span class="SpellE">sed</span> 's/://g' | <span class="SpellE">xxd</span> -r -<span class="SpellE">ps</span> | base64</span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: white; line-height: 107%; mso-themecolor: background1"> </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">Run the following command to export the public key of the certificate. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; background: purple; color: white; line-height: 107%; mso-themecolor: background1; mso-highlight: purple">tail -n+2 <span class="SpellE">cert.pem</span> | head -n-1</span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: white; line-height: 107%; mso-themecolor: background1"> </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">On the portal, under your application configure tab, click on the manage manifest option and select download manifest</span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6523.manifestfile_471C677C.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6523.manifestfile_5F00_471C677C.png"><img title="manifestfile" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="manifestfile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/7128.manifestfile_thumb_0FD5E041.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/7128.manifestfile_5F00_thumb_5F00_0FD5E041.png" width="644" height="149" /></a></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">It will download a JSON file which has basic details of your application registered with AD. We will modify this JSON file to add the thumbprint and the public key of the certificate we will be using to authenticate the application with Azure AD. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">In the manifest, update the <span class="SpellE">keyCredentials</span> file with the certificate details (please <span class="GramE">note ,</span> copy paste the values as is from your VM and do not add/update/delete spaces) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2e75b6; mso-highlight: white">keyCredentials</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2e75b6; mso-highlight: white">&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: [ </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span>{ </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2e75b6; mso-highlight: white">&quot;<span class="SpellE">customKeyIdentifier</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;</span><span style="font-size: 9.5pt; font-family: consolas; color: black">Base 64 thumbprint</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2e75b6; mso-highlight: white">&quot;<span class="SpellE">keyId</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;GUID generated &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, (you can use <span class="SpellE">uuidgen</span> –r to generate a GUID) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2e75b6; mso-highlight: white">&quot;type&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;AsymmetricX509Cert&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2e75b6; mso-highlight: white">&quot;usage&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Verify&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2e75b6; line-height: 107%; mso-highlight: white">&quot;value&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> (Paste the public key value here” </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">Your JSON file should look like the one below:</span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%"></span></p>    <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8640.jsonsample_5F426288.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8640.jsonsample_5F00_5F426288.png"><img title="jsonsample" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="jsonsample" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8540.jsonsample_thumb_68EA0F17.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8540.jsonsample_5F00_thumb_5F00_68EA0F17.png" width="532" height="484" /></a></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">&#160;</p>    <p class="MsoNormal">Save the JSON file and upload the file using the Upload manifest option. Please make sure it uploads successfully. If it gives an error without specifying the field name, it’s probably because there is an additional character that has been added. Please make sure you have copied the thumbprint encoded &amp; the public key value as is. If you have, try using another editor.</p>    <p class="MsoNormal">Make sure you save the private key in a location where you can reference it in your code.</p>    <p class="MsoNormal">Following code snippet shows how to obtain the Access token from AD based on certificate:</p>    <p class="MsoNormal">The <span class="SpellE">client_det</span> dictionary hold the <span class="SpellE">tenant_id</span>, <span class="SpellE">client_id</span> of the application.</p>    <p class="MsoNormal"></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>endpoint = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'https://login.windows.net/'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + <span class="SpellE">client_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">tenant_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'/oauth2/token'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span> = {} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-tab-count: 1"></span>jwt_token_body[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'aud<span class="GramE">'<span style="color: black">]=</span></span>'https://login.windows.net/'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+client_det[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'tenant_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'/oauth2/token'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">iss</span><span class="GramE">'<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">client_det</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'sub<span class="GramE">'<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">client_det</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">dt_now</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">int</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">time</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.time</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">()) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">nbf</span><span class="GramE">'<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE">dt_now</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">exp</span><span class="GramE">'<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE">dt_now</span> +600) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">jti</span><span class="GramE">'<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">uuid</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.uuid1()) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">privateKey</span> = open(<span class="SpellE">CERTIFICATE_KEY_PATH,<span style="color: #a31515">'r</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'</span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">).read</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>headers = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'x5t'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'oxvnmTdtpW4H1o64tVooW7NzNXc='</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">#<span class="SpellE">cert_str</span> = &quot;-----BEGIN CERTIFICATE-----&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">#<span class="SpellE">cert_obj</span> = load_pem_x509_<span class="GramE">certificate(</span><span class="SpellE">cert_str</span>, <span class="SpellE">default_backend</span>())</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">#<span class="SpellE">public_key</span> = <span class="SpellE">cert_<span class="GramE">obj.public</span>_key</span>()</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">#<span class="SpellE">private_key</span> = <span class="SpellE">cert_<span class="GramE">obj.private</span>_key</span>()</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">client_assertion_val</span> = </span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">jwt</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.encode</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(payload=jwt_token_body,key=privateKey,algorithm=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'RS256'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,headers=headers) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>payload = { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;grant_type&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">client_credentials</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">client_id</span><span class="GramE">&quot;<span style="color: black"> :</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">client_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">], </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;client_assertion_type&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="GramE">urn:ietf</span>:params:oauth:client-assertion-type:jwt-bearer&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;client_assertion<span class="GramE">&quot;<span style="color: black">:<span class="SpellE">client</span></span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">_assertion_val</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">resource<span class="GramE">&quot;<span style="color: black">:_</span></span><span style="color: black">resource</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>endpoint = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'https://login.microsoftonline.com/'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + _<span class="SpellE">tenant_id</span> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'/oauth2/token'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>payload = { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">grant_type</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_credentials</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: _<span class="SpellE">client_id</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_secret</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: _<span class="SpellE">client_secret</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'resource'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: _resource </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>response = </span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">requests</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.post</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">endpoint, data=payload) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">#<span class="GramE">print(</span>'response content ' + <span class="SpellE">response.content</span>)</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">json_val</span> = </span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.loads</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE">response.content</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span> = {} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (<span class="SpellE"><span class="GramE">response.status</span>_code</span> == 200): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">access_token</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = <span class="SpellE">json_val</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">access_token</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;status&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;1&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">exp_time</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = <span class="SpellE">json_val</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">expires_in</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">exp_date</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = <span class="SpellE">json_val</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">expires_on</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">accessDetails</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = <span class="SpellE">json_val</span> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;details&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE"><span class="GramE">response.status</span>_code</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">access_token_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;status&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;0&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 2">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">access_token_det</span> </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">The application creates a JWT token, which follows the following structure</p>    <p class="MsoNormal"></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 1"></span>jwt_token_body[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'aud<span class="GramE">'<span style="color: black">]=</span></span>'https://login.windows.net/'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+client_det[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'tenant_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'/oauth2/token'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">iss</span><span class="GramE">'<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">client_det</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'sub<span class="GramE">'<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">client_det</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">dt_now</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">int</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">time</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.time</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">()) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">nbf</span><span class="GramE">'<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE">dt_now</span>) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">exp</span><span class="GramE">'<span style="color: black">]=</span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(<span class="SpellE">dt_now</span> +600) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span class="SpellE">jwt_token_body</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">jti</span><span class="GramE">'<span style="color: black">]=</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">uuid</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.uuid1()) </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">Make sure the audience claim (<span class="SpellE">aud</span>) is same as the endpoint, and you add the header with the certificate thumbprint.</p>    <p class="MsoNormal">Encode the token using the <span class="SpellE"><span class="GramE">jwt.encode</span></span>() method and pass the private key as the parameter for key.</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span class="GramE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">jwt</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.encode</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(payload=jwt_token_body,key=privateKey,algorithm=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'RS256'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,headers=headers) </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">Then create the payload as the following:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>payload = { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;grant_type&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">client_credentials</span>&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">client_id</span><span class="GramE">&quot;<span style="color: black"> :</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> <span class="SpellE">client_det</span>[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">], </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-tab-count: 1">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;client_assertion_type&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="GramE">urn:ietf</span>:params:oauth:client-assertion-type:jwt-bearer&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;client_assertion<span class="GramE">&quot;<span style="color: black">:<span class="SpellE">client</span></span></span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">_assertion_val</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;<span class="SpellE">resource<span class="GramE">&quot;<span style="color: black">:_</span></span><span style="color: black">resource</span></span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>    <p class="MsoNormal">You will notice it is different from the client secret based payload which is in the else part:</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>payload = { </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">grant_type</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_credentials</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_id</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: _<span class="SpellE">client_id</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'<span class="SpellE">client_secret</span>'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: _<span class="SpellE">client_secret</span>, </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 4">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'resource'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: _resource </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-tab-count: 3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">Once you get the access token, you can proceed to deploy or manage ARM infrastructure on Azure as explained in the next blog part.</p>    <p class="MsoNormal">We will look at the user-based authentication along with the deployment description in the next post.</p> </div>]]></content:encoded>
    </item>
    <item>
      <title>Authentication with Azure AD for Azure Resource Manager with Python – The multitenant app approach</title>
      <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/authentication-with-azure-ad-for-azure-resource-manager-with-python-the-multitenant-app-approach</link>
      <pubDate>Wed, 21 Oct 2015 10:24:50 GMT</pubDate>
      <dc:creator><![CDATA[Shweta Gupta (TE - Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shwetasblogs/2015/10/21/authentication-with-azure-ad-for-azure-resource-manager-with-python-the-multitenant-app-approach/</guid>
      <description><![CDATA[This would be the most likely scenario you want to automate Azure infrastructure. Where you are...]]></description>
      <content:encoded><![CDATA[<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 15" /><meta name="Originator" content="Microsoft Word 15" /><link rel="File-List" href="AuthenticationMultitenant_files/filelist.xml" /><link rel="Edit-Time-Data" href="AuthenticationMultitenant_files/editdata.mso" /><link rel="themeData" href="AuthenticationMultitenant_files/themedata.thmx" /><link rel="colorSchemeMapping" href="AuthenticationMultitenant_files/colorschememapping.xml" />  <div class="WordSection1">   <p class="MsoNormal">This would be the most likely scenario you want to automate Azure infrastructure. Where you are either a multi-cloud infrastructure management provider or Azure only, you will need to incorporate the AD authentication mechanism for a user.</p>    <p class="MsoNormal">Azure AD implements OAuth2.0 authentication, following are the steps you can follow to set it up.</p>    <p class="MsoNormal">Please note at the time of writing of this blog, Azure ADL for Python has just been released. We will modify this blog later to add those details.</p>    <p class="MsoNormal">Meanwhile, you could refer to the complete code at:</p>    <p class="MsoNormal"><a title="https://github.com/shwetams/arm-samples-py" href="https://github.com/shwetams/arm-samples-py">https://github.com/shwetams/arm-samples-py</a>&#160;</p>    <p class="MsoNormal"><span style="mso-no-proof: yes"><shapetype id="_x0000_t75"><stroke></stroke><formulas><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f><f></f></formulas><path></path><lock aspectratio="t" v:ext="edit"></lock></shapetype><shape id="Diagram_x0020_1" style="height: 252pt; width: 469pt; visibility: visible" o:gfxdata="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&#13;&#10;AAAKAAoAmwIAAF40AAAAAA==&#13;&#10;" o:spid="_x0000_i1031"><imagedata o:title="o:title"></imagedata><lock aspectratio="f" v:ext="edit"></lock></shape></span></p>    <h2>Pre-requisite</h2>    <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/4454.Img1_20EB7CC7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/4454.Img1_5F00_20EB7CC7.png"><img title="Img1" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto" border="0" alt="Img1" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/7317.Img1_thumb_39E9DDBD.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/7317.Img1_5F00_thumb_5F00_39E9DDBD.png" width="644" height="278" /></a> </p>    <h3>Step 1: Add application AIM to your subscription</h3>    <p class="MsoNormal">You can add the application through the portal or through command line. We will show the portal route, but you could refer to the link below to do that through command line.</p>    <p class="MsoNormal"><a href="https://azure.microsoft.com/en-us/documentation/articles/active-directory-integrating-applications/"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; line-height: 107%">https://azure.microsoft.com/en-us/documentation/articles/active-directory-integrating-applications/</span></a><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"> </span></p>    <h3>Step 2: Add Azure Service Management &amp; AD app permissions to your application</h3>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Under the configure tab, click on Add application under permissions to other applications section: </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6607.addapplication_7F90F88C.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6607.addapplication_5F00_7F90F88C.png"><img title="addapplication" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="addapplication" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/0407.addapplication_thumb_68657E0E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/0407.addapplication_5F00_thumb_5F00_68657E0E.png" width="644" height="218" /></a></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="mso-no-proof: yes"><shape id="Picture_x0020_8" style="height: 156.5pt; width: 468pt; visibility: visible; mso-wrap-style: square" o:spid="_x0000_i1030"><imagedata o:title="o:title"></imagedata></shape></span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">The popup window loads with default Microsoft Apps, select Windows Azure Service management API and select ok. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/1425.app_listpermissions_3F5D6FC3.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/1425.app_5F00_listpermissions_5F00_3F5D6FC3.png"><img title="app_listpermissions" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="app_listpermissions" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/4186.app_listpermissions_thumb_4E93D890.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/4186.app_5F00_listpermissions_5F00_thumb_5F00_4E93D890.png" width="644" height="295" /></a></span></p>    <p class="MsoNormal"><span style="mso-no-proof: yes"><shape id="Picture_x0020_9" style="height: 212.5pt; width: 468pt; visibility: visible; mso-wrap-style: square" o:spid="_x0000_i1029"><imagedata o:title="o:title"></imagedata></shape></span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Once the application gets added, click on delegated permissions and select the Access Azure Service Management option. </span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6354.app_permissions_707F3B14.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6354.app_5F00_permissions_5F00_707F3B14.png"><img title="app_permissions" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="app_permissions" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/7026.app_permissions_thumb_0DF41CD2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/7026.app_5F00_permissions_5F00_thumb_5F00_0DF41CD2.png" width="644" height="223" /></a></span></p>    <p class="MsoNormal"><span style="mso-no-proof: yes"><shape id="Picture_x0020_10" style="height: 160pt; width: 468pt; visibility: visible; mso-wrap-style: square" o:spid="_x0000_i1028"><imagedata o:title="o:title"></imagedata></shape></span><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Segoe UI&quot;,sans-serif; color: black; line-height: 107%">Then save the settings. </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">     <br /><span class="Heading2Char"><span style="font-size: 13pt; line-height: 107%; mso-bidi-font-size: 11.5pt">Obtain Authorization from user</span></span>       <br />These set of steps will need to be done each time a user is added or wants to edit their logon settings. Or perhaps add additional subscriptions they want to manage.</p>    <p class="MsoNormal">All the steps below have been implemented in the <a href="https://github.com/shwetams/arm-samples-py/blob/master/arm_basic_samples/aad_integration/views.py" target="_blank">aad_integration</a> module.</p>    <p class="MsoNormal"></p>    <h3>Step 3: Redirect user to login using OpenID Connect to get a JWT token</h3>    <p class="MsoNormal">If you take a look at the aad_integration module <span style="background: yellow; mso-highlight: yellow"></span><span style="background: yellow; mso-highlight: yellow"></span><a href="https://github.com/shwetams/arm-samples-py/blob/master/arm_basic_samples/aad_integration/views.py" target="_blank">views.py</a><span style="background: yellow; mso-highlight: yellow"></span><span style="background: yellow; mso-highlight: yellow"></span>, function authorise_user() creates the Open ID logon url.       <br />      <br />The initialize() method called initializes the client_id, secret and other variables of the application generated and stored in steps above.</p>    <p class="MsoNormal">The method expects a hint on the domain name whether it is a work account or a Microsoft account. As each of them have a separate logon url generated.</p>    <p class="MsoNormal"><rect id="Rectangle_x0020_2" style="height: 273pt; width: 462.8pt; margin-top: 5pt; position: absolute; margin-left: 0px; z-index: 251659264; visibility: visible; mso-wrap-style: square; mso-width-percent: 0; mso-height-percent: 0; mso-wrap-distance-left: 9pt; mso-wrap-distance-top: 0; mso-wrap-distance-right: 9pt; mso-wrap-distance-bottom: 0; mso-position-horizontal: absolute; mso-position-horizontal-relative: text; mso-position-vertical: absolute; mso-position-vertical-relative: text; mso-width-relative: margin; mso-height-relative: margin; v-text-anchor: middle" o:gfxdata="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&#13;&#10;" o:spid="_x0000_s1026"><textbox style="height: 264.812pt; width: 447.406pt; margin-top: 4.593pt; margin-left: 8.187pt; left: auto; top: auto">     <table cellspacing="0" cellpadding="0" width="100%"><tbody>         <tr>           <td>             <div>               <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"> authorise_user(</span><span style="font-size: 9pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>initialise() </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>PROVIDER_ISSUER_URL = </span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://login.windows.net/common/OAuth2/Authorize&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">.method == </span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;GET&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160; </span>isMSA = False </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160; </span>noonce_val = </span><span style="font-size: 9pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">str</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">(</span><span style="font-size: 9pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">uuid</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">.uuid4()) </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"> isMSA == True: </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>PROVIDER_ISSUER_URL = </span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://login.windows.net/common/OAuth2/Authorize?client_id=&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">+client_id+</span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;response_mode=form_post&amp;response_type=code+id_token&amp;nonce=&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">+\</span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">noonce_val + </span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;redirect_uri=https://127.0.0.1:8000/armaccess/&amp;resource=https://management.azure.com/\</span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&amp;scope=openid+profile&amp;\</span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">domain_hint=live.com&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>PROVIDER_ISSUER_URL =</span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://login.windows.net/common/OAuth2/Authorize?client_id=&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">+client_id+</span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;response_mode=form_post&amp;response_type=code+id_token&amp;nonce=&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">+ \</span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white">noonce_val + </span><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;&amp;redirect_uri=https://127.0.0.1:8000/armaccess/&amp;resource=https://management.azure.com/&amp; \</span></p>                <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">scope=openid+profile&quot;</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>                <p class="MsoNormal"><span style="font-size: 9pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9pt; font-family: consolas; background: white; color: blue; line-height: 107%; mso-highlight: white">return</span><span style="font-size: 9pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> redirect(PROVIDER_ISSUER_URL)</span><span style="font-size: 10pt; line-height: 107%; mso-bidi-font-size: 9.0pt"> </span></p>             </div>           </td>         </tr>       </tbody></table> </textbox></rect></p>    <br style="mso-ignore: vglayout" clear="all" />    <p class="MsoNormal">     <br style="mso-special-character: line-break" />      <br style="mso-special-character: line-break" /></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">This redirect URI will take the user to the Azure AD login page and request the user to login as shown in the diagram below:</p>    <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6763.OAuth2Login_24B5F50C.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6763.OAuth2Login_5F00_24B5F50C.png"><img title="OAuth2Login" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="OAuth2Login" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/5277.OAuth2Login_thumb_5CF6FCD5.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/5277.OAuth2Login_5F00_thumb_5F00_5CF6FCD5.png" width="644" height="318" /></a></p>    <p class="MsoNormal" style="page-break-after: avoid"><span style="mso-no-proof: yes"><shape id="Picture_x0020_3" style="height: 229.5pt; width: 468pt; visibility: visible; mso-wrap-style: square" o:spid="_x0000_i1027"><imagedata o:title="o:title"></imagedata></shape></span></p>    <p class="MsoCaption">Figure <span style="mso-no-proof: yes">1</span>: Azure AD Login page redirect</p>    <p class="MsoNormal">Once the user logs in, the user will be automatically redirected to a “Allow access” page where the user will be requested explicit access for the application to access Azure Service Management (Preview).</p>    <p class="MsoNormal">Note: This will work seamlessly with organizational accounts. However, for Microsoft accounts, the account needs to be explicitly added to the AD of your account.</p>    <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/2548.OAuth2Access_331688A0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/2548.OAuth2Access_5F00_331688A0.png"><img title="OAuth2Access" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="OAuth2Access" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/5047.OAuth2Access_thumb_2B2407A0.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/5047.OAuth2Access_5F00_thumb_5F00_2B2407A0.png" width="644" height="329" /></a></p>    <p class="MsoNormal"></p>    <p class="MsoNormal" style="page-break-after: avoid"><span style="mso-no-proof: yes"><shape id="Picture_x0020_4" style="height: 237.5pt; width: 468pt; visibility: visible; mso-wrap-style: square" o:spid="_x0000_i1026"><imagedata o:title="o:title"></imagedata></shape></span></p>    <p class="MsoCaption">Figure <span style="mso-no-proof: yes">2</span>: Allow access to application:</p>    <p class="MsoNormal">     <br />Once the user clicks on “Accept”. Azure redirects the response to the Redirect URI provided in the post request. In our case it is <a href="https://localhost/armaccess">https://localhost/armaccess</a>. </p>    <p class="MsoNormal"><b>The application is added as a Service Principal to the user’s subscription automatically by Azure AD. </b></p>    <p class="MsoNormal">Azure returns a JWT token which has user details including tenant ID and an access token.</p>    <h3>Step 4: Use JWT to fetch subscriptions the logged in user has authority to manage</h3>    <p class="MsoNormal">The returned Json Web Token has all the details of the user, following is a sample JWT <a href="https://www.authnauthz.com/OAuth/ParseJWTToken?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSIsImtpZCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE1iYTlnb0VLWSJ9.eyJhdWQiOiJhMDQ0ODM4MC1jMzQ2LTRmOWYtYjg5Ny1jMTg3MzNkZTkzOTQiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC83ZmU4NzdlNi1hMTUwLTQ5OTItYmJmZS1mNTE3ZTMwNGRmYTAvIiwiaWF0IjoxNDMyMDMwMDIzLCJuYmYiOjE0MzIwMzAwMjMsImV4cCI6MTQzMjAzMzkyMywidmVyIjoiMS4wIiwidGlkIjoiN2ZlODc3ZTYtYTE1MC00OTkyLWJiZmUtZjUxN2UzMDRkZmEwIiwib2lkIjoiODc3ZjBhYjgtOWM1Zi00MjBiLWJmODgtYTFjNmM3ZTI2NDNlIiwidXBuIjoiZWxsZW5hQGFhZGRlbW8uY29tIiwic3ViIjoiWVlCczJkZy1IUU5icnVRTEV4SEN5Z1NtdFg2d25sRy16Vi1pVVVJOG9WYyIsImdpdmVuX25hbWUiOiJFbGxlbiIsImZhbWlseV9uYW1lIjoiQWRhbXMiLCJuYW1lIjoiRWxsZW4gQWRhbXMiLCJhbXIiOlsicHdkIl0sInVuaXF1ZV9uYW1lIjoiZWxsZW5hQGFhZGRlbW8uY29tIiwibm9uY2UiOiI2MzU2NzYyNzExMzY3NjA2MDYuWkRZd09EZGlZamt0TVRNM05DMDBZVE5rTFdGaE16RXRNRGM1TWpVd09EZGtNVFV5Wm1NNE1qQmtOek10TnpreE1TMDBZV0ZqTFdFelpEa3RNR1F3TVRRMU5EbGhNak15IiwiY19oYXNoIjoiRzBfZjhybnJHcUxMb1l4MnVlUFRqZyJ9.VaviLo846Fr2QA2d0bWOq1m7Kd6rz4Zn31D7vR1vWMNz-6rno4x2zTlFZx5bRISRWVREe0EC2e_kXmzR0BwSM2BXdmPG2tmbhgcXLtEVRnd9Xib_WhVpVgP3fjDSeR1CZ-gJNmeLnzBl4I6fJdfsJXDgjlOzIVyb6Ga1jfVn6JZQ9It5a6eU1YmyJJZJC-ZY_JUQMoJLUYiE_ZuCAq7Wn95UldKT--7-fuVRqEGEdFXS19YqrzyR6ZcinojQ4IW5qIPAu2dVBjY1ftL88LKjNYOO0bJLBlt99ATlv-2bxJb41JgAwoaOSM2h7bt1cPZBCx-h9MXTTvIBL1DHZ5JX1Q">token</a>.</p>    <p class="MsoNormal">The code sample uses Python library jwt to decode the JSON web token. Please take a look at the armaccess function in views.py of <a href="https://github.com/shwetams/arm-samples-py/blob/master/arm_basic_samples/aad_integration/views.py" target="_blank">aad_integration</a> module.</p>    <p class="MsoNormal">We first retrieve the token which returns in the POST request.</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">id_token = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.POST[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;id_token&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">token_payload = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; line-height: 107%; mso-highlight: white">jwt</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.decode(id_token,verify=False)</span></p>    <p class="MsoNormal">Then we call the access_token method to get the access token for next steps.</p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">access_token = get_access_token(tenant_id=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; line-height: 107%; mso-highlight: white">str</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">(token_payload[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;tid&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">]),client_id=client_id,code=code,client_secret=client_secret, \</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">redirect_uri=redirect_uri)<span style="mso-spacerun: yes">&#160;&#160; </span></span></p>    <p class="MsoNormal">Please do keep in mind that the <b>tenant_id</b> we are passing in this case <b>is not the</b> tenant_id of the application but it is of the customer who has logged in and returned with the JWT token as <b>tid. </b></p>    <p class="MsoNormal">With this token that is returned we retrieve the list of subscriptions the user has linked to his/her account:</p>    <p class="MsoNormal">Let’s take a look at the get_subscription_list function. The url to get the subscription list is:</p>    <p class="MsoNormal"><a href="https://management.azure.com/subscriptions?api-version=2014-04-01-preview"><span style="font-size: 9.5pt; font-family: consolas; background: white; line-height: 107%; mso-highlight: white">https://management.azure.com/subscriptions?api-version=2014-04-01-preview</span></a><span style="font-size: 9.5pt; font-family: consolas; color: #a31515; line-height: 107%"> </span></p>    <p class="MsoNormal">We use the GET method and pass the token obtained in the earlier step in the header.</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> get_subscription_list(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">token_det</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>initialise() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>subs_url = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://management.azure.com/subscriptions?api-version=2014-04-01-preview&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>headers = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Authorization&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Bearer &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">token_det</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> } </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>req = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(method=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;GET&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,url=subs_url,headers=headers) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>req_prepped = req.prepare() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>s = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Session</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Response</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = s.send(req_prepped) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>subs_list = [] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (res.status_code == 200): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>resJSON = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.loads(res.content) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_list = resJSON[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;value&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_err = {} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_err[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;state&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;error&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_err[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;subscriptionId&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Error&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_err[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;displayName&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = res.content + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;token &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">token_det</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_list.append(subs_err) </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 107%; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> subs_list</span></p>    <p class="MsoNormal">The API returns an array of JSON objects containing the SubscriptionID (subscriptionID), Display name (displayName) and if it is enabled.</p>    <p class="MsoNormal">But before we move to the next step, we should ideally filter out subscriptions that the particular user doesn’t have access rights to manage. This is because we will be adding the application as a service principal on each of these subscriptions using the token retrieved by user details.</p>    <p class="MsoNormal">Let’s take a look at the following function:</p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; line-height: 107%; mso-highlight: white">def</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"> get_subscription_permissions(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; line-height: 107%; mso-highlight: white">token_det</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; line-height: 107%; mso-highlight: white">subscription_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">):</span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>initialise() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>url = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://management.azure.com/subscriptions/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">subscription_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/providers/&#160; \</span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">microsoft.authorization/permissions?api-version=2014-07-01-preview&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>headers = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Authorization&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Bearer &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">token_det</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>req = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(method=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;GET&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,url=url,headers=headers) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>req_prepped = req.prepare() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>s = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Session</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Response</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>hasPermission = False </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">#hasPermission = {}</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = s.send(req_prepped) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>per_sp = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;microsoft.authorization/roleassignments/write&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>per_gen = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;microsoft.authorization/*/write&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>hasPermission = res.content </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (res.status_code == 200): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>resJSON = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.loads(res.content) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>actions_result = resJSON[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;value&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">for</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> actions_r </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> actions_result: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>actions = actions_r[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;actions&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>notactions = actions_r[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;notActions&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> per_sp </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> actions: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> per_gen </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">not</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> notactions: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>hasPermission = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">else</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> per_gen </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> actions: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> per_gen </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">not</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> notactions: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>hasPermission = True </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> hasPermission </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">Basically, the function is called for every subscription ID that is returned and then checks for the permissions the user has. If either the permission of role assignment (<span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">microsoft.authorization/roleassignments/write</span><span style="font-size: 9.5pt; font-family: consolas; color: #a31515; line-height: 107%">) </span>or a generic permission that has all writes<span style="font-size: 9.5pt; font-family: consolas; color: #a31515; line-height: 107%"> (<span style="background: white; mso-highlight: white">microsoft.authorization/*/write</span>) </span>in Actions and not present in notActions then the function returns True. Which is then included in the subscription list below and sent back as a response as shown below.</p>    <p class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8712.ListSubscription_138C5A2D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8712.ListSubscription_5F00_138C5A2D.png"><img title="ListSubscription" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="ListSubscription" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/3704.ListSubscription_thumb_1A41F461.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/3704.ListSubscription_5F00_thumb_5F00_1A41F461.png" width="644" height="432" /></a></p>    <p class="MsoNormal" style="page-break-after: avoid"><span style="mso-no-proof: yes"><shape id="Picture_x0020_6" style="height: 298.5pt; width: 446pt; visibility: visible; mso-wrap-style: square" o:spid="_x0000_i1025"><imagedata o:title="o:title"></imagedata></shape></span></p>    <p class="MsoCaption">Figure <span style="mso-no-proof: yes">3</span>: List subscriptions</p>    <p class="MsoNormal">I had created a free trial account with my Office 365 ID. Hence it lists only one subscription in the screenshot.</p>    <h3>Step 5: Let the user select from the list of subscriptions they want to manage</h3>    <p class="MsoNormal">As the screenshot above shows the application will return a list of subscriptions that the user can select from. Once the user selects the subscription she/he wants the application to deploy infrastructure on and clicks on Connect. Following is the assignrole(request) function which is invoked on the server side when a user clicks the button.</p>    <p class="MsoNormal">The html page sends a list of subscription IDs, User ID &amp; Tenant ID in the POST request</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> assignrole(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>initialise() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160; </span><span style="mso-spacerun: yes">&#160;</span>subs_list_assigned = [] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.method == </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;POST&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_list = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.loads(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.POST[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;subs_list&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>user_id = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.POST[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;user_id&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>t_id = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.POST[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;tenant_id&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>token_user = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; line-height: 107%; mso-highlight: white">request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">.POST[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;token_user&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">]</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal">We need to again use the tenant_id of the user to generate the token that will be used to get the service principal ID that was created when the user had clicked on Accept.</p>    <p class="MsoNormal">Please do make a note of the resource URI that we are passing it is different from what we generally call:</p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">get_acacess_token_app(tenant_id=t_id,client_id=client_id,client_secret=client_secret, \</span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><b>resource=</b></span><b><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;https://graph.windows.net/&quot;</span></b><b><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">)</span></b><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">The function<span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> <span style="background: white; mso-highlight: white">get_principal_id(token=access_token[</span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; line-height: 107%; mso-highlight: white">&quot;details&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white">],tenant_id=t_id,client_id=client_id)</span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"> </span></p>    <p class="MsoNormal">Is called to get the Principal ID. Following is its body.</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">def</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> get_principal_id(</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">token</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">tenant_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">client_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>initialise() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>get_url = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://graph.windows.net/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">tenant_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/servicePrincipals?api-version=1.5&amp;$filter=appid%20eq%20'&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+<span style="mso-spacerun: yes">&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">client_id</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> +</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;'&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>headers = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Authorization&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">: </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Bearer &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: gray; mso-highlight: white">token</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>req = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(method=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;GET&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,url=get_url,headers=headers) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>req_prepped = req.prepare() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>principalId = None </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>s = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Session</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Response</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>res = s.send(req_prepped) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> (res.status_code==200): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>responseJSON = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.loads(res.content) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>value = responseJSON[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;value&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">for</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> val </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">in</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> value: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>principalId = val[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;objectId&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">return</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> principalId </span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">It returns the ObjectId value which is the Principal ID of the application for the user’s account.</p>    <p class="MsoNormal"></p>    <h3>Step 6: Add AIM as a contributor to all the subscriptions selected by user</h3>    <p class="MsoNormal">Once we have the Principal ID and the list of subscriptions that the user can manager, we need to Assign the application as a contributor role to all the subscriptions:</p>    <p class="MsoNormal">Please take a look at the code snippet we create a PUT request which sends the body that contains the principal ID, the access rights the application needs and the Contributor’s role ID which is: </p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: green; mso-highlight: white">### Predefined role definition ID</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">role_def_id_reader = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;acdd72a7-3385-48ef-bd42-f606fba81ae7&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><b><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">role_def_id_contributor = </span></b><b><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;b24988ac-6180-42a0-ab88-20f7382dd24c&quot;</span></b><b><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></b></p>    <p class="MsoNormal"></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">put_url = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;https://management.azure.com//subscriptions/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + subs +</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/providers/Microsoft.Authorization/roleAssignments/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + role_assgn_id + </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;?api-version=2014-07-01-preview&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>body = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;properties&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:{</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;roleDefinitionId&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/subscriptions/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">+ subs +</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;/providers/Microsoft.Authorization/roleDefinitions/&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + role_def_id_contributor ,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;principalId&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:principal_id}} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="mso-spacerun: yes">&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>headers_val = {</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Authorization&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Bearer &quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> + token_user, </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;Content-Type&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;application/json&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>req = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Request</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">(method=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;PUT&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">,headers=headers_val,json=body,url=put_url) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>req_prepped = req.prepare() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>s = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Session</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>res = </span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #2b91af; mso-highlight: white">Response</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">() </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>res = s.send(req_prepped) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> res.status_code == 201: </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>subs_list_assigned.append({</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;subscriptionid&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:subs,</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;assigned_status&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">:True}) </span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="mso-spacerun: yes">&#160;</span></p>    <h3>Step 7: Save the subscription IDs and application’s configuration against the user</h3>    <p class="MsoNormal">In this sample application, we are storing the user’s configuration in the default SQLLite storage.</p>    <p class="MsoNormal">The application stores a JSON array of subscription IDs, the client_id, client_secret (same as the application’s registered one) and tenant_id. </p>    <p class="MsoNormal">When a user deploys resources through the application, the application will use these details to generate an Auth token and submit the ARM requests.</p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">auth_settings = {} </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'auth_type'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">&quot;A&quot;</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'client_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=client_id </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'tenant_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=t_id </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'redirect_uri'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=redirect_uri </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'client_secret'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=client_secret </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'subscription_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]=</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #6f008a; mso-highlight: white">json</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">.dumps(subscription_list) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'user'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">] = user_id </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>user = User.objects.get(pk=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'user'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: blue; mso-highlight: white">if</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"> AuthSettings.objects.filter(user_id_id=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'user'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]).exists(): </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>u = AuthSettings.objects.get(user_id_id=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'user'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">]) </span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>u.delete()<span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal" style="margin-bottom: 0pt; line-height: normal; text-autospace: ; mso-layout-grid-align: none"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>settings = AuthSettings(user_id=user,auth_type=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'auth_type'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">],client_id=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'client_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">],tenant_id=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'tenant_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">],client_secret=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'client_secret'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">],redirect_uri=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'redirect_uri'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">],subscription_id=auth_settings[</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: #a31515; mso-highlight: white">'subscription_id'</span><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; mso-highlight: white">])<span style="mso-spacerun: yes">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; background: white; color: black; line-height: 107%; mso-highlight: white"><span style="mso-spacerun: yes">&#160;&#160;&#160; </span>settings.save()<span style="mso-spacerun: yes">&#160; </span></span><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"><span style="font-size: 9.5pt; font-family: consolas; color: black; line-height: 107%"></span></p>    <p class="MsoNormal"></p>    <p class="MsoNormal">Once this is done, the application returns the user a confirmation as shown above (it’s a basic message, you could modify it to make it more pretty! The user is not ready to deploy infrastructure on his/her set of subscriptions.</p>    <p class="MsoNormal"></p> </div>]]></content:encoded>
    </item>
    <item>
      <title>Setting up SQL Server 2014 Always On Availability Groups with Azure Premium Storage using the new SQL Server 2014 Always On resource group template</title>
      <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/setting-up-sql-server-2014-always-on-availability-groups-with-azure-premium-storage-using-the-new-sql-server-2014-always-on-resource-group-template</link>
      <pubDate>Mon, 13 Jul 2015 22:58:27 GMT</pubDate>
      <dc:creator><![CDATA[Shweta Gupta (TE - Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shwetasblogs/2015/07/13/setting-up-sql-server-2014-always-on-availability-groups-with-azure-premium-storage-using-the-new-sql-server-2014-always-on-resource-group-template/</guid>
      <description><![CDATA[&#160;  With Azure premium storage offering launched, I bet many of you have been wanting to use it...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>With Azure premium storage offering launched, I bet many of you have been wanting to use it for setting up their SQL Server 2014 Always on Availability Group clusters. </p>  <p>While, one can go ahead and set it up manually, what would be ideal is to use the available SQL Server 2014 Always On resource group template. A few clicks and you have the whole SQL Server Always On Availability Group environment setup.</p>  <p>At the time of writing of this blog, the template uses A3 Standard instances as default and a standard RA-GRS storage account. I am writing some steps below that you can implement to edit the setup created by the template for the SQL nodes to use Azure Premium Storage disks for Data &amp; Logs.</p>  <p>These steps are based out of <a href="https://blogs.technet.com/b/keithmayer/archive/2014/12/22/extending-sql-server-2014-alwayson-resource-group-with-storage-spaces-on-microsoft-azure.aspx" target="_blank">Keith’s blog</a> on extending SQL Server Always On Availability Group setup, I have tweaked them to use Azure premium storage.</p>  <p>Please do ensure you follow all the steps and in the same order. </p>  <ol>   <li>     <h5>Create the SQL Server Always On Availability Group setup from template with DS-series VMs        <br />        <br /></h5>      <p>The Azure premium storage account can at this point in time only be attached to the DS series VM. So our first step will be creating the template using DS series VM. </p>      <p>Logon to the new portal at <a href="https://portal.azure.com">https://portal.azure.com</a> and in the +New page click on Azure Marketplace. Type “SQL Server Always On” and hit enter you will find the template in the list (Figure 1).</p>      <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6281.image_50008BAD.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6281.image_5F00_50008BAD.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/7242.image_thumb_018E89F4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/7242.image_5F00_thumb_5F00_018E89F4.png" width="628" height="338" /></a>       <br />Figure 1       <br />      <br />It loads the template, and you can enter a resource group name (make a note of the name as we will be creating a premium account in this resource group in next steps).       <br />      <br />The template uses A3 instances by default. Click on the SQL Server Settings option and click on Pricing Tier. It will load the recommended pricing tier, click View All and select the DS-Series VM you want to use. Please keep in mind, the VM instance SKU matters for the IOPS you need from the premium storage. The SKUs have the maximum IOPS number so it should be easy to identify the one that you need. I selected DS2 the for this which has 6400 IOPS (Figure 2).       <br />      <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/0675.image_7352A1B4.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/0675.image_5F00_7352A1B4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/3276.image_thumb_7DA656C5.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/3276.image_5F00_thumb_5F00_7DA656C5.png" width="628" height="291" /></a>&#160; <br />Figure 2       <br /></li>    <li>     <h5>Create premium storage account in the same Resource Group        <br /></h5>      <p>After some time elapses, while the servers are getting created we can go ahead and create a premium storage account in the <strong>same resource group</strong>. This is very important we want the account to be created as close to the VMs as possible. For doing this, please click on the +New button, Data + Storage and select Storage Account option.         <br />        <br />This will load the Create Storage account blade. Click on Pricing Tier and you will see list of storage account tiers. Please click “View All” and you will find the new Premium Locally Redundant option. Please select that and create the storage account. (Figure 3)         <br />        <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/7776.image_78C633BA.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/7776.image_5F00_78C633BA.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6266.image_thumb_4A030BC9.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6266.image_5F00_thumb_5F00_4A030BC9.png" width="628" height="436" /></a>         <br />Figure 3         <br />        <br />Now let’s wait till the entire setup has been deployed. Once you get a confirmation notification on the dashboard.         <br />        <br />        <br />Please repeat the following steps for every SQL Node that has been created in the template.</p>   </li>    <li>     <h5>Disable Automatic Clustering </h5>      <p>Select the SQL Server node and then logon to the SQL Server using “Connect” option (Figure 4).        <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6558.image_492D3690.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6558.image_5F00_492D3690.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/5554.image_thumb_43E0E090.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/5554.image_5F00_thumb_5F00_43E0E090.png" width="767" height="379" /></a>         <br />Figure 4         <br />        <br /></p> Once you are connected, run the following powershell command to disable automatic clustering. We need to do this because we don’t want SQL Server to automatically cluster each time we add/remove a disk.       <br />      <br /><font color="#004080">Get-StorageSubSystem -FriendlyName &quot;Clustered Storage Spaces*&quot; | Set-StorageSubSystem -AutomaticClusteringEnabled $False        <br /></font>      <br />I use powershell_ise.exe as I like the intellisense feature it provides. Once you have run this command, please keep the connection running and do not disconnect.       <br /></li>    <li>     <h4></h4>      <h5></h5>      <h5>Remove regular storage data disks and attach premium storage disks </h5>      <p>We need to remove the regular data disks that have been attached to the SQL Server node. To do that let’s go back to the portal, select the SQL server node, click on Settings which loads the settings blade and click on Disks.        <br />In the disks tab, select the data disks , right click and select Detach (Figure 6). Detach all the disks attached one by one (these are done sequentially so you will need to wait till previous one has been detached before you go to the next one).         <br />        <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8547.image_2A0F3B12.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8547.image_5F00_2A0F3B12.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/2727.image_thumb_4DCAF35D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/2727.image_5F00_thumb_5F00_4DCAF35D.png" width="628" height="498" /></a>         <br />Figure 6</p>      <p>Once all the attached Data Disks have been detached, please click on “Attach New” disk. Click on “Select Storage Container” option, and select the new premium storage account you had created in step 2. Create a container “vhds” if you already haven't done that. Please make sure you select the premium storage account, as only this account tier has premium storage disks.        <br />        <br />Select host caching as “None” if you are going to use it for logging and select it as Read Only if its going to be used for data. (Figure 7)         <br />        <br /><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6712.image_386FCEA6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6712.image_5F00_386FCEA6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/4201.image_thumb_1F0A5C1D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/4201.image_5F00_thumb_5F00_1F0A5C1D.png" width="628" height="606" /></a>         <br />Figure 7         <br /></p>      <h5>       <br /></h5>   </li>    <li>     <h5>Setup disks for use</h5>      <p>Once you have attached all the disks, let’s go back to the remote desktop connection powershell window in the SQL Server and run the following powershell commands:        <br />        <br /><font color="#333333"><font color="#004080">$datadisks = Get-PhysicalDisk -CanPool $true            <br /></font>          <br /></font>This gets the list of data disks that have been attached and can be pooled.         <br />        <br />Note: If you plan to have both logging and data on the premium storage disks, please make sure you attached separate set of disks for each, and repeat 4 and 5 for each of them.         <br />        <br /><font color="#004080">New-StoragePool -FriendlyName &quot;SQLDataPool&quot; -StorageSubSystemFriendlyName &quot;Clustered Storage Spaces*&quot; -PhysicalDisks $datadisks | New-VirtualDisk -FriendlyName &quot;SQLDataDisk&quot; -UseMaximumSize -NumberOfColumns $datadisks.Count -ResiliencySettingName &quot;Simple&quot; -ProvisioningType Fixed -Interleave 65536 | Initialize-Disk -Confirm:$False -PassThru | New-Partition -DriveLetter J –UseMaximumSize</font>         <br />        <br />This creates the drive J, please use any letter you like.&#160; Once the drive is created, please run the following command to format it for use. </p>      <p><font color="#004080">Get-Partition -DriveLetter J | Format-Volume -FileSystem NTFS -NewFileSystemLabel &quot;SQLDataVol&quot; -AllocationUnitSize 65536 -Confirm:$False</font></p>      <h5>       <br />        <br />        <br /></h5>   </li>    <li>     <h5>Change the default location for data and logging in SQL Server Node</h5> Please use the <a href="https://msdn.microsoft.com/en-us/library/dd206993.aspx" target="_blank">Link</a> to change the data and log settings on SQL Server node.       <br /></li> </ol>  <p>You can run the SQLIO tool to get the details of IOPS and verify that you are maximizing the disk performance. After following these steps, I was getting 6450 IOPS.</p>]]></content:encoded>
    </item>
    <item>
      <title>Solving the “big legacy data” problem using Azure Data Factory…</title>
      <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/solving-the-big-legacy-data-problem-using-azure-data-factory</link>
      <pubDate>Wed, 06 May 2015 01:44:34 GMT</pubDate>
      <dc:creator><![CDATA[Shweta Gupta (TE - Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shwetasblogs/2015/05/06/solving-the-big-legacy-data-problem-using-azure-data-factory/</guid>
      <description><![CDATA[&#160;  I am sure as architects and systems developers we have at least one Big Data solution we are...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>I am sure as architects and systems developers we have at least one Big Data solution we are working on. Today, many enterprises and businesses are in their “revamp” stage of applications where there existing systems are no longer adequate to handle current data processing workloads. The systems have been built/updated over years, some times more than a decade. They are now moving towards SaaS based solutions preferably leveraging public cloud offerings that bring in cost efficiencies as well as scalable to the increasing workloads.</p>  <p>I am working with a few such enterprises, who want to adopt Azure and its services to evolve their equipment monitoring and maintenance systems (yes yes Internet of Things. This blog explains what their existing big legacy data scenario is and a possible solution that came up and is being implemented after weeks’ of deliberation and PoCs.</p>  <p>I have explained the problem in quite a detail, as I believe it is necessary to understand the scenario. However, if you are in a hurry it should be sufficient for you can scan through the infographics and skip to the solution.</p>  <p>&#160;</p>  <h4>The big legacy data problem</h4>  <p>Following infographic (figure 1) describes a generalized version device monitoring and maintenance system of a large scale device manufacturer who could have 100’s of device types built and developed across different divisions. Evolved over years, typically various device types have their own data formats and structures. This eventually means their own parsers!</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8078.figure1_2EBAA35E.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8078.figure1_5F00_2EBAA35E.png"><img title="figure1" style="border-top: 0px; border-right: 0px; border-bottom: 0px; float: none; margin-left: auto; border-left: 0px; display: block; margin-right: auto" border="0" alt="figure1" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/1513.figure1_thumb_62F15D55.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/1513.figure1_5F00_thumb_5F00_62F15D55.png" width="640" height="375" /></a></p>  <p align="center"><em>Figure 1: Generalized Legacy systems</em></p>  <h5>Key features of the existing system:</h5>  <ul>   <li>The system accepted and processed monitoring data from 10,000’s of devices (about 400 device types) </li>    <li>Each of the device types had their own data format and structure, some were XML, CSV, Binary and unstructured. </li>    <li>There were multiple parsers built to cater one or more device types (that had similar file structures). </li>    <li>All of the parsers parse files extract information and create SQL insert statements that get inserted in batches on the RDMS </li>    <li>Triggers run and create action inserts for the application to query and perform actions like mailing alerts </li> </ul>  <h5>What are the pain points?</h5>  <ol>   <li>Multiple file formats, multiple structures and 1000’s of such files being uploaded every day </li>    <li>Infrastructure that hosts the parsers not adequate and getting very expensive to maintain </li>    <li>Maintenance nightmare of these parsers, data </li>    <li>Expensive RDMS storage </li>    <li>Not scalable, adding a new device type takes a really long cycle ; </li>    <li>Similarly adding new triggers/conditions to check the device also takes a long time </li> </ol>  <p>&#160;</p>  <h4>Desired Workflow</h4>  <p>Building a solution on Azure, we could easily cater to a lot of the pain points; infrastructure scaling and costs reduction by using the services provided by Azure, replacing RDMS with Azure blob storage; deploying services like Stream Analytics that can query data directly from blob storage.</p>  <p>A typical desired workflow would be:</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8802.figure2_6D451266.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8802.figure2_5F00_6D451266.png"><img title="figure2" style="border-top: 0px; border-right: 0px; border-bottom: 0px; float: none; margin-left: auto; border-left: 0px; display: block; margin-right: auto" border="0" alt="figure2" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/1348.figure2_thumb_53DF9FDD.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/1348.figure2_5F00_thumb_5F00_53DF9FDD.png" width="640" height="161" /></a> </p>  <p align="center"><em>Figure 2: Ideal Workflow</em></p>  <p></p>  <h4>But the problem persists</h4>  <p>Our ideal solution has one caveat, which is, we still need to tackle the problem where we have various file structures, and we cannot really run conditions on the files that have been uploaded as is. For example, if a condition is:</p>  <p>If value1 &gt; 0.5 for 30 minutes, and value2 &gt; 1.5 for 30 minutes then generate an alert.</p>  <p>The above condition could be easily built using Stream Analytics query. However, <b>value1 and value2 could be coming in from two different files different structures and different formats</b>, one could be XML and one could be CSV, or both could be xml but different structures.</p>  <p>So we still need to <b>PARSE</b> all of them into one format &amp; structure.</p>  <p>&#160;</p>  <h3>The Solution</h3>  <p>After some weeks it struck me that we don’t need to <b>“PARSE” but “TRANSFORM”</b> data into one format. Simply because Stream Analytics works on a <b>loosely defined schema</b> unlike a custom application which expects a fixed data format.</p>  <p>If we look at the CSV &amp; XML format, it may vary in different ways but it still as structure to it, something that can be read and predicted. XML files, will have tags, child tags, attributes and values, CSV has headers and values or no headers only values. </p>  <p>So it’s possible to write a single transformation script that could transform XML &amp; CSV into JSON (I chose JSON because it’s the most flexible structured format available right now and works beautifully with Stream Analytics). To process the unstructured data, it could be achieved by a hive job.</p>  <p>To modify the workflow and accommodate it I would add a step to transform data.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6175.figure3_57804B6B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6175.figure3_5F00_57804B6B.png"><img title="figure3" style="border-top: 0px; border-right: 0px; border-bottom: 0px; float: none; margin-left: auto; border-left: 0px; display: block; margin-right: auto" border="0" alt="figure3" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/3302.figure3_thumb_3E1AD8E2.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/3302.figure3_5F00_thumb_5F00_3E1AD8E2.png" width="640" height="206" /></a> </p>  <p align="center"><em>Figure 3: Adding file transformation</em></p>  <p align="left"><em></em></p>  <p>Following is the C# script that transforms any XML &amp; CSV data into JSON, this is generic and should work on any kind of structure. Available on <a href="https://github.com/shwetams/xmlcsvtojson/blob/master/adf.transformations/adf.filetransformation/adf.filetransformation/TransformToJSON.cs">github</a>. It follows a simple algorithm that runs recursively navigating through the XML tags hierarchy. </p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6278.Table2_4EB5CA23.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6278.Table2_5F00_4EB5CA23.png"><img title="Table2" style="border-top: 0px; border-right: 0px; border-bottom: 0px; float: none; margin-left: auto; border-left: 0px; display: block; margin-right: auto" border="0" alt="Table2" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8625.Table2_thumb_395AA56C.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8625.Table2_5F00_thumb_5F00_395AA56C.png" width="640" height="178" /></a> </p>  <p></p>  <p>For example, lets take addresses as XML tags: </p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6102.xmlstructure_7207E02A.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6102.xmlstructure_5F00_7207E02A.png"><img title="xmlstructure" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="xmlstructure" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8032.xmlstructure_thumb_114D17AF.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8032.xmlstructure_5F00_thumb_5F00_114D17AF.png" width="240" height="137" /></a> </p>  <p>&#160;</p>  <p>It’s JSON equivalent would be:</p>  <p>“Addresses”:[ “Address”:{“type”:”home”,”HouseNo”:”123,”StreetName”: “Contoso Street”, “City” : “Contoso”, “PinCode” : 123456},{“type”: “business”, “ HouseNo”: 12334, “StreetName”: “Contoso Street”, “City” : “Contoso”, “PinCode” : 123456}]]</p>  <p>Similarly, the script also transforms CSV files. If the CSV file has a header, it creates an array of JSON objects, each row having header key and their respective values. If there is no header, it will create a key as “key&lt;n&gt;” where n is the column index. The code uses a third party open sources CSVReader provided by Greene Stellman, available for download and use from this <a href="https://www.stellman-greene.com/CSVReader/">link</a>.</p>  <p>Now we have a script that can transform any XML/CSV file into JSON objects. These can be directly queried by Stream Analytics. In the above, example if I want the data to be extracted only if address is home I could easily query it now:</p>  <p>Select * from input where address.type= “home” into output </p>  <p>&#160;</p>  <h4>Scaling transformation to process thousands of incoming files…</h4>  <p>Next step is to scale this script to process thousands of incoming file. We also need to run Hive scripts on the unstructured files to extract data. I figured <a href="https://azure.microsoft.com/en-us/documentation/services/data-factory/">Azure Data Factory</a> would be an ideal solution, it is completely managed, runs and maintains the pipelines, provides detailed audit and logging reports; real time dashboard. Otherwise managing these data processing pipelines at such a large scale would be a nightmare.</p>  <p>Following diagram shows the Data Factory dashboard implementing three pipelines for processing XML/CSV; Unstructured and also copying data into the on-premise SQL database (Oracle/SQL Server) for other legacy applications that depend on it.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/7230.figure4_3D51B591.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/7230.figure4_5F00_3D51B591.png"><img title="figure4" style="border-top: 0px; border-right: 0px; border-bottom: 0px; float: none; margin-left: auto; border-left: 0px; display: block; margin-right: auto" border="0" alt="figure4" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6507.figure4_thumb_2A9F4C8B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6507.figure4_5F00_thumb_5F00_2A9F4C8B.png" width="1024" height="537" /></a> </p>  <p align="center"><em>Figure 4: Azure Data Factory Solution</em></p>  <p align="left"><em></em></p>  <p>In the Azure Data Factory, I created three pipelines:</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/2100.Table1_7AD26172.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/2100.Table1_5F00_7AD26172.png"><img title="Table1" style="border-top: 0px; border-right: 0px; border-bottom: 0px; float: none; margin-left: auto; border-left: 0px; display: block; margin-right: auto" border="0" alt="Table1" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6864.Table1_thumb_2136D56F.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6864.Table1_5F00_thumb_5F00_2136D56F.png" width="640" height="102" /></a> </p>  <p>All the activities will push data into blob storage, which I can use as input in the Azure Stream Analytics jobs. </p>  <p>Following is the extract from the C# code that runs in the custom C# activity, you can find the complete project at <a href="https://github.com/shwetams/xmlcsvtojson">github</a>, along with scripts to setup Azure Data Factory. I have used the custom C# activity documentation in the azure portal as base, you can find the earlier steps on this <a href="https://azure.microsoft.com/en-us/documentation/articles/data-factory-use-custom-activities/#SupportedSourcesAndSinks">link</a>.</p>  <p>The base class needs to inherit the <b>IDotNetActivity</b> class. The function <b>Execute</b> needs to be implemented, it accepts Input tables which is a dataset (Explained later), and output tables. </p>  <p>&#160;</p>  <p>&#160;</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/6082.xmlcodef1_74F9F285.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/6082.xmlcodef1_5F00_74F9F285.png"><img title="xmlcodef1" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="xmlcodef1" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/7571.xmlcodef1_thumb_74241D4C.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/7571.xmlcodef1_5F00_thumb_5F00_74241D4C.png" width="768" height="768" /></a> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/5381.xmlcodef2_05999F87.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/5381.xmlcodef2_5F00_05999F87.png"><img title="xmlcodef2" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="xmlcodef2" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/0003.xmlcodef2_thumb_0FED5498.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/0003.xmlcodef2_5F00_thumb_5F00_0FED5498.png" width="780" height="768" /></a> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/4087.xmlcodef3_43B7DB9A.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/4087.xmlcodef3_5F00_43B7DB9A.png"><img title="xmlcodef3" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="xmlcodef3" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/0638.xmlcodef3_thumb_7C651658.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/0638.xmlcodef3_5F00_thumb_5F00_7C651658.png" width="770" height="768" /></a> </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/8032.xmlcodef4_3B5927A5.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/8032.xmlcodef4_5F00_3B5927A5.png"><img title="xmlcodef4" style="border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px; display: inline" border="0" alt="xmlcodef4" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/69/06/metablogapi/3678.xmlcodef4_thumb_2CB39D22.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-69-06-metablogapi/3678.xmlcodef4_5F00_thumb_5F00_2CB39D22.png" width="1024" height="600" /></a> </p>  <p>&#160;</p>  <p>The solution works beautifully, the output to blob storage could be easily queries by the Stream Analytics jobs running various conditions and is undergoing planned discussions for load tests. I will update the blog post should there be anything else. </p>]]></content:encoded>
    </item>
    <item>
      <title>Creating, deployment &amp; customizing Linux VMs  with Python &amp; Chef – Part 2</title>
      <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/creating-deployment-customizing-linux-vms-with-python-chef-part-2</link>
      <pubDate>Thu, 19 Feb 2015 03:22:00 GMT</pubDate>
      <dc:creator><![CDATA[Shweta Gupta (TE - Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shwetasblogs/2015/02/19/creating-deployment-customizing-linux-vms-with-python-chef-part-2/</guid>
      <description><![CDATA[Shweta Gupta
  Shweta Gupta
  2
  211
  2015-02-19T11:11:00Z
  2015-02-19T11:11:00Z...]]></description>
      <content:encoded><![CDATA[<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Shweta Gupta</o:Author>
  <o:LastAuthor>Shweta Gupta</o:LastAuthor>
  <o:Revision>2</o:Revision>
  <o:TotalTime>211</o:TotalTime>
  <o:Created>2015-02-19T11:11:00Z</o:Created>
  <o:LastSaved>2015-02-19T11:11:00Z</o:LastSaved>
  <o:Pages>3</o:Pages>
  <o:Words>921</o:Words>
  <o:Characters>5254</o:Characters>
  <o:Lines>43</o:Lines>
  <o:Paragraphs>12</o:Paragraphs>
  <o:CharactersWithSpaces>6163</o:CharactersWithSpaces>
  <o:Version>15.00</o:Version>
 </o:DocumentProperties>
 <o:OfficeDocumentSettings>
  <o:AllowPNG/>
 </o:OfficeDocumentSettings>
</xml><![endif]--> <!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:HideSpellingErrors/>
  <w:HideGrammaticalErrors/>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:TrackMoves>false</w:TrackMoves>
  <w:TrackFormatting/>
  <w:PunctuationKerning/>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF/>
  <w:LidThemeOther>EN-US</w:LidThemeOther>
  <w:LidThemeAsian>X-NONE</w:LidThemeAsian>
  <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:SplitPgBreakAndParaMark/>
   <w:EnableOpenTypeKerning/>
   <w:DontFlipMirrorIndents/>
   <w:OverrideTableStyleHps/>
  </w:Compatibility>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math"/>
   <m:brkBin m:val="before"/>
   <m:brkBinSub m:val="&#45;-"/>
   <m:smallFrac m:val="off"/>
   <m:dispDef/>
   <m:lMargin m:val="0"/>
   <m:rMargin m:val="0"/>
   <m:defJc m:val="centerGroup"/>
   <m:wrapIndent m:val="1440"/>
   <m:intLim m:val="subSup"/>
   <m:naryLim m:val="undOvr"/>
  </m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="false"
  DefSemiHidden="false" DefQFormat="false" DefPriority="99"
  LatentStyleCount="371">
  <w:LsdException Locked="false" Priority="0" QFormat="true" Name="Normal"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 1"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 2"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 3"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 4"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 5"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 6"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 7"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 8"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="heading 9"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index 9"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 1"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 2"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 3"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 4"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 5"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 6"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 7"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 8"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" Name="toc 9"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Normal Indent"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="footnote text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="annotation text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="header"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="footer"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="index heading"/>
  <w:LsdException Locked="false" Priority="35" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="caption"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="table of figures"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="envelope address"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="envelope return"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="footnote reference"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="annotation reference"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="line number"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="page number"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="endnote reference"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="endnote text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="table of authorities"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="macro"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="toa heading"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Bullet 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Number 5"/>
  <w:LsdException Locked="false" Priority="10" QFormat="true" Name="Title"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Closing"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Signature"/>
  <w:LsdException Locked="false" Priority="1" SemiHidden="true"
   UnhideWhenUsed="true" Name="Default Paragraph Font"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text Indent"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="List Continue 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Message Header"/>
  <w:LsdException Locked="false" Priority="11" QFormat="true" Name="Subtitle"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Salutation"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Date"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text First Indent"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text First Indent 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Note Heading"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text Indent 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Body Text Indent 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Block Text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Hyperlink"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="FollowedHyperlink"/>
  <w:LsdException Locked="false" Priority="22" QFormat="true" Name="Strong"/>
  <w:LsdException Locked="false" Priority="20" QFormat="true" Name="Emphasis"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Document Map"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Plain Text"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="E-mail Signature"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Top of Form"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Bottom of Form"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Normal (Web)"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Acronym"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Address"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Cite"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Code"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Definition"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Keyboard"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Preformatted"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Sample"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Typewriter"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="HTML Variable"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Normal Table"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="annotation subject"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="No List"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Outline List 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Outline List 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Outline List 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Simple 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Simple 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Simple 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Classic 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Colorful 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Colorful 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Colorful 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Columns 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Grid 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 4"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 5"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 6"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 7"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table List 8"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table 3D effects 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Contemporary"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Elegant"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Professional"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Subtle 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Subtle 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Web 1"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Web 2"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Web 3"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Balloon Text"/>
  <w:LsdException Locked="false" Priority="39" Name="Table Grid"/>
  <w:LsdException Locked="false" SemiHidden="true" UnhideWhenUsed="true"
   Name="Table Theme"/>
  <w:LsdException Locked="false" SemiHidden="true" Name="Placeholder Text"/>
  <w:LsdException Locked="false" Priority="1" QFormat="true" Name="No Spacing"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 1"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 1"/>
  <w:LsdException Locked="false" SemiHidden="true" Name="Revision"/>
  <w:LsdException Locked="false" Priority="34" QFormat="true"
   Name="List Paragraph"/>
  <w:LsdException Locked="false" Priority="29" QFormat="true" Name="Quote"/>
  <w:LsdException Locked="false" Priority="30" QFormat="true"
   Name="Intense Quote"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 1"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 1"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 2"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 2"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 2"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 3"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 3"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 3"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 4"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 4"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 4"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 5"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 5"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 5"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="60" Name="Light Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="61" Name="Light List Accent 6"/>
  <w:LsdException Locked="false" Priority="62" Name="Light Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="63" Name="Medium Shading 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="64" Name="Medium Shading 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="65" Name="Medium List 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="66" Name="Medium List 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="67" Name="Medium Grid 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="68" Name="Medium Grid 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="69" Name="Medium Grid 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="70" Name="Dark List Accent 6"/>
  <w:LsdException Locked="false" Priority="71" Name="Colorful Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="72" Name="Colorful List Accent 6"/>
  <w:LsdException Locked="false" Priority="73" Name="Colorful Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="19" QFormat="true"
   Name="Subtle Emphasis"/>
  <w:LsdException Locked="false" Priority="21" QFormat="true"
   Name="Intense Emphasis"/>
  <w:LsdException Locked="false" Priority="31" QFormat="true"
   Name="Subtle Reference"/>
  <w:LsdException Locked="false" Priority="32" QFormat="true"
   Name="Intense Reference"/>
  <w:LsdException Locked="false" Priority="33" QFormat="true" Name="Book Title"/>
  <w:LsdException Locked="false" Priority="37" SemiHidden="true"
   UnhideWhenUsed="true" Name="Bibliography"/>
  <w:LsdException Locked="false" Priority="39" SemiHidden="true"
   UnhideWhenUsed="true" QFormat="true" Name="TOC Heading"/>
  <w:LsdException Locked="false" Priority="41" Name="Plain Table 1"/>
  <w:LsdException Locked="false" Priority="42" Name="Plain Table 2"/>
  <w:LsdException Locked="false" Priority="43" Name="Plain Table 3"/>
  <w:LsdException Locked="false" Priority="44" Name="Plain Table 4"/>
  <w:LsdException Locked="false" Priority="45" Name="Plain Table 5"/>
  <w:LsdException Locked="false" Priority="40" Name="Grid Table Light"/>
  <w:LsdException Locked="false" Priority="46" Name="Grid Table 1 Light"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark"/>
  <w:LsdException Locked="false" Priority="51" Name="Grid Table 6 Colorful"/>
  <w:LsdException Locked="false" Priority="52" Name="Grid Table 7 Colorful"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 1"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 1"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 1"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 2"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 2"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 2"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 3"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 3"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 3"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 4"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 4"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 4"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 5"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 5"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 5"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="46"
   Name="Grid Table 1 Light Accent 6"/>
  <w:LsdException Locked="false" Priority="47" Name="Grid Table 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="48" Name="Grid Table 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="49" Name="Grid Table 4 Accent 6"/>
  <w:LsdException Locked="false" Priority="50" Name="Grid Table 5 Dark Accent 6"/>
  <w:LsdException Locked="false" Priority="51"
   Name="Grid Table 6 Colorful Accent 6"/>
  <w:LsdException Locked="false" Priority="52"
   Name="Grid Table 7 Colorful Accent 6"/>
  <w:LsdException Locked="false" Priority="46" Name="List Table 1 Light"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark"/>
  <w:LsdException Locked="false" Priority="51" Name="List Table 6 Colorful"/>
  <w:LsdException Locked="false" Priority="52" Name="List Table 7 Colorful"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 1"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 1"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 1"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 1"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 2"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 2"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 2"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 2"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 3"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 3"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 3"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 3"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 4"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 4"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 4"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 4"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 5"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 5"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 5"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 5"/>
  <w:LsdException Locked="false" Priority="46"
   Name="List Table 1 Light Accent 6"/>
  <w:LsdException Locked="false" Priority="47" Name="List Table 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="48" Name="List Table 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="49" Name="List Table 4 Accent 6"/>
  <w:LsdException Locked="false" Priority="50" Name="List Table 5 Dark Accent 6"/>
  <w:LsdException Locked="false" Priority="51"
   Name="List Table 6 Colorful Accent 6"/>
  <w:LsdException Locked="false" Priority="52"
   Name="List Table 7 Colorful Accent 6"/>
 </w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>

<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Through this two part series we will look at using Python to setup and create Linux virtual machines on Azure and <span class="SpellE">customing</span> the machines through Custom Script Extensions (<a href="https://blogs.msdn.com/b/shwetasblogs/archive/2015/01/19/creating-deployment-amp-customizing-linux-vms-with-python-amp-chef-part-1.aspx">Part 1</a>) and Chef VM Extensions (Part 2).</p>
<p class="MsoNormal">This is part 2 series where we will use the same script (available on <a href="https://github.com/shwetams/python_azure_iaas">github</a>) and deploy a MySQL <span class="SpellE">Percona</span> cluster using the Linux Chef VM Extension.</p>
<p class="MsoNormal">In part 1, the Python script creates a VM, and installs a Custom script extension. This extension downloads the custom Linux scripts from a blob storage and executes them. Logging the execution details. We created a script that downloads and installs the Chef client and then runs a MySQL <span class="SpellE">Percona</span> <span class="SpellE">runbook</span>.</p>
<p class="MsoNormal">The Linux Chef extension is a very specific extension, which automatically installs the chef client and runs a single or multiple run books for provisioning the server.</p>
<p class="MsoNormal">Please follow all the steps explained in <a href="https://blogs.msdn.com/b/shwetasblogs/archive/2015/01/19/creating-deployment-amp-customizing-linux-vms-with-python-amp-chef-part-1.aspx">Part 1</a>, as everything remains the same except the script &ldquo;python percona_cluster_setup.py<span class="GramE">&rdquo; .</span> Please use the &ldquo;<strong>percona_cluster_setup_linuxchefclient.p</strong>y&rdquo; script instead.</p>
<p class="MsoNormal">The script is largely the same except that the <span class="SpellE">Get_Resource_<span class="GramE">Extension</span></span><span class="GramE">(</span>) function returns a <span class="SpellE">LinuxChefClient</span> resource extension details instead of Linux VM Extension explained in <a href="https://blogs.msdn.com/b/shwetasblogs/archive/2015/01/19/creating-deployment-amp-customizing-linux-vms-with-python-amp-chef-part-1.aspx">Part 1</a>.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Following is the function.</p>
<p class="MsoNormal"><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: blue; background: white; mso-highlight: white;">def</span></span></span><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white; mso-highlight: white;"> <span class="SpellE">Get_Res_Ext_List</span>():</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">chef_server_url</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"https://api.opscode.com/organizations/<span class="SpellE">paigeinc</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">validation_client_name</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">paigeinc</span>-validator"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">run_list</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="GramE">role[</span><span class="SpellE">percona</span>]"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt; font-family: Consolas; color: green; background: white; mso-highlight: white;"># For multiple cookbooks : <span class="SpellE">run_list</span> =<span style="mso-spacerun: yes;">&nbsp; </span>"recipe[cookbook1::recipe1],role[test_role1],recipe[cookbook2::recipe2],role[test_role2]<br /> </span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt; font-family: Consolas; color: green; background: white; mso-highlight: white;">##Note- update following path with your local</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">validation_key_file_path</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">validation.pem</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_ext_ref</span> = []</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="GramE">res</span> = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white; mso-highlight: white;">ResourceExtensionReference</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.reference_name</span>=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">LinuxChefClient</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>res.name = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">LinuxChefClient</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.publisher</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">Chef.Bootstrap.WindowsAzure</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.version</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"11.16"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.label</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">LinuxChefClient</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt; font-family: Consolas; color: green; background: white; mso-highlight: white;"># <span class="GramE">Sets</span> the public configuration for extension</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_rb</span> = </span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white; mso-highlight: white;">ResourceExtensionParameterValue</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">()</span></span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_rb.key</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">PublicParams</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pub_config</span> = {}</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pub_<span class="GramE">config</span></span><span class="GramE">[</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">'<span class="SpellE">client_rb</span>'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">] = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">chef_server_url</span> \t %s\<span class="SpellE">nvalidation_client_name</span>\<span class="SpellE">t%s</span>"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"> % (</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">chef_server_url</span>), </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">validation_client_name</span>))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pub_<span class="GramE">config</span></span><span class="GramE">[</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">'<span class="SpellE">runlist</span>'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">] = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">run_list</span>)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_rb.value</span> = _encode_<span class="GramE">base64(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">pub_config</span>))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_rb.type</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"Public"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 9.5pt; font-family: Consolas; color: green; background: white; mso-highlight: white;"># <span class="GramE">Sets</span> the Private configuration for extension</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_validation</span> = </span><span class="SpellE"><span class="GramE"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white; mso-highlight: white;">ResourceExtensionParameterValue</span></span></span><span class="GramE"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">()</span></span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_validation.key</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">PrivateParams</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">validation_key_file</span> = <span class="GramE">open(</span><span class="SpellE">validation_key_file_path</span>, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"r+"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pri_config</span> = {}</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pri_<span class="GramE">config</span></span><span class="GramE">[</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">'<span class="SpellE">validation_key</span>'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">] = <span class="SpellE">validation_key_file.read</span>()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_validation.value</span> = _encode_<span class="GramE">base64(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">pri_config</span>))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_validation.type</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"Private"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>res.resource_extension_parameter_values.resource_extension_parameter_<span class="GramE">values.append(</span>res_chef_client_rb)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>res.resource_extension_parameter_values.resource_extension_parameter_<span class="GramE">values.append(</span>res_chef_client_validation)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_ext_<span class="GramE">ref.append</span></span><span class="GramE">(</span>res)</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span></span><span class="GramE"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: blue; background: white; mso-highlight: white;">return</span></span><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white; mso-highlight: white;"> <span class="SpellE">res_ext_ref</span></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black;">&nbsp;</span></p>
<p class="MsoNormal">First we set the <span class="SpellE">LinuxChefClient</span> resource extension details, you can find this information if you use the <strong style="mso-bidi-font-weight: normal;">Get-<span class="SpellE"><span class="GramE">AzureVMExtension</span></span><span class="GramE"> <span style="font-weight: normal;"><span style="mso-spacerun: yes;">&nbsp;</span>command</span></span></strong> on <span class="SpellE">powershell</span>/Azure CLI or the <a href="https://msdn.microsoft.com/en-us/library/dn495441.aspx">REST API</a>. If you just need to get details of a specific extension you could use this <a href="https://msdn.microsoft.com/en-us/library/dn495440.aspx">link</a>. <span style="mso-spacerun: yes;">&nbsp;</span></p>
<p class="MsoNormal">Back to our Chef Client extension, following is the latest version at the time of writing of this blog.</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.reference_name</span>=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">LinuxChefClient</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>res.name = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">LinuxChefClient</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.publisher</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">Chef.Bootstrap.WindowsAzure</span>"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.version</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"11.16"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res.label</span> = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">LinuxChefClient</span>"</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Since this is a Chef extension, all we need is to provide the <span class="SpellE"><span class="GramE">rb</span></span> &amp; .<span class="SpellE">pem</span> files and the list of <span class="SpellE">runbooks</span> that need to be run. <span style="mso-spacerun: yes;">&nbsp;</span><br /> <br /> The <span class="SpellE">client.rb</span> file and the <span class="SpellE">runbook</span> list goes as &ldquo;<strong style="mso-bidi-font-weight: normal;">public</strong>&rdquo; parameters, and the validation key goes as private. The parameters are passed as JSON in the format shown below:</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">pub_config</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"> = {}</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pub_<span class="GramE">config</span></span><span class="GramE">[</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">'<span class="SpellE">client_rb</span>'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">] = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"<span class="SpellE">chef_server_url</span> \t %s\<span class="SpellE">nvalidation_client_name</span>\<span class="SpellE">t%s</span>"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"> % (</span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">chef_server_url</span>), </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">validation_client_name</span>))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pub_<span class="GramE">config</span></span><span class="GramE">[</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">'<span class="SpellE">runlist</span>'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">] = </span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">run_list</span>)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_rb.value</span> = _encode_<span class="GramE">base64(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">pub_config</span>))</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_rb.type</span> = </span><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"Public"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">pri_config</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"> = {}</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">pri_<span class="GramE">config</span></span><span class="GramE">[</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">'<span class="SpellE">validation_key</span>'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">] = <span class="SpellE">validation_key_file.read</span>()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; mso-layout-grid-align: none; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_validation.value</span> = _encode_<span class="GramE">base64(</span></span><span class="SpellE"><span style="font-size: 9.5pt; font-family: Consolas; color: #6f008a; background: white; mso-highlight: white;">json</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">.dumps</span></span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white; mso-highlight: white;">(<span class="SpellE">pri_config</span>))</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white; mso-highlight: white;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span class="SpellE">res_chef_client_validation.type</span> = </span><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: #a31515; background: white; mso-highlight: white;">"Private"</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: #a31515;">&nbsp;</span></p>
<p class="MsoNormal"><br /> Please ensure that the validation key file contents are base64 encoded. I have used the Azure Python SDK&rsquo;s existing function _encode_<span class="GramE">bas64(</span>) , it could be a custom function that you would like to write.</p>
<p class="MsoNormal">Once, you run the script as explained in Part 1, give it some time till the VM&rsquo;s provisioning is done. You will notice the &ldquo;Linux Chef Client&rdquo; extension installed in the extensions installed section of the portal&rsquo;s dashboard.</p>
<p class="MsoNormal">&nbsp;</p>
<h2>Troubleshooting</h2>
<p class="MsoNormal">While the vm_getstatus.py script can be used to get status of the request submission, sometimes the startup script might fail to run during the provisioning state. You can monitor the VM creation progress on the portal too.</p>
<p class="MsoNormal">Once the VM reaches the running status, you can logon to the VM and view the following logs in case of any errors in VM provisioning.</p>
<p class="MsoNormal">Following log file logs all the VM provisioning activity by Azure VM agent.</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri; mso-bidi-font-family: 'Times New Roman'; color: black;">/<span class="SpellE">var</span>/log/waagent.log</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri; mso-bidi-font-family: 'Times New Roman'; color: black;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri; mso-bidi-font-family: 'Times New Roman'; color: black;">Following log logs running of the extension script.</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri; mso-bidi-font-family: 'Times New Roman'; color: black;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="mso-ascii-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-hansi-font-family: Calibri; mso-bidi-font-family: 'Times New Roman'; color: black;"><span style="mso-spacerun: yes;">&nbsp;</span>/<span class="SpellE">var</span>/log/azure/<span class="SpellE">Microsoft.OSTCExtensions.LinuxChefClient</span> /1.1/extension.log</span></p>
<p class="MsoNormal">&nbsp;</p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Creating, deployment &amp; customizing Linux VMs  with Python &amp; Chef – Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/shwetasblogs/creating-deployment-customizing-linux-vms-with-python-chef-part-1</link>
      <pubDate>Mon, 19 Jan 2015 02:29:00 GMT</pubDate>
      <dc:creator><![CDATA[Shweta Gupta (TE - Microsoft)]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/shwetasblogs/2015/01/19/creating-deployment-customizing-linux-vms-with-python-chef-part-1/</guid>
      <description><![CDATA[Creating, deployment &amp; customizing Linux VMs&nbsp; with Python &amp; Chef &ndash; Part...]]></description>
      <content:encoded><![CDATA[<div class="WordSection1">
<p class="MsoNormal"><span class="Heading1Char"><span style="font-size: 16.0pt; line-height: 107%;">Creating, deployment &amp; customizing Linux VMs&nbsp; with Python &amp; Chef &ndash; Part 1</span></span></p>
<p class="MsoNormal">Recent surveys and trends have shown Python as one of the fast emerging &amp;&nbsp;preferred scripting languages especially for DevOps (reference: <a href="https://redmonk.com/sogrady/2015/01/14/language-rankings-1-15/">https://redmonk.com/sogrady/2015/01/14/language-rankings-1-15/</a>).</p>
<p class="MsoNormal">Through this two part series we will look at using Python to setup and create Linux virtual machines on Azure and customizing the machines through Custom Script Extensions (Part 1) and Chef VM Extensions (Part 2).</p>
<p class="MsoNormal">To elaborate as many features as possible, we will create a MySQL Percona cluster by setting up three VMs, on a virtual network and using custom script extensions, install MySQL through a Chef cookbook. But before we begin we need to ensure we have the following pre-requisites in place. There is a lot of information available in MSDN &amp; Internet in general, I have added some of the references I found useful to get you started quick.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h2>Pre-requisites</h2>
<p class="MsoNormal">Throughout this post I have referenced various code snippets, the complete code can be found in the github repository (<span class="MsoHyperlink"><a href="https://github.com/shwetams/python_azure_iaas">https://github.com/shwetams/python_azure_iaas</a></span>) , I would recommend downloading it and referring the code files as we go through the following steps.</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 1: Setup Azure account</h3>
<p>&nbsp;</p>
<p class="MsoNormal">You need to have an Azure account setup before we begin. If you don&rsquo;t already have an Azure account you can create one at the azure <a href="https://azure.microsoft.com/en-us/pricing/free-trial/">portal</a>.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 2: Create a Virtual Network</h3>
<p class="MsoNormal">The VMs which this script creates uses a Vnet, since all the clusters in a MySQL cluster need to be on a Virtual network. Also, it is a good practice to have all your VMs connected over a single Virtual network.</p>
<p class="MsoNormal">Please use the steps described in the link to create a Vnet. Also, the <a href="https://msdn.microsoft.com/en-us/library/azure/dn631643.aspx">link</a> has several references to create different kinds of network, site to site, point to site etc. Please choose the one appropriate to your requirement.</p>
<p class="MsoNormal">If you want to use Python to create the Vnet, you can do so by calling the REST API as explained in the <a href="https://msdn.microsoft.com/en-us/library/azure/jj157181.aspx">msdn</a> link. Following is a sample Virtual network config file that I used for setting up the three VMs.</p>
<p class="MsoNormal"><a href="https://github.com/shwetams/python_azure_iaas/blob/master/Vnet_Config_File.xml">https://github.com/shwetams/python_azure_iaas/blob/master/Vnet_Config_File.xml</a></p>
<p class="MsoNormal">It&rsquo;s however much quicker to simply create it from portal as described earlier, since Virtual network will be a one time activity in most cases.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 3: Create storage account &amp; upload files</h3>
<p class="MsoNormal">The shell script to execute should be stored in Azure blob storage account for the Azure VM Agent to be able to access and download the script for execution.</p>
<p class="MsoNormal">You can create a storage account by following these steps on the <a href="https://azure.microsoft.com/en-us/documentation/articles/storage-create-storage-account/">portal</a>. Or simply use the &nbsp;Python script percona_cluster_setup.py and enter &ldquo;sa&rdquo;. The createstorage() account function will create the storage account after taking required parameters as input.&nbsp; Following is an extract from the script.</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">storage_acc_name = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">""</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; storage_replication = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">""</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; storage_location_name = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">""</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: green; background: white;">#Standard_LRS, Standard_ZRS, Standard_GRS, Standard_RAGRS</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_acc_name == </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">""</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; storage_acc_name = str(input(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Enter a storage account name. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only... "</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isBoolStorageAccountNameUnique = </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">False</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">while</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> isBoolStorageAccountNameUnique == </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">False</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = svc.check_storage_account_name_availability(storage_acc_name)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> res.result&nbsp; == </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isBoolStorageAccountNameUnique = </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> len(storage_location_name) &lt;= 0: </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; storage_location_name = str(input(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Enter storage location... "</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> len(storage_replication) &lt;= 0:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; storage_replication = str(input(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Enter replication factor (Standard_LRS, Standard_ZRS, Standard_GRS, Standard_RAGRS)... "</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isBoolStorageReplicationValid = </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">False</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">while</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> isBoolStorageReplicationValid == </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">False</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_replication != </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Standard_LRS"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">and</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_replication != </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Standard_ZRS"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">and</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_replication != </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Standard_GRS"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">and</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_replication != </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Standard_RAGRS"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; storage_replication = str(input(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Invalid entry: Please re-enter replication factor (Standard_LRS, Standard_ZRS, Standard_GRS, Standard_RAGRS), press E if you want to exit"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_replication == </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"E"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">or</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_replication == </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"e"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isStorageAccCreated = </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">False</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">break</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">else</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isBoolStorageReplicationValid = </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> isBoolStorageReplicationValid == </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; svc.create_storage_account(storage_acc_name,storage_acc_name,storage_acc_name,None,storage_location_name,</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,None)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; isStorageAccCreated = </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">else</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; storage_acc_name = str(input(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"The storage account name entered is already in use, please re-enter another one, press E to exit.."</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_acc_name == </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"E"</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">or</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> storage_acc_name == </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"e"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isStorageAccCreated = </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">False</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">break</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">if</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> isStorageAccCreated == </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Storage account..."</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> + storage_acc_name + </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">" has been created"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">else</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">:</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Storage account could be created"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">return</span><span style="font-size: 9.5pt; font-family: Consolas; color: blue; background: white;">True</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">In this sample, we are using same storage account for storing shell scripts, custom image as well as VM disks. You can create multiple based on your requirement.</p>
<p class="MsoNormal">This <a href="https://azure.microsoft.com/en-us/documentation/articles/storage-introduction/">link</a> explains various kinds of storage accounts available on Azure.</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 4: Upload the Percona Cookbook</h3>
<p>&nbsp;</p>
<p class="MsoNormal">You can find the chef cookbook for Percona used on the github repository <a href="https://github.com/phlipper/chef-percona"><span style="color: windowtext; text-decoration: none;">https://github.com/phlipper/chef-percona</span></a>. After uploading it on the Chef server please create a client.rb and validation.pem file. Detailed steps to use Chef and chef cookbooks can be found on the link below.</p>
<p class="MsoNormal"><a href="https://www.digitalocean.com/community/tutorials/how-to-understand-the-chef-configuration-environment-on-a-vps"><span style="color: windowtext; text-decoration: none;">https://www.digitalocean.com/community/tutorials/how-to-understand-the-chef-configuration-environment-on-a-vps</span></a> &nbsp;&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 4: Modify and Upload script file</h3>
<p class="MsoNormal">Upload the install-sh.sh script file (present in the github repository). In this sample, the shell script is downloading the validation.pem &amp; client.rb file and installing the chef client, and then running custom Chef cookbook for installing the Percona cluster.</p>
<p class="MsoNormal">Change the path of the blob storage based on where you have uploaded the client.rb and validation.pem file</p>
<p class="MsoNormal"><span style="background: yellow;"><a href="https://%3cyour">https://&lt;your</a> storage account name&gt;.blob.core.windows.net/demo/client.rb </span></p>
<p class="MsoNormal"><span style="background: yellow;"><a href="https://%3cyour">https://&lt;your</a> storage account name&gt;/demo/validation.pem</span></p>
<p class="MsoNormal">Make sure you modify the install-sh shell script to include your client.rb, validation.pem and the chef cookbook path.</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 5: Create an image (optional)</h3>
<p class="MsoNormal">You can create a VM from a custom image, or from image gallery. In our sample scripts below, we have shown both. We create the VM from a custom image in the powershell scripts and from an image gallery in the Python scripts, explained in more detail below.</p>
<p class="MsoNormal">This <a href="https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-capture-image-windows-server/">link</a> will guide you through step by step to create a custom image on Azure.</p>
<p class="MsoNormal">The Python script on github uses an image from Gallery.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h2>Running sample python script</h2>
<p class="MsoNormal">The script is written in python 3.4.2. Following describes the script and steps needed to run the script.</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Configuration path</h3>
<p class="MsoNormal">The scripts extensively use a folder at &ldquo;C:\Python_Files&rdquo;, please change this to your location wherever applicable or create a folder on the C: drive with the name "Python_Files".</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 1: Registration of Azure certificate</h3>
<p class="MsoNormal">The scripts use Azure REST API reference to setup VMs. In order to access the REST API, the script needs to use a registered certificate to authenticate itself.</p>
<p class="MsoNormal">You need to have a certificate file (.cer) while using the script and also for uploading it on the Azure portal.</p>
<p class="MsoNormal">If you have a .pem file, you can install openssl and use the following command to create a .cer file:</p>
<p style="margin: 0in; margin-bottom: .0001pt;"><span style="font-size: 10.0pt; font-family: Consolas; color: #222222; background: #EEEEEE;">openssl x509 -inform PEM -in cacert.pem -outform DER -out certificate.cer</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Following link explains the steps to upload an Azure management certificate.</p>
<p class="MsoNormal"><a href="https://www.simple-talk.com/cloud/security-and-compliance/windows-azure-management-certificates/">https://www.simple-talk.com/cloud/security-and-compliance/windows-azure-management-certificates/</a></p>
<p class="MsoNormal">Open the python script &ldquo;percona_cluster_setup.py&rdquo; and set the variables. The certificate_path variable is the system registry path that azure python sdk uses to extract the certificate file for authentication.</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">subscription_id = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"&lt;subscription id&gt;"</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white;">certificate_path = </span><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: #a31515; background: white;">"CURRENT_USER\\my\\AzureCertificate"</span></p>
<p class="MsoNormal">You should change the certificate_path to the .cer file path if you are running it on Linux VM.</p>
<p class="MsoNormal">Also update the script &ldquo;vm_getstatus.py&rdquo; with the subscription_id variable.</p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white;">subscription_id = </span><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: #a31515; background: white;">"&lt;subscription id&gt;"</span></p>
<p class="MsoNormal">You will also need a .pem file with key and without key to run some basic http access functions (that do not use the Azure SDK), please update the path to certificate key, and certificate file in the &ldquo;VMClusterSetupClass.py&rdquo;, as explained below:</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">cert_path = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"C:\Python_Files\AzureCertificate.pem"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">cert_key_path = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"C:\Python_Files\AzureCertificateKey.pem"</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 2: Set all script constants</h3>
<p class="MsoNormal">Refer to the following lines of code to change/edit or modify features of the VM in &ldquo;percona_cluster_setup.py&rdquo;:</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><strong><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">Defining the user name and password:</span></strong></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">linux_config = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">LinuxConfigurationSet</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(host_name=vm_name,user_name=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"azureuser"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,user_password=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"&lt;yourpassword&gt;"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,disable_ssh_password_authentication=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"false"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">)</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white;">Defining the end points/external &amp; internal ports</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">network = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSet</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network.configuration_set_type = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"NetworkConfiguration"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network.input_endpoints.input_endpoints.append(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSetInputEndpoint</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'ssh'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'tcp'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'22'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'22'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network.input_endpoints.input_endpoints.append(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSetInputEndpoint</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'http'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'tcp'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'80'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'80'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_02 = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSet</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_02.configuration_set_type = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"NetworkConfiguration"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_02.input_endpoints.input_endpoints.append(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSetInputEndpoint</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'ssh'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'tcp'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'223'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'22'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_02.input_endpoints.input_endpoints.append(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSetInputEndpoint</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'http'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'tcp'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'8023'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'8023'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_03 = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSet</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_03.configuration_set_type = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"NetworkConfiguration"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_03.input_endpoints.input_endpoints.append(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSetInputEndpoint</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'ssh'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'tcp'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'224'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'22'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; network_03.input_endpoints.input_endpoints.append(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ConfigurationSetInputEndpoint</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'http'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'tcp'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'8024'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">, </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'8024'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">))</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white;">&nbsp;</span></p>
<p class="MsoNormal">Please note that within a vnet there are only unique external ports allowed. So if you are create multiple VMs, you need to define different ssh external ports all mapping to the same internal ssh port, in this case 22.</p>
<p class="MsoNormal">Enter the storage account name to complete the URL where the VM&rsquo;s OS disk will be created. Please make sure you have a container called &ldquo;vhds&rdquo; created, or change the container name to whatever you have created in the url below.</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">os_hd = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">OSVirtualHardDisk</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(source_image_name=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_1-LTS-amd64-server-20140927-en-us-30GB"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,media_link=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"https</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: yellow;">://&lt;storage account name</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">&gt;.blob.core.windows.net/vhds/"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> + cs_name + </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"pipedrivevhd010101sgvr01.vhd"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,os=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Linux"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; os_hd_01 = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">OSVirtualHardDisk</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(source_image_name=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_1-LTS-amd64-server-20140927-en-us-30GB"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,media_link=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"https</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: yellow;">://&lt;storage account name&gt;</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">.blob.core.windows.net/vhds/"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> + cs_name + </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"pipedrivevhd020202sgvr02.vhd"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,os=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Linux"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; os_hd_02 = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">OSVirtualHardDisk</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">(source_image_name=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_1-LTS-amd64-server-20140927-en-us-30GB"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,media_link=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"https</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: yellow;">://&lt;storage account name&gt;.</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">blob.core.windows.net/vhds/"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;"> + cs_name + </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"pipedrivevhd030303sgvr03.vhd"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">,os=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Linux"</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">)</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">The resource extension parameter is used to instructe the azure VMagent to download and run the script, following is the code snippet.</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">res_ext_ref = []</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_exts = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ResourceExtensionReferences</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ResourceExtensionReference</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res.reference_name=</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"MyCustomScriptExtension"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res.name = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"CustomScriptForLinux"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res.publisher = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Microsoft.OSTCExtensions"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res.version =&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"1.1"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res.label= </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"MyCustomScriptExtension"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9.5pt; font-family: Consolas; color: green; background: white;">#_encode_base64(</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_chef_client_rb = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ResourceExtensionParameterValue</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">()</span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal">Setting up start up script details in the resource extension.</p>
<p class="MsoNormal">Please update the path where the startup scripts are located and the storage account details as highlighted below,</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">res_chef_client_rb.key = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"CustomScriptExtensionPublicConfigParameter"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_chef_client_rb.value = _encode_base64(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'{"fileUris":["</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: yellow;">https://&lt;storage account name&gt;.blob.core.windows.net/demo/install-chef.sh</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"],"commandToExecute":"sh install-chef.sh"}'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">) </span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_chef_client_rb.type = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Public"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_chef_client_validation = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af; background: white;">ResourceExtensionParameterValue</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">()</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_chef_client_validation.key = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"CustomScriptExtensionPrivateConfigParameter"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_chef_client_validation.value = _encode_base64(</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'{"storageAccountName</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: yellow;">":"&lt;storage account name</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">&gt;","storageAccountKey":"</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: yellow;">&lt;storage account key&gt;"}</span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">'</span><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">)</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; res_chef_client_validation.type = </span><span style="font-size: 9.5pt; font-family: Consolas; color: #a31515; background: white;">"Private"</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; text-autospace: none;"><span style="font-size: 9.5pt; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white;">&nbsp;&nbsp;&nbsp; </span></p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 3: Create cloud services</h3>
<p class="MsoNormal">The script is creating three VMs in three different cloud service. You can modify the script to create all three VMs in the same cloud service as well (in the <span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black; background: white;">Create_Virtual_Machine_New</span><span style="font-size: 9.5pt; line-height: 107%; font-family: Consolas; color: black;">() function, change the parameters in vm02 and vm03 &ldquo;add_role&rdquo; to true</span>).</p>
<p class="MsoNormal">However, the script assumes that the cloud service name remains the same and there is a suffix of 01,02 &amp; 03.</p>
<p class="MsoNormal">For example, if the cloud service name is &ldquo;mydummycs&rdquo;, the three cloud services created should be &ldquo;mydummycs01&rdquo;,&rdquo;mydummycs02&rdquo;,&rdquo;mydummycs03&rdquo;.</p>
<p class="MsoNormal">You can manually create cloud service from the portal or use the script and enter &ldquo;cs&rdquo; to create the cloud services when prompted.</p>
<p class="MsoNormal">&gt;python percona_cluster_setup.py cs</p>
<p class="MsoNormal">&nbsp;</p>
<h3>Step 4: Run the scripts to create VMs</h3>
<p>&nbsp;</p>
<p class="MsoNormal">Once you have setup all the constants please run the script with &ldquo;vm&rdquo; input when prompted.</p>
<p class="MsoNormal">&gt;python percona_cluster_setup.py vm</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; vertical-align: middle;"><span style="color: black;">The script will print three Request IDs for the three VMs create, please save it for accessing the request status as explained in the next step.</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; vertical-align: middle;">&nbsp;</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal; vertical-align: middle;"><span style="color: black;">&nbsp;</span></p>
<h3>Step 5: Use the request IDs to get status updates</h3>
<p class="MsoNormal">The vm_getstatus.py script accepts request id as a parameter and prints the status response into the &ldquo;C:\Python_Files&rdquo; folder. You can run this script and pass the request ID to get status of the request as shown in the example below:</p>
<p class="MsoNormal">&gt;python vm_getstatus.py &ndash;r &lt;requested&gt;</p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">&nbsp;</p>
<h2>Troubleshooting</h2>
<p class="MsoNormal">While the vm_getstatus.py script can be used to get status of the request submission, and the runtime logs while running the powershell runbook, sometimes the startup script might fail to run. You can monitor the VM creation progress on the portal too.</p>
<p class="MsoNormal">Once the VM reaches the running status, you can logon to the VM and view the following logs in case of any errors in VM provisioning.</p>
<p class="MsoNormal">Following log file logs all the VM provisioning activity by Azure VM agent.</p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="color: black;">/var/log/waagent.log</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="color: black;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="color: black;">Following log logs running of the extension script.</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="color: black;">&nbsp;</span></p>
<p class="MsoNormal" style="margin-bottom: .0001pt; line-height: normal;"><span style="color: black;">&nbsp;/var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux/1.1/extension.log</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">By the end of this you will have three VMs running on a Virtual network with the MySQL Percona cluster installed through the chef client. In my next series, we will use the Linux Chef client VM extension which simplifies the process further.</p>
<p class="MsoNormal">&nbsp;</p>
</div>]]></content:encoded>
    </item>
  </channel>
</rss>