Created
November 16, 2019 03:18
-
-
Save dzeyelid/23209409d6ff2b2814f5e5fe16ccdada to your computer and use it in GitHub Desktop.
Bash script to create an environment for Azure Bastion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX=try-bastion | |
RESOURCE_GROUP_NAME=${PREFIX}-rg | |
LOCATION=japaneast | |
VNET_NAME=${PREFIX}-vnet | |
SUBNET_NAME=${PREFIX}-subnet | |
BASTION_NAME=${PREFIX}-bastion | |
BASTION_PUBLICIP_NAME=${PREFIX}-bastion-ip | |
VM_NAME=${PREFIX}-vm | |
VM_ADMIN_USERNAME=<Your username> | |
VM_ADMIN_PASSWORD=<Your password> | |
az login | |
az group create \ | |
--name ${RESOURCE_GROUP_NAME} \ | |
--location ${LOCATION} | |
vnet=$(az network vnet create \ | |
--resource-group ${RESOURCE_GROUP_NAME} \ | |
--name ${VNET_NAME} \ | |
--subnet-name AzureBastionSubnet \ | |
--subnet-prefix 10.0.0.0/24) | |
subnet=$(az network vnet subnet create \ | |
--resource-group ${RESOURCE_GROUP_NAME} \ | |
--name ${SUBNET_NAME} \ | |
--vnet-name ${VNET_NAME} \ | |
--address-prefixes 10.0.1.0/24) | |
az network public-ip create \ | |
--resource-group ${RESOURCE_GROUP_NAME} \ | |
--name ${BASTION_PUBLICIP_NAME} \ | |
--location ${LOCATION} \ | |
--allocation-method Static \ | |
--sku Standard | |
SUBNET_ID=$(echo $subnet | jq .id -r) | |
az vm create \ | |
--resource-group ${RESOURCE_GROUP_NAME} \ | |
--name ${VM_NAME} \ | |
--image MicrosoftWindowsDesktop:Windows-10:19h1-pro:18362.418.1910070306 \ | |
--admin-username ${VM_ADMIN_USERNAME} \ | |
--admin-password ${VM_ADMIN_PASSWORD} \ | |
--subnet ${SUBNET_ID} \ | |
--public-ip-address "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment