2017-08-18 29 views
2

我有帶定時器觸發器的Azure函數。禁用在Visual Studio 2017中不起作用的Azure函數的屬性

public static void Run([TimerTrigger("0 */15 * * * *"), Disable("True")]TimerInfo myTimer, TraceWriter log) 

這裏Disable("true")不起作用。它生成function.json"disabled": "True",這是不正確的。它應該是"disabled": True, 禁用只接受字符串值。 有什麼方法可以改變它嗎?或任何其他方式來禁用功能?

回答

2

禁用的屬性的默認值是true

使用Disable()而不是Disable("true")

因此,代碼會看起來像

public static void Run([TimerTrigger("0 */15 * * * *"), Disable()]TimerInfo myTimer, TraceWriter log)

如果要啓用功能,請使用Disable("False")

+0

將此問題提交給Azure功能團隊。同樣的問題與門戶也。 更多信息:https://github.com/Azure/azure-functions-ux/issues/1712 –

1

字符串類型值 - 「disabled」:「true」也可以禁用該函數。請看下面的測試結果。

這是我的函數定義。

public static void Run([TimerTrigger("0 */5 * * * *"),Disable("true")]TimerInfo myTimer, TraceWriter log) 

這是Azure門戶上發佈的函數。

enter image description here

+0

這是門戶網站的工作。但不適用於本地調試環境。 (Visual Studio 2017) –

+0

是的,你是對的。如果您不想運行該功能,則可以退出調試。爲什麼要禁用調試環境中的功能? – Amor

+0

我也測試「禁用」:在我的本地環境中爲true。它也無法工作。它認爲我們的本地環境將跳過這個屬性,因爲我們無法隨時在我們當地的環境中停止該功能。 – Amor

0

您是否嘗試過在您的解決方案中修改host.json?它具有以下屬性供您指定在運行時加載哪些函數。

// Array of functions to load. Only functions in this list will be enabled. 
// If not specified, all functions are enabled. 
"functions": ["QueueProcessor", "GitHubWebHook"] 

請注意,如果你有你的解決方案多功能應用的項目,您還需要作出改變,以他們的相應host.json(即每個項目都有自己的host.json)

文檔:https://github.com/Azure/azure-webjobs-sdk-script/wiki/host.json

相關問題