infraascode

Deploy Azure VM Pool and Load Balancer

Neste post iremos demonstrar o deploy de Virtuais Machines em Windows Server 2016 com IIS Habilitado, porém iremos fazer em alta disponibilidade com metade de nosso ambiente em ZONA 1 e a outra metade em ZONE 2, a diferença aqui será no deploy feito com @Array, com isso conseguimos criar varias VMs em apenas uma linha de comando azure cli bash.

Vamos ao nosso cenário:

Vamos ao nosso código bash (azure cli)

##Declarando Variaveis (Obrigatório)
export Subscription_Name="XXXXXXXXXXXXX"  ###Substituir pela sua subscription
export RG="rg"
export Depto_Corp="corp"
export ObjectNameCorp="web"
export Env="prod"
export Location="eastus"
export RGNameCorpWeb="${RG}"-"${Depto_Corp}"-"${ObjectNameCorp}"-"${Env}"-"${Location}"

##Declarando Variaveis de Rede
export vnet="vnet"
export VnetNameWEB="${vnet}"-"${Depto_Corp}"-"${ObjectNameCorp}"-"${Env}"-"${Location}"
export CIDR_WEB="10.40.50.0/24"
export Prefix_WEBFE01="10.40.50.0/26"
export Prefix_WEBFE02="10.40.50.64/26"
export snet="snet"
export SnetNameWebFE01="${snet}"-"${Depto_Corp}"-"${ObjectNameCorp}"-"${Env}"-"${Location}"-fe01
export SnetNameWebFE02="${snet}"-"${Depto_Corp}"-"${ObjectNameCorp}"-"${Env}"-"${Location}"-fe02

##Declarando Variaveis de VMs
export VM_Object_Name="vm"
export VMName="${VM_Object_Name}""${ObjectNameCorp}""${Env}"
export SKU="Standard_LRS"
export Image_Windows="Win2016Datacenter"
export OsDisk_Name="disk-os"
export Zone01="1"
export Zone02="2"
export UserName="azroot"
export Password="[email protected]#"
export VMSize="Standard_DS1_v2"

##Declarando Variaveis de Interfaces de Rede
export Int_Object_Name01="int"
export Int_Object_Name02="eth"
export Int_Number="0"
export IntNameWeb="${Int_Object_Name01}"-"${Int_Object_Name02}""${Int_Number}"-"${VM_Object_Name}"-"${ObjectNameCorp}"-"${Location}"

##Declarando Variaveis de Storage Account
export Storage_Object_Name01="stg"
export Storage_Object_Name02="diag"
export StorageNameFE="${Storage_Object_Name01}""${Storage_Object_Name02}""${VM_Object_Name}""${ObjectNameCorp}""${Depto_Corp}"

##Declarando Variaveis NSG
export NSG_Object_Name="nsg"
export NSGWEB="${NSG_Object_Name}"-"${snet}"-"${Depto_Corp}"-"${Env}"-"${Location}"-fe

##Variaveis de Load Balance
export ObjectNameWebLB="lb"
export ObjectName_WebLB="${ObjectNameWebLB}"-"${Depto_Corp}"-"${ObjectNameCorp}"-"${Env}"-"${Location}"
export SKULB="Standard"
export PoolFE="PoolFE"
export PoolBE="PoolBackend"

##Declarando Variaveis de IP Publico
export PublicIPWebObject="pip"
export PublicIPWebSku="Standard"
export PublicIPNameWeb01="${PublicIPWebObject}"-"${Depto_Corp}"-"${ObjectNameCorp}"-"${Env}"-"${Location}"-1

##Variaveis de Tags
export Description="Departamento"
export Value_Description="${Depto_Corp}"
export Cost_Center="Centro de Custo"
export Cost_Center_Value="${Depto_Corp}"
export Support_Description_Description="E-mail Suporte"
export Support_Description_Value="support"-"${Depto_Corp}""@xpto.com"

###Selecionar subscription
az account set --subscription "${Subscription_Name}"

###Criando Resource Group
az group create -n "${RGNameCorpWeb}" -l "${Location}" \
--tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

###Criando Storage Account
az storage account create -g "${RGNameCorpWeb}" -n "${StorageNameFE}" --sku "${SKU}" -l "${Location}" --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

###Criando NSG
az network nsg create -g "${RGNameCorpWeb}" -n "${NSGWEB}" -l "${Location}" \
--tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

###Criando Regras NSG InBound
az network nsg rule create -g "${RGNameCorpWeb}" --nsg-name "${NSGWEB}"  --name 'AllowHttpsInBound' \
--protocol 'tcp' --direction 'inbound' --source-address-prefix 'internet' --source-port-range '*' \
--destination-address-prefix '*' --destination-port-range '443' --access 'Allow' --priority '120'

az network nsg rule create -g "${RGNameCorpWeb}" --nsg-name "${NSGWEB}"  --name 'AllowHttpInBound' \
--protocol 'tcp' --direction 'inbound' --source-address-prefix 'internet' --source-port-range '*' \
--destination-address-prefix '*' --destination-port-range '80' --access 'Allow' --priority '121'

###Criando Vnet
az network vnet create -g "${RGNameCorpWeb}" -n "${VnetNameWEB}" --address-prefix "${CIDR_WEB}" \
-l "${Location}" --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

###Criando Snet
az network vnet subnet create -g "${RGNameCorpWeb}" --vnet-name "${VnetNameWEB}" \
-n "${SnetNameWebFE01}" --address-prefixes "${Prefix_WEBFE01}"

az network vnet subnet create -g "${RGNameCorpWeb}" --vnet-name "${VnetNameWEB}" \
-n "${SnetNameWebFE02}" --address-prefixes "${Prefix_WEBFE02}"

###Anexando NSG a Snet
az network vnet subnet update -g "${RGNameCorpWeb}" --vnet-name "${VnetNameWEB}" \
-n "${SnetNameWebFE01}" --network-security-group "${NSGWEB}"

