【问题标题】:Download and store GRIB2 files in Azure在 Azure 中下载和存储 GRIB2 文件
【发布时间】:2020-02-25 21:49:37
【问题描述】:

目前,在我的 Linux Docker 容器上,我有一个 bash 脚本,它能够通过 cookie 登录从特定 URL 下载许多 GRIB2 天气预报文件。 下载这些文件后,我使用安装在同一个 Docker 容器中的 ECCODES 库中的可执行文件来过滤掉不需要的数据,以减小文件大小。

我的公司可以访问 Azure 平台,我想直接在 Azure 平台中下载和过滤这些 GRIB2 文件,这样我就不必手动运行脚本并且总是下载文件然后将它们上传到 Azure存储。

但是,我之前从未使用过 Azure,所以我想知道的是:

是否有可能在 Azure 虚拟机中运行此脚本,该虚拟机将下载过滤后的 GRIB2 文件并将其直接存储在 Azure 存储中(根据我目前所读到的内容,Blob 存储似乎是最佳选择)?

谢谢!

【问题讨论】:

  • 您想了解如何从 Azure blob 下载文件并将文件上传到 Azure blob?如果有,请参考docs.microsoft.com/en-us/azure/active-directory/…
  • 感谢@JimXu,我一直在研究 Azure 文档,我编写了一个 bash 脚本,用于创建 blob 存储容器并上传不存在的文件。我即将开始 C++ 实现以在我的应用程序中下载这些文件。
  • 既然您的问题已经解决,能否请您发表您的答案?

标签: azure-blob-storage azure-virtual-machine


【解决方案1】:
#!/usr/bin/env bash

export AZURE_STORAGE_ACCOUNT=your_azure_storage_account
export AZURE_STORAGE_ACCESS_KEY=your_azure_storage_access_key

# Retrieving current date to upload only new files
date=`date +%Y-%m-%dT%H:%MZ`

az login -u xxx@yyy.com -p password --output none

containerName=your_container_name

containerExists=`az storage container exists --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --name $containerName --output tsv`
if [[ $containerExists == "False" ]]; then
    az storage container create --name $containerName # Create a container
fi

# Upload GRIB2 files to container
fileExists=`az storage blob exists --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --container-name $containerName --name "gfs.0p25.2019061300.f006.grib2" --output tsv`
if [[ $fileExists == "False" ]]; then
    az storage blob upload --container-name $containerName --file ../Resources/Weather/Historical_Data/gfs.0p25.2019061300.f006.grib2 --name gfs.0p25.2019061300.f006.grib2
fi

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-17
    • 2021-12-08
    • 2016-10-26
    • 1970-01-01
    • 2015-08-22
    • 2020-11-09
    相关资源
    最近更新 更多