azure function powershell Set-AzContext throws exception

Dheeraj 351 Reputation points
2021-10-18T09:45:39.837+00:00

Below is setup of my Az Powershell Func
requirements.psd1:
141327-1.png

profile.ps1 contents:
141358-2.png

powershell code:
141363-3.png

After all this, it throws ERROR: Please provide a valid tenant or a valid subscription.
Error details:
141346-4.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2021-10-19T07:43:20.467+00:00

    @Dheeraj As per the error message looks like your Tenant or subscription ID is invalid. Can you please confirm if this is correct?
    You can update your requirements.psd1 Az.Accounts pointing to the latest version and as per the code I don't see you are using legacy AzureRm commands so you can comment Enable-AzureRMAlias

    Az.Accounts' = '2.*'  
    

    I have tested the same with the below setting and couldn'tt observe any issue. Please make sure that you have enabled the Identity on your function app.

    141653-image.png

    141682-image.png

    141674-image.png

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.