Azure Functions

Occasional Visitor

Hi There,

Im new to azure functions.

Essentially I'd like to run a PowerShell module from an Azure function to get an Azure MetaData service's Access Token and then retrieved it to a token that will be used to make an external REST call.


I've created a function and I've enabled System Identity for that. But when I try to access the Azure MetaData but it, not successful. Did anybody called Azure MetaData services from Azure Functions? Please help how to achieve this


# Input bindings are passed in via param block.

# Get the current universal time in the default string format.
$currentUTCtime = (Get-Date).ToUniversalTime()

# The 'IsPastDue' property is 'true' when the current function invocation is later than scheduled.
if ($Timer.IsPastDue) {
    Write-Host "PowerShell timer is running late!"

# Write an information log with the current time.
Write-Host "PowerShell timer trigger function ran! TIME: $currentUTCtime"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Metadata", "true")
Write-Host "Nirmal === Kumar "
$response = Invoke-RestMethod '' -Method 'GET' -Headers $headers
 Write-Host "Nirmal ==== "                        
$access_token =$response.access_token
Write-Host "$access_token"


The error is shown below:


1 Reply
Not sure if you got this sorted, but take a look at this Blog post:

Tells you where you can upload your PS module too to make sure the cmdlet is there or editing the 'requirements.psd1' file.