azure】 azure命令行工具【win】


安装 azure 命令行

sudo apt-get install nodejs-legacy

sudo apt-get install npm

sudo npm install -g azure-cli

这将输出一个网址和一个设备代码,供你使用浏览器登录

azure login

这将在控制台中提示你的密码

azure login -u

这将使用一个服务委托人登录

azure login -u "" -p "" --service-principal --tenant ""

查找名称中含有Linux的image

azure vm image list | grep "Linux"

启动一个新的虚拟机(在asm模式下)

azure vm create ${vm_name} ${image_name} -u ${azureuser} -p "${password}" -z "Small" -e -l "West US"

列出虚拟机的磁盘

azure vm disk list

移除标有LABEL的虚拟机的所有磁盘

for disk in $(azure vm disk list | grep LABEL | awk '{print $2}')

do

    azure vm disk delete --blob-delete "$disk"

done

在 "West US "创建存储账户$myacct

azure storage account create ${storage_account} --label ${storage_account} --location 'West US'

设置默认账户环境变量

export AZURE_STORAGE_ACCOUNT=$account_name

export AZURE_STORAGE_ACCESS_KEY=$account_key

基于存储文件创建一个虚拟机镜像

azure vm image create ${image_name} --os linux -l 'West Europe' --blob-url https:${storage_account}.blob.core.windows.net:443/vms/${image_name}.vhd -v

分享一个文件(例如一个vm image)

azure storage blob sas create -a ${storage_account} --container ${container} --blob ${filename} --permissions r

使用curl/wget从blob存储中下载一个文件

头部变量的值可以像这样计算: https:gist.github.com/jrwren/ff46f4ba177f042ccdc48c080c198f60

curl -v \

  -H "$x_ms_date_h" \

  -H "$x_ms_version_h" \

  -H "$authorization_header" \

"$URL"


腾图小抄 SCWY.net v0.03 小抄561条 自2022-01-02访问365767次