0

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.

Prasanth K S
  • 63
  • 1
  • 2
  • 7

1 Answers1

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]

enter image description here

Stanley Gong
  • 11,522
  • 1
  • 8
  • 16
  • Yes seems this will be nice idea , but in between after executing Get-AzVmssVM command there will be 50 plus servers , but i just need to consider one among them . from that particular one server i need to push the code to azure storage . how we can select a particular server which is existing in that 50 servers ? –  Prasanth K S Nov 18 '20 at 06:09
  • @PrasanthKS,Glad to know that my solution is helpful. Please click on the check mark beside the answer to toggle it from greyed out to filled in to mark it as an answer, so that it will help others and close this query : ) – Stanley Gong Nov 18 '20 at 07:41
  • Thanks @Stanley Gong ..its helped for my requirement –  Prasanth K S Nov 18 '20 at 07:51
  • one more , how can include IP of VM in $destVM as out put @Stanley Gong –  Prasanth K S Nov 18 '20 at 08:01
  • @PrasanthKS, if the original issue has been solved, please mark this answer fist and for the new query, please raise a new case. On stack overflow, it's one question one case : ) – Stanley Gong Nov 18 '20 at 08:15
  • IP also part of my question , since Remote login is enabled though IP , that's why i am waiting to mark.. –  Prasanth K S Nov 18 '20 at 08:25
  • @PrasanthKS, I see, thanks for your mark and I think you can refer to this for public IP of vmss instance: https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-networking#querying-the-public-ip-addresses-of-the-virtual-machines-in-a-scale-set – Stanley Gong Nov 18 '20 at 08:48