标签: azure-blob-storage

批量上传文件到Azure(C#)的最快方法

批量上传文件Azure Blob存储的最快方法是什么?我试过两种方法,syncasync上传,async显然是最快的,但我不知道是否有更好的方法?是否内置了对批量上传的支持?我在文档中找不到任何内容但可能错过了它.

这是我跑的测试:

static void Main(string[] args)
{
    int totalFiles = 10; //10, 50, 100
    byte[] randomData = new byte[2097152]; //2mb
    for (int i = 0; i < randomData.Length; i++)
    {
        randomData[i] = 255;
    }

    CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
    var blobClient = cloudStorageAccount.CreateCloudBlobClient();

    var container = blobClient.GetContainerReference("something");
    container.CreateIfNotExists();


    TimeSpan tsSync = Test1(totalFiles, randomData, container);
    TimeSpan tsAsync = Test2(totalFiles, randomData, container);

    Console.WriteLine($"Sync: {tsSync}");
    Console.WriteLine($"Async: {tsAsync}");

    Console.ReadLine();

}

public static TimeSpan Test2(int total, byte[] …
Run Code Online (Sandbox Code Playgroud)

.net c# azure azure-storage azure-blob-storage

6
推荐指数
2
解决办法
3529
查看次数

使用 C# 从 Azure Blob 复制到 AWS S3

请注意,这是我第一次用 C# 做任何事情,所以请善待,我可能犯了一些非常基本的错误。(是的,我知道我不应该对密钥进行硬编码,但会在代码执行我想要的操作时修复它)。

我正在尝试创建一个 Azure 函数,将任何新项目从 Blob 存储复制到 AWS S3。我已经设法使用本文中的代码从 blob 复制到 blob:https : //cmatskas.com/copy-azure-blob-data-between-storage-accounts-using-functions/

我试图修改该代码以保存到 AWS S3 存储桶。虽然此代码成功编译并为我提供了成功的日志记录,但它不会复制任何文件。有任何想法吗?

using System;
using System.IO;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.S3.Transfer;
using Microsoft.Azure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

public async static void Run(CloudBlockBlob myBlob, TraceWriter log) 
{
    await CopyBlob(myBlob, log);
}

private async static Task CopyBlob(CloudBlockBlob myBlob, TraceWriter log)
{
    var existingBucketName = "bucketname";
    var keyName = "backup";
    var accessKey = "key";
    var secretKey = "secretkey";

    TransferUtility fileTransferUtility = new TransferUtility(new AmazonS3Client(accessKey,secretKey,Amazon.RegionEndpoint.eu-west-2)); …
Run Code Online (Sandbox Code Playgroud)

c# amazon-s3 azure azure-blob-storage azure-functions

6
推荐指数
1
解决办法
3741
查看次数

Azure 搜索返回已删除 Blob 资源的结果

我有一个 Azure 搜索服务,用于根据 BLOB 元数据搜索 BLOBS(即图像)。

搜索所基于的索引设置为每小时刷新一次。

但是,我仍然得到搜索结果中不再存在的 BLOB 的结果。

使用获取索引器状态 API(下面的输出)显示在删除 BLOBS 后索引已成功刷新。

"status": "running",
"lastResult": {
    "status": "success",
    "errorMessage": null,
    "startTime": "2018-02-05T16:00:03.29Z",
    "endTime": "2018-02-05T16:00:03.416Z",
    "errors": [],
    "warnings": [],
    "itemsProcessed": 0,
    "itemsFailed": 0,
    "initialTrackingState": "{\r\n  \"lastFullEnumerationStartTime\": \"2018-02-05T14:59:31.966Z\",\r\n  \"lastAttemptedEnumerationStartTime\": \"2018-02-05T14:59:31.966Z\",\r\n  \"nameHighWaterMark\": null\r\n}",
    "finalTrackingState": "{\"LastFullEnumerationStartTime\":\"2018-02-05T15:59:33.2900956+00:00\",\"LastAttemptedEnumerationStartTime\":\"2018-02-05T15:59:33.2900956+00:00\",\"NameHighWaterMark\":null}"
},
"
Run Code Online (Sandbox Code Playgroud)

如果相关,则使用Azure 存储资源管理器删除了 BLOB

这导致的问题是这些图像被输出到网页并且当前显示为丢失的图像以及使索引大于它需要的大小。

azure azure-storage-blobs azure-cognitive-search azure-blob-storage

6
推荐指数
2
解决办法
1287
查看次数

如何“欺骗” Azure Function 使其运行时间超过 10 分钟

Azure Functions 的时间限制为 10 分钟。假设我有一个长时间运行的任务,例如下载一个需要 1 小时才能下载的文件。

[FunctionName("PerformDownload")]
[return: Queue("download-path-queue")]
public static async Task<string> RunAsync([QueueTrigger("download-url-queue")] string url, TraceWriter log)
{
   string downloadPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString);
   log.Info($"Downloading file at url {url} to {downloadPath} ...");
   using (var client = new WebClient())
   {
       await client.DownloadFileAsync(new Uri(url), myLocalFilePath);
   }
   log.Info("Finished!");   
}
Run Code Online (Sandbox Code Playgroud)

有没有什么hacky的方法可以让这样的事情开始,然后在时间限制到期之前恢复另一个功能?或者有没有更好的方法可以将这样的长任务集成到使用 Azure Functions 的工作流中?

(在一个稍微相关的说明中,普通的 Azure Web 作业是否已过时?我在资源下找不到它。)

c# azure azure-blob-storage azure-functions

6
推荐指数
2
解决办法
1万
查看次数

使用AD令牌获取请求的Azure Blob存储“授权权限不匹配”错误

我正在构建一个Angular 6应用程序,它将能够在Azure Blob存储上进行CRUD操作。但是,我正在使用邮差来测试请求,然后再在应用程序内部实现它们,并将我从Angular获得的令牌复制粘贴到该资源中。

尝试读取存储在存储中的文件以进行测试时,我得到: <Code>AuthorizationPermissionMismatch</Code> <Message>This request is not authorized to perform this operation using this permission.

  • 全部在生产环境中(尽管正在开发中)
  • 通过Oauth专为存储资源获取的令牌
  • 邮递员将令牌策略称为“承载者”
  • 应用程序已授予“ Azure Storage”委托权限。
  • 应用程序和我要获取令牌的帐户都作为“所有者”添加到了天蓝色的访问控制IAM中
  • 我的IP已添加到Blob存储上的CORS设置中。
  • StorageV2(通用v2)-标准-热门
  • 使用的x-ms-version标头是:2018-03-28因为这是我可以找到的最新消息,所以我刚刚创建了存储帐户。

azure azure-storage-blobs azure-active-directory azure-blob-storage

6
推荐指数
2
解决办法
6717
查看次数

在 Python 中覆盖 Azure Blob 的最佳方法

如果我尝试覆盖现有的 blob:

blob_client = BlobClient.from_connection_string(connection_string, container_name, blob_name)
blob_client.upload_blob('Some text')
Run Code Online (Sandbox Code Playgroud)

我得到一个ResourceExistsError.

我可以检查 blob 是否存在,将其删除,然后上传:

try:
    blob_client.get_blob_properties()
    blob_client.delete_blob()
except ResourceNotFoundError:
    pass
blob_client.upload_blob('Some text')
Run Code Online (Sandbox Code Playgroud)

考虑到 python azure blob 存储 API 可用的内容以及惯用的 python 样式,是否有更好的方法来覆盖现有 blob 的内容?我期望有某种覆盖参数可以在upload_blob方法中选择性地设置为 true ,但它似乎不存在。

python azure-blob-storage

6
推荐指数
1
解决办法
2793
查看次数

Azure 应用服务“应用程序日志记录(Blob)”在指定的保留期后不会删除日志

我已将 Azure 应用服务的“应用程序日志记录 (Blob)”配置为保留期为 1 天:

在此处输入图片说明

但是,在保留期之后不会清除日志。

我错过了什么?看起来应该是直截了当的,但是文档很少。

我的问题似乎与此问题相同,但没有公认的答案。

任何帮助,将不胜感激。

c# azure-blob-storage asp.net-core azure-appservice

6
推荐指数
0
解决办法
165
查看次数

powershell 中的 foreach 与 ForEach-Object -Parallel - 出了什么问题?

我对 ForEach-Object -Parallel 感到困惑。以下代码有包含超过 2000 个 blob 的 $blobs 数组。使用常规的foreach,我可以毫无问题地打印每个 blob 的名称。然后在第一个 foreach 之后使用ForEach-Object -Parallel ,不会打印任何内容。为什么 ?

foreach ($blob in $blobs) {
           Write-Host    $blob.Name
}

# Use parallel processing to process blobs concurrently
$blobs|ForEach-Object -Parallel {
         param (
             $blob)
    
        Write-Host $blob.Name 
} -ThrottleLimit 300
Run Code Online (Sandbox Code Playgroud)

parallel-processing powershell azure-blob-storage foreach-object

6
推荐指数
1
解决办法
81
查看次数

扫描上传到 Azure 的文件中的恶意软件

我正在构建一个具有文件上传功能的 .net 应用程序(Azure 应用程序服务),该功能会将 pdf/docx 文件上传到 Azure blob 存储。

我只是想知道如果恶意用户上传了受病毒感染的文件、word 文件中的错误宏,Azure 是否能够扫描并删除/隔离该文件?

在应用程序中,管理员用户将能够使用 URL 下载文件。该文件没有病毒吗?或者,在管理员下载文件后,我是否需要显式调用 Symantec End Point 等防病毒软件。

请让我知道您的专家想法。

azure azure-blob-storage

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

How to get only folder name in blob using new Azure.Storage.Blobs namespace

快照

I want to get all the folder name under a container using new SDK - Azure.Storage.Blobs

c# azure azure-blob-storage

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