Visual Studio Code y Azure

En este articulo exploraremos Visual studio Code, desde una perspectiva dinamica y divertida…

Es como todas las historias de aventuras de D&D, o del señor de los anillos, estamos todos reunidos en la mayor comodidad, tranquilos disfrutando de la tarde, y el destino nos va a llegar nuevo un «Quest», una busqueda o reto, en este caso vamos a acompañar a este valiente explorador, de abultado vientre, y corta vista, en un terreno poco explorado, como lo es el uso de las diferentes plataformas de administracion de la nube como las lineas de comando y particularmente el vscode para gestionar plantillas ARM.

Instalacion de prerequisitos

Si usted no tiene una suscripcion de Azure haga clic aqui, necesitara un equipo con Windows 10 preferiblemente, y lo invito a que preparemos los pre-requisitos:

  • Primero que todo una enorme taza del café de su preferencia
  • El modulo de Azure para powershell, aunque se puede administrar Azure desde el portal web cual seria la gracia, este modulo AZ se puede instalar iniciando el PowerShell en modo administrador (es decir dando clic derecho sobre el icono de PowerShell), y usando los siguientes comandos:
$PSVersionTable.PSVersion #para verificar que version de Powershell se tiene con version 5.0 o superior podemos hacer uso de

Install-Module -Name Az #Esto tomara un rato, porque son varios modulos, tambien es posible que te solicite confirmacion de que confias en el repositorio de PSGallery antes de continuar.

Para mas informacion consulte aqui

  • El Azure CLI tambien vale la pena tenerlo, vamos a instalarlo desde aqui esta es otra manera de interactuar con Azure desde PowerShell como administrador ejecutaremos
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi
  • Es posible ingresar a la tienda de Microsoft Store, y descargar el Windows Terminal
  • Tambien puedes querer descargar el WSL (Windows Subsystem for Linux) que permite la ejecucion de un linux Ubuntu dentro de tu sistema operativo, para tener acceso por BASH y poder ejecutar herramientas propias de linux, para instalar el WSL
  • Descargue el Visual Studio Code desde aqui el instalador es muy liviano, pesa menos de 100MB. la instalacion es super simple, y vamos a ir complementandola con las extensiones para Azure a lo largo de este workshop
$VSCode = "https://code.visualstudio.com/docs/?dv=win"
New-FileDownload -SourceFile $VSCode

Guia de laboratorio

Visual Studio Code

Empecemos reconociendo el terreno,

