title: Connect-AzAccount error when running Azure Functions coded in PowerShell
body: <p>I am getting this error when trying to run my Azure Function (Which is in PowerShell). PowerShell script works normally when ran locally.</p>
  <p>Error:</p>
  <pre><code>[Error] ERROR: No subscription found in the context.  Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Connect-AzAccount to login
  </code></pre>
  <p>In <code>requirements.ps1</code>:</p>
  <pre><code>@{
      'Az.Accounts' = '1.9.0'
      'Az.Resources' = '1.1.2'
      'AzTable' = '2.0.3'
      'Az.Storage' = '1.7.0'
      'Az.KeyVault' = '1.5.1'
  }
  </code></pre>
  <p>In the <code>run.ps1</code>, I added the <code>Import-Module</code> commands:</p>
  <pre><code>Import-Module Az.Resources
  Import-Module Az.Accounts
  Import-Module Az.KeyVault
  Import-Module AzTable
  </code></pre>
  <p>First few lines in '<code>run.ps1</code>':</p>
  <pre><code>$activeKey = Get-AzKeyVaultManagedStorageAccount -VaultName $keyVaultName -Name $storageAccountName
  
  # Get Storage Account Key 
  $key = (Get-AzStorageAccountKey -ResourceGroupName $rgName -Name $storageAccountName)
  </code></pre>
  <p>In <code>profile.ps1</code>:</p>
  <pre><code>if ($env:MSI_SECRET) {
      Disable-AzContextAutosave
      Connect-AzAccount -Identity
  }
  </code></pre>
  <p>Thanks!</p>