I've created an Azure function that looks like this (actually, the Microsoft template did most of the work!):
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("%queue-name%", AccessRights.Listen)]string myQueueItem, TraceWriter log)
{
log.Info($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}
My local.settings.json looks like this:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "..",
"AzureWebJobsDashboard": "..",
"AzureWebJobsServiceBus": "..",
"queue-name": "testqueue"
}
}
I then deployed this function. This is a strange SO question, because my problem is that this worked immediately, but I didn't expect it to. The function.json is here:
{
"generatedBy": "Microsoft.NET.Sdk.Functions-1.0.0.0",
"configurationSource": "attributes",
"bindings": [
{
"type": "serviceBusTrigger",
"queueName": "%queue-name%",
"accessRights": "listen",
"name": "myQueueItem"
}
],
"disabled": false,
"scriptFile": "..\\bin\\FunctionApp8.dll",
"entryPoint": "FunctionApp8.Function1.Run"
}
Clearly, the values in local.settings.json have been copied into the function settings, but i can't see them in the portal. My question is: where are these settings now stored (queue-name and AzureWebJobsServiceBus)?
EDIT:
My Application Settings for the function:
They'll be under the "Application settings" tab of the published function app in the Azure Portal (see picture).
There's a bit of documentation here! Note that most app settings are not published automatically, and require a bit of configuration either at the publish step or after publishing.
UPDATE: If two functions are listening for an event on the same queue, only one function will be fired. This can cause seemingly buggy behavior, as a function will appear to fire/not fire when expected.
In this case, the unexpected behavior came from a competing functions and not an unexpected connection string.
In Azure the function settings are taken from Application settings tab, which is the same as in App Service.
You probably published them too, go check in the portal UI.
Related
I have an Azure Http Trigger function, which builds successfully and runs without errors, but it's not loading the function or functions.
The current run output gives out the following in verbose mode:
While testing the endpoint, using Postman, it gives me out of obvious reasons the 404 HTTP response.
Trying to resolve the issue I have tried multiple possibilities that can be related to the function itself, such as:
Incorrect project type
Missing function triggers, and any issues related to them
Invalid function signatures
Missing Nuget packages
Incorrect local.settings.json
Incorrect host.json
Run configuration
Going through verbose logs output on run and build for any pointers
Initial assumptions were that it was due to the function I was working on, but further investigations showed that it's happening for all the local development functions that I want to run and debug locally(tried it in multiple IDEs and Terminal with a new test function). Which points to a more global issue.
Currently running it using JetRider but have also tried using Visual Studio and directly the command line execution.
The azure function using
Azure Functions Core Tools: 4.0.4915
Function Runtime Version: 4.14.0.19631
Framework: .net 6.0
Language: C#
Question:
What could be causing this and or how can it be resolved?
Update:
While investigating it was discovered that func doesn't read the host.json and local.settings.json from the project function root. How can this be corrected to read it from the project?
I took a .NET 6 Azure Function with an Http Trigger and run the function with the command func host start --verbose, then I got the below logs in the Console/Terminal:
PS C:\Users\Hari\Azure Functions\KrishNet6FunApp104> func host start --verbose
MSBuild version 17.4.1+9a89d02ff for .NET
Determining projects to restore...
All projects are up-to-date for restore.
KrishNet6FunApp104 -> C:\Users\Hari\Azure Functions\KrishNet6FunApp104\bin\output\KrishNet6FunApp104.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:14.49
%%%%%%
%%%%%%
# %%%%%% #
## %%%%%% ##
### %%%%%%%%%%% ###
## %%%%%%%%%% ##
## %%%% ##
## %%% ##
## %% ##
%%
%
Azure Functions Core Tools
Core Tools Version: 4.0.4915 Commit hash: N/A (64-bit)
Function Runtime Version: 4.14.0.19631
[2023-02-14T07:11:40.662Z] Found C:\Users\Hari\Azure Functions\KrishNet6FunApp104\KrishNet6FunApp104.csproj. Using for user secrets file configuration.
[2023-02-14T07:11:42.596Z] Building host: version spec: , startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '6d9cc98b-20c2-463b-822a-05cf23ae8998'
[2023-02-14T07:11:42.617Z] Reading host configuration file 'C:\Users\Hari\Azure Functions\KrishNet6FunApp104\bin\output\host.json'
[2023-02-14T07:11:42.622Z] Host configuration file read:
[2023-02-14T07:11:42.624Z] {
[2023-02-14T07:11:42.626Z] "version": "2.0",
[2023-02-14T07:11:42.627Z] "logging": {
[2023-02-14T07:11:42.628Z] "applicationInsights": {
[2023-02-14T07:11:42.630Z] "samplingSettings": {
[2023-02-14T07:11:42.631Z] "isEnabled": true,
[2023-02-14T07:11:42.633Z] "excludedTypes": "Request"
[2023-02-14T07:11:42.635Z] }
[2023-02-14T07:11:42.636Z] }
[2023-02-14T07:11:42.638Z] }
[2023-02-14T07:11:42.639Z] }
[2023-02-14T07:11:42.671Z] Loading extensions from C:\Users\Hari\Azure Functions\KrishNet6FunApp104\bin\output\bin. BundleConfigured: False, PrecompiledFunctionApp: False, LegacyBundle: False
[2023-02-14T07:11:42.674Z] Script Startup resetting load context with base path: 'C:\Users\Hari\Azure Functions\KrishNet6FunApp104\bin\output\bin'.
[2023-02-14T07:11:42.707Z] Reading host configuration file 'C:\Users\Hari\Azure Functions\KrishNet6FunApp104\bin\output\host.json'
[2023-02-14T07:11:42.709Z] Host configuration file read:
[2023-02-14T07:11:42.711Z] {
[2023-02-14T07:11:42.714Z] "version": "2.0",
[2023-02-14T07:11:42.716Z] "logging": {
[2023-02-14T07:11:42.717Z] "applicationInsights": {
[2023-02-14T07:11:42.719Z] "samplingSettings": {
[2023-02-14T07:11:42.721Z] "isEnabled": true,
[2023-02-14T07:11:42.723Z] "excludedTypes": "Request"
[2023-02-14T07:11:42.724Z] }
[2023-02-14T07:11:42.725Z] }
[2023-02-14T07:11:42.727Z] }
[2023-02-14T07:11:42.728Z] }
[2023-02-14T07:11:43.950Z] Initializing Warmup Extension.
[2023-02-14T07:11:44.090Z] Initializing Host. OperationId: '6d9cc98b-20c2-463b-822a-05cf23ae8998'.
[2023-02-14T07:11:44.115Z] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=6d9cc98b-20c2-463b-822a-05cf23ae8998
[2023-02-14T07:11:44.173Z] LoggerFilterOptions
[2023-02-14T07:11:44.174Z] {
[2023-02-14T07:11:44.176Z] "MinLevel": "None",
[2023-02-14T07:11:44.178Z] "Rules": [
[2023-02-14T07:11:44.180Z] {
[2023-02-14T07:11:44.182Z] "ProviderName": null,
[2023-02-14T07:11:44.183Z] "CategoryName": null,
[2023-02-14T07:11:44.185Z] "LogLevel": null,
[2023-02-14T07:11:44.187Z] "Filter": "<AddFilter>b__0"
[2023-02-14T07:11:44.190Z] },
[2023-02-14T07:11:44.192Z] {
[2023-02-14T07:11:44.193Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2023-02-14T07:11:44.195Z] "CategoryName": null,
[2023-02-14T07:11:44.197Z] "LogLevel": "None",
[2023-02-14T07:11:44.199Z] "Filter": null
[2023-02-14T07:11:44.200Z] },
[2023-02-14T07:11:44.202Z] {
[2023-02-14T07:11:44.204Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2023-02-14T07:11:44.206Z] "CategoryName": null,
[2023-02-14T07:11:44.208Z] "LogLevel": null,
[2023-02-14T07:11:44.210Z] "Filter": "<AddFilter>b__0"
[2023-02-14T07:11:44.212Z] },
[2023-02-14T07:11:44.214Z] {
[2023-02-14T07:11:44.216Z] "ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
[2023-02-14T07:11:44.218Z] "CategoryName": null,
[2023-02-14T07:11:44.220Z] "LogLevel": null,
[2023-02-14T07:11:44.222Z] "Filter": "<AddFilter>b__0"
[2023-02-14T07:11:44.224Z] }
[2023-02-14T07:11:44.226Z] ]
[2023-02-14T07:11:44.231Z] }
[2023-02-14T07:11:44.234Z] LoggerFilterOptions
[2023-02-14T07:11:44.236Z] {
[2023-02-14T07:11:44.238Z] "MinLevel": "None",
[2023-02-14T07:11:44.241Z] "Rules": [
[2023-02-14T07:11:44.243Z] {
[2023-02-14T07:11:44.245Z] "ProviderName": null,
[2023-02-14T07:11:44.249Z] "CategoryName": null,
[2023-02-14T07:11:44.251Z] "LogLevel": null,
[2023-02-14T07:11:44.253Z] "Filter": "<AddFilter>b__0"
[2023-02-14T07:11:44.255Z] },
[2023-02-14T07:11:44.260Z] {
[2023-02-14T07:11:44.266Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2023-02-14T07:11:44.268Z] "CategoryName": null,
[2023-02-14T07:11:44.271Z] "LogLevel": "None",
[2023-02-14T07:11:44.274Z] "Filter": null
[2023-02-14T07:11:44.276Z] },
[2023-02-14T07:11:44.278Z] {
[2023-02-14T07:11:44.281Z] "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[2023-02-14T07:11:44.283Z] "CategoryName": null,
[2023-02-14T07:11:44.286Z] "LogLevel": null,
[2023-02-14T07:11:44.288Z] "Filter": "<AddFilter>b__0"
[2023-02-14T07:11:44.291Z] },
[2023-02-14T07:11:44.294Z] {
[2023-02-14T07:11:44.297Z] "ProviderName": "Azure.Functions.Cli.Diagnostics.ColoredConsoleLoggerProvider",
[2023-02-14T07:11:44.300Z] "CategoryName": null,
[2023-02-14T07:11:44.303Z] "LogLevel": null,
[2023-02-14T07:11:44.305Z] "Filter": "<AddFilter>b__0"
[2023-02-14T07:11:44.310Z] }
[2023-02-14T07:11:44.313Z] ]
[2023-02-14T07:11:44.315Z] }
[2023-02-14T07:11:44.317Z] ConcurrencyOptions
[2023-02-14T07:11:44.320Z] {
[2023-02-14T07:11:44.322Z] "DynamicConcurrencyEnabled": false,
[2023-02-14T07:11:44.326Z] "MaximumFunctionConcurrency": 500,
[2023-02-14T07:11:44.332Z] "CPUThreshold": 0.8,
[2023-02-14T07:11:44.335Z] "SnapshotPersistenceEnabled": true
[2023-02-14T07:11:44.337Z] }
[2023-02-14T07:11:44.339Z] FunctionResultAggregatorOptions
[2023-02-14T07:11:44.343Z] {
[2023-02-14T07:11:44.346Z] "BatchSize": 1000,
[2023-02-14T07:11:44.350Z] "FlushTimeout": "00:00:30",
[2023-02-14T07:11:44.353Z] "IsEnabled": true
[2023-02-14T07:11:44.357Z] }
[2023-02-14T07:11:44.361Z] SingletonOptions
[2023-02-14T07:11:44.366Z] {
[2023-02-14T07:11:44.372Z] "LockPeriod": "00:00:15",
[2023-02-14T07:11:44.376Z] "ListenerLockPeriod": "00:00:15",
[2023-02-14T07:11:44.379Z] "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[2023-02-14T07:11:44.383Z] "LockAcquisitionPollingInterval": "00:00:05",
[2023-02-14T07:11:44.385Z] "ListenerLockRecoveryPollingInterval": "00:01:00"
[2023-02-14T07:11:44.387Z] }
[2023-02-14T07:11:44.393Z] Starting JobHost
[2023-02-14T07:11:44.405Z] Starting Host (HostId=c1ml47687ms-778510111, InstanceId=454fc6f1-0750-4023-b206-73112827b0d6, Version=4.14.0.19631, ProcessId=5892, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
[2023-02-14T07:11:44.483Z] Loading functions metadata
[2023-02-14T07:11:44.491Z] Reading functions metadata
[2023-02-14T07:11:44.497Z] Reading functions metadata
[2023-02-14T07:11:44.524Z] 1 functions found
[2023-02-14T07:11:44.531Z] 1 functions found
[2023-02-14T07:11:44.566Z] Reading functions metadata
[2023-02-14T07:11:44.622Z] 1 functions found
[2023-02-14T07:11:44.626Z] 1 functions loaded
[2023-02-14T07:11:45.667Z] Generating 1 job function(s)
[2023-02-14T07:11:45.771Z] Found the following functions:
[2023-02-14T07:11:45.773Z] KrishNet6FunApp104.Function1.Run
[2023-02-14T07:11:45.775Z]
[2023-02-14T07:11:45.805Z] HttpOptions
[2023-02-14T07:11:45.807Z] {
[2023-02-14T07:11:45.809Z] "DynamicThrottlesEnabled": false,
[2023-02-14T07:11:45.810Z] Initializing function HTTP routes
[2023-02-14T07:11:45.812Z] "EnableChunkedRequestBinding": false,
[2023-02-14T07:11:45.814Z] Mapped function route 'api/Function1' [get,post] to 'Function1'
[2023-02-14T07:11:45.816Z] "MaxConcurrentRequests": -1,
[2023-02-14T07:11:45.818Z]
[2023-02-14T07:11:45.820Z] "MaxOutstandingRequests": -1,
[2023-02-14T07:11:45.825Z] "RoutePrefix": "api"
[2023-02-14T07:11:45.830Z] }
[2023-02-14T07:11:45.855Z] Host initialized (1410ms)
[2023-02-14T07:11:45.865Z] Host started (1453ms)
[2023-02-14T07:11:45.868Z] Job host started
Functions:
Function1: [GET,POST] http://localhost:7071/api/Function1
I have observer that before Generating and Validating the number of functions found in the project, Runtime Worker is reading the Function Metadata:
After I Created the 2nd Http Trigger Function in the Same project:
[2023-02-14T08:45:23.800Z] Starting JobHost
[2023-02-14T08:45:23.804Z] Starting Host (HostId=c1ml47687ms-778510111, InstanceId=08cbea94-a74d-4167-892f-9802ed417b9a, Version=4.14.0.19631, ProcessId=18812, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
[2023-02-14T08:45:23.829Z] Loading functions metadata
[2023-02-14T08:45:23.834Z] Reading functions metadata
[2023-02-14T08:45:23.837Z] Reading functions metadata
[2023-02-14T08:45:23.849Z] 2 functions found
[2023-02-14T08:45:23.854Z] 2 functions found
[2023-02-14T08:45:23.867Z] Reading functions metadata
[2023-02-14T08:45:23.882Z] 1 functions found
[2023-02-14T08:45:23.886Z] 2 functions loaded
[2023-02-14T08:45:24.100Z] Generating 2 job function(s)
[2023-02-14T08:45:24.145Z] Found the following functions:
[2023-02-14T08:45:24.147Z] KrishNet6FunApp104.Function1.Run
[2023-02-14T08:45:24.149Z] Company.Function.Function2.Run
[2023-02-14T08:45:24.150Z]
[2023-02-14T08:45:24.161Z] HttpOptions
[2023-02-14T08:45:24.163Z] Initializing function HTTP routes
[2023-02-14T08:45:24.163Z] {
[2023-02-14T08:45:24.165Z] Mapped function route 'api/Function1' [get,post] to 'Function1'
[2023-02-14T08:45:24.168Z] "DynamicThrottlesEnabled": false,
[2023-02-14T08:45:24.169Z] Mapped function route 'api/Function2' [get,post] to 'Function2'
[2023-02-14T08:45:24.170Z] "EnableChunkedRequestBinding": false,
[2023-02-14T08:45:24.171Z]
[2023-02-14T08:45:24.172Z] "MaxConcurrentRequests": -1,
[2023-02-14T08:45:24.174Z] "MaxOutstandingRequests": -1,
[2023-02-14T08:45:24.175Z] "RoutePrefix": "api"
[2023-02-14T08:45:24.176Z] }
[2023-02-14T08:45:24.185Z] Host initialized (365ms)
[2023-02-14T08:45:24.192Z] Host started (384ms)
[2023-02-14T08:45:24.194Z] Job host started
Functions:
Function1: [GET,POST] http://localhost:7071/api/Function1
Function2: [GET,POST] http://localhost:7071/api/Function2
This Function metadata is specific to the trigger type such as Http, Queue, Blob Storage, etc.
For Http Trigger, it expects the Name, Type and Direction should be correctly mapped to the binding metadata as mentioned in this MS Doc 1 & 2
All these Bindings will be available in the Function Declaration for the Http Trigger Class File - cSharp Azure Function Created locally.
Here is the GitHub Repository, I have pushed my Azure Functions (.NET 6 Stack) - Http Trigger Project Code for your reference.
I created the following function:
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
namespace FunctionApp1
{
public class DINotWorking
{
ILogger _log;
public DINotWorking(ILogger<DINotWorking> log)
{
_log = log;
_log.LogInformation("I can in constructor");
}
[FunctionName("HttpTrg1")]
public IActionResult Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,ILogger logger1)
{
_log.LogInformation("Contructor injected Log works !");
logger1.LogInformation("Function injected log Work!");
string name = req.Query["name"];
string responseMessage = $"Hello, '{name}'. This HTTP triggered function executed successfully.";
return new OkObjectResult(responseMessage);
}
}
}
host.json
{
"version": "2.0",
"logging": {
"fileLoggingMode": "always",
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"logLevel": {
"FunctionApp1.DINotWorking": "Information",
"FunctionApp1.DINotWorking.User": "Information"
}
}
}
The function has two loggers available in it:
_log is a dependency injected class member with the type ILogger<DINotWorking>.
logger1 is dependency injected function parameter with the type ILogger
I am going to reference them as #1 and #2 going forward.
They behave differently in different environments:
local development - Azure Function tools
In local development environment in azure function tools both #1 and #2 behave identical:
Deployed - Azure Function portal - Application Insight
In Azure Function portal, they both log to Application Insight. Means both #1 and #2 behave identical:
Deployed - Azure Function portal - Filesystem Logs
In Azure Function portal, #1 log entries do not show in the Filesystem logs. Why?
Question: Why #1 log entries do not show in Filesystem logs?
Azure function logging is a black box to me.
Obviously, there is a difference between constructor injected ILogger and Function injected ILogger.
Does this have anything to do with Log Categories explained here
How can I see the difference in my code?
How can I make them behave the same in all environment in the host.json?
Update #1
Per #Hari Krishna suggestion, I've changed the host.json file to the following.
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"fileLoggingMode": "always",
"logLevel": {
"FunctionApp1.HttpTrg1": "Information",
"FunctionApp1.HttpTrg1.User": "Information"
}
}
}
The issue is still persisting (outstanding).
How can I diagnose this issue? Is there anyway the hosting tells me why it is ignoring constructor injected log entries from file system logs?
AFAIK,
In Azure Function portal, #1 log entries do not show in the Filesystem logs. Why?
By default, FileSystem Logs shows the Function execution logs like executing, executed, and error.
We can configure the host.json file to get all the logs (App Insights logs + File System Logs) in File System Logs because everything should be configured whatever the logs you want to push to Application Insights:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
},
"fileLoggingMode": "always",
"logLevel": {
"Function.HttpTrigger1": "Information",
"default": "None"
}
}
}
I have configured the fileLoggingMode in host.json to log both (application & function). Then the output is:
File System Logs:
App Insights Logs:
For more information on fileLoggingMode attributes, refer to this MS Doc and GitHub Open Informative Ticket.
Updated Answer:
Please Check that I have uploaded my code on my GitHub Repository by writing the similar code as yours and shown how to configure the Host.json as well as Function Code.
Results:
Locally I can see both the logs:
After deploying to Azure Function App, App Insights Logs were:
Also, the File System Logs were:
I am using Azure Queue Trigger for my Function. But the Infrastructure (e.g., Queue, Blob storage) for that Function is not in place. So, the Azure storage connection string will also be empty. But while running the Function App, it is expecting the connection string and throwing an exception at runtime. Even though I disabled the Function using the [Disable("MY_TIMER_DISABLED")] attribute.
Exception
System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
The reason I found is that while running the Function App, the Startup is invoking all the Functions, and then it is reading the properties associated with those Functions. So, at the initial invoke, it is expecting the Queue, Connection String, etc., even though the function is Disabled.
public class UserDataRetryFunction()
{
[FunctionName(UserDataRetryFunction)]
[Disable("AzureWebJobs.UserDataRetryFunction.Disabled")]
public async Task RetryData([QueueTrigger("%RetryQueueName%", Connection = "%ConnectionStrings:StorageConnectionString%")])
{
// Process the Queue Message
}
}
appsetings.json
{
"IsEncrypted": false,
"RetryQueueName" : "retry-response-queue",
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobs.UserDataRetryFunction.Disabled": "true"
},
"ConnectionStrings": {
"StorageConnectionString" : "",
}
}
I have tried many documents and sites, but could not able to find the solution.
Some of the links I’ve evaluated are stated below.
https://learn.microsoft.com/en-us/azure/azure-functions/disable-function?tabs=portal
https://forums.asp.net/t/2165324.aspx?Value+cannot+be+null+Parameter+connectionString+
Value cannot be null. Parameter name: connectionString appsettings.json in starter
The behaviour you're setting is expected. In Azure disabling a function only means disabling the trigger as you have done and as detailed in the link you referenced. This disables the trigger but doesn't stop the entire function.
If you wish to stop the entire function you can do so in the Azure Portal.
You can also use the AZ CLI as follows:
az functionapp stop --name MyFunctionApp --resource-group MyResourceGroup
With PowerShell you can stop a function with the following command:
Stop-AzFunctionApp -Name MyAppName -ResourceGroupName MyResourceGroupName
I'm trying to setup an Azure Function, Linux based in consumption mode, Queue triggered.
It works perfectly locally in debug (said every programmer ever), but when deploying nothing happens. I can't find any logs.
I started over, uploaded an empty function - it worked, but as soon as I add my own libraries, it stopped working.
I then tried to remove my libraries and re-upload the 'hello world' function but it still doesn't work.
This is the host.json:
{
"logging": {
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Host.Results": "Information",
"Function": "Information",
"Host.Aggregator": "Information"
},
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
},
"console": {
"isEnabled": "true"
}
},
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=****;AccountKey=*****;BlobEndpoint=https://***.blob.core.windows.net/;TableEndpoint=https://*****.table.core.windows.net/;QueueEndpoint=https://****.queue.core.windows.net/;FileEndpoint=https://****.file.core.windows.net/",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
},
"version": "2.0"
}
The function code (without my libraries), works on first upload only.
[FunctionName("EmailQueueWorker")]
//public static async Task Run(
public static async Task Run(
[QueueTrigger(queueName: "email", Connection = "AzureWebJobsStorage")] string queueItem,
ILogger log
)
{
log.LogWarning("Start run()");
}
What am I doing wrong (or where can I find logs? the Application Insights is empty)? Thanks
I ran into the same problem a week or two ago; I'd bet good money the problem is your connection to the queue. For comparison, this is my full and complete host.json for my (working) queue trigger function:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true
}
},
"fileLoggingMode": "always",
"logLevel": {
"default": "Information",
"Host.Results": "Error",
"Function": "Trace",
"Host.Aggregator": "Trace"
}
}
}
Connection String
Our logLevel section is a bit different, and you'll note there aren't any connection strings there. I'm still farely new to Azure but from what I've learned, that isn't where they go.
In Visual Studio 2019, right click on the Project, then Publish. Under Actions, click Manage Azure App Service settings. There, you can add any needed connection string settings. If you need to specify a storage account, the setting name should be the name of the storage account plus "_STORAGE". For example, if your storage account was named MyVault then the name of the setting would be MyVault_STORAGE.
In VS Code, it's a bit different to get to. You have to look under Azure, Functions, and then be sure you select your Azure subscription (not the local copy!) and drill down into the function, Application Settings, where you can add/edit.
In the Azure portal, you can manage app settings this way.
Logs
In Azure portal, start by going to Function App. Click on your primary function name. Now, under the new menu for that function, under Functions sub-menu, click on Functions. Now you'll see a list of all the different functions that comprise your queue trigger function. Among them should be EmailQueueWorker - click on it. Now, you should see the execution count, and you can click on Monitor in the left hand menu, then Logs in the middle area. You can Start/Stop/Clear as needed.
For whatever reason, I find that I see the actual log data a lot faster when I use either Visual Studio 2019 or VS Code to stream it rather than the web console. There seems to be a bit of a delay at times with the web console.
i have a console application. i built this application and uploaded it to the Azure blob storage. Then i run this application Azure data factory pipeline. All are fine but the problem is if i want to add new parameters(get input) to console application how can i do that? Is there any specific way to do it?
{
"name": "samplebatch",
"type": "Custom",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false
},
"typeProperties": {
"command": "SampleApp.exe",
"folderPath": "customactv2/SampleApp",
"resourceLinkedService": {
"referenceName": "StorageLinkedService",
"type": "LinkedServiceReference"
}
"linkedServiceName": {
"referenceName": "dataloadbatchservice",
"type": "LinkedServiceReference"
}
}
This is what i have done so far in the data factory pipeline code.
Please refer to the extendedProperties property in typeProperties, you could use it.
User-defined properties that can be passed to the custom application
in JSON format so your custom code can reference additional properties
Doc: https://learn.microsoft.com/en-us/azure/data-factory/transform-data-using-dotnet-custom-activity#custom-activity
Sample:https://github.com/Azure/Azure-DataFactory/blob/master/Samples/ADFv2CustomActivitySample/MyCustomActivityPipeline.json