«VS Code viene con un diseño simple e intuitivo que maximiza el espacio provisto para el editor mientras deja un amplio espacio para navegar y acceder al contexto completo de su carpeta o proyecto. La IU se divide en cinco áreas:

  • Editor: el área principal para editar sus archivos. Puede abrir tantos editores como desee, uno al lado del otro, vertical y horizontalmente.
  • Barra lateral: contiene diferentes vistas como el Explorador para ayudarlo mientras trabaja en su proyecto.
  • Barra de estado: información sobre el proyecto abierto y los archivos que edita.
  • Barra de actividad: ubicada en el extremo izquierdo, le permite cambiar de vista y le brinda indicadores adicionales específicos del contexto, como la cantidad de cambios salientes cuando Git está habilitado.
  • Paneles: puede mostrar diferentes paneles debajo de la región del editor para obtener información de salida o depuración, errores y advertencias, o un terminal integrado. El panel también se puede mover hacia la derecha para obtener más espacio vertical.» tomado de:(https://code.visualstudio.com/docs/getstarted/userinterface#_basic-layout)

ahora el Tiki-tiki

Para empezar a probar que todo nos este funcionando, usaremos la barra lateral, para crear un nuevo archivo. Quiero que lo llamemos test.ps1, esta extension hara que el Visual Studio Code identifique que estas intentando crear un Script de PowerShell, por lo que en el modulo de Extensiones te solicitara la instalacion de la extension de PowerShell, en mi escenario utilice la de «PowerShell preview»-

vamos a abrir la consola de PowerShell dentro del vscode, en la seccion inferior aparecen cuatro pestañas, «Problemas», «Salidas», «Consola de Depuracion», y «Terminal» esta ultima es la que me interesa, y vamos a validar que en la parte de la derecha aparece indicando que esta en modo PowerShell, porque tambien puede que esta consola nos funcione para bash.-

Connect-AzAccount #Aqui te pedira iniciar sesion sobre el portal de https://microsoft.com/devicelogin 
get-azresource |ft

PowerShell en 5 minutos

Write-Host #"Powershell tiene una estructura sencilla, es una composicion de un verbo en infinitivo, un guion al medio y un sustantivo singular" -ForegroundColor Yellow
Write-Host #"Por ejemplo podemos encontrar un Get-Command, un Get-Help, o un Get-Service en mas de 800 cmd-lets" -ForegroundColor Yellow
Get-Command
Write-host #"Si queremos saber que esta haciendo nuestro equipo, hacemos un get-process" -ForegroundColor Yellow
Get-process
Write-Host #"Si la informacion es muy extensa, como en este caso, podemos ordenarla" -ForegroundColor Yellow
Update-Help
get-help Get-Process
get-help Get-Process -full
get-help Get-Process -detailed
get-help Get-Process -examples
get-help Get-Process -Online
Get-Service
Get-Service -Name Spooler |Stop-Service
Get-Service M* |Format-List

Command-lets y Parametros

Get-Service M* |Format-Custom
Get-Service M* |Where-Object {$_.Status -eq "Running"}
Get-Service M* |Where-Object {$_.Status -eq "Stopped"}
Get-Service | Sort-Object Status
Get-Service | Sort-Object Status |Format-Table -GroupBy Status Name, DisplayName
Get-Service |Get-Member
Get-Process |Get-Member
Get-Service Spooler |Select-Object ServicesDependedOn
Show-Command Get-Service
Stop-Service M* -WhatIf
Stop-Service M* -Confirm

Pasando resultados con el Pipe o Piping

Get-Process |sort CPU -Descending
Get-EventLog -LogName System -EntryType Error -Newest 10
Get-EventLog -LogName System -EntryType Error -Newest 10 |fl
Get-EventLog -LogName System -EntryType Error -Newest 10 |ogv

Variables y Scripts

$var = "Hola DevOps2020"
$var
Write-host "$var" -ForegroundColor Yellow
Get-Variable 
#podemos manejar strings
$num = 123
$num
#Podemos contener listas o arrays tambien
$num = 1,2,3
$num
$var.GetType().FullName
$var.Length
$var[1]
[int[]] $var = (1,2,3)
$var[2] = "1234"
$var[2]
$v1 = "Hello "
$v2 = "world"
$v1+$v2
($var1+$var2).Length
#Comparar con -eq -ne -gt -lt -ge -le
"Juan Perez" -eq "Ramon Valdez"
#formatos
"{0:f2}" -f 12.4
"|{0,10:C}|" -f 12.4
"{0:hh:mm}" -f (get-date)
#Scripting
Get-ExecutionPolicy
Set-ExecutionPolicy Unrestricted
Get-ExecutionPolicy
runas /user:username PowerShell
##Mas info sobre seguridad en PoSh http://technet.microsoft.com/en-us/magazine/2007.09.powershell.aspx
#------------------------
#test.ps1
#Show Hello and time
"" #Blank line
"Hello"+$Env:USERNAME +"!"
"Time is" + "{0:HH}:{0:mm}" -f (get-Date)
"" #blank line
#------------------------
#Funciones
function get-soup (
    [switch] $please,
    [String] $soup = "chicken noodle"
    )
{
    if ($please){
        "Here's your $soup soup"
    }
    else {
        "No soup for you!"
    }
}
#------------------------

Entornos y modulos

#---------
$User = "fabian.campo@MiDominio.com"
$Pass = ConvertTo-SecureString "AzurePa55w.rd" -AsPlainText -Force
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $Pass
Import-Module MSOnline
Connect-msolservice -Credential $Cred
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session
Import-Module LyncOnlineConnector
import-module microsoft.online.sharepoint.powershell
$Session = New-CsOnlinesession -Credential $Cred
Import-PSSession $Session
[string]$tenant = get-msoldomain | where {$_.name -like "*.onmicrosoft.com" -and -not($_.name -like "*mail.onmicrosoft.com")} | select name
$tenant
$tenant3 = $tenant -split("=")
[string]$tenant4 = $tenant3[1]
$tenant4
$tenant5 = $tenant4 -split(".on")
[string]$tenant6 = $tenant5[0]
$url = "https://" + $tenant6 + "-admin.sharepoint.com"
Connect-SPOService -Url $url -credential $Cred  
#---------

Registro, Certificados y otros almacenes

Get-psprovider
Get-psDrive
New-PsDrive -Name HKCS -PSProvider Registry -Root "HKEY_CLASSES_ROOT"
cd HKCS:
dir .ht*
$process = Get-WmiObject -Class win32_Process
$item.name
foreach ($item in $process)
{
    $item.name
}

Creando Maquinas virtuales en Azure

Connect-AzAccount
Get-AZSubscription | Sort SubscriptionName | Select SubscriptionName
$subscrName="Plataformas de MSDN"
Select-AzSubscription -SubscriptionName $subscrName
$rgName="Devops2020_rg"
$locName="eastus"
New-AZResourceGroup -Name $rgName -Location $locName
Get-AZStorageAccountNameAvailability "campoh1473"
$rgName="Devops2020_rg"
$saName="campoh1473"
$locName=(Get-AZResourceGroup -Name $rgName).Location
New-AZStorageAccount -Name $saName -ResourceGroupName $rgName -Type Standard_LRS -Location $locName
$rgName="Devops2020_rg"
$locName=(Get-AZResourceGroup -Name $rgName).Location
$vnetName="Vnet01"
$SubnetName="Subnet01"
$Subnet=New-AZVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix 10.0.0.0/27
New-AZVirtualNetwork -Name $vnetName -ResourceGroupName $rgName -Location $locName -AddressPrefix 10.0.0.0/24 -Subnet $Subnet -DNSServer 10.0.0.4
$rule1 = New-AZNetworkSecurityRuleConfig -Name "RDPTraffic" -Description "Allow RDP to all VMs on the subnet" -Access Allow -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$rule2 = New-AZNetworkSecurityRuleConfig -Name "ExchangeSecureWebTraffic" -Description "Allow HTTPS to the Exchange server" -Access Allow -Protocol Tcp -Direction Inbound -Priority 101 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix "10.0.0.5/32" -DestinationPortRange 443
$rule3 = New-AZNetworkSecurityRuleConfig -Name "SharePointSecureWebTraffic" -Description "Allow HTTPS to the SharePoint server" -Access Allow -Protocol Tcp -Direction Inbound -Priority 102 -SourceAddressPrefix Internet -SourcePortRange * -DestinationAddressPrefix "10.0.0.7/32" -DestinationPortRange 80
New-AZNetworkSecurityGroup -Name $SubnetName -ResourceGroupName $rgName -Location $locName -SecurityRules $rule1, $rule2, $rule3
$vnet=Get-AZVirtualNetwork -ResourceGroupName $rgName -Name $vnetName
$nsg=Get-AZNetworkSecurityGroup -Name $SubnetName -ResourceGroupName $rgName
Set-AZVirtualNetworkSubnetConfig -VirtualNetwork $vnet -Name $SubnetName -AddressPrefix "10.0.0.0/27" -NetworkSecurityGroup $nsg
$vnet | Set-AzVirtualNetwork
$rgName="Devops2020_rg"
# Create an availability set for domain controller virtual machines
New-AZAvailabilitySet -ResourceGroupName $rgName -Name dcAvailabilitySet -Location $locName -Sku Aligned  -PlatformUpdateDomainCount 5 -PlatformFaultDomainCount 2
# Create the domain controller virtual machine
$vmName="adVM"
$vmSize="Standard_D1_v2"
$vnet=Get-AZVirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$pip = New-AZPublicIpAddress -Name ($vmName + "-PIP") -ResourceGroupName $rgName -Location $locName -AllocationMethod Dynamic
$nic = New-AZNetworkInterface -Name ($vmName + "-NIC") -ResourceGroupName $rgName -Location $locName -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -PrivateIpAddress 10.0.0.4
$avSet=Get-AZAvailabilitySet -Name dcAvailabilitySet -ResourceGroupName $rgName
$vm=New-AZVMConfig -VMName $vmName -VMSize $vmSize -AvailabilitySetId $avSet.Id
$vm=Set-AZVMOSDisk -VM $vm -Name ($vmName +"-OS") -DiskSizeInGB 128 -CreateOption FromImage -StorageAccountType "Standard_LRS"
$diskConfig=New-AZDiskConfig -AccountType "Standard_LRS" -Location $locName -CreateOption Empty -DiskSizeGB 20
$dataDisk1=New-AZDisk -DiskName ($vmName + "-DataDisk1") -Disk $diskConfig -ResourceGroupName $rgName
$vm=Add-AZVMDataDisk -VM $vm -Name ($vmName + "-DataDisk1") -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun 1
$cred=Get-Credential -Message "Type the name and password of the local administrator account for adVM."
$vm=Set-AZVMOperatingSystem -VM $vm -Windows -ComputerName adVM -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm=Set-AZVMSourceImage -VM $vm -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"
$vm=Add-AZVMNetworkInterface -VM $vm -Id $nic.Id
New-AZVM -ResourceGroupName $rgName -Location $locName -VM $vm
## conecte al adVM y ejecute
$disk=Get-Disk | where {$_.PartitionStyle -eq "RAW"}
$diskNumber=$disk.Number
Initialize-Disk -Number $diskNumber
New-Partition -DiskNumber $diskNumber -UseMaximumSize -AssignDriveLetter
Format-Volume -DriveLetter F
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Install-ADDSForest -DomainName campoh.lab -DatabasePath "F:\NTDS" -SysvolPath "F:\SYSVOL" -LogPath "F:\Logs"
Add-WindowsFeature RSAT-ADDS-Tools
New-ADUser -SamAccountName sp_farm_db -AccountPassword (read-host "Set user password" -assecurestring) -name "sp_farm_db" -enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false
New-ADUser -Name EXCHSVC -GivenName EXCHSVC -UserPrincipalName EXCHSVC -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name SYSADMIN -GivenName EXCHADMIN -UserPrincipalName EXCHADMIN -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name EFlores -GivenName "Maria Elena" -surname "Flores" -UserPrincipalName EFlores -EmailAddress EFlores@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name Vgarcia -GivenName "Victor" -surname "Garcia" -UserPrincipalName Vgarcia -EmailAddress Vgarcia@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name LRodriguez -GivenName "Lourdes" -surname "Rodriguez" -UserPrincipalName LRodriguez -EmailAddress LRodriguez@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name JLSanchez -GivenName "Jorge Luis" -surname "Sanchez" -UserPrincipalName JLSanchez -EmailAddress JLSanchez@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name CZambrano -GivenName "Cecilia" -surname "Zambrano" -UserPrincipalName CZambrano -EmailAddress CZambrano@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name MSalazar -GivenName "Mariana " -surname "Salazar" -UserPrincipalName MSalazar -EmailAddress MSalazar@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name JCTorres -GivenName "Juan Carlos" -surname "Torres" -UserPrincipalName JCTorres -EmailAddress JCTorres@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name ALAndrade -GivenName "Ana Lucia" -surname "Andrade" -UserPrincipalName ALAndrade -EmailAddress ALAndrade@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
New-ADUser -Name MVera -GivenName "Miguel Angel" -surname "Vera" -UserPrincipalName MVera -EmailAddress MVera@campoh.lab -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString -AsPlainText "p@ssw0rd" -Force) -Enabled $true
## Fase 2- Creamos ahora la maquina de Exchange
$vmDNSName="mail2393"
$rgName="Devops2020_rg"
$locName=(Get-AZResourceGroup -Name $rgName).Location
Test-AZDnsAvailability -DomainQualifiedName $vmDNSName -Location $locName
# Set up key variables
$subscrName="Plataformas de MSDN"
$rgName="Devops2020_rg"
$vmDNSName="mail2393"
# Set the Azure subscription
Select-AzSubscription -SubscriptionName $subscrName
# Get the Azure location and storage account names
$locName=(Get-AZResourceGroup -Name $rgName).Location
$saName=(Get-AZStorageaccount | Where {$_.ResourceGroupName -eq $rgName}).StorageAccountName
# Create an availability set for Exchange virtual machines
New-AZAvailabilitySet -ResourceGroupName $rgName -Name exAvailabilitySet -Location $locName -Sku Aligned  -PlatformUpdateDomainCount 5 -PlatformFaultDomainCount 2
# Specify the virtual machine name and size
$vmName="exVM"
$vmSize="Standard_D3_v2"
$vnet=Get-AZVirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$avSet=Get-AZAvailabilitySet -Name exAvailabilitySet -ResourceGroupName $rgName
$vm=New-AZVMConfig -VMName $vmName -VMSize $vmSize -AvailabilitySetId $avSet.Id
# Create the NIC for the virtual machine
$nicName=$vmName + "-NIC"
$pipName=$vmName + "-PublicIP"
$pip=New-AZPublicIpAddress -Name $pipName -ResourceGroupName $rgName -DomainNameLabel $vmDNSName -Location $locName -AllocationMethod Dynamic
$nic=New-AZNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $locName -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -PrivateIpAddress "10.0.0.5"
# Create and configure the virtual machine
$cred=Get-Credential -Message "Type the name and password of the local administrator account for exVM."
$vm=Set-AZVMOSDisk -VM $vm -Name ($vmName +"-OS") -DiskSizeInGB 128 -CreateOption FromImage -StorageAccountType "Standard_LRS"
$vm=Set-AZVMOperatingSystem -VM $vm -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm=Set-AZVMSourceImage -VM $vm -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"
$vm=Add-AZVMNetworkInterface -VM $vm -Id $nic.Id
New-AZVM -ResourceGroupName $rgName -Location $locName -VM $vm
## Conectese a exVM y ejecute
Add-Computer -DomainName "campoh.lab"
Install-WindowsFeature AS-HTTP-Activation, Server-Media-Foundation, NET-Framework-45-Features, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Clustering-CmdInterface, RSAT-Clustering-Mgmt, RSAT-Clustering-PowerShell, WAS-Process-Model, Web-Asp-Net45, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-Mgmt-Console, Web-Mgmt-Service, Web-Net-Ext45, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, Windows-Identity-Foundation, RSAT-ADDS
Restart-Computer
## Configurar el Exchange
Write-Host (Get-AZPublicIpaddress -Name "40.84.58.22" -ResourceGroup $rgName).DnsSettings.Fqdn
## Desde exVM
## descarga los pre-requisitos, 
## https://go.microsoft.com/fwlink/p/?linkid=863265 ".NET Framework 4.7.2 "
## https://go.microsoft.com/fwlink/?linkid=327788 "Paquete redistribuible de Visual C++ para Visual Studio 2012"
## https://go.microsoft.com/fwlink/?linkid=2002913 "Paquete redistribuible de Visual C++ para Visual Studio 2013"
## https://go.microsoft.com/fwlink/p/?linkId=258269 "API administrada de comunicaciones unificadas de Microsoft 4.0, Core Runtime (64 bits)" 
## descarga el ISO de Exchange con el ultimo CU
e:
.\setup.exe /prepareSchema /IacceptExchangeServerLicenseTerms
.\setup.exe /prepareAD /OrganizationName:LandonHotel /IacceptExchangeServerLicenseTerms
.\setup.exe /mode:Install /role:Mailbox /OrganizationName:LandonHotel /IacceptExchangeServerLicenseTerms
Restart-Computer
$dnsName="mail1473.eastus2.cloudapp.azure.com"
$user1Name="chris@" + $dnsName
$user2Name="janet@" + $dnsName
$db=Get-MailboxDatabase
$dbName=$db.Name
$password = Read-Host "Enter password" -AsSecureString
New-Mailbox -UserPrincipalName $user1Name -Alias chris -Database $dbName -Name ChrisAshton -OrganizationalUnit Users -Password $password -FirstName Chris -LastName Ashton -DisplayName "Chris Ashton"
New-Mailbox -UserPrincipalName $user2Name -Alias janet -Database $dbName -Name JanetSchorr -OrganizationalUnit Users -Password $password -FirstName Janet -LastName Schorr -DisplayName "Janet Schorr"
## Fase 3- Creamos ahora la maquina de SQL Server
# Log in to Azure
Connect-AzAccount
# Set up key variables
$subscrName="Plataformas de MSDN"
$rgName="Devops2020_rg"
# Set the Azure subscription and location
Select-AzSubscription -SubscriptionName $subscrName
$locName=(Get-AzResourceGroup -Name $rgName).Location
# Create an availability set for SQL Server virtual machines
New-AzAvailabilitySet -ResourceGroupName $rgName -Name sqlAvailabilitySet -Location $locName -Sku Aligned  -PlatformUpdateDomainCount 5 -PlatformFaultDomainCount 2
# Create the SQL Server virtual machine
$vmName="sqlVM"
$vmSize="Standard_D3_V2"
$vnetName="Vnet01"
$vnet=Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$pip=New-AzPublicIpAddress -Name ($vmName + "-PIP") -ResourceGroupName $rgName -Location $locName -AllocationMethod Dynamic
$nic=New-AzNetworkInterface -Name ($vmName + "-NIC") -ResourceGroupName $rgName -Location $locName -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -PrivateIpAddress "10.0.0.6"
$avSet=Get-AzAvailabilitySet -Name sqlAvailabilitySet -ResourceGroupName $rgName 
$vm=New-AzVMConfig -VMName $vmName -VMSize $vmSize -AvailabilitySetId $avSet.Id
$vm=Set-AzVMOSDisk -VM $vm -Name ($vmName +"-OS") -DiskSizeInGB 128 -CreateOption FromImage -StorageAccountType "Standard_LRS"
$diskSize=100
$diskConfig=New-AzDiskConfig -AccountType "Standard_LRS" -Location $locName -CreateOption Empty -DiskSizeGB $diskSize
$dataDisk1=New-AzDisk -DiskName ($vmName + "-SQLData") -Disk $diskConfig -ResourceGroupName $rgName
$vm=Add-AzVMDataDisk -VM $vm -Name ($vmName + "-SQLData") -CreateOption Attach -ManagedDiskId $dataDisk1.Id -Lun 1
$cred=Get-Credential -Message "Type the name and password of the local administrator account of the SQL Server computer." 
$vm=Set-AzVMOperatingSystem -VM $vm -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm=Set-AzVMSourceImage -VM $vm -PublisherName MicrosoftSQLServer -Offer SQL2017-WS2016 -Skus Standard -Version "latest"
$vm=Add-AzVMNetworkInterface -VM $vm -Id $nic.Id
New-AzVM -ResourceGroupName $rgName -Location $locName -VM $vm
## Connect sqlVM 
Add-Computer -DomainName "campoh.lab"
Restart-Computer
Get-Disk | Where PartitionStyle -eq "RAW" | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "SQL Data"
md f:\Data
md f:\Log
md f:\Backup
New-NetFirewallRule -DisplayName "SQL Server ports 1433, 1434, and 5022" -Direction Inbound -Protocol TCP -LocalPort 1433,1434,5022 -Action Allow
## Fase 4- Creamos ahora la maquina de SP Server
# Set up key variables
$subscrName="Plataformas de MSDN"
$rgName="Devops2020_rg"
$dnsName="campoh1473"
# Set the Azure subscription
Select-AzSubscription -SubscriptionName $subscrName
# Get the location
$locName=(Get-AzResourceGroup -Name $rgName).Location
# Create an availability set for SharePoint virtual machines
New-AzAvailabilitySet -ResourceGroupName $rgName -Name spAvailabilitySet -Location $locName -Sku Aligned  -PlatformUpdateDomainCount 5 -PlatformFaultDomainCount 2
# Create the spVM virtual machine
$vmName="spVM"
$vmSize="Standard_D3_V2"
$vnetName="Vnet01"
$vm=New-AzVMConfig -VMName $vmName -VMSize $vmSize
$pip=New-AzPublicIpAddress -Name ($vmName + "-PIP") -ResourceGroupName $rgName -DomainNameLabel $dnsName -Location $locName -AllocationMethod Dynamic
$vnet=Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$nic=New-AzNetworkInterface -Name ($vmName + "-NIC") -ResourceGroupName $rgName -Location $locName -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -PrivateIpAddress "10.0.0.7"
$avSet=Get-AzAvailabilitySet -Name spAvailabilitySet -ResourceGroupName $rgName 
$vm=New-AzVMConfig -VMName $vmName -VMSize $vmSize -AvailabilitySetId $avSet.Id
$vm=Set-AzVMOSDisk -VM $vm -Name ($vmName +"-OS") -DiskSizeInGB 128 -CreateOption FromImage -StorageAccountType "Standard_LRS"
$cred=Get-Credential -Message "Type the name and password of the local administrator account."
$vm=Set-AzVMOperatingSystem -VM $vm -Windows -ComputerName $vmName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm=Set-AzVMSourceImage -VM $vm -PublisherName "MicrosoftSharePoint" -Offer "MicrosoftSharePointServer" -Skus "2019" -Version "latest"
$vm=Add-AzVMNetworkInterface -VM $vm -Id $nic.Id
New-AzVM -ResourceGroupName $rgName -Location $locName -VM $vm
## Connect spVM 
Add-Computer -DomainName "campoh.lab"
Restart-Computer
New-NetFirewallRule -DisplayName "SQL Server ports 1433, 1434, and 5022" -Direction Inbound -Protocol TCP -LocalPort 1433,1434,5022 -Action Allow
Write-Host (Get-AzPublicIpaddress -Name "13.77.127.118" -ResourceGroup $rgName).DnsSettings.Fqdn
##Desplegar un cliente
$rgName="Devops2020_rg"
$locName=(Get-AzResourceGroup -Name $rgName).Location
$vnet=Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgName
$pip=New-AzPublicIpAddress -Name CLIENT1-PIP -ResourceGroupName $rgName -Location $locName -AllocationMethod Dynamic
$nic=New-AzNetworkInterface -Name CLIENT1-NIC -ResourceGroupName $rgName -Location $locName -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id
$vm=New-AzVMConfig -VMName CLIENT1 -VMSize Standard_A1
$cred=Get-Credential -Message "Type the name and password of the local administrator account for CLIENT1."
$vm=Set-AzVMOperatingSystem -VM $vm -Windows -ComputerName CLIENT1 -Credential $cred -ProvisionVMAgent -EnableAutoUpdate
$vm=Set-AzVMSourceImage -VM $vm -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2016-Datacenter -Version "latest"
$vm=Add-AzVMNetworkInterface -VM $vm -Id $nic.Id
$vm=Set-AzVMOSDisk -VM $vm -Name "CLIENT1-OS" -DiskSizeInGB 128 -CreateOption FromImage -StorageAccountType "Standard_LRS"
New-AzVM -ResourceGroupName $rgName -Location $locName -VM $vm
## Detener / Iniciar las maquinas virtuales
$rgName="Devops2020_rg"
Stop-AZVM -Name Client1 -ResourceGroupName $rgName -Force
Stop-AZVM -Name exVM -ResourceGroupName $rgName -Force
Stop-AzVM -Name spVM -ResourceGroupName $rgName -Force
Stop-AzVM -Name sqlVM -ResourceGroupName $rgName -Force
Stop-AZVM -Name adVM -ResourceGroupName $rgName -Force
$rgName="Devops2020_rg"
Start-AZVM -Name adVM -ResourceGroupName $rgName
Start-AZVM -Name exVM -ResourceGroupName $rgName
Start-AzVM -Name sqlVM -ResourceGroupName $rgName
Start-AzVM -Name spVM -ResourceGroupName $rgName
Start-AZVM -Name Client1 -ResourceGroupName $rgName

