title: "No subscription found in the context" error when invoking Azure Powershell cmdlets
body: <p>I am trying to write some simple <strong>Powershell</strong> scripts to stop, start and restart our <strong>Azure</strong> web app. I can see that there are <em>cmdlets</em> called <code>Stop-AzWebApp</code>, <code>Start-AzWebApp</code> and <code>Restart-AzWebApp</code> that do this. The problem is they all require a parameter called <strong>DefaultProfile</strong> of type <em>Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer</em>. How do I get hold of this?</p>
  
  <p>I have looked around for solutions but it seems confusing as there seem to be several ways of doing this including invoking <code>Connect-AzAccount</code>, but this requires multiple parameters (and I'm not sure which ones I need to supply).</p>
  
  <p>Here is the error I get when I invoke <code>Get-AzSubscription</code> from our TFS build. </p>
  
  <p><a href="https://i.stack.imgur.com/x6S11.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x6S11.png" alt="enter image description here"></a></p>
  
  <p>Here is the error I get when I invoke <code>Stop-AzWebApp</code> from our TFS build.</p>
  
  <p><a href="https://i.stack.imgur.com/IWo5y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IWo5y.png" alt="enter image description here"></a></p>
  
  <pre><code>No subscription found in the context Please ensure that the credentials you provided are authorized to access the Azure subscription then run Connect-AzAccount to login
  </code></pre>
  
  <p>Here's the PS script I'm using.</p>
  
  <pre><code>$ResourceGroupName = "MyResourceGroup"
  $Name = "MyWebAppName"
  
  "Stopping web application " + $Name
  
  "ResourceGroupName: " + $ResourceGroupName
  "Name: " + $Name
  
  $SubscriptionId = "xxxx-xxxx-xxxx-xxxx"
  "SubscriptionId is: " + $SubscriptionId
  
  $Subscription = Get-AzSubscription -SubscriptionId $SubscriptionId
  "Subscription : " + $Subscription
  
  Stop-AzWebApp -ResourceGroupName $ResourceGroupName -Name $Name
  </code></pre>
  
  <p>What's the simplest way to start, stop and restart an Azure web app?</p>