无法使用Azure自定义脚本扩展名复制文件 [英] Unable to copy files using Azure Custom script extension

查看:101
本文介绍了无法使用Azure自定义脚本扩展名复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

配置完后,我想在Azure虚拟机中安装NAGIOS之类的工具.我想使用"Azure自定义脚本"来安装工具.下面是我正在使用的代码.

I want to install tools like NAGIOS inside an Azure virtual machine once it is provisioned. I want to use "Azure Custom Script" to install the tools. Below is the code that I am using.

作为自定义脚本发送的Powershell脚本:

new-item "C:\newfile.txt" -Type file
copy-item -Path "\\xxx.xx.x.x\c$\Nagios for windows" -Destination "C:\nagios" -Recurse
Start-Process "c:\nagios\NSCP-0.4.3.143-x64.msi" /qn -Wait

问题: 代码的第一行正在工作(我将其作为健全性检查来确认脚本确实在工作).但是,第二和第三行不起作用(最重要的部分).我也没有在日志中看到任何错误.有人可以帮我吗?

Problem: The first line of code is working (I have it as a sanity check to confirm that the script is indeed working). However, the second and third line is not working (the most important part). I am not seeing any errors in the logs as well. Can someone help me out, please?

推荐答案

作为解决方法,您可以将文件上传到Azure存储帐户(Blob,容器),然后使用PowerShell进行下载.

As a work around, you can upload your file to Azure storage account(Blob, Container), then use PowerShell to download it.

您可以这样创建容器:

然后通过Azure门户上传文件到该Blob.

Then upload file to that blob via Azure portal.

然后,您可以使用PowerShell命令下载:

Then you can use PowerShell command to download it:

Invoke-WebRequest -Uri https://jasondisk2.blob.core.windows.net/msi/01.PNG -outfile 'C:\'

您可以将此命令添加到Azure自定义脚本扩展中.

You can add this command to Azure custom script extension.

希望这会有所帮助.

这篇关于无法使用Azure自定义脚本扩展名复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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