-1

我可以使用 Azure 门户创建函数应用和函数,并将输出绑定添加到消息队列。例如,通过使用函数下的集成选项,我可以添加一个新的输出,在本例中是一个消息队列:

天青功能

添加新消息队列后,function.json 文件将使用门户中的新绑定进行更新。

前:

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "Request",
      "methods": [
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "Response"
    }
  ]
}

后:

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "Request",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "Response"
    },
    {
      "type": "queue",
      "name": "myQueueItem",
      "queueName": "myoutputqueue",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }
  ]
}

现在我可以在我的 Azure 函数中引用消息队列。

在门户中很容易做到。但是,如果它尚不存在,我想通过构建管道创建队列存储(或任何其他类型)。我认为这在发布定义中最有意义,但我无法确定如何检测帐户和队列是否已经存在,或者如果不存在则创建它们。我想我可以通过 Azure Powershell 脚本发布定义任务使用 Azure Powershell 命令,并使用此处描述的命令:

使用 Azure PowerShell 执行 Azure 队列存储操作

但是当我尝试在 Azure Powershell CLI 中手动使用“Get-AzureStorageAccount”来查看存储帐户是否存在时,我收到一条错误消息,指出“Get-AzureStorageAccount”不是有效的命令行开关。有没有办法通过 CI/CD 管道管理 Azure 函数存储和绑定?

4

1 回答 1

0

这对我来说并不明显,但如果它不存在,函数应用程序将创建队列,因此无需在管道中创建一个。终于遇到了这个提到它的链接:

Azure Functions 的 Azure 队列存储绑定

于 2019-07-07T03:44:51.670 回答