小编See*_*arp的帖子

Azure 是否有开箱即用的密钥分布式锁定方式?

我希望能够编写类似的代码

using (await LockAsync(x.Id))
{
    // here goes code that is unsafe with respect to x.Id
    // because it can be executed in multiple threads on
    // the same instance or on multiple instances (e.g.
    // multiple Azure Functions
}
Run Code Online (Sandbox Code Playgroud)

我知道有一些开箱即用的方法可以在不使用密钥的情况下锁定整个执行上下文(例如[ActivityTrigger]在函数中),并且我知道我可以使用 blob 租约滚动自己的带钥匙的锁,但是有没有一种开箱即用的方法钥匙锁?

c# locking azure azure-webjobs azure-functions

7
推荐指数
1
解决办法
3881
查看次数

Azure 函数存储帐户连接字符串

我有一个函数应用程序定义如下

[StorageAccount("DefaultEndpointsProtocol=...;AccountName=…;AccountKey=...")]
public static class Function1
{
    [FunctionName("Function1")]
    [return: Queue("lets-test-this-out")]
    public static async Task<string> Run([QueueTrigger("lets-test-this-in")] Guid  guid, TraceWriter log)
    {
        await Task.Delay(1000);
        log.Info($"C# Queue trigger function processed: {guid}");
        return Guid.NewGuid().ToString();
    }
}
Run Code Online (Sandbox Code Playgroud)

其中lets-test-this-inlets-test-this-out是带有连接字符串的存储帐户下的现有存储队列的名称"DefaultEndpointsProtocol=...;AccountName=…;AccountKey=..."(直接从访问键 - 连接字符串复制门户中的)。我发布时生成的 function.json 就像

{
  "generatedBy": "Microsoft.NET.Sdk.Functions.Generator-1.0.6",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "queueTrigger",
      "queueName": "lets-test-this-in",
      "connection": "DefaultEndpointsProtocol=...;AccountName=...;AccountKey=...;",
      "name": "guid"
    }
  ],
  "disabled": false,
  "scriptFile": "../bin/FunctionAppTest.dll",
  "entryPoint": "FunctionAppTest.Function1.Run"
}
Run Code Online (Sandbox Code Playgroud)

唯一值得怀疑的是我没有看到[return: Queue("lets-test-this")]在那里被转化为任何价值。

无论如何,这是行不通的:

  • 当我尝试在门户中测试该功能时,我看到 Status: 202 Accepted …

c# azure azure-storage azure-storage-queues azure-functions

5
推荐指数
1
解决办法
7566
查看次数

“函数运行时无法启动”

我知道它可能与配置错误有关,但是很遗憾,我得到的最多信息是

函数运行时无法启动。会话ID:b939c608ae424150878a55eeac6e7d36时间戳:2018-10-04T18:05:22.023Z

我的功能看起来像

    [FunctionName("DoJob")]
    public static async Task DoJobAsync([ServiceBusTrigger("job-queue", Connection = "MyServiceBusConnection")] string json, ILogger log)
    {

       … 

    }
Run Code Online (Sandbox Code Playgroud)

而我的local.settings.json就像

{
    "IsEncrypted": false,
    "Values": {
      "AzureWebJobsStorage": "UseDevelopmentStorage=true",
      "AzureWebJobsDashboard": "UseDevelopmentStorage=true",
      "MyServiceBusConnection": "[my service bus connection string]"
    }
}
Run Code Online (Sandbox Code Playgroud)

该功能应用程序在本地构建并发布,但是一旦我在门户中导航到该应用程序,我就会收到上述错误。

我正在使用.NET Standard(V2)和最新版本1.0.22。

另外,如果尝试在门户中进行测试,则会收到500 Internal Server Error,但日志流中没有任何显示。

c# azure azure-webjobs azure-functions azure-functions-runtime

3
推荐指数
1
解决办法
2960
查看次数