使用更详细的调试输出更新下面
过去,我已经成功地使用本地dev主机运行Azure函数。
我最近还没能让blobTrigger正常工作。我已采取以下步骤:
func init NewWave
cd NewWave
func new # -> select httpTrigger called HttpTrigger in language python
func new # -> select blobTrigger called BlobTrigger in language python
func host starthost.json包含:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}local.settings.json包含:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "{AzureWebJobsStorage}"
}
}AzureWebJobsStorage是通过环境变量设置的连接字符串。
包含:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "samples-workitems/{name}",
"connection": ""
}
]
}__init__.py包含:
import logging
import azure.functions as func
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")HttpTrigger加载,但BlobTrigger不加载。产出如下:
Azure Functions Core Tools (2.7.1373 Commit hash: cd9bfca26f9c7fe06ce245f5bf69bc6486a685dd)
Function Runtime Version: 2.0.12507.0
Warning: 'connection' property in '~/NewWave/BlobTrigger/function.json' is empty.
Skipping 'AzureWebJobsStorage' from local settings as it's already defined in current environment variables.
[...]
[6/24/19 12:45:28 PM] Starting JobHost
[...]
[6/24/19 12:45:28 PM] Generating 2 job function(s)
[6/24/19 12:45:28 PM] Found the following functions:
[6/24/19 12:45:28 PM] Host.Functions.HttpTrigger
[6/24/19 12:45:28 PM] Host.Functions.BlobTrigger
[6/24/19 12:45:28 PM]
[6/24/19 12:45:28 PM] Host initialized (280ms)
Http Functions:
HttpTrigger: [GET,POST] http://localhost:7071/api/HttpTrigger
[6/24/19 12:45:28 PM] A host error has occurred
[6/24/19 12:45:28 PM] Microsoft.Azure.WebJobs.Extensions.Storage: Object reference not set to an instance of an object.
[6/24/19 12:45:28 PM] Stopping JobHost是什么导致了这个错误,我如何解决它?
如果需要进一步的设置,日志等,请在下面的评论中提出建议,我会更新。
谢谢
操作系统: macOS高塞拉10.13.6
Python版本:
Python 3.6.8 Anaconda Inc.(缺省值,2018年12月29日,19:04:46) GCC 4.2.1兼容Clang 4.0.1 (标记/Release401/final)在达尔文类型“帮助”、“版权”、“信贷”或“许可”上获得更多信息。
pip冻结:
应用洞察力=0.1.0 azure-cognitiveservices-vision-customvision==1.0.0 azure-batch=4.1.3 azure==4.0.0 azure-azure==4.0.0=1.1.20 azure-cosmosdb-nspkg=2.0.2 azure-cosmosdb-table=1.0.5 azure-datalake-store==0.0.45 azure-azure==4.0.0 mgmt=1.2.0 azure-#en0#=1.0.0b8 azure-azure==4.0.0 batch=1.0.0b8 azure-keyvault==1.1.0 azure-loganalytics==0.azure-mgmt=4.0.0-mgmt=4.0.0.0.1 azure-mgmt-应用洞察力=0.1.1天青-mgmt-授权==0.50.0天青-mgmt-批处理=5.0.1天青-mgmt-batchai==2.0.0天-mgmt-帐单==0.2.0天青-mgmt-cdn==3.1.0 azure-mgmt-cdn=3.1.0 azure-mgmt-cognitiveservices=3.0.0 azure-mgmt-commerce=1.0.1 azure-mgmt-计算==4.6.2 azure-mgmt-计算=2.0.0 azure-mgmt-compute=1.4.1 azure-mgmt-.0.1=2.8.0mgerure=2.8.0mgmmt=4.4。0 azure-mgmt=0.4.1 azure-mgmt-datafactory=0.6.0 azure-mgmt-datalake-analytics==0.6.0 azure-mgmt-datalake-nspkg==3.0.1 azure-mgmt-datalake-store==0.5.0 azure-mgmt-datamigration=1.0.0 azure-mgmt-datamigration=1.0.0 azure-mgmt-devspaces==0.1.0 -mgmt-datalake==2.2.0.1.0 azure-mgmt=0.5.0 azure-machinelearningcompute=0.2.0 azure-mgmt=1.1.0 azure-mgmt=0.2.0 azure-mgmt-逻辑=3.0.0 azure-mgmt-mgmt-media=0.4.1 azure-mgmt managementpartner==0.1.0 azure-mgmt-managementpartner==0.1.0 azure-mgmt-mgmt-map=0.1.0 azure-mgmt-mgmt-media=1.1.0-mgmt-媒体=1.1mgmt-mgmt=0.5.2mgmt-mgmt=0.1.0mgmt-mgmt=0.1.0 mgmt-mgmt=0.1.0 mgmt=mgmt=0.1.0 mgmt=0.1.00 azure- mgmt-mgmt=2.7.0 azure-mgmt-通知集线器==2.1.0 azure-mgmt-nspkg=3.0.2 azure-mgmt==0.1.0 azure-mgmt-powerbiembedded==2.0.0 azure-mgmt-rdbms=1.8.0 azure-mgmt-recoveryservices=0.3.0天青-mgmt-recoveryservicesbackup=0.3.0 azure-mgmt-redis=5.0.0 azure-mgmt-中继=0.1.0-mgmt-预订=0.1.0mgmt-search=2.0.0 azure-mgmt-servicebus==0.5.3 azure-mgmt-servicefabric==0.2.0 azure- mgmt-signalr=0.1.1 azure-mgmt-sql=0.9.1 azure-mgmt-存储=2.0.0 azure-mgmt-订阅=0.2.0 azure-mgmt-流量管理器=0.50.0-mgmt-web=0.35.0-nspkg=3.0.2天青-servicebus=0.21.1-servicefabric=6.3.0.0蔚蓝-服务管理-遗留物=0.20.6=0.20.6-存储-存储=0.30.0-mgmt-web=0.35.0-nspkg=3.0.2天青-servicebus=0.21.1-servicefabric=6.3.0.0存储-blob==2.0.1 azure-存储-通用=2.0.0 azure-存储-文件=1.4.0天蓝色-存储-队列=1.4.0 msrestazure==0.6.0
更新
因此,我找到了一些更详细的日志文件(注意,我在macOS上):
2019-06-24T11:14:42.213 [Error] A host error has occurred
System.NullReferenceException : Object reference not set to an instance of an object.
at Microsoft.Azure.WebJobs.Host.Blobs.Listeners.CloudBlobClientComparer.GetHashCode(CloudBlobClient obj) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\CloudBlobClientComparer.cs : 34
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key,TValue value,InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key,TValue value)
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.PollLogsStrategy.RegisterAsync(CloudBlobContainer container,ITriggerExecutor`1 triggerExecutor,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\PollLogsStrategy.cs : 74
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.ScanBlobScanLogHybridPollingStrategy.RegisterAsync(CloudBlobContainer container,ITriggerExecutor`1 triggerExecutor,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\ScanBlobScanLogHybridPollingStrategy.cs : 61
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.BlobListenerFactory.RegisterWithSharedBlobListenerAsync(String hostId,SharedBlobListener sharedBlobListener,CloudBlobClient blobClient,CloudQueue hostBlobTriggerQueue,IMessageEnqueuedWatcher messageEnqueuedWatcher,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\BlobListenerFactory.cs : 155
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Blobs.Listeners.BlobListenerFactory.CreateAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Blobs\Listeners\BlobListenerFactory.cs : 93
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexer.ListenerFactory.CreateAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Indexers\FunctionIndexer.cs : 426
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Listeners.HostListenerFactory.CreateAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\HostListenerFactory.cs : 62
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryListener.StartAsyncCore(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\ListenerFactoryListener.cs : 45
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Host.Listeners.ShutdownListener.StartAsync(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\ShutdownListener.cs : 29
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.JobHost.StartAsyncCore(CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs : 101
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.ScriptHost.StartAsyncCore(CancellationToken cancellationToken) at C:\azure-webjobs-sdk-script\src\WebJobs.Script\Host\ScriptHost.cs : 241
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.StartHostAsync(CancellationToken cancellationToken,Int32 attemptCount,JobHostStartupMode startupMode) at C:\azure-webjobs-sdk-script\src\WebJobs.Script.WebHost\WebJobsScriptHostService.cs : 163发布于 2019-06-25 10:43:59
通过尝试和错误-和一个完全误导错误信息..。
答案只是将环境变量AzureWebJobsStorage设置为存储帐户的主访问键连接字符串,该字符串如下所示:
DefaultEndpointsProtocol=https;AccountName=<account name>;AccountKey=<account key>;EndpointSuffix=core.windows.net而不是通过az storage account generate-sas创建的SAS连接字符串。
发布于 2019-06-25 06:23:05
我建议您在"connection“中添加一个设置中为空的值。
{
"scriptFile": "__init__.py",
"disabled": false,
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "samples-workitems/{name}",
"connection":"MyStorageAccountAppSetting"
}
]
}这是我的local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"mohitsa_STORAGE": ""
}
}希望能帮上忙。
https://stackoverflow.com/questions/56737086
复制相似问题