This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
3-prepare-vm.bat
38 lines (29 loc) · 1.54 KB
/
3-prepare-vm.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
@echo off
REM #############################################################################################
REM # Ensure you have logged in to Azure with your credentials prior to running this script
REM # az login
REM # Ensure that you have the Azure subscription ID, it should show up after you have logged in and it has the format:
REM # "id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
REM # Ensure that you have installed in the virtual machine all you need prior to creating the image
REM #############################################################################################
REM #############################################################################################
REM # General variables used in the different Azure CLI commands run from this script
SET YOURSUBSCRIPTIONID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
SET RESOURCEGROUPNAME=myResourceGroup
SET REGIONNAME=japanwest
REM # Variables for preparing the Virtual Machine
SET VMNAME=myVirtualMachine
REM #############################################################################################
REM #############################################################################################
REM # Connect to Azure
CALL az login
REM # Set the Azure subscription
CALL az account set --subscription %YOURSUBSCRIPTIONID%
ECHO Stopping and deallocating the virtual machine named %VMNAME%
CALL az vm deallocate ^
--resource-group %RESOURCEGROUPNAME% ^
--name %VMNAME%
ECHO Generalizing the virtual machine named %VMNAME%
CALL az vm generalize ^
--resource-group %RESOURCEGROUPNAME% ^
--name %VMNAME%