当前位置: 首页 > 知识库问答 >
问题:

将文件从Azure文件存储移动到Azure Blob存储

靳祺然
2023-03-14

我相当愚蠢地上传了一个vhd到Azure文件存储,以为我可以从它创建一个虚拟机,却发现它真的需要在Blob存储中。

我知道我可以再上传一次,但它非常大,我的上传速度非常慢。

我的问题是-我可以将文件从文件存储移动到blob存储,而无需再次下载/上传吗?也就是说,Azure门户UI中是否有任何东西可以执行此操作,甚至是PowerShell命令?

共有3个答案

孙德本
2023-03-14

另一个选择是使用Azure CLI。。。

az storage copy -s /path/to/file.txt -d https://[account].blob.core.windows.net/[container]/[path/to/blob]

更多信息请点击此处:az存储副本

穆华彩
2023-03-14

c#中:

public static CloudFile GetFileReference(CloudFileDirectory parent, string path)
{
    var filename = Path.GetFileName(path);
    var fullPath = Path.GetDirectoryName(path);
    if (fullPath == string.Empty)
    {
        return parent.GetFileReference(filename);
    }
    var dirReference = GetDirectoryReference(parent, fullPath);
    return dirReference.GetFileReference(filename);
}

public static CloudFileDirectory GetDirectoryReference(CloudFileDirectory parent, string path)
{
    if (path.Contains(@"\"))
    {
        var paths = path.Split('\\');
        return GetDirectoryReference(parent.GetDirectoryReference(paths.First()), string.Join(@"\", paths.Skip(1)));
    }
    else
    {
        return parent.GetDirectoryReference(path);
    }
}

要复制的代码:

// Source File Storage
string azureStorageAccountName = "shareName";
string azureStorageAccountKey = "XXXXX";
string name = "midrive";
CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentials(azureStorageAccountName, azureStorageAccountKey), true);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
CloudFileShare fileShare = fileClient.GetShareReference(name);
CloudFileDirectory directorio = fileShare.GetRootDirectoryReference();
CloudFile cloudFile = GetFileReference(directorio, "SourceFolder\\fileName.pdf");

// Destination Blob
string destAzureStorageAccountName = "xx";
string destAzureStorageAccountKey = "xxxx";
CloudStorageAccount destStorageAccount = new CloudStorageAccount(new StorageCredentials(destAzureStorageAccountName, destAzureStorageAccountKey), true);
CloudBlobClient destClient = destStorageAccount.CreateCloudBlobClient();
CloudBlobContainer destContainer = destClient.GetContainerReference("containerName");
CloudBlockBlob destBlob = destContainer.GetBlockBlobReference("fileName.pdf");

// copy
await TransferManager.CopyAsync(cloudFile, destBlob, true);
熊俊人
2023-03-14

你可以试试AzCopy:

AzCopy.exe /Source:{*URL to source container*} /Dest:{*URL to dest container*} /SourceKey:{*key1*} /DestKey:{*key2*} /S

从文件存储复制到Blob存储时,默认Blob类型为block Blob,用户可以指定选项/BlobType:page来更改目标Blob类型。

默认情况下,AzCopy在两个存储endpoint之间异步复制数据。因此,复制操作将使用备用带宽容量在后台运行,在blob复制速度方面没有SLA,AzCopy将定期检查复制状态,直到复制完成或失败。/SyncCopy选项可确保复制操作获得一致的速度。

 类似资料:
  • 我在数据库中创建了一个连接到我的blob存储的挂载,并且我能够使用笔记本将文件从blob读取到数据库。 然后我使用pyspark将. txt转换为json格式,现在我想将其加载回blob存储。有人知道我会怎么做吗? 以下是我尝试过的一些事情: <code>my_json.write。选项(“header”,“true”).json(“mnt/my_mount/file_name.json”) <

  • 我想通过运行在Azure VM上的FTP服务器与用户共享Azure Blob存储中的文件。 据我所知,您不能在VM上挂载Blob存储,但可以使用“网络使用”挂载Azure文件共享。 Blob存储上的文件将以增量方式上载,因此理想情况下,我希望在上载时将其复制到Azure文件,Azure功能似乎是理想的方式,因为它们很容易为我设置和处理Blob存储上的触发器。 我如何使用Azure功能将文件从Blo

  • 我有一个通过System.Drawing动态生成的图像。然后,我将生成的图像输出到以存储到我的Azure blob中。 但我似乎无法将我的文件存储在我选择的blob中。没有发生错误,并且我的图像成功地保存到。不出所料,我的blob是空的。 到 但我会标记“Gaurav Mantri”的回应是正确的。如果不是他的洞察力,我的图像就不会上传到Blob上。

  • 为了清理一些磁盘空间,我将我的mp3收藏从内部存储移到外部存储。我的设备是根的,当时我是。 文件可以看到(和播放)从文件管理器,但我的音乐播放器没有看到他们。 看起来有趣的是移动后的文件权限。这是一个文件仍然在内部存储,但没有移动。 下面是几个被移到外部存储的文件: 将它们移动到外部存储似乎更改了权限。不幸的是,不会影响实际的文件权限: 我尝试将文件移回内部存储以更改那里的权限。直到我将文件移回外

  • 我正在尝试将一个图像文件从html页面上传到azure blob存储。到目前为止,我已经编写了一个web服务来为我的blob容器创建SAS。由此,我创建了一个uri,格式为“blob地址”/“容器名称”/“blob名称”?“sas”。我的html页面上有一个上传控件。 然后,我尝试使用以下代码上传该文件: 其中blobPath是上面提到的uri,upFile是我的html上传控件。 当我试图上传文

  • 早些时候,我的文件上载到存储文件夹中。但是现在我想在s3存储桶上上传图像。如何迁移s3存储桶上现有的本地数据? 我在这里找到了脚本https://www.stefanwienert.de/blog/2018/11/05/active-storage-migrate-between-providers-from-local-to-amazon/但是得到了一个错误 为活动存储调用私有方法打开 那么,我