Plantillas ARM

$location = 'eastus'
$rgName = 'az-rg1'
New-AzResourceGroup -Name $rgName -Location $location
New-AzResourceGroupDeployment `
   -ResourceGroupName $rgName `
   -TemplateFile $HOME/az-vms-template.json `
   -TemplateParameterFile $HOME/az-vm-parameters.json `
   -AsJob

$rgName = 'az-rg2'
New-AzResourceGroup -Name $rgName -Location $location

New-AzResourceGroupDeployment `
   -ResourceGroupName $rgName `
   -TemplateFile $HOME/az-vm-template.json `
   -TemplateParameterFile $HOME/az-vm-parameters.json `
   -nameSuffix 2 `
   -AsJob

$rgName = 'az-rg3'
New-AzResourceGroup -Name $rgName -Location $location

New-AzResourceGroupDeployment `
   -ResourceGroupName $rgName `
   -TemplateFile $HOME/az-vm-template.json `
   -TemplateParameterFile $HOME/az-vm-parameters.json `
   -nameSuffix 3 `
   -AsJob

$virtualNetwork1 =az-vnet01
$virtualNetwork2 =az-vnet02
$virtualNetwork3 =az-vnet03

Add-AzVirtualNetworkPeering `
  -Name myVirtualNetwork1-myVirtualNetwork2 `
  -VirtualNetwork $virtualNetwork1 `
  -RemoteVirtualNetworkId $virtualNetwork2.Id

Add-AzVirtualNetworkPeering `
  -Name myVirtualNetwork2-myVirtualNetwork1 `
  -VirtualNetwork $virtualNetwork2 `
  -RemoteVirtualNetworkId $virtualNetwork1.Id

Get-AzVirtualNetworkPeering `
  -ResourceGroupName myResourceGroup `
  -VirtualNetworkName myVirtualNetwork1 `
  | Select PeeringState

Add-AzVirtualNetworkPeering `
  -Name myVirtualNetwork2-myVirtualNetwork3 `
  -VirtualNetwork $virtualNetwork2 `
  -RemoteVirtualNetworkId $virtualNetwork3.Id

Add-AzVirtualNetworkPeering `
  -Name myVirtualNetwork3-myVirtualNetwork2 `
  -VirtualNetwork $virtualNetwork3 `
  -RemoteVirtualNetworkId $virtualNetwork2.Id

Get-AzVirtualNetworkPeering `
  -ResourceGroupName myResourceGroup `
  -VirtualNetworkName myVirtualNetwork2 `
  | Select PeeringState

$PIP=Get-AzPublicIpAddress `
  -Name az-vm0 `
  -ResourceGroupName myResourceGroup | Select IpAddress

mstsc /v:$PIP

New-NetFirewallRule –DisplayName "Allow ICMPv4-In" –Protocol ICMPv4

mstsc /v:10.1.0.4
ping 10.0.0.4

Install-WindowsFeature RemoteAccess -IncludeManagementTools
Install-WindowsFeature -Name Routing -IncludeManagementTools -IncludeAllSubFeature
Install-WindowsFeature -Name "RSAT-RemoteAccess-Powershell"
Install-RemoteAccess -VpnType RoutingOnly
Get-NetAdapter | Set-NetIPInterface -Forwarding Enabled

