Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managed identity auto-login periodically fails from Azure Function App #2565

Open
Xoph opened this issue Nov 26, 2024 · 0 comments
Open

Managed identity auto-login periodically fails from Azure Function App #2565

Xoph opened this issue Nov 26, 2024 · 0 comments

Comments

@Xoph
Copy link

Xoph commented Nov 26, 2024

I have an Azure Function App setup with a system-assigned managed identity. I see that every night all my requests to get the managed identity authentication are failing for ~5 to 10 minutes, at 11 pm. The requests are coming from an AzCopy command. At all other times, the managed identity authentication is working fine.

It's a v4 runtime, on a S1 app service plan.

The error is:

Failed to perform Auto-login: ManagedIdentityCredential: Get "http://127.0.0.1:41044/msi/token/?api-version=2019-08-01&resource=https%3A%2F%2Fstorage.azure.com": dial tcp 127.0.0.1:41044: connectex: No connection could be made because the target machine actively refused it..

My C# code that calls it is:

string arguments = "copy https://source.blob.core.windows.net/ab12345/ABCLog/DEF/ https://destination.blob.core.windows.net/container/AB12345 --recursive=true --include-before 2024-11-25T09:30:42.7597254-05:00 --include-after 2024-11-25T10:30:42.7597254-05:00
ProcessStartInfo startInfo = new ProcessStartInfo()
{
    FileName = "azcopy.exe",
    Arguments = arguments,
    RedirectStandardOutput = true,
    UseShellExecute = false,
};
startInfo.EnvironmentVariables.Add("AZCOPY_AUTO_LOGIN_TYPE", "MSI");
startInfo.EnvironmentVariables.Add("AZCOPY_LOG_LOCATION", Environment.GetEnvironmentVariable("TEMP"));
startInfo.EnvironmentVariables.Add("AZCOPY_JOB_PLAN_LOCATION", Environment.GetEnvironmentVariable("TEMP"));
Process process = new Process()
{
    StartInfo = startInfo
};
process.Start();
process.WaitForExit();

Which is basically equivalent to running:

$env:AZCOPY_AUTO_LOGIN_TYPE=MSI
azcopy.exe copy https://source.blob.core.windows.net/ab12345/ABCLog/DEF/ https://destination.blob.core.windows.net/container/AB12345 --recursive=true --include-before 2024-11-25T09:30:42.7597254-05:00 --include-after 2024-11-25T10:30:42.7597254-05:00

I also created an AzCopy repo issue, but I believe this is related to the function app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant