I’m not sure if anyone else has this problem, but I always have a bias towards working against what an IT system error message is telling me. Perhaps this is down to the numerous occasions where I’ve been presented with erroneous error messages, resulting in a solution that you could never have reasonably anticipated from the outset. As such, you can sometimes completely overlook when an error message is telling you clearly what the issue and solution is. Often, evaluating the problem carefully or taking a break from investigating it leads to faster resolutions and the preservation of your patience/sanity.
I recently played victim to this very problem when attempting to deploy out an Azure Template project from Visual Studio 2019 to a resource group on Microsoft Azure. I kept getting the following message just as the script was starting its deployment:
New-AzureRmResourceGroup : Your Azure credentials have not been set up or have expired, please run Connect-AzureRmAccount to set up your Azure credentials.
This error confused me initially as I had, only moments ago, successfully connected up to Azure and created a Resource Group via the Visual Studio 2019 interface. In the end, after a bit of head-scratching and a brief spell down the rabbit hole, the solution turned out to be ridiculously straightforward:
- Open a new PowerShell session.
- Run the Connect-AzureRmAccount cmdlet and, when prompted, login in using your Microsoft Azure credentials. Verify that the details of your subscription are correct after the cmdlet completes successfully, as indicated below:
Now, when attempting to redeploy your Template project from Visual Studio, it should connect and deploy out successfully; assuming no further issues with the underlying template.
I already alluded to this earlier, but it’s worth reiterating once again the importance sometimes of taking a step back and not over-complicating a potential IT issue out of the gate. As this example so excellently illustrates, adopting an objective standpoint and reading the error message can sometimes tell you everything you need to get a problem resolved promptly. Save yourself some effort early on by always reverting to Occam’s razor - namely, that the simplest solution is more than likely the correct one 🙂