gpt4 book ai didi

c# - 如何将 blob 上传到 C# 函数中的现有容器

转载 作者:行者123 更新时间:2023-12-03 20:24:54 25 4
gpt4 key购买 nike

我正在学习如何将存储 blob 与 Azure Functions 结合使用,并且我遵循了以下文档:https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet

     // Create a BlobServiceClient object which will be used to create a container client
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

// Create the container and return a container client object
BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync("<containername>");

// Get a reference to a blob
BlobClient blobClient = containerClient.GetBlobClient("<blobname>");

// Open the file and upload its data
using FileStream uploadFileStream = File.OpenRead("<localfilepath>");
await blobClient.UploadAsync(uploadFileStream, true);
uploadFileStream.Close();
教程中的这段代码仅展示了如何在新容器中上传 blob,但我想上传到现有容器。我能做什么?谢谢。

最佳答案

使用 GetBlobContainerClient .你得到的其他 awnsers 都是为了 v11 .

var serviceClient = new BlobServiceClient(connectionString);
var containerClient = serviceClient.GetBlobContainerClient(containerName);

关于c# - 如何将 blob 上传到 C# 函数中的现有容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63149205/

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