无法从自定义脚本扩展运行AzureRM命令 [英] Unable to Run AzureRM commands from Custom Script Extension

查看:90
本文介绍了无法从自定义脚本扩展运行AzureRM命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在运行一个ARM模板,该模板先部署一个VM,然后在Custom Script extension的帮助下运行一个脚本.该脚本很简单,它将在本地VM上创建一个文件,然后尝试将其上传到Azure存储.当我提到Login-AzureRMAccount 在脚本中它无法显示未找到命令.因此,尽管我可能需要先安装AzureRM模块,当我尝试运行Install-Module -Name AzureRM时,脚本仍在继续运行.所以主要的问题是我无法运行任何相关的命令 通过自定义脚本扩展到AzureRM模块

I am running a ARM template which deploys a VM and then runs a script with the help of Custom Script extension.The Script is simple it will create a file on the local VM and then try to upload it to the Azure Storage .When I mention Login-AzureRMAccount in the script it fails saying that command not found.So I though maybe I need to install AzureRM module first ,when i try to run Install-Module -Name AzureRM the scripts keeps on running.So mainly the problem is that i am not able to run any commands related to AzureRM module through Custom Script Extension

推荐答案

尝试在安装模块AzureRM的末尾添加-Force命令

Try adding the -Force Command to the end of Install-Module AzureRM

所以这样

获取模块AzureRM I
nstall-Module AzureRM -Force

Get-Module AzureRM I
nstall-Module AzureRM -Force

如果要运行Azure PowerShell命令,一种简单的解决方案是登录到VM并安装模块.这样,您每次在VM上运行新脚本时都将安装它.

Easily solution if you are going to be running Azure PowerShell commands is to login to the VM and install the module. That way it is installed every time you run a new script against the VM.


这篇关于无法从自定义脚本扩展运行AzureRM命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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