az network vnet subnet update -g "${RGNameCorpWeb}" --vnet-name "${VnetNameWEB}" \
-n "${SnetNameWebFE02}" --network-security-group "${NSGWEB}"

###Criando IP Publico
az network public-ip create -g "${RGNameCorpWeb}" -n "${PublicIPNameWeb01}" --sku "${PublicIPWebSku}"

##Criando interfaces de Rede (Snet1)
array=("${IntNameWeb}"-001 "${IntNameWeb}"-002 "${IntNameWeb}"-003 "${IntNameWeb}"-004 "${IntNameWeb}"-005)
  for vmnic in "${array[@]}"
  do
    az network nic create \
    --resource-group "${RGNameCorpWeb}" --name $vmnic --vnet-name "${VnetNameWEB}" --subnet "${SnetNameWebFE01}"
  done

##Criando interfaces de Rede (Snet2)
array=("${IntNameWeb}"-006 "${IntNameWeb}"-007 "${IntNameWeb}"-008 "${IntNameWeb}"-009 "${IntNameWeb}"-010)
  for vmnic in "${array[@]}"
  do
    az network nic create \
    --resource-group "${RGNameCorpWeb}" --name $vmnic --vnet-name "${VnetNameWEB}" --subnet "${SnetNameWebFE02}"
  done

###Criando Maquinas Virtuais
array=(-001 -002 -003 -004 -005)
  for n in "${array[@]}"
  do
    az vm create -g "${RGNameCorpWeb}" --name "${VMName}"$n --nics "${IntNameWeb}"$n \
    --image "${Image_Windows}" \
    --admin-username "${UserName}" \
    --admin-password "${Password}" \
    --os-disk-name "${OsDisk_Name}"-"${VMName}"$n \
    --zone "1" --size "${VMSize}" \
    --boot-diagnostics-storage "${StorageNameFE}" \
    --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"
    done

array=(-006 -007 -008 -009 -010)
  for n in "${array[@]}"
  do
    az vm create -g "${RGNameCorpWeb}" --name "${VMName}"$n --nics "${IntNameWeb}"$n \
    --image "${Image_Windows}" \
    --admin-username "${UserName}" \
    --admin-password "${Password}" \
    --os-disk-name "${OsDisk_Name}"-"${VMName}"$n \
    --zone "2" --size "${VMSize}" \
    --boot-diagnostics-storage "${StorageNameFE}" \
    --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"
    done

###Ativando IIS nas VMs criadas
array=(-001 -002 -003 -004 -005 -006 -007 -008 -009 -010)
  for n in "${array[@]}"
  do
    az vm extension set --publisher Microsoft.Compute --version 1.8 --name CustomScriptExtension \
    --vm-name "${VMName}"$n --resource-group "${RGNameCorpWeb}" \
    --settings '{"commandToExecute":"powershell Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature -IncludeManagementTools; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}'
    done

##Criando Load Balance
az network lb create -g "${RGNameCorpWeb}" -n "${ObjectName_WebLB}" --sku "${SKULB}" \
--frontend-ip-name "${PoolFE}" --backend-pool-name "${PoolBE}" --public-ip-address "${PublicIPNameWeb01}" \
--tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

#Create health probe on port 80/443
az network lb probe create -g "${RGNameCorpWeb}" --lb-name "${ObjectName_WebLB}" \
--name "Probe-HTTPS" --protocol tcp --port 443

az network lb probe create -g "${RGNameCorpWeb}" --lb-name "${ObjectName_WebLB}" \
--name "Probe-HTTP" --protocol tcp --port 80

#Create load balancer rule for port 80/443
az network lb rule create -g "${RGNameCorpWeb}" --lb-name "${ObjectName_WebLB}" \
--name "HTTP" --protocol "tcp" --frontend-port 80 --backend-port 80 --frontend-ip-name "${PoolFE}" \
--backend-pool-name "${PoolBE}" --probe-name Probe-HTTP

az network lb rule create -g "${RGNameCorpWeb}" --lb-name "${ObjectName_WebLB}" \
--name "HTTPS" --protocol "tcp" --frontend-port 443 --backend-port 443 --frontend-ip-name "${PoolFE}" 
--backend-pool-name "${PoolBE}" --probe-name Probe-HTTPS

#Adicionando Inteface REDE ao pool de backend Load Balance
array=("${IntNameWeb}"-001 "${IntNameWeb}"-002 "${IntNameWeb}"-003 "${IntNameWeb}"-004 "${IntNameWeb}"-005 "${IntNameWeb}"-006 "${IntNameWeb}"-007 "${IntNameWeb}"-008 "${IntNameWeb}"-009 "${IntNameWeb}"-010)
  for vmnic in "${array[@]}"
  do
    az network nic ip-config address-pool add \
        --resource-group "${RGNameCorpWeb}" \
        --nic-name $vmnic \
        --address-pool "${PoolBE}" \
        --ip-config-name "ipconfig1" \
        --lb-name "${ObjectName_WebLB}"
        done

####Fim do Script

Vamos aos objetos criados

Nossas VM em Zonas diferentes ###

Nosso LB

Vamos ver nossoas VM com ISS instalado

Agora vamos ver na prática o funcionamento, fiz os acessos via celular

Espero ter ajudado.

Seja Feliz!!!!!!!!!!!!!

Deploy Azure Firewall (EDGE)(bash) infraestrutura

Olá, neste post iremos fazer o deploy do Azure Firewall em uma infraestrutura de Firewal EDGE (como ja feito com Palo Alto e Fortigate)
Nesta topologia teremos Azure Firewall como borda de toda rede Azure (neste exemplo)

Vamos aos objetos criados

ObjetoNameDescrição
Resource Grouprg01-fw-edge-shared-brazilsouthRG
Azure Firewallfw-edgeStandard
Public IPpip-fw-edge-shared-brazilsouth-nat-outxxx.xxx.xxx.xxx
Public IPpip-fw-edge-shared-brazilsouth-nat-rdpxxx.xxx.xxx.xxx
Public IPpip-fw-edge-shared-brazilsouth-nat-sshxxx.xxx.xxx.xxx
Route Tablert-fw-edge-shared-brazilsouthRoute Table
Virtual Networkvnet-fw-edge-shared-brazilsouth10.225.0.0/22

