问题
I need help to rectify one trouble which i am facing, am hosting my application through Azure auto scale set feature (virtual machine scale set) , when it get huge hit it will automatically scale up and an reverse when hit down, for that i need to maintain a azure storage location as well, so while push the code i need to push the similar code to azure storage from one of the VM , if we have fixed VM name we can use azcopy to push code to azure store but since its auto scale i don't have particular VM name.
simply for eg, currently there is 100 scale set servers/vm's are in pool i need to push code to azure storage from one of the server from that 100 and i dont have any particular name for that servers, how does it possible ??? condition is only one time i have push code to storage from one server.
回答1:
You can just use this PS command :
Get-AzVmssVM -ResourceGroupName <resource group name> -VMScaleSetName <VMSS name>
To get all instance names so that you can perform your copy logic. And refer to this post to retry the whole process in case of the instance that you picked get deleted while you copying data by your scaling rules.
If you want to get 1 VM from the VM list, you can just get the first one in the list as below:
$destVM = (Get-AzVmssVM -ResourceGroupName <group name> -VMScaleSetName <vmss name>)[0]
来源:https://stackoverflow.com/questions/64881572/code-sync-from-azure-scale-set-vm-to-azure-storage