SOLVED

Create and configure several Virtual machine

%3CLINGO-SUB%20id%3D%22lingo-sub-2331138%22%20slang%3D%22en-US%22%3ECreate%20and%20configure%20several%20Virtual%20machine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2331138%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CBR%20%2F%3EPlease%20help%20to%20understand%20if%20it's%20possible%20to%20write%20PowerShell%20script%20for%20next%20steps.%3CBR%20%2F%3E1.Connect%20to%20Azure%3CBR%20%2F%3E2.%20Create%20Virtual%20machine%3CBR%20%2F%3E3.%20Make%20additional%20configurations%20into%20VM%20(by%20Remote%20PowerShell%20Session%3F%3F)%20without%20additional%20direct%20connect%20to%20VM%20for%20switching%20of%20firewall%20on%20VM%20level%2C%20for%20example%2C%26nbsp%3B%20and%20etc.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2331424%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20and%20configure%20several%20Virtual%20machine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2331424%22%20slang%3D%22en-US%22%3EHi%2C%20if%20you%20don't%20want%20to%20%2F%20cannot%20expose%20your%20VM%20to%20the%20Internet%20(so%20you%20can%20connect%20to%20it%20from%20your%20machine)%20and%20if%20we%20exclude%20options%20like%20P2S%20VPN%20between%20your%20machine%20an%20Azure%20VNet%2C%20where%20your%20VM%20gets%20deployed%2C%20there%20are%20three%20options%3A%3CBR%20%2F%3E1.%20You%20can%20use%20a%20Custom%20script%20VM%20Extension%20with%20either%20a%20shell%20or%20a%20PowerShell%20script.%20The%20script%20itself%20could%20either%20be%20provided%20in-line%20or%20referenced%20via%20a%20public%20URI.%20VM%20Extensions%20are%20Azure%20resources%2C%20so%20they%20can%20be%20created%20programmatically%20in%20both%20imperative%20(script)%20and%20declarative%20(ARM%20JSON%2C%20Bicep%2C%20Terraform)%20way.%20More%20info%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Fcustom-script-windows%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Fcustom-script-windows%3C%2FA%3E%3CBR%20%2F%3E2.%20You%20could%20use%20Run%20Command%20feature%2C%20more%20info%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fwindows%2Frun-command%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fwindows%2Frun-command%3C%2FA%3E%3CBR%20%2F%3E3.%20You%20could%20use%20a%20proven%20Config%20management%20tool%20like%20Chef%2C%20Puppet%2C%20Ansible%2C%20etc.%20but%20this%20requires%20more%20infrastructure%2C%20and%20it%20is%20more%20complex%20to%20implement.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2332405%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20and%20configure%20several%20Virtual%20machine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2332405%22%20slang%3D%22en-US%22%3EThank%20you%20very%20much.%3CBR%20%2F%3Eit%20looks%20it%20works.%20It's%20cool%20!%3CBR%20%2F%3EI%20couldn't%20believe%20that%20it%20can%20be%20so%20easy.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2332406%22%20slang%3D%22en-US%22%3ERe%3A%20Create%20and%20configure%20several%20Virtual%20machine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2332406%22%20slang%3D%22en-US%22%3EI'm%20glad%20it%20helped%20you%2C%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1046745%22%20target%3D%22_blank%22%3E%40Serg08%3C%2FA%3E.%20Take%20care.%3C%2FLINGO-BODY%3E
New Contributor

Hi
Please help to understand if it's possible to write PowerShell script for next steps.
1.Connect to Azure
2. Create Virtual machine
3. Make additional configurations into VM (by Remote PowerShell Session??) without additional direct connect to VM for switching of firewall on VM level, for example,  and etc.

3 Replies
best response confirmed by Serg08 (New Contributor)
Solution
Hi, if you don't want to / cannot expose your VM to the Internet (so you can connect to it from your machine) and if we exclude options like P2S VPN between your machine an Azure VNet, where your VM gets deployed, there are three options:
1. You can use a Custom script VM Extension with either a shell or a PowerShell script. The script itself could either be provided in-line or referenced via a public URI. VM Extensions are Azure resources, so they can be created programmatically in both imperative (script) and declarative (ARM JSON, Bicep, Terraform) way. More info: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
2. You could use Run Command feature, more info here: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/run-command
3. You could use a proven Config management tool like Chef, Puppet, Ansible, etc. but this requires more infrastructure, and it is more complex to implement.
Thank you very much.
it looks it works. It's cool !
I couldn't believe that it can be so easy.
I'm glad it helped you, @Serg08. Take care.