Azure Function fails to find file

Related searches

I have an azure function that uses the Azure context. When I execute my function from visual studio 2019 on my machine, it executes correctly. However when I publish this to my Azure account, I get an error that the my.azureauth file cannot be found.

Could not find file 'D:\Program Files (x86)\SiteExtensions\Functions\2.0.12950\32bit\my.azureauth'

The code that is used:

var authFilePath = "my.azureauth";
Console.WriteLine($"Authenticating with Azure using credentials in file at {authFilePath}");
azure = Azure.Authenticate(authFilePath).WithDefaultSubscription();
sub = azure.GetCurrentSubscription();

Console.WriteLine($"Authenticated with subscription '{sub.DisplayName}' (ID: {sub.SubscriptionId})");

This is code that I found on one of the Microsoft tutorials. I have set my my.azureauth file to "Copy Always".

Could anyone point my in the right direction?

You are get this file path because the Directory.GetCurrentDirectory() would return D:\Program Files (x86)\SiteExtensions\Functions\2.0.12950\32bit instead of D:\home\site\wwwroot\ or D:\home\site\wwwroot\FunctionName.

And if you want to get the wwwroot folder or the function app directory you should use ExecutionContext. Further more information you could refer to this wiki doc.

So the right file path should be context.FunctionDirectory+"\my.azureauth" or context.FunctionAppDirectory+"\my.azureauth", which one to use depends on where your file is stored.

Azure Function can't find file on D:\ - MSDN, But new stuff will not. Edit: If I use d:\local\temp, then check and create d:\local\ temp\mca, ftp files to the mca folder, the functions can read the� Slow file copying to and from Azure Files in Windows. You might see slow performance when you try to transfer files to the Azure File service. If you don't have a specific minimum I/O size requirement, we recommend that you use 1 MiB as the I/O size for optimal performance.

Welcome to Stackoverflow.

Firstly, I'd recommend strongly against using file-based authentication as shown in your question.

From notes:

Note, file-based authentication is an experimental feature that may or may not be available in later releases. The file format it relies on is subject to change as well.

Instead, I would personally store the connection string details (AzureCredentials) in the config file (Web/SiteSettings) and use the provided constructor...

Again, the below are taken from the documentation notes:

Similarly to the file-based approach, this method requires a service principal registration, but instead of storing the credentials in a local file, the required inputs can be supplied directly via an instance of the AzureCredentials class:

var creds = new AzureCredentialsFactory().FromServicePrincipal(client, key, tenant, AzureEnvironment.AzureGlobalCloud);
var azure = Azure.Authenticate(creds).WithSubscription(subscriptionId);


var creds = new AzureCredentialsFactory().FromServicePrincipal(client, pfxCertificatePath, password, tenant, AzureEnvironment.AzureGlobalCloud);
var azure = Azure.Authenticate(creds).WithSubscription(subscriptionId);

where client, tenant, subscriptionId, and key or pfxCertificatePath and password are strings with the required pieces of information about your service principal and subscription. The last parameter, AzureEnvironment.AzureGlobalCloud represents the Azure worldwide public cloud. You can use a different value out of the currently supported alternatives in the AzureEnvironment enum.

The first example is most likely the one you should be looking at.

The notes I got this information from can be accessed here.

How to view Azure Function files deployed, You'll find the ZIP files in D:\home\data\SitePackages . They're timestamped so it should be easy enough to see which is the latest, but you can� Azure function guys have a little mess here :D and looks like tools and sdk are not fully in sync. So, the thing is you got a dependency on some dll: Microsoft.AspNetCore.Mvc.Abstractions, Version= But the actual host that runs the function is not in your project, but in here: C:\Users\<user>\AppData\Roaming pm ode_modules\azure-functions-core-tools\bin , and there you MUST have the

I have found that Kudu is extremely useful in seeing what has been deployed to Azure.

Navigate to your function in the Azure portal. The instructions here will help get to the kudu console.

From there you can browse the files which have been deployed into your function's file system.

If you add " , ExecutionContext context)" at the end of the function's run entry point, you can then get the folder which your function is running from with "var path = context.FunctionAppDirectory;

PS apologies for any formatting I am editing this on my phone.

Relative file paths don't work as expected in Azure Functions � Issue , Suppose you create an Azure function which opens a config file in the Seems to pop up very frequently as users don't find the current pattern intuitive. HttpTrigger' (Failed, Id=44ab374c-5429-44aa-a4d1-2cbbc1cf0b5a)� It’s been working great, but last night it failed. So how can you find out what went wrong with your Azure Function? In the Portal. Well, the easiest way is to navigate to your function app in the portal, select the function, and go to the Monitor tab. In here we see a nice breakdown of when the function ran, and how long it ran for:

If you have some problems with AAD, these screenshots may help you.

Client ID:


Please note that the Key value can only be copied when it is created, after which it will be hidden.

Hope this helps you get started with AAD quickly.

Runtime Exception in 1.0.13, Runtime Exception in 1.0.13 - "Could not find file function.json" #196 Azure. WebJobs.Host; namespace FunctionApp1 { public static class� Develop more efficiently with Functions, an event-driven serverless compute platform that can also solve complex orchestration problems. Build and debug locally without additional setup, deploy and operate at scale in the cloud, and integrate services using triggers and bindings.

1.0.11-1.0.12: Azure Function Host Fails to Initialize � Issue #745 , Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft. I&#39;ve written about how to serve a single HTML page or a single Swagger file with Azure Functions before. But it hasn&#39;t really been easy or even possible to serve an entire site with Azure Functions. With the release of a new feature called Azure Functions Proxies a couple of weeks ago, we can now create a pretty capable HTTP static file server using Azure Functions.

# Azure Functions localsettings file local.settings.json If you couldn't tell by the name, Microsoft has intended for this local.settings.json file to be for local development purposes only. It is not intended to be committed to a source control repository and it is not intended to be deployed to an Azure environment.

When you create your function app in the Azure portal, from the command line by using Azure Functions Core Tools, or by using Visual Studio Code, Application Insights integration is enabled by default. The Application Insights resource has the same name as your function app, and it's created either in the same region or in the nearest region.

  • That's really useful, thank you. I am doing some reading into the AzureCredentialsFactory now. I've managed to find my tenant id (by going to Azure AD and then 'Default Directory', but how do I get the client and key?
  • @James87262 Sorry, I am not entirely sure, I'd start by looking here though.
  • @James87262 I took some screenshots, hoping to help you get started quickly.