Chr*_*ris 4 c# azure azure-storage azure-sdk-.net azure-webjobs
我正在尝试将azure SDK从v1更新到v3,并将其连接到Azure存储模拟器进行测试;使用控制台应用程序和.NET Framework。
它似乎不像以前使用的任何触发器一样,错误中的“ SomeFunction”是带有超时的简单QueueTrigger。
异常:Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException:'错误索引方法'* .SomeFunction'
内部异常:InvalidOperationException:未配置存储帐户“存储”。
[Timeout("00:30:00")]
public static async Task SomeFunction([QueueTrigger("queue")] CloudQueueMessage message, CancellationToken cancellationToken)
{
// do stuff
}
Run Code Online (Sandbox Code Playgroud)
app.config:
<connectionStrings>
<add name="AzureWebJobsDashboard" connectionString="AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;" />
<add name="AzureWebJobsStorage" connectionString="AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;" />
</connectionStrings>
<appSettings>
<add key="StorageConnectionString" value="UseDevelopmentStorage=true" />
<add key="AzureQueueName" value="queue" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)
Art*_*ous 10
Microsoft.Azure.WebJobs的版本3不再配置app.config文件,而是配置appSettings.json文件。将其放置在应用程序的根目录中,并确保将appSettings.json文件的“ 复制到输出目录 ”属性设置为复制(如果较新)或始终复制,或使用Always或PreserveNewest直接将其添加到文件中:.csproj
<Project ...>
...
<ItemGroup>
<None Include="appSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
...
</Project>
Run Code Online (Sandbox Code Playgroud)
您的appSettings.json文件应具有存储连接字符串:
{
"ConnectionStrings": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
}
}
Run Code Online (Sandbox Code Playgroud)
{
"ConnectionStrings": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=mystorage;AccountKey=key;..."
}
}
Run Code Online (Sandbox Code Playgroud)
有关在版本3中进行配置的更多信息,请参见此.NET Core 2.1示例主机应用程序。尽管它可能与所使用的.NET Framework有所不同。
| 归档时间: |
|
| 查看次数: |
1233 次 |
| 最近记录: |