azure - 在 Windows VM 中使用 VM 自定义扩展安装 Azure 文件时出现问题
问题描述
我在使用 Powershell 预配 VM 时尝试挂载 Azure 文件共享。共享确实显示了,但由于用户名或密码不正确而“断开连接”。如果我 RDP 进入服务器并自己运行脚本,则文件共享安装没有问题。以下是我在 powershell 脚本和 ARM TEMPLATE 扩展资源中使用的内容。
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2019-07-01",
"name": "[concat(parameters('virtualMachines_azvmtest_name'), '/newCustomScriptExtension')]",
"location": "westus",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/',parameters('virtualMachines_azvmtest_name'))]"
],
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.9",
"autoUpgradeMinorVersion":true,
"settings": {
"fileUris": [
"https://xyz.blob.core.windows.net/fileshare/fileshare.ps1#key is masked"
],
"commandToExecute": "powershell.exe -ExecutionPolicy Unrestricted -File fileshare.ps1"
},
"protectedSettings": {}
}
}
Below is the power shell code:
Invoke-Expression -Command ("cmdkey /add:`"XYZ.file.core.windows.net`" /user:`"Azure\XYZ`" /pass:`"KEY MASKED`"")
$password = ConvertTo-SecureString -String "KEY MASKED" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential -ArgumentList "AZURE\XYZ", $password
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\XYZ.file.core.windows.net\abc" -Credential $credential -Persist
扩展已成功配置,但我无法打开它显示为断开连接的已安装文件共享。
解决方案
推荐阅读
- json - 如何使用邮递员在错误消息中返回键/值进行 ajv 验证
- angularjs - 对于复选框,ng-dropdown-multiselect 在 angularjs 中与 ng-disabled 一起使用
- c - 如何使系统函数调用起作用?
- reactjs - 可重用的反应组件将数据动态绑定到多个列表中的多个下拉列表
- java - 使用罗马数字删除编号
- mysql - 每次使用mysql时`join`都会生成笛卡尔积吗?
- javascript - 有没有办法使用 Nightmare 或类似的方法来访问 json 响应?
- url-rewriting - 如何制定此重写规则以便它可以接受查询字符串?
- java - 在 spring-data-elasticsearch 项目的 Criteria 类中使用 not() 方法时出现异常
- mysql - 对于有两位作者的每本书的选择标题、出版商名称、类型和作者姓名,没有得到任何结果