title: The Azure PowerShell session has not been properly initialized. Please import the module and try again
body: <p>I'm writing my first powershell script to load data from a CSV to an Azure Storage table. I'm not sure why the line </p>
  
  <pre><code>$storageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName)[0].Value
  </code></pre>
  
  <p>is throwing an error:</p>
  
  <p><a href="https://i.stack.imgur.com/jwgIx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jwgIx.png" alt="enter image description here"></a></p>
  
  <p>Running <code>Get-Module</code> gives this result:
  <a href="https://i.stack.imgur.com/mQmxw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mQmxw.png" alt="enter image description here"></a></p>
  
  <p>This is a snippet of the code that I have written till now:</p>
  
  <pre><code># Step 1, Set variables
  # Enter Table Storage location data 
  $resourceGroupName = "ComputeTesting"
  $storageAccountName = 'computetestingdiag'
  $tableName = 'strtable'
  $dateTime = get-date
  
  # Step 2, Login to your Azure subscription
  $sub = Get-AzSubscription -ErrorAction SilentlyContinue
  if(-not($sub))
  {
      Connect-AzAccount
  }
  
  # If you have multiple subscriptions, set the one to use
  # Select-AzSubscription -SubscriptionId "&lt;SUBSCRIPTIONID&gt;"
  
  # Step 3, Get the access key for the Azure Storage account
  $storageAccountKey = (Get-AzStorageAccountKey -ResourceGroupName $resourceGroupName -Name $storageAccountName)[0].Value
  
  # Step 4, Connect to Azure Table Storage
  $storageCtx = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
  $table = Get-AzureStorageTable -Name $tableName -Context $storageCtx
  </code></pre>
  
  <p>I checked some of the similar questions and what I understand that uninstalling and re-installing the Azure modules might help. Although I didn't try this yet, is there any other workaround for this? Any help whatsoever would be highly helpful.</p>