*Não criamos aqui as VMs (Windows/Linux), mas elas estão na SubNet AzureFirewallSubnet-Trust
Nossas Subnets

AzureFirewallSubnet = 10.225.0.0/24
AzureFirewallManagementSubnet = 10.225.1.0/24
AzureFirewallSubnet-Trust = 10.225.2.0/24

Vamos ao nosso script bash

##Declarando variaveis Subscription(obrigatórias)
export Subscription_Name="XXXXX" ###Insira aqui sua subscription Azure

##Declarando variaveis Resource Group(obrigatórias)
export Name_RG_01="rg01"
export Name_RG_02="fw-edge"
export Name_Environment="shared"
export Location_Region="brazilsouth"
export RG_FULL_NAME="${Name_RG_01}"-"${Name_RG_02}"-"${Name_Environment}"-"${Location_Region}"

###Declarando variaveis Firewall (Obrigatório)
export FW_Name01="fw"

##Declarando Variaveis da Vnet (Obrigatório)
export Vnet_Name01="vnet"
export Vnet_FULL_Name="${Vnet_Name01}"-"${Name_RG_02}"-"${Name_Environment}"-"${Location_Region}"
export CIDR="10.225.0.0/22"

##Declarando Variaveis da Subnet (Obrigatório)
export SubnetName="AzureFirewallSubnet"
export Prefix="10.225.0.0/24"
export SubnetName02="AzureFirewallManagementSubnet"
export Prefix02="10.225.1.0/24"
export SubnetName03="AzureFirewallSubnet-Trust"
export Prefix03="10.225.2.0/24"

##Declarando Variaveis SKU/TIER
export SKU="AZFW_VNet"
export TIER="Standard"
export NameIP_01="ifconfig1"
export NameIP_02="nat-ssh"
export NameIP_03="nat-rdp"

##Declarando variaveis de ZONA
export ZONES="1"

##Declarando Variaveis IP Publico
export Public_IP_01="pip"
export Public_IP_02="${Public_IP_01}"-"${Name_RG_02}"-"${Name_Environment}"-"${Location_Region}"-"${Collection_Name03}"
export Public_IP_03="${Public_IP_01}"-"${Name_RG_02}"-"${Name_Environment}"-"${Location_Region}"-"${Collection_Name01}"
export Public_IP_04="${Public_IP_01}"-"${Name_RG_02}"-"${Name_Environment}"-"${Location_Region}"-"${Collection_Name02}"
export SKU_IP="Standard"
export IP_Zone="1"
export AlLocation="Static"
export Tier_IP="Regional"

###Declarando Variaveis de Route Table
export RT_Name01="rt"
export RT_Name02="${RT_Name01}"-"${Name_RG_02}"-"${Name_Environment}"-"${Location_Region}"
export RT_Name03="Default"
export Prefix_Address01="0.0.0.0/0"

###Declarando Variaveis NAT RULE
export Collection_Name01="nat-ssh"
export Collection_Name02="nat-rdp"
export Collection_Name03="nat-out"
export Destination01="10.225.2.4"

###Declarando Variaveis para acesso a internet HTTP/HTTPs
export Colletion_Name_Internet="Acesso_Internet"

##Variaveis TAGs (Não Obrigatório)
export Description="Departamento"
export Value_Description="Redes/Telecom/Segurança/Infraestrutura"
export Cost_Center="Centro de Custo"
export Cost_Center_Value="Redes/Telecom/Segurança/Infraestrutura"
export Support_Description_Description="E-mail Suporte"
export Support_Description_Value="[email protected]"

###Selecionar subscription
az account set --subscription "${Subscription_Name}"

##Criando RG
az group create -n "${RG_FULL_NAME}" -l "${Location_Region}" --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

####Criando Virtual Network (Vnet)
az network vnet create -g "${RG_FULL_NAME}" -n "${Vnet_FULL_Name}" --address-prefix "${CIDR}" -l "${Location_Region}" --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

###Criando Subnet 
az network vnet subnet create -g "${RG_FULL_NAME}" --vnet-name "${Vnet_FULL_Name}" -n "${SubnetName}" --address-prefixes "${Prefix}"
az network vnet subnet create -g "${RG_FULL_NAME}" --vnet-name "${Vnet_FULL_Name}" -n "${SubnetName02}" --address-prefixes "${Prefix02}"
az network vnet subnet create -g "${RG_FULL_NAME}" --vnet-name "${Vnet_FULL_Name}" -n "${SubnetName03}" --address-prefixes "${Prefix03}"

###Criando IP Publico
az network public-ip create -n "${Public_IP_02}" -g "${RG_FULL_NAME}" -l "${Location_Region}" --zone "${IP_Zone}" --allocation-method "${AlLocation}" --sku "${SKU_IP}" --tier "${Tier_IP}" --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"
az network public-ip create -n "${Public_IP_03}" -g "${RG_FULL_NAME}" -l "${Location_Region}" --zone "${IP_Zone}" --allocation-method "${AlLocation}" --sku "${SKU_IP}" --tier "${Tier_IP}" --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"
az network public-ip create -n "${Public_IP_04}" -g "${RG_FULL_NAME}" -l "${Location_Region}" --zone "${IP_Zone}" --allocation-method "${AlLocation}" --sku "${SKU_IP}" --tier "${Tier_IP}" --tags "${Description}"="${Value_Description}" "${Cost_Center}"="${Cost_Center_Value}" "${Support_Description_Description}"="${Support_Description_Value}"

##Criando Azure Firewall
az network firewall create -g "${RG_FULL_NAME}" -n "${Name_RG_02}" --sku "${SKU}" --tier "${TIER}" -z "1" --threat-intel-mode "Alert"

