Привет Согласно моему пониманию, функция Azure будет выполняться
В случае RunOnStartup = true
1. on startup
2. if a host changed
3. a new deployment happen
4. on schedule time
И, в случае RunOnStartup = false или нетопределить
1. on schedule time only
, но когда я запускаю его локально с RunOnStartup = false , он выполняется и при запуске, и на портале Azure работает нормально.Кто-нибудь может подсказать, почему это произошло?
обновление: - Код функции: -
public static void Run([TimerTrigger("0 30 3 * * *", RunOnStartup = false)]TimerInfo myTimer, TraceWriter log, ExecutionContext executionContext)
{
log.Info($"Function1- Timer trigger function executed at: {DateTime.Now}");
try
{
//main work
}
catch (Exception ex)
{
log.Error(ex.Message, ex);
}
finally
{
log.Info($"Function1 - Timer trigger function ENDED at: {DateTime.Now}");
}
}
Вывод на консоль: -
your worker runtime is not set. As of 2.0.1-beta.26 a worker runtime setting is
требуется.Пожалуйста, запустите func settings add FUNCTIONS_WORKER_RUNTIME <option>
или добавьте FUNCTION S_WORKER_RUNTIME в ваш local.settings.json Доступные опции: dotnet, node, python
%%%%%%
%%%%%%
@ %%%%%% @
@@ %%%%%% @@
@@@ %%%%%%%%%%% @@@
@@ %%%%%%%%%% @@
@@ %%%% @@
@@ %%% @@
@@ %% @@
%%
%
Azure Functions Core Tools (2.3.148 Commit hash: f9b3db04f9833b431f1b001efb3e5783a169ebfc)
Function Runtime Version: 2.0.12210.0
[19-Dec-18 8:22:47 AM] Building host: startup suppressed:False, configuration suppressed: False
[19-Dec-18 8:22:47 AM] Reading host configuration file 'D:\path****\host.json'
[19-Dec-18 8:22:47 AM] Host configuration file read:
[19-Dec-18 8:22:47 AM] {
[19-Dec-18 8:22:47 AM] "version": "2.0"
[19-Dec-18 8:22:47 AM] }
[19-Dec-18 8:22:47 AM] Initializing Host.
[19-Dec-18 8:22:47 AM] Host initialization: ConsecutiveErrors=0, StartupCount=1
[19-Dec-18 8:22:47 AM] Starting JobHost
[19-Dec-18 8:22:47 AM] Starting Host (HostId=boldsombirk-85417686, InstanceId=4f41b83d-022e-4e75-b75b-528890f62058, Version=2.0.12210.0, ProcessId=7012, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=)
[19-Dec-18 8:22:47 AM] Loading functions metadata
[19-Dec-18 8:22:48 AM] 1 functions loaded
[19-Dec-18 8:22:48 AM] Generating 1 job function(s)
[19-Dec-18 8:22:48 AM] Found the following functions:
[19-Dec-18 8:22:48 AM] Function1.Run
[19-Dec-18 8:22:48 AM]
[19-Dec-18 8:22:48 AM] Host initialized (673ms)
[19-Dec-18 8:22:49 AM] Executing 'Function1' (Reason='Timer fired at 2018-12-19T13:52:49.5718606+05:30', Id=e1603f8f-41d0-492e-8674-d5771813422d)
[19-Dec-18 8:23:41 AM] Function1 - Timer trigger function executed at: 19-Dec-18 1:53:41 PM
Спасибо