带有的Azure VMSS中的customScript扩展



我曾经创建一个扩展,如下

--version 2.0 --publisher Microsoft.Azure.Extensions 
--settings '{
"fileUris": ["https://$saName.blob.core.windows.net/$scName/agent.sh"],
"commandToExecute": "sh agent.sh"
}'

然而,最近我们限制了blob存储的公共访问,因此我不能以上述方式访问,而是需要生成一个SAS URI并通过该方式访问。所以问题是如何将SAS URI放入fileUris值中?下载像这样的代理.sh是不起作用的

https://$saName.blob.core.windows.net/$scName?sp=r&st=2021-12-20T08:50:14Z&se=2099-12-20T16:50:14Z&spr=https&sv=2020-08-04&sr=c&sig=xxxxxxxxxxxxxxxxx/agent.sh

那么我该怎么办呢?

一旦生成了具有所需权限的SAS就可以将其与您正在使用的文件uri连接起来,如<fileusri><SAS Token>

https://$saName.blob.core.windows.net/$scName/agent.sh?sv=2020-08-04&ss=bfqt&srt=sco&sp=rwltfx&se=2021-12-31T13:10:45Z&st=2021-12-31T05:10:45Z&spr=https&sig=xxxxxxxxxxxxxxxxxxxxxxx

否则,正如VenkateshDodda MT所建议的那样,您可以提供VMSSStorage Blob Data ReaderStorage Blob Data Contributor的标识后,在设置参数使用VMSS的托管标识角色:

--version 2.0 --publisher Microsoft.Azure.Extensions 
--settings '{
"fileUris": ["https://$saName.blob.core.windows.net/$scName/agent.sh"],
"managedIdentity":{"objectId": "you can find this ID in the Identity blade of the VMSS in azure portal"}
"commandToExecute": "sh agent.sh"
}'

参考:

用于Windows的Azure自定义脚本扩展-Azure虚拟机|Microsoft Docs

最新更新