##Associando IP Publico Azure Firewall
az network firewall ip-config create --firewall-name "${Name_RG_02}" --name "${NameIP_01}" --public-ip-address "${Public_IP_02}" -g "${RG_FULL_NAME}" --vnet-name "${Vnet_FULL_Name}"
az network firewall ip-config create --firewall-name "${Name_RG_02}" --name "${NameIP_02}" --public-ip-address "${Public_IP_03}" -g "${RG_FULL_NAME}"
az network firewall ip-config create --firewall-name "${Name_RG_02}" --name "${NameIP_03}" --public-ip-address "${Public_IP_04}" -g "${RG_FULL_NAME}"

###Declarando Variaveis para utilizar IP privado do Azure Firewall
fwprivaddr01="$(az network firewall ip-config list -g "${RG_FULL_NAME}" -f "${Name_RG_02}" --query "[?name=='ifconfig1'].privateIpAddress" --output tsv)"
fwprivaddr02="$(az network public-ip show -g "${RG_FULL_NAME}" -n "${Public_IP_03}" --query "{address: ipAddress}" --output tsv)"
fwprivaddr03="$(az network public-ip show -g "${RG_FULL_NAME}" -n "${Public_IP_04}" --query "{address: ipAddress}" --output tsv)"

###Crando Route Table
az network route-table create -n "${RT_Name02}" -g "${RG_FULL_NAME}" -l "${Location_Region}" --disable-bgp-route-propagation "true"

###Associando Route Table a Subnet
az network vnet subnet update -n "${SubnetName03}" -g "${RG_FULL_NAME}" --vnet-name "${Vnet_FULL_Name}" --address-prefixes "${Prefix03}" --route-table "${RT_Name02}"

###Criando Static Route
az network route-table route create -g "${RG_FULL_NAME}" --name "${RT_Name03}" --route-table-name "${RT_Name02}" --address-prefix "${Prefix_Address01}" --next-hop-type "VirtualAppliance" --next-hop-ip-address $fwprivaddr01

###Criando regra de NAT para acessar uma VM com IP interno 10.255.2.4
az network firewall nat-rule create --collection-name "${Collection_Name}" \
--dest-addr "$fwprivaddr02" --destination-ports "22" --firewall-name "${Name_RG_02}" \
--name "nat-ssh-vm01" --protocols "tcp" -g "${RG_FULL_NAME}" --translated-port "22" \
--action "Dnat" --description "Acesso a VM01" --priority "200" \
--source-addresses "179.xxx.182.42/32" --translated-address "10.225.2.4"

###Criando regra de NAT para acessar uma VM com IP interno 10.255.2.5
az network firewall nat-rule create --collection-name "${Collection_Name02}" \
--dest-addr "$fwprivaddr03" --destination-ports "22" --firewall-name "${Name_RG_02}" \
--name "nat-rdp-vm02" --protocols "tcp" -g "${RG_FULL_NAME}" --translated-port "3389" \
--action "Dnat" --description "Acesso a VM02" --priority "201" \
--source-addresses "179.xxx.182.42/32" --translated-address "10.225.2.5"

###Criando Regras de acesso para Internet (somente HTTP/HTTPs)
az network firewall network-rule create --collection-name "${Colletion_Name_Internet}" \
--destination-ports "80" "443" --firewall-name "${Name_RG_02}" --name "Acesso a Internet" \
--protocols "tcp" --resource-group "${RG_FULL_NAME}" --action "Allow" \
--description "Acesso a Internet rede 10.225.2.0/24" --dest-addr "0.0.0.0/0" \
--priority "200" --source-addresses "10.225.2.0/24" 

###Fim do script

Vemos a VM Windows

Vemos a VM Linux

Agora vemos o NAT OutBound para acesso a internet

Windows (mesmo IP cadastrado no Firewall)

Linux (mesmo IP cadastrado no Firewall)

Em cima desta topologia podemos criar varias Vnets com peering e fazer do azure firewall nossa BORDA (EDGE), tudo contralado em um só lugar.

Seja Feliz!!!!

DEPLOY Fortigate HA AZURE CLI (BASH) TEMPLATE ARM

Neste post iremos fazer o deploy de Fortigate (Version 7) em HA (Active/Passive) “Load Balance (ELB/ILB)”, utilizando um template modificado fornecido pela prória fortigate (adequado as preferencias para este artigo de exemplo).
Nesta topologia/arquitetura de rede colocamos o Fortigate EDGE para ser a rota default de todas as nossas vnets que estão no azure, com isso toda entrada ou saida de dados passa obrigatóriamente pelo Fortigate EDGE, essa arquitetura não esta certa nem errada, tudo vai depender do compliance de cada empresa, time de segurança, time de rede e claro do orçamento de cada um. Lembra muito o artigo que escrevi sobre Palo Alto

No final vou deixar os arquivos para download e algumas explicações sobre os arquivos .json

Uma breve explicação.

Vamos aos objetos criados no azure

Resource Group
rg-fw-edge-shared-brazilsouth

NAMETYPELOCATION
fwedge01_OsDisk_1_8e3e21f33b774e919ba304a2ec8a3b62DiskBrazil South
fwedge01_disk2_5e1d09faa5fa446eb56329f30ce3ff51DiskBrazil South
fwedge02_OsDisk_1_cbedf98d06474b009df9c9c13b972f55DiskBrazil South
fwedge02_disk2_c8449694114e4b849123c6f93103624fDiskBrazil South
elb-fwedge-01Load balancerBrazil South
ilb-fwedge-01Load balancerBrazil South
int-fwedge01-eth0Network interfaceBrazil South
int-fwedge01-eth1Network interfaceBrazil South
int-fwedge01-eth2Network interfaceBrazil South
int-fwedge01-eth3Network interfaceBrazil South
int-fwedge02-eth0Network interfaceBrazil South
int-fwedge02-eth1Network interfaceBrazil South
int-fwedge02-eth2Network interfaceBrazil South
int-fwedge02-eth3Network interfaceBrazil South
nsg-fwedge-sharedbrazilsouthNetwork security groupBrazil South
pip-fwedge-mgmt-aPublic IP addressBrazil South
pip-fwedge-mgmt-bPublic IP addressBrazil South
pip-lb-external-fwedge-01Public IP addressBrazil South
rt-fw-edge-shared-brazilsouthRoute tableBrazil South
fwedge01Virtual machineBrazil South
fwedge02Virtual machineBrazil South
vnet-fwedge-shared-brazilsouthVirtual networkBrazil South