Contribuciones

Las solicitudes de extracción son bienvenidas. Para cambios importantes, abra primero un problema para discutir qué le gustaría cambiar.

Asegúrese de actualizar las pruebas según corresponda.

Fabian Alberto Campo
Microsoft Most Valuable Professional 2018-2020
Microsoft Certified Trainer /LinkedIn Learning Author
Website: [www.campohenriquez.com]
LinkedIn: [https://www.linkedin.com/in/fcampo/]
Twitter: [https://twitter.com/fcampo]
Youtube: [https://www.youtube.com/channel/UC5_-RLpII-4R_xyF6R4CZ2Q?view_as=subscriber]

License

MIT

Azure Network planning

Hi people, today i’ve been thinking about what to tell you, about Azure, and Powershell, so i said, why not to talk about inter connectivity and Azure.-

The first think i want to show you is and world map, as you probably know Microsoft Azure is offering 50 Datacenters in a World wide spread… but if you are planning to move your company to the Azure Cloud what should be the best DC to minimize the network lag? well, you should take a look of https://www.submarinecablemap.com which is a fascinating map to understand how we reach the internet providers. there after you migth still asking how to scale our connectivity, so go to http://www.azurespeed.com/ and watch out the better time response from each Azure Datacenter, also you should pay attention of the Azure Status, go to https://azure.microsoft.com/es-es/status/ there is a good start point to plan your networking strategy. When you bring up a resource group in Azure, and deploy a virtual switch in there, you can start constructing a very complex configuration, but you have to start making the doodle, a simple scratch graphic design where you imagine how to bring it up and how to do it. tomorrow i’ll give the next step.

PowerShell is the cloud tool

Nowadays we have a radical change, Windows is no longer Graphic based operating system, and server distributions without GUI are growing faster, least disk space is needed, the WinRM and WMI allows the remote management and using this new paradigm the shell became stronger.

Power Shell became an MIT approved open source project, this mean that anyone can write more contents, commandlets, and functions for Power Shell, even create new branch and modify the shell itself.

I write this article to teach you how to easy is to download and install new modules. the first i want to tell is that you must check the power shell version installed on your computer, to do this you can open Power Shell and write Get-Host, this will show the version. if you have Windows Vista, 7, 8, 8.1 on your computer, it’s almost sure you got Power shell version 3.0 or 4.0, so let’s bring it to the latest version, by access this URL,  after that you can have Power Shell 5.0 or higher, All right.

now we can type Find-Module MSOnline, to retrieve the repository where this module is listed in the latest version, i’ve selected this module because with it you can manage the users, groups and licenses from Office 365, but you gonna need the AzureRM module too, AzureAD, and by the way SQLServer.

bright calamity charge clouds
Photo by Pixabay on Pexels.com

Azure storage con azure-cli

Resulta que no hay muchas capacitaciones o contenidos en los cursos de Azure, sobre como se utiliza el Azure CLI, por eso he decidido hacer una serie de contenidos para reflejar unos interesantes scripts disponibles en Git-Hub sobre este tema en particular.

#!/bin/bash
# A simple Azure Storage example script
#Declaramos las variables. Como queremos que sea el nombre del almacenamiento

#Cabe aclarar que hace falta crear un Resource Group primero…

#Recuerden la estructura, ResourceGroup-StorageAccount-Container
export AZURE_STORAGE_ACCOUNT=<storage_account_name>
export AZURE_STORAGE_ACCESS_KEY=<storage_account_key>

export container_name=<container_name>
export blob_name=<blob_name>
export file_to_upload=<file_to_upload>
export destination_file=<destination_file>
#aqui vamos a crear un nuevo contenedor.
echo «Creating the container…»
az storage container create –name $container_name
#y le copiamos algo de informacion para probar.
echo «Uploading the file…»
az storage blob upload –container-name $container_name –file $file_to_upload –name $blob_name
#para cerrar listamos los BLOBS que tenemos declarados.
echo «Listing the blobs…»
az storage blob list –container-name $container_name –output table
#es posible que necesites descargar contenidos desde tu almacenamiento…
echo «Downloading the file…»
az storage blob download –container-name $container_name –name $blob_name –file $destination_file –output table

echo «Done»

MyAvatar

PPE Azure Hybrid Santo Domingo

onescript_png-550x0

Estuvimos con un grupo maravilloso en las instalaciones de Microsoft de santo domingo en la republica dominicana, desarrollando y fortaleciendo las habilidades de Azure para los partner en un evento de Partner practice enablement, donde vimos los temas de Windows Server 2016 como

Realizamos laboratorios de https://www.microsoft.com/Handsonlabs y pudimos trabajar tambien temas de profundizacion en administracion de Azure, powershell, AzureCLI, y varias herramientas.

Cloud

Recuerden, Me voy agradecido con toda mi audiencia, y reconozco que el evento fue un exito rotundo.

 

Con Azure-CLI desde Linux administra tu tenant de Azure

Bogota, Diciembre 12 de 2017.

En estos días de inquietud mental, me puse a aprender como usar el Azure-CLI (command Line Interface).

Iniciamos conectándonos a Azure con AZ login, Seleccionamos la suscripción con AZ Account, con AZ interactive iniciamos una sesión interactiva, que nos autocompleta los comandos.

sysadmin@SURFACE:~$ sudo -i

[sudo] password for sysadmin:

root@SURFACE:~# az login

To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code FBSYDW8GX to authenticate.

[

{

«cloudName»: «AzureCloud»,

«id»: «6017ae4e-e175-4795-9265-0a775dded652»,

«isDefault»: true,

«name»: «Pay-As-You-Go Dev/Test»,

«state»: «Enabled»,

«tenantId»: «ffb3db32-9dfc-4eae-b841-a4f906b8c449»,

«user»: {

«name»: «fcampo@hotmail.com»,

«type»: «user»

}

},

{

«cloudName»: «AzureCloud»,

«id»: «837632d5-0ee5-468e-aea1-d4290f927a73»,

«isDefault»: false,

«name»: «Plataformas de MSDN»,

«state»: «Enabled»,

«tenantId»: «f35a6d11-e1f6-485b-aedf-cb6735dcc8e6»,

«user»: {

«name»: «fcampo@hotmail.com»,

«type»: «user»

}

}

]

root@SURFACE:~# az –help

 

For version info, use ‘az –version’

 

Group

az

 

Subgroups:

account : Manage subscriptions.

acr : Manage Azure Container Registries.

acs : Manage Azure Container Services.

ad : Synchronize on-premises directories and manage Azure Active Directory

resources.

appservice : Manage your App Service plans.

batch : Manage Azure Batch.

billing : Manage Azure Billing.

cdn : Manage Azure Content Delivery Networks (CDN).

cloud : Manage the registered Azure clouds.

cognitiveservices: Manage Cognitive Services accounts in Azure Resource Manager.

component : Manage and update Azure CLI 2.0 components.

consumption : Manage Azure Consumption.

cosmosdb : Manage Azure Cosmos DB database accounts.

disk : Manage Azure Managed Disks.

dla : Commands to manage Data Lake Analytics accounts, jobs, and catalogs.

dls : Commands to manage Data Lake Store accounts, and filesystems.

feature : Manage resource provider features, such as previews.

functionapp : Manage your function app.

group : Manage resource groups and template deployments.

image : Manage custom Virtual Machine Images.

iot : Connect, monitor, and control millions of IoT assets.

keyvault : Safeguard and maintain control of keys, secrets, and certificates.

lab : Commands to manage DevTest Labs.

lock : Manage Azure locks.

managedapp : Manage template solutions provided and maintained by the ISV using managedapp

and managedapp definitions.

monitor : Commands to manage Azure Monitor service.

mysql : Commands to manage Azure Database for MySQL servers.

network : Manages Azure Network resources.

policy : Manage resource policies.

postgres : Commands to manage Azure Database for PostgreSQL servers.

provider : Manage resource providers.

redis : Access to a secure, dedicated cache for your Azure applications.

resource : Manage Azure resources.

role : Use role assignments to manage access to your Azure resources.

sf : Manage and administer a Service Fabric cluster.

snapshot : Manage point-in-time copies of managed disks, native blobs, or other

snapshots.

sql : Manage Azure SQL Databases and Data Warehouses.

storage : Durable, highly available, and massively scalable cloud storage.

tag : Manage resource tags.

vm : Provision Linux or Windows virtual machines in seconds.

vmss : Create highly available, auto-scalable Linux or Windows virtual machines.

webapp : Manage web apps.

 

Commands:

configure : Configure Azure CLI 2.0 or view your configuration. The command is

interactive, so just type `az configure` and respond to the prompts.

feedback : Loving or hating the CLI? Let us know!

find : Find Azure CLI commands based on a given query.

interactive : Start the interactive experience.

login : Log in to access Azure subscriptions.

logout : Log out to remove access to Azure subscriptions.

 

root@SURFACE:~# az interactive

When in doubt, ask for ‘help’

 

Do you agree to sending telemetry (yes/no)? Default answer is yes: yes

az>> az account list

[

{

«cloudName»: «AzureCloud»,

«id»: «6017ae4e-e175-4795-9265-0a775dded652»,

«isDefault»: true,

«name»: «Pay-As-You-Go Dev/Test»,

«state»: «Enabled»,

«tenantId»: «ffb3db32-9dfc-4eae-b841-a4f906b8c449»,

«user»: {

«name»: «fcampo@hotmail.com»,

«type»: «user»

}

},

{

«cloudName»: «AzureCloud»,

«id»: «837632d5-0ee5-468e-aea1-d4290f927a73»,

«isDefault»: false,

«name»: «Plataformas de MSDN»,

«state»: «Enabled»,

«tenantId»: «f35a6d11-e1f6-485b-aedf-cb6735dcc8e6»,

«user»: {

«name»: «fcampo@hotmail.com»,

«type»: «user»

}

}

]

az>> az account set –subscription «Plataformas de MSDN»

az>> az group create –name myazurelab001 –location eastus2

{

«id»: «/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001»,

«location»: «eastus2»,

«managedBy»: null,

«name»: «myazurelab001»,

«properties»: {

«provisioningState»: «Succeeded»

},

«tags»: null

}

urelab001 –location eastus2 –address-prefixes 10.100.0.0/24 –subnet-name snet001 –subnet-prefix 10.100.0.0/27

{

«newVNet»: {

«addressSpace»: {

«addressPrefixes»: [

«10.100.0.0/24»

]

},

«dhcpOptions»: {

«dnsServers»: []

},

«etag»: «W/\»0e02916a-34f2-45e0-a2f3-89e82fca8ba3\»»,

«id»: «/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001»,

«location»: «eastus2»,

«name»: «vnet001»,

«provisioningState»: «Succeeded»,

«resourceGroup»: «myazurelab001»,

«resourceGuid»: «71d144cc-73d5-4a06-a276-b340b55807fc»,

«subnets»: [

{

«addressPrefix»: «10.100.0.0/27»,

«etag»: «W/\»0e02916a-34f2-45e0-a2f3-89e82fca8ba3\»»,

«id»: «/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001/subnets/snet001»,

«ipConfigurations»: null,

«name»: «snet001»,

«networkSecurityGroup»: null,

«provisioningState»: «Succeeded»,

«resourceGroup»: «myazurelab001»,

«resourceNavigationLinks»: null,

«routeTable»: null

}

],

«tags»: {},

«type»: «Microsoft.Network/virtualNetworks»,

«virtualNetworkPeerings»: []

}

}

create –name storage001 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorage

The storage account named storage001 is already taken.

unt create –name storage00100 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorag

The storage account property ‘accessTier’ is invalid or cannot be set at this time.

rage00100 –resource-group myazurelab001 –location eastus2 –sku Standard_LRS –kind BlobStorage –access-tier Cool

{

«accessTier»: «Cool»,

«creationTime»: «2017-07-26T19:48:54.399653+00:00»,

«customDomain»: null,

«encryption»: null,

«id»: «/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Storage/storageAccounts/storage00100»,

«kind»: «BlobStorage»,

«lastGeoFailoverTime»: null,

«location»: «eastus2»,

«name»: «storage00100»,

«primaryEndpoints»: {

«blob»: «https://storage00100.blob.core.windows.net/«,

«file»: null,

«queue»: null,

«table»: «https://storage00100.table.core.windows.net/»

},

«primaryLocation»: «eastus2»,

«provisioningState»: «Succeeded»,

«resourceGroup»: «myazurelab001»,

«secondaryEndpoints»: null,

«secondaryLocation»: null,

«sku»: {

«name»: «Standard_LRS»,

«tier»: «Standard»

},

«statusOfPrimary»: «available»,

«statusOfSecondary»: null,

«tags»: {},

«type»: «Microsoft.Storage/storageAccounts»

}

az>> az ad app list

[

{

«appId»: «15e431d4-7ab0-4f8d-a3c8-afd0bd271aca»,

«appPermissions»: null,

«availableToOtherTenants»: false,

«displayName»: «heraclito_yMJkalX/21DJERDukzmq5XZ6yshUhyHTZsEDIrqe6m4=»,

«homepage»: «https://management.azure.com//subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourcegroups/rg_campohenriquez/providers/Microsoft.Automation/automationAccounts/heraclito«,

«identifierUris»: [

«https://spn/yMJkalX%2f21DJERDukzmq5XZ6yshUhyHTZsEDIrqe6m4%3d»

],

«objectId»: «cfadc5e8-e497-43c7-8807-4b636e668cb1»,

«objectType»: «Application»,

«replyUrls»: []

}

]

az>> az ad app delete –id 15e431d4-7ab0-4f8d-a3c8-afd0bd271aca

az>> az ad app list

[]

az>> az ad user list

[

{

«displayName»: «Fabian Alberto Campo Henriquez»,

«mail»: null,

«mailNickname»: «fcampo_hotmail.com#EXT#»,

«objectId»: «d6877962-a794-454d-bd2f-cc5a4a7dc1ed»,

«objectType»: «User»,

«signInName»: null,

«userPrincipalName»: «fcampo_hotmail.com#EXT#@salondelmal.onmicrosoft.com»

},

{

«displayName»: «Luis Ronderos»,

«mail»: null,

«mailNickname»: «Luis.Ronderos»,

«objectId»: «d284a888-db3f-4e23-a733-4c65090d5d7f»,

«objectType»: «User»,

«signInName»: null,

«userPrincipalName»: «Luis.Ronderos@salondelmal.onmicrosoft.com»

}

]

az>> az ad user delete –upn-or-object-id luis.ronderos@salondelmal.onmicrosoft.com

az>> az ad user list

[

{

«displayName»: «Fabian Alberto Campo Henriquez»,

«mail»: null,

«mailNickname»: «fcampo_hotmail.com#EXT#»,

«objectId»: «d6877962-a794-454d-bd2f-cc5a4a7dc1ed»,

«objectType»: «User»,

«signInName»: null,

«userPrincipalName»: «fcampo_hotmail.com#EXT#@salondelmal.onmicrosoft.com»

}

]

az>> az vmss create –name lililabdc -g myazurelab001 -l eastus2 –image Win2012R2Datacenter –admin-username liliana –admin-password C0l0mbia2o17$ –vnet-name vnet001 –subnet snet001

{

«vmss»: {

«overprovision»: true,

«provisioningState»: «Succeeded»,

«singlePlacementGroup»: true,

«uniqueId»: «d3e3205d-4028-4cd1-b6f7-95e6ab30686d»,

«upgradePolicy»: {

«mode»: «Manual»

},

«virtualMachineProfile»: {

«networkProfile»: {

«networkInterfaceConfigurations»: [

{

«name»: «lilila97cNic»,

«properties»: {

«dnsSettings»: {

«dnsServers»: []

},

«enableAcceleratedNetworking»: false,

«ipConfigurations»: [

{

«name»: «lilila97cIPConfig»,

«properties»: {

«loadBalancerBackendAddressPools»: [

{

«id»: «/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/loadBalancers/lililabdcLB/backendAddressPools/lililabdcLBBEPool»,

«resourceGroup»: «myazurelab001»

}

],

«loadBalancerInboundNatPools»: [

{

«id»: «/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/loadBalancers/lililabdcLB/inboundNatPools/lililabdcLBNatPool»,

«resourceGroup»: «myazurelab001»

}

],

«privateIPAddressVersion»: «IPv4»,

«subnet»: {

«id»: «/subscriptions/837632d5-0ee5-468e-aea1-d4290f927a73/resourceGroups/myazurelab001/providers/Microsoft.Network/virtualNetworks/vnet001/subnets/snet001»,

«resourceGroup»: «myazurelab001»

}

}

}

],

«primary»: true

}

}

]

},

«osProfile»: {

«adminUsername»: «liliana»,

«computerNamePrefix»: «lilila97c»,

«secrets»: [],

«windowsConfiguration»: {

«enableAutomaticUpdates»: true,

«provisionVMAgent»: true

}

},

«storageProfile»: {

«imageReference»: {

«offer»: «WindowsServer»,

«publisher»: «MicrosoftWindowsServer»,

«sku»: «2012-R2-Datacenter»,

«version»: «latest»

},

«osDisk»: {

«caching»: «ReadWrite»,

«createOption»: «FromImage»,

«managedDisk»: {

«storageAccountType»: «Standard_LRS»

}

}

}

}

}

}

az>> az vmss list-instance-connection-info -g myazurelab001 –name lililabdc

{

«instance 0»: «52.179.172.137:50000»,

«instance 2»: «52.179.172.137:50002»

}

az>>