我尝试使用此脚本将一些zip文件上传到Azure blob存储:
#!/bin/bash
# Sample script to upload a file to a BLOB container
if [ $# -eq 0 ]
then
echo "Please specify a filename"
exit 1
fi
# Required parameters
file_name=$1
azure_account=xxx
azure_key=xxx
container_name=xxx
blob_name=xxx
# Used by azure-cli
export AZURE_STORAGE_ACCOUNT=$azure_account
export AZURE_STORAGE_ACCESS_KEY=$azure_key
azure storage blob upload $file_name $container_name $blob_name
但每当我运行它时,我得到:
sh upload-file.sh file.zip info:执行命令存储blob 上传错误:无法调用方法' substr' null info:错误 信息已记录到/home/usr/.azure/azure.err错误:
storage blob upload命令失败
答案 0 :(得分:0)
我假设你在Windows上。以下内容适用于我的计算机上的PowerShell。
sh upload-file.sh file.zip
脚本开头的#!/bin/bash
表示that it is supposed to use bash
to execute。 您是否安装了bash?通过bash --version
进行检查。
> bash --version
GNU bash, version 3.1.23(6)-release (i686-pc-msys)
Copyright (C) 2005 Free Software Foundation, Inc.
如果您没有bash,请安装它。我在Windows上安装bash
的方式是msysGit。这将安装所谓的git-bash和Git for Windows。还有其他方法可以在Windows上安装bash,例如win-bash和cygwin,但我对这些方法并不熟悉。