Discos

Temos dois discos em cada Fortigate VM:
DiskOS 2GB SSD Premium
DiskDATA 30GB SSD Premium

Teremos uma VNET “vnet-fwedge-shared-brazilsouth” com as seguintes subnets (snets)

NameCIDR
snet-fwedge-shared-brazilsouth-External10.126.0.0/27
snet-fwedge-shared-brazilsouth-Internal10.126.0.32/27
snet-fwedge-shared-brazilsouth-HASync10.126.0.64/27
snet-fwedge-shared-brazilsouth-Management10.126.0.96/27
snet-fwedge-shared-brazilsouth-Protected10.126.0.128/27
snet-fwedge-shared-brazilsouth-LoadBalance10.126.0.160/27

Temos 4 interfaces de rede para cada VM

Interface NameVM AttachSnet NameIP IntCIDR
int-fwedge01-eth0fwedge01snet-fwedge-shared-brazilsouth-External10.126.0.510.126.0.0/27
int-fwedge01-eth1fwedge01snet-fwedge-shared-brazilsouth-Internal10.126.0.3710.126.0.32/27
int-fwedge01-eth2fwedge01snet-fwedge-shared-brazilsouth-HASync10.126.0.6910.126.0.64/27
int-fwedge01-eth3fwedge01snet-fwedge-shared-brazilsouth-Management10.126.0.10110.126.0.96/27
int-fwedge02-eth0fwedge02snet-fwedge-shared-brazilsouth-External10.126.0.610.126.0.0/27
int-fwedge02-eth0fwedge02snet-fwedge-shared-brazilsouth-Internal10.126.0.3810.126.0.32/27
int-fwedge02-eth0fwedge02snet-fwedge-shared-brazilsouth-HASync10.126.0.7010.126.0.64/27
int-fwedge02-eth0fwedge02snet-fwedge-shared-brazilsouth-Management10.126.0.10210.126.0.96/27

Temos dois Load Balances

1x Internal Load Balance (ilb-fwedge-01) IP: 10.126.0.190
1x External Load Balance (elb-fwedge-01) IP: XXX.XXX.XXX.XXX

Temos 1 NSG (Network Security Group) (snet-fwedge-shared-brazilsouth-03 “Management”)

1x “nsg-fwedge-shared-brazilsouth-mgmt” com as seguintes regras

Allow-MGMT-HTTPS/SSH
Source: XXX.XXX.XXX.XXX/XX (IP ou IPs de origem que podem se conectar na interface MGMT)
Destination: 10.126.0.96/24 (Rede de gerencia MGMT)

Temos 3 IPs Publicos

pip-fwedge-mgmt-a (Management Fortigate A)
pip-fwedge-mgmt-b (Management Fortigate B)
pip-lb-external-fwedge-01 (IP Publico External Load Balance)

Temos 2 Virtual Machines

fwedge01 (Standard_F8s – 8vCPUs, 16 GB Memory)
fwedge02 (Standard_F8s – 8vCPUs, 16 GB Memory)

Temos um arquivo de Route Table “rt-fw-edge-shared-brazilsouth”, nele temos as seguintes rotas:

NameCIDRNext Hop typeNext Hop IP address
DefaultRoute0.0.0.0/0VirtualAppliance10.126.0.190

Agora vamos ao nosso script

#!/bin/bash
##Declarando variaveis

##Declarando Variaveis (Obrigatório)
export Subscription_Name="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ##inserir sua Subscription Azure
export RG_Name02="rg-fw-edge-shared-brazilsouth"
export Location_Region="brazilsouth"

###Script
###Selecionar subscription
az account set --subscription "${Subscription_Name}"

##Criando RG
az group create -n "${RG_Name02}" -l "${Location_Region}"

##Deploy Fortigate Template
az deployment group create -g "${RG_Name02}" --template-file template.json --parameters @parametersFile.json

##Desligando VMs
az vm stop -g "${RG_Name02}" -n "fwedge01"
az vm stop -g "${RG_Name02}" -n "fwedge02"

##Deallocate
az vm deallocate -g "${RG_Name02}" -n "fwedge01"
az vm deallocate -g "${RG_Name02}" -n "fwedge02"

###Criando Storage Accout (Para boot diag)
az storage account create -g "${RG_Name02}" -n "stgdiagfwedgefgt01" -l "${Location_Region}" --sku "Standard_LRS"

##Criando Snet Internal Load Balance (Subnet para load balance interno)
az network vnet subnet create -g "${RG_Name02}" --vnet-name "vnet-fwedge-shared-brazilsouth" -n "snet-fwedge-shared-brazilsouth-LoadBalance" --address-prefixes "10.126.0.160/27"

##alterando IP Internal Load Balance
az network lb frontend-ip update -g "${RG_Name02}" --lb-name "ilb-fwedge-01" -n "frontend-fwedge-internal-01" --vnet-name "vnet-fwedge-shared-brazilsouth" --subnet "snet-fwedge-shared-brazilsouth-LoadBalance" --private-ip-address "10.126.0.190"

###Habilitando Boot dioag VM01/02
az vm boot-diagnostics enable -n "fwedge01" -g "${RG_Name02}" --storage "stgdiagfwedgefgt01" 
az vm boot-diagnostics enable -n "fwedge02" -g "${RG_Name02}" --storage "stgdiagfwedgefgt01" 

##Fixando IP eht0 (VM01/02)
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge01-eth0" -n "ipconfig1" --private-ip-address "10.126.0.5"
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge02-eth0" -n "ipconfig1" --private-ip-address "10.126.0.6"

