I am new for Azure and currently working for an Azure function project for accessing and working with Blob storage files. I am using User secret (secret.json) for setting connection string (just replaced actual values with something ).
{
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=something;AccountKey=ccwq2cRbydk0wnT2FKFmNonpyqMXiEO/ADnCmI7UB/5IfnL9NHDc8wioZQu5PHzg==;BlobEndpoint=https://something.blob.core.windows.net/;TableEndpoint=https://something.table.core.windows.net/;QueueEndpoint=https://something.queue.core.windows.net/;FileEndpoint=https://something.file.core.windows.net/",
"AzureWebJobsStorage:blob": "https://something.net/",
"CosmosDb": "AccountEndpoint=https://localhost:8080/;AccountKey=C2y6ybIZnqyMsEcaGQy67XIw/Jw=="
}
I am not able to run the Application , getting error on terminal like :
Can’t determine project language from files. Please use one of [–csharp, –javascript, –typescript, –java, –python, –powershell, –custom]
Missing value for AzureWebJobsStorage in local.settings.json. This is required for all triggers other than httptrigger, kafkatrigger, rabbitmqtrigger, orchestrationTrigger, activityTrigger, entityTrigger. You can run ‘func azure functionapp fetch-app-settings ‘, specify a connection string in local.settings.json, or use managed identity to authenticate.
Press any key to continue….
I am using user secret so it should have precedence over local setting , right ?
Can you please help me for fixing this error .
I am using user secret so it should have precedence over local setting , right ?
Can you please help me for fixing this error .I dont have local.settings.json file in project .
2
Answers
While creating Azure Functions locally you need to store all your secrets and connection string in local.settings.json file and not secrets.json, These settings can be called by using – os.environ[“myappsettings”]
and os.getenv(“appsettings”)
While you’re running your function locally during runtime the function is not able to fetch which Function framework you’re using while deploying your function code from local machine to azure or while running your Function locally.
and your function code is unable to read the connection string or secret required by your function app.
I tried running an Azure function without local.settings.json and received same error, Refer below:-
I created a new Azure Function by using Azure function extension in VS code like below:-
Azure Function HTTP trigger got created like below with all the required Function files including local.settings.json:-
local.settings.json:-
In order to use settings from my Azure function to my local function> I visited my Azure function app and copied the storage account string and added it to my local function like below:-
Azure Function app on portal> Click on Configuration > Application setting > AzureWebJobStorage > Copy the connection string and paste it in local.settings.json for your local function to use the storage account in azure
My default init.py
When you create a new function app locally with HTTP Trigger, Default code is created for the same:-
I ran my function by running the code below and did not receive any error:-
Output:-
Visited the HTTP URL in my browser :-
Note- The settings in local.settings.json are not ran during runtime as they are part of git ignore file. If you need to add any settings in your Function app, You need to do it directly on Azure Portal like below:-
Go to your Function app > Configurations > New application settings > Add new Application settings with the secret and value:-
Output:-
To eliminate the problem: Can’t determine project language from files. Please use one of [–csharp, –javascript, –typescript, –java, –python, –powershell, –
You can put this in your Properties-> LaunchSetting:
if you are using csharp put –csharp as appear in the example code. if you use other languajr change it property, you can see the value to add in the error code.