An Azure service that provides an event-driven serverless compute platform.
Powershell Azure Function throws EXCEPTION: Connect-AzAccount : An attempt was made to access a socket in a way forbidden by its access permissions
Hi
I have Powershell Azure function which is called directly by logic app as one of the steps in the workflow. Authentication was established by using system assigned managed identity approach and all was working.
I needed to refactor the way how this function app is called as the function was long running and implemented orchestration durable function approach. Now I call the function from another Azure function using HttpClient using the code below
var authenticationContext = new AuthenticationContext($"https://login.microsoftonline.com/{tenantId}");
var clientCredential = new ClientCredential(clientId, clientSecret);
AuthenticationResult authenticationResult = await authenticationContext.AcquireTokenAsync(audienceId, clientCredential);
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authenticationResult.AccessToken);
HttpResponseMessage result = await _client.PostAsync(url, null);
I successfully passed authentication and execution reached the code in the function but it throws exception when it reaches the line Connect-AzAccount -Identity in my profile.ps1 file
EXCEPTION: Connect-AzAccount : An attempt was made to access a socket in a way forbidden by its access permissions
Both functions have system Assigned managed identity. I assigned "Contributor" role to the caller function with a scope of the function
that I am calling.
I read posts about similar issue but for the case when User assigned managed identity was used which is not in my case.
Any tips/help would be appreciated
Thanks,
Romanm