gpt4 book ai didi

c# - 尝试在 blobstorage 触发函数中引用 CloudBlockBlob 时出现编译错误

转载 作者:太空宇宙 更新时间:2023-11-03 20:53:56 25 4
gpt4 key购买 nike

这是我的函数代码。

#r "Microsoft.WindowsAzure.Storage.Blob"

public static async Task Run(CloudBlockBlob uploadedVideo, string name, CloudBlockBlob processedVideo, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {uploadedVideo.Length} Bytes");
var fileEntry = new
{
fileName = $"uploaded-videos/{name}",
fileType = "video",
correlationId = Guid.NewGuid()
};
await processedVideo.StartCopyAsync(uploadedVideo);
await uploadedVideo.DeleteIfExistsAsync();
}

这是我的 function.json

{
"bindings": [
{
"name": "uploadedVideo",
"type": "blobTrigger",
"direction": "in",
"path": "uploaded-videos/{name}",
"connection": "AzureWebJobsStorage"
},
{
"type": "blob",
"name": "processedVideo",
"path": "processed-videos/{name}-{rand-guid}",
"connection": "AzureWebJobsStorage",
"direction": "out"
}
]
}

这是我运行此函数时不断抛出的错误。

2018-09-25T07:34:10.813 [Error] Function compilation error 2018-09-25T07:34:10.982 [Error] BlobTriggerCSharp.csx(2,1): error CS0006: Metadata file 'Microsoft.WindowsAzure.Storage.Blob' could not be found 2018-09-25T07:34:11.040 [Error] BlobTriggerCSharp.csx(4,30): error CS0246: The type or namespace name 'CloudBlockBlob' could not be found (are you missing a using directive or an assembly reference?) 2018-09-25T07:34:11.128 [Error] BlobTriggerCSharp.csx(4,73): error CS0246: The type or namespace name 'CloudBlockBlob' could not be found (are you missing a using directive or an assembly reference?)

最佳答案

没有 Microsoft.WindowsAzure.Storage.Blob 程序集,它是 Microsoft.WindowsAzure.Storage 中包含的命名空间。程序集和命名空间应按如下方式使用。

#r "Microsoft.WindowsAzure.Storage"

using Microsoft.WindowsAzure.Storage.Blob;

CloudBlockBlob无法直接获取Length属性,我们必须先获取blob属性。

await uploadedVideo.FetchAttributesAsync();
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {uploadedVideo.Properties.Length} Bytes");

关于c# - 尝试在 blobstorage 触发函数中引用 CloudBlockBlob 时出现编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52492992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com