输出blob路径“$ web / index.html”被认为对Functions App无效

问题描述 投票:0回答:1

Azure Blob存储通过强制容器名称“$ web”支持“静态Web”功能。

构建函数应用程序时,如果要保存函数在blob文档中生成的内容,则需要指定路径,但容器名称为“$ web”的路径将被视为无效。

我使用Javascript作为语言使用Azure函数runtime~2。

function.json文件如下所示。

{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 0 5 * * *"
    },
    {
      "type": "blob",
      "name": "$return",
      "path": "$web/index.html",
      "connection": "AzureWebJobsStorage",
      "direction": "out"
    }
  ]
}

我希望输出生成并将文件保存到blob路径$web/index.html,但我得到以下错误。

Validation failed for property 'BlobPath', value '$web/index.html'. The field BlobPath is invalid. 
azure azure-functions azure-storage-blobs
1个回答
1
投票

我没有使用标准的Azure函数输出管道,而是使用了Azure node SDK

我宣传了上传方法(使用V2 SDK中的回调)。

function upload(svc, container, blob, content) {
    return new Promise((res, rej) => svc.createBlockBlobFromText(container, blob, content, (err, resp, _) => {
        if (err) {
            rej(err);
        }

        res(resp);
    }));
}

然后我用它来上传我生成的文件。

const blobSvc = createBlobService();
await upload(blobSvc, process.env.OUTPUT_CONTAINER, process.env.OUTPUT_BLOB, render(readFileSync('D:/home/site/wwwroot/TimerTrigger1/template.html', 'utf-8'), { user, photos }));
© www.soinside.com 2019 - 2024. All rights reserved.