###Fixando IP eth1 (VM01/02)
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge01-eth1" -n "ipconfig1" --private-ip-address "10.126.0.37"
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge02-eth1" -n "ipconfig1" --private-ip-address "10.126.0.38"

###Fixando IP eth2 (VM01/02)
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge01-eth2" -n "ipconfig1" --private-ip-address "10.126.0.69"
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge02-eth2" -n "ipconfig1" --private-ip-address "10.126.0.70"

###Fixando IP eth3 (VM01/02)
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge01-eth3" -n "ipconfig1" --private-ip-address "10.126.0.101"
az network nic ip-config update -g "${RG_Name02}" --nic-name "int-fwedge02-eth3" -n "ipconfig1" --private-ip-address "10.126.0.102"

###Anexando NSG MGMT a snet mgmt 
az network vnet subnet update -g "${RG_Name02}" -n "snet-fwedge-shared-brazilsouth-Management" --vnet-name "vnet-fwedge-shared-brazilsouth" --network-security-group "nsg-fwedge-shared-brazilsouth-mgmt"

###Deletando regras existentes (criadas pelo templete, pode-se alterar diretamente no template tb)
az network nsg rule delete -g "${RG_Name02}" --nsg-name "nsg-fwedge-shared-brazilsouth-mgmt" -n "AllowAllInbound"
az network nsg rule delete -g "${RG_Name02}" --nsg-name "nsg-fwedge-shared-brazilsouth-mgmt" -n "AllowAllOutbound"

##Criando regras NSG MGMT HTTPS
az network nsg rule create -g "${RG_Name02}" --nsg-name "nsg-fwedge-shared-brazilsouth-mgmt" -n "Allow-MGMT-HTTPS" --priority "100" \
--source-address-prefixes "179.215.182.42/32" --source-port-ranges "*" \
--destination-address-prefixes "10.126.0.96/27" --destination-port-ranges "443" --access "Allow" \
--protocol "TCP" --description "Acesso liberado a snet management"

##Alterando regras NSG MGMT SSH
az network nsg rule create -g "${RG_Name02}" --nsg-name "nsg-fwedge-shared-brazilsouth-mgmt" -n "Allow-MGMT-SSH" --priority "101" \
--source-address-prefixes "179.215.182.42/32" --source-port-ranges "*" \
--destination-address-prefixes "10.126.0.96/27" --destination-port-ranges "22" --access "Allow" \
--protocol "TCP" --description "Acesso liberado a snet management"

###Anexando Subnet Internal a Route Table
az network vnet subnet update -g "${RG_Name02}" -n "snet-fwedge-shared-brazilsouth-Internal" --vnet-name "vnet-fwedge-shared-brazilsouth" --route-table "rt-fw-edge-shared-brazilsouth-internal" 

###Inciando as VM01/02
az vm start -g "${RG_Name02}" -n "fwedge01"
az vm start -g "${RG_Name02}" -n "fwedge02"

Agora tudo pronto, vamos acessar nosso FGT, iremos acesso pelo IP Publico “pip-fwedge-mgmt-a”

Entre com usuário e senha que contas no template

Vamos as configurações iniciais

Clique em “Begin”
Clique em “ok”
Clique e “ok”

Temos nosso Dashbord inicial

Vamos verificar nosso HA Sync

Vamos em System / HA

Tudo certo

Vamos agora em “Network” “Static Routes”

Por padrão teremos essas rotas (Isso pode ser editado/alterado no template)

Vamos fazer algumas modificações e deixar desta forma

Basicamente, iremos remover a rota “168.63.129.16/32” “10.126.0.1” “port1”

Ficará desta forma

Toda e qualquer nova rede que for criar e for feito peering com a rede do Firewall-EDGE 10.126.0.0/24 teremos que criar a “Static Route”

Vamos a um exemplo, em nosso ambiente azure temos a Vnet “10.188.0.0/24”, iremos fazer um peering com ela e add route static no FGT.

Sempre usaremos a port2, pois ela é nossa “LAN-Trust”, o gw 10.126.0.33 é o gw do azure (já expliquei em outros posts como funciona a rede no azure, que ele guarda para si os 3 primeiros IP de cada subnet)
Agora nossa Static Route ficará desta forma

Vamos agora criar um regra de acesso a internet
“Policy & Objects” “Firewall Policy”

Create New

Clique em “ok”

Agora nos temos uma regra que vem da nossa interface “LAN-Trust” para a nossa interface “WAN-UnTrust”

Agora vamos add essa vnet/subnet ao nosso Route Table

Assim ficou nosso arquivo

**(Esta vnet tem que possui peering com nossa rede do firewall edge)

Vamos ao teste

Criamos a seguinte vm “vm-lan-trust-01”
subnet 10.188.0.0/26
IP: 10.188.0.4

Estamos dentro da nossa VM Trust

vamos fazer um teste de curl para http//ifconfig.me e monitor em nosso firewall

Como podem ver em nossa VM Trust, trouxe o IP da interface WAN-UnTrust e todo trafego passou pelo nossa firewall

Agora um outro cenário, temos parceiros/clientes que precisam acessar nossas aplicações ou um ambiente de “Transfer” (Connect Direct IBM, SFTP, FTPS, SMB) para isso acontecer de forma segura podemos estabelecer Tuneis IPSec com nossas Parceiros/Clientes e desta forma liberar o acesso de forma segura.
Outra cenario seria a publicação de uma aplicação interna e expo-la para internet, temos varias possibilidade de forma segura em nossa ambiente.

Agora algumas explicações referente aos .json

Linha 5/6: usuário de acesso ao firewall
Linha 8/9: senha
Linha 12: prefixo do firewall
Linha 15: versão do licenciamento, neste exemplo seria PayAsGo (Pague pelo uso, se vc possui BYOL, altere para o valor que consta no template)
Linha 18: ultima versão do firmware
Linha 21: Size VM
Linha 36: nome do IP Publico do External LB
Linha 39: RG
Linha 42: IP Publico MGMT FGT A
Linha 45: RG
Linha 48: IP Publico MGMT FGT B
Linha 51: RG

Continuando

Linha 57: nome da vnet (o proprio template cria a vnet)
Linha 60: RG
Linha 63: CIDR da Vnet
Linha 66: Nome da Vnet External
Linha 69: CIDR da Subnet External

As outras são auto explicativas

***Nunca esquecer de add Static Route em nosso firewall, sempre add as subnet no arquivo Route Table, sempre fazer peering para novas Vnets.

Link para download

Seja Feliz!!!!!!!!!!!!!!!!!

Criando Azure Redis Cache CLI (Bash)

Neste artigo iremos criar Azure Redis Cache via CLI na modalidade mais simples.
Vamos ao script

##Declarando Variaveis (Obrigatório)

export Subscription_Name=”Santana-Corp”
export RG_Name=”Redis-PRD”
export Location=”eastus”
export Object_Name=”DB-Redis”

##Variaveis Redis

export SKU=”Basic”
export TierVM=”c0″

##Variaveis TAGs (Não Obrigatório)

export Costacenter=”Centro de Custos”
export Value_Costcenter=”111245″
export Environment=”Environment”
export Environment_Value=”Produção”
export Depto=”Departamento”
export Depto_Value=”Recursos Humanos”

##Criando Resource Group

az group create -n “${RG_Name}” -l “${Location}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###

az redis create -l “${Location}” -n “${Object_Name}” -g “${RG_Name}” –sku “${SKU}” –vm-size “${TierVM}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

Criando Virtual Machine CentOS Azure CLI (bash) com acesso via chave publica/privada

Neste artigo iremos criar uma Maquina Virtual com CentOS Linux utilizando uma Vnet existente e fixando IP (rede interna), criaremos também um NSG para esta VM, um storage account para diagnostico de boot e conjunto de disponibilidade e com acesso via chave publica/privada sem a necessidade de utilizar senha.

#!/bin/bash

##Declarando variáveis

##Declarando variáveis (Obrigatório)

export Subscription_Name=”Azure Subscription”
export RG_Name=”Nome do Resource Group”
export Location=”Azure Region”
export Object_Name=”Nome do Objeto”

##Storage Accout

export Storage=”Nome do Storage Account” ##Exemplo storagevmdiag##
export SKU_Storage=”SKU do Storage Account” ##Exemplo Standard_LRS##

##Conjunto de Disponibiliade Availability Set

export Name_AV_SET=”AV-SET”-“Nome do Conjunto de Disponibilidade”
export Fault_Domain=”3″
export Update_Domain=”20″

##Network Security Group NSG

export NSG_Name=”Nome do NSG” ##Exemplo NSG-VM-Frontend##

##Vnet Existente (Variáveis para utilizar Vnet Existente)

export RG_Vnet=”Nome do Resurce Goup onde encontra-se a Vnet existente”
export Subnet_Name=”Nome da subnet existente”
export Vnet_Name=”Nome da Vnet existente”

##Variáveis de Rede (Obrigatório)

export NIC_Name=”Nome da interface de rede”
export Accelerated=”False ou true”

##Variavel para criacao da VM (Obrigatório)

export Image_SO=”CentOS”
export VM_Name=”Nome do servidor”
export User_Name=”azroot”
export key_PUB=”Local da chave publica” ##Exemplo /script/key/chave_publica.pub## caminho absoluto
export Size=”Tier da VM”
export SKU_STG=”Sku do Disco” ## Disco ## Exemplo Standard_LRS###

##Variaveis TAGs (Não Obrigatório)

export Costacenter=”Centro de Custos”
export Value_Costcenter=”Numero do centos de custo”
export Environment=”Environment”
export Environment_Value=”Ambiente” ##’Desenvolvimento’-‘Homologação’-‘Produção’##
export Depto=”Departamento” ##Squad-Team-Time##
export Depto_Value=”Nome do Departamento” ##infra-cartões-telecom

###Execução do Script

###Selecionar subscription

az account set –subscription “${Subscription_Name}”

###Criando Resource Group

az group create -n “${RG_Name}” -l “${Location}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Criando Storage Accout

az storage account create -g “${RG_Name}” -n “${Storage}” -l “${Location}” –sku “${SKU_Storage}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Criando Network Security Group NSG

az network nsg create -g “${RG_Name}” -n “${NSG_Name}” -l “${Location}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Criar Grupo de Disponibilidade

az vm availability-set create -g “${RG_Name}” -n “${Name_AV_SET}” –platform-fault-domain-count “${Fault_Domain}” –platform-update-domain-count “${Update_Domain}” -l “${Location}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Declarando variável para utilizar Vnet existente (Obrigatório)

SUBNET_ID001=$(az network vnet subnet show –name “${Subnet_Name}” –vnet-name “${Vnet_Name}” -g “${RG_Vnet}” –query id –output tsv)
export IPConfig_Name=”ipconfig1″

###Criando NIC (Interface de rede)

az network nic create –name “${NIC_Name}” -g “${RG_Name}” –subnet $SUBNET_ID001 –accelerated-networking “${Accelerated}” –network-security-group “${NSG_Name}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Declaranado Variaveis para Fixar IP

NIC_ID001=$(az network nic show –name “${NIC_Name}” -g “${RG_Name}” –query id –output tsv)

###Declarando varivel para utilizar IP Fixo existente (Obrigatório)

IP_ID001=$(az network nic ip-config show -g “${RG_Name}” -n “${IPConfig_Name}” –nic-name “${NIC_Name}” –query privateIpAddress –output tsv)

###Fixando IP na interface de rede#Fixando IP

az network nic ip-config update -g “${RG_Name}” –nic-name “${NIC_Name}” -n “${IPConfig_Name}” –private-ip-address $IP_ID001

###Criando Virtual Machine CentOS

az vm create –name “${VM_Name}” -g “${RG_Name}” -l “${Location}” –availability-set “${Name_AV_SET}” –boot-diagnostics-storage “${Storage}” –image “${Image_SO}” –nics $NIC_ID001 –admin-username “${User_Name}” –ssh-key-values “${key_PUB}” –size “${Size}” –storage-sku “${SKU_STG}”

Links de referencia

https://docs.microsoft.com/en-us/cli/azure/vm/image?view=azure-cli-latest
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage
https://docs.microsoft.com/pt-br/cli/azure/
https://docs.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest#az_vm_create
https://docs.microsoft.com/en-us/rest/api/compute/virtual-machines/create-or-update#osprofile
https://docs.microsoft.com/pt-br/azure/virtual-machines/availability-set-overview
https://docs.microsoft.com/pt-br/azure/virtual-network/network-security-groups-overview

Link para geração da chave
https://charlessantana.com.br/2021/10/20/criando-chave-publica-e-private-com-puttygen/

Criando Virtual Machine (CentOS – Linux) Azure CLI (Bash)

Neste artigo iremos criar uma Maquina Virtual com CentOS Linux utilizando uma Vnet existente e fixando IP (rede interna), criaremos também um NSG para esta VM, um storage account para diagnostico de boot e conjunto de disponibilidade.

Vamos ao script

#!/bin/bash
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#|||Script Charles Aureliano Santana|||
#|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

##Declarando variaveis
export Subscription_Name=”Azure Subscription”
export RG_Name=”Nome do Resource Group”
export Location=”Azure Region”
export Object_Name=”Nome do Objeto”

##Storage Accout
export Storage=”Nome do Storage Account” ##Exemplo storagevmdiag##
export SKU_Storage=”SKU do Storage Account” ##Exemplo Standard_LRS##

##Conjunto de Disponibiliade Availability Set
export Name_AV_SET=”AV-SET”-“Nome do Conjunto de Disponibilidade”
export Fault_Domain=”3″
export Update_Domain=”20″

##Network Security Group NSG
export NSG_Name=”Nome do NSG” ##Exemplo NSG-VM-Frontend##

###Vnet Existente (Variaveis para utilizar Vnet Existente)
export RG_Vnet=”Nome do Resurce Goup onde encontra-se a Vnet existente”
export Subnet_Name=”Nome da subnet existente”
export Vnet_Name=”Nome da Vnet existente”

##Variaveis de Rede (Obrigatório)
export NIC_Name=”Nome da interface de rede”
export Accelerated=”False ou true”

##Variavel para criacao da VM (Obrigatório)
export Image_SO=”SKU Image Azure” ##Exemplo ‘CentOS’
export VM_Name=”Nome do Servidor” “”15 caracteres
export User_Name=”Usuário do SO”
export PWD=”Senha do usuário do SO”
export Size=”Standard_D2S_v3″ ## Tier da VM
export SKU_STG=”Standard_LRS” ## Disco ##

##Variaveis TAGs (Não Obrigatório)
export Costacenter=”Centro de Custos”
export Value_Costcenter=”Numero do centos de custo”
export Environment=”Environment”
export Environment_Value=”Ambiente” ##’Desenvolvimento’-‘Homologação’-‘Produção’##
export Depto=”Departamento” ##Squad-Team-Time##
export Depto_Value=”Nome do Departamento” ##infra-cartões-telecom

##Execução do Script
###Selecionar subscription
az account set –subscription “${Subscription_Name}”

###Criando Resource Group
az group create -n “${RG_Name}” -l “${Location}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Criando Storage Accout
az storage account create -g “${RG_Name}” -n “${Storage}” -l “${Location}” –sku “${SKU_Storage}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Criando Network Security Group NSG
az network nsg create -g “${RG_Name}” -n “${NSG_Name}” -l “${Location}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Criar Grupo de Disponibilidade
az vm availability-set create -g “${RG_Name}” -n “${Name_AV_SET}” –platform-fault-domain-count “${Fault_Domain}” –platform-update-domain-count “${Update_Domain}” -l “${Location}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Declarando varivel para utilizar Vnet existente (Obrigatório)
SUBNET_ID001=$(az network vnet subnet show –name “${Subnet_Name}” –vnet-name “${Vnet_Name}” -g “${RG_Vnet}” –query id –output tsv)
export IPConfig_Name=”ipconfig1″

###Criando NIC (Interface de rede)
az network nic create –name “${NIC_Name}” -g “${RG_Name}” –subnet $SUBNET_ID001 –accelerated-networking “${Accelerated}” –network-security-group “${NSG_Name}” –tags “${Costacenter}”=”${Value_Costcenter}” “${Environment}”=”${Environment_Value}” “${Depto}”=”${Depto_Value}”

###Declaranado Variaveis para Fixar IP
NIC_ID001=$(az network nic show –name “${NIC_Name}” -g “${RG_Name}” –query id –output tsv)

###Declarando varivel para utilizar IP Fixo existente (Obrigatório)
IP_ID001=$(az network nic ip-config show -g “${RG_Name}” -n “${IPConfig_Name}” –nic-name “${NIC_Name}” –query privateIpAddress –output tsv)

###Fixando IP na interface de rede#Fixando IP
az network nic ip-config update -g “${RG_Name}” –nic-name “${NIC_Name}” -n “${IPConfig_Name}” –private-ip-address $IP_ID001

###Criando Virtual Machine CentOS Linux
az vm create –name “${VM_Name}” -g “${RG_Name}” -l “${Location}” –availability-set “${Name_AV_SET}” –boot-diagnostics-storage “${Storage}” –image “${Image_SO}” –nics $NIC_ID001 –admin-username “${User_Name}” –admin-password “${PWD}” –size “${Size}” –storage-sku “${SKU_STG}”

Links de referencia

https://docs.microsoft.com/en-us/cli/azure/vm/image?view=azure-cli-latest
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage
https://docs.microsoft.com/pt-br/cli/azure/
https://docs.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest#az_vm_create
https://docs.microsoft.com/en-us/rest/api/compute/virtual-machines/create-or-update#osprofile
https://docs.microsoft.com/pt-br/azure/virtual-machines/availability-set-overview
https://docs.microsoft.com/pt-br/azure/virtual-network/network-security-groups-overvie