从命令行使用 Azure 开发存储

发布于 2024-12-29 08:36:50 字数 225 浏览 2 评论 0原文

我需要使用脚本将一些文件上传到我的 Azure 存储模拟器。使用 Azure PowerShell cmdlet 可以轻松执行远程 Azure 存储的相同任务,只需调用

Add-Blob -BlobType Block -FilePath $myFilePath -ContainerName $myContainerName

但是如何对本地存储模拟器执行相同的操作?

I need to upload some files to my Azure storage emulator using scripts. The same task for remote Azure storage is performed easily with Azure PowerShell cmdlets, just call

Add-Blob -BlobType Block -FilePath $myFilePath -ContainerName $myContainerName

But how can I do the same thing for local storage emulator?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2025-01-05 08:36:50

对于那些寻找如何使用 Azure SDK (2.1) 执行此操作的人,以下是操作方法:

$StorageContext = New-AzureStorageContext -Local
Set-AzureStorageBlobContent -File $SourceFilePath `
    -Container $DestinationContainerName -Blob `
    $DestinationBlobName -Context $StorageContext

如果您想实际上传到 Azure 存储帐户,请更改 $StorageContext:

New-AzureStorageContext –StorageAccountName $StorageAccountName `
    -StorageAccountKey $StorageAccountKey

For those looking for how to do this with Azure SDK (2.1), here is how:

$StorageContext = New-AzureStorageContext -Local
Set-AzureStorageBlobContent -File $SourceFilePath `
    -Container $DestinationContainerName -Blob `
    $DestinationBlobName -Context $StorageContext

If you want to actually upload to an Azure storage account, change the $StorageContext:

New-AzureStorageContext –StorageAccountName $StorageAccountName `
    -StorageAccountKey $StorageAccountKey
一梦等七年七年为一梦 2025-01-05 08:36:50

您可以使用 Azure 命令行工具,此处提供:

https://github.com/RobBlackwell/AzureCommandLineTools

它们在普通命令提示符下运行,它们实际上不是 powershell cmdlet。

SET AZURE_CONNECTION_STRING=UseDevelopmentStorage=true
PutBlob filename [containername[/blobname]]

You could use the Azure Command Line Tools, available here:

https://github.com/RobBlackwell/AzureCommandLineTools

They run on the normal command prompt, they're not actually powershell cmdlets.

SET AZURE_CONNECTION_STRING=UseDevelopmentStorage=true
PutBlob filename [containername[/blobname]]
如梦初醒的夏天 2025-01-05 08:36:50

使用 PowerShell Cmdlet 找到了解决方案。

您需要为 cmdlet 指定 -UseDevelopmentStorage 选项:

Get-Container -UseDevelopmentStorage

或者

Add-Blob -UseDevelopmentStorage -BlobType Block -FilePath $myFilePath -ContainerName $myContainerName

Found the solution using PowerShell Cmdlets.

You need to specify -UseDevelopmentStorage option to the cmdlets:

Get-Container -UseDevelopmentStorage

or

Add-Blob -UseDevelopmentStorage -BlobType Block -FilePath $myFilePath -ContainerName $myContainerName
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文