Hi , Verify that the Azure Function App has the necessary permissions to access the Key Vault. The managed identity or service principal associated with the Azure Function App should have at least "Get" permissions on secrets in the Key Vault. check document for details to assign permissions on KV https://learn.microsoft.com/en-us/azure/key-vault/general/assign-access-policy?tabs=azure-portal Please accept answer if it helps
EXCEPTION: Please provide a valid tenant or a valid subscription.
Dhaval Shah
20
Reputation points
Hello,
We have one Azure function app function with one Powershell script running. we have stored the value of secrets in the key vault and in the PowerShell script it retrieves from the key vault. when powershell script runs it shows the below error.
[Error] EXCEPTION: Please provide a valid tenant or a valid subscription.
We have checked the vault and the value is correct in the key vault. Please find the attached screenshot of the error.
Can you please help here
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,888 questions
2 answers
Sort by: Most helpful
-
Deepanshukatara-6769 16,160 Reputation points Moderator
2024-02-23T09:55:16.42+00:00 -
Deepanshukatara-6769 16,160 Reputation points Moderator
2024-02-23T11:12:29.1466667+00:00 Please check this
try { # Retrieve the secret value from Key Vault $secret = Get-AzKeyVaultSecret -VaultName "<your-unique-keyvault-name>" -Name "FUN-ONBOARDING-PARAMS" -AsPlainText # Convert the secret string to a PowerShell hashtable $onboardingParams = Invoke-Expression $secret # Set Azure context using the subscription ID from the retrieved secret Set-AzContext -Subscription $onboardingParams.AzSubscription } catch { Write-Host "Error: $_" }