如何使用本地Azure Cli安装运行Azure Cli脚本 [英] How do I run Azure Cli Script using my local Azure Cli installation

查看:178
本文介绍了如何使用本地Azure Cli安装运行Azure Cli脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我很疯狂地问这个问题,对不起,这是否是一个愚蠢的问题.一定很明显,因为我到处搜索并且找不到答案!

First off I feel crazy asking this, sorry if this is a really stupid question. It must be obvious as I have searched everywhere and cannot find an answer!

我应该如何运行此Azure脚本来创建Azure Function应用? https://docs.microsoft.com/en-us/azure/azure-functions/scripts/functions-cli-create-serverless

How I am supposed to run this Azure script to create an Azure Function App? https://docs.microsoft.com/en-us/azure/azure-functions/scripts/functions-cli-create-serverless

#!/bin/bash

# Function app and storage account names must be unique.
storageName=mystorageaccount$RANDOM
functionAppName=myserverlessfunc$RANDOM

# Create a resource group.
az group create --name myResourceGroup --location westeurope

# Create an Azure storage account in the resource group.
az storage account create \
  --name $storageName \
  --location westeurope \
  --resource-group myResourceGroup \
  --sku Standard_LRS

# Create a serverless function app in the resource group.
az functionapp create \
  --name $functionAppName \
  --storage-account $storageName \
  --consumption-plan-location westeurope \
  --resource-group myResourceGroup

Clean up deployment

该页面提供了有关如何使用门户中的控制台运行它的示例,并且该页面还建议如果安装了我拥有的Azure CLI,则可以在本地运行它.我需要从本地计算机上运行它,以便可以使用参数对其进行自动化.

The page gives an example of how to run it using the console in the portal and the page also suggests I can run it locally if install the Azure CLI which I have. I need to run it from my local machine so that it can be automated with parameters.

但是此页面什么也没告诉我.

However this page tells me nothing.

该文件的扩展名应该是什么? .sh? 我要使用什么命令从cli调用脚本?

What should the extension of this file be ? .sh? What command do I use to call the script from my cli?

我尝试只输入保存为.sh的文件名

I have tried just typing the file name saved as .sh

例如,我有az --help,那里也看不到任何东西.

e.g I have az --help and I can't see anything there either.

推荐答案

我刚刚在Mac上进行了测试.

I just tested this on my Mac.

将脚本复制到扩展名为.sh的文件中.我使用了test.sh.

Copy the script into a file with the .sh extension. I used test.sh.

确保您已登录到Azure CLI的本地实例.

Make sure you are logged into your local instance of Azure CLI.

然后运行: . /<path>/test.sh

这篇关于如何使用本地Azure Cli安装运行Azure Cli脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