You are browsing the archive for 2019 February.

Azure PowerShell Error: “Your Azure credentials have not been set up or have expired, please run Connect-AzureRmAccount to set up your Azure credentials”

6:28 pm in Azure, Azure credentials, Azure PowerShell by Wim Matthyssen

While working on a new Azure IaaS deployment for a customer, I encountered the following error when running several Azure PowerShell cmdlets.

“Your Azure credentials have not been set up or have expired, please run Connect-AzureRmAccount to set up your Azure credentials”

clip_image002

Running the Connect-AzureRmAccount command for several times, like proposed in the error message, did not solve the problem. Neither did opening a new PowerShell window or even completely restarting my Surface laptop.

clip_image004

I finally got it fixed by running the Remove-AzureRmAccount cmdlet, which removes all credentials and contexts (subscription and tenant information) associated with that specific Azure account.

clip_image006

After executing the Remove-AzureRmccount cmdlet , and after login in again using the Login-AzureRmAccount cmdletall other cmdlets ran again like they should.

clip_image008

clip_image010

Hope this helps!

Wim Matthyssen (@wmatthyssen)

PowerShell: AzCopy download and silent installation

10:52 am in AzCopy, Azure, Download, PowerShell, PowerShell Script, Silent installation by Wim Matthyssen

AzCopy is a free command-line tool that is offered by Microsoft. It allows you to easily copy and transfer data (data migration) from and to Azure storage. It is designed for high performance transfers and can be deployed on both Windows and Linux systems (separate versions). AzCopy for example allows users to copy data between a file system and a storage account, or between storage accounts. Users have the possibility to select items by specifying patterns, like wildcards or prefixes, to identify the needed files for upload or download. It currently supports Microsoft Azure Blob, File and Table storage.

To automate the download and silent installation process of this useful tool, I wrote the below PowerShell script which does all of the following:

  • Create a Temp folder on the C: drive if not already available.
  • Create an AzCopy download folder in C:\Temp if not already available.
  • Download the latest Azcopy .msi (Windows) file.
  • Install AzCopy silently without any user interaction.
  • Delete the .msi file after installation.
  • Remove the AzCopy folder.
  • Exit the PowerShell window.

 PowerShell script

clip_image002

clip_image004

clip_image006

clip_image008

If you prefer you can download the complete script from the TechNet gallery.

More information and how to use AzCopy you can find over here.

This concludes this blog post, have fun using AzCopy for moving or copying data to or between storage accounts.

Wim Matthyssen (@wmatthyssen)