1. C:\ITnator
  2. PowerShell

Virtuelle Maschine in Microsoft Azure erstellen

Autor
Johannes Huber
Veröffentlicht
Aktualisiert
Lesezeit
2 Minuten
Comic: Admin vor einem Monitor mit PowerShell, zum Artikel: Virtuelle Maschine in Microsoft Azure erstellen

Microsoft Azure kommt immer mehr! Hier liegen beispielsweise unsere Virtuellen Maschinen in der Cloud. Virtuelle Maschine in Microsoft Azure anzulegen, bzw. zu erstellen ist aber mit PowerShell kein Problem!

Was ist Microsoft Azure ?

Microsoft Azure ist eine Sammlung integrierter Clouddienste, die ständig erweitert wird. Entwickler und IT-Profis nutzen Azure, um Anwendungen über unser globales Netzwerk aus Rechenzentren zu erstellen, bereitzustellen und zu verwalten.

Voraussetzungen: Azure PowerSehll Modul 4.0 oder höher
Um die installiere Version zu finden, folgenden Befehl ausführen:

PowerShell
Get-Module -ListAvailable AzureRM

Virtuelle Maschine in Microsoft Azure erstellen / anlegen

Um eine Verbindung zu Azure herzustellen, muss man folgenden Befehl ausführen:

PowerShell
Login-AzureRmAccount

Mit folgenden Script erstellt man nun eine neue virtuelle Maschine in Microsoft Azure:

PowerShell
# Variablen
$resourceGroup = "myResourceGroup"
$location = "westeurope"
$vmName = "myVM"

# User Objekt erstellen
$cred = Get-Credential -Message "Benutzernamen und Passwort fuer die VM eingeben."

# resource group erstellen
New-AzureRmResourceGroup -Name $resourceGroup -Location $location

# Subnetz configuration
$subnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name mySubnet -AddressPrefix 192.168.1.0/24

# virtual network erstellen
$vnet = New-AzureRmVirtualNetwork -ResourceGroupName $resourceGroup -Location $location `
  -Name MYvNET -AddressPrefix 192.168.0.0/16 -Subnet $subnetConfig

# oeffentliche IP address 
$pip = New-AzureRmPublicIpAddress -ResourceGroupName $resourceGroup -Location $location `
  -Name "mypublicdns$(Get-Random)" -AllocationMethod Static -IdleTimeoutInMinutes 4

# Create an inbound network security group rule for port 3389
$nsgRuleRDP = New-AzureRmNetworkSecurityRuleConfig -Name myNetworkSecurityGroupRuleRDP  -Protocol Tcp `
  -Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * `
  -DestinationPortRange 3389 -Access Allow

# Create a network security group
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $resourceGroup -Location $location `
  -Name myNetworkSecurityGroup -SecurityRules $nsgRuleRDP

# Create a virtual network card and associate with public IP address and NSG
$nic = New-AzureRmNetworkInterface -Name myNic -ResourceGroupName $resourceGroup -Location $location `
  -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id -NetworkSecurityGroupId $nsg.Id

# Create a virtual machine configuration
$vmConfig = New-AzureRmVMConfig -VMName $vmName -VMSize Standard_D1 | `
Set-AzureRmVMOperatingSystem -Windows -ComputerName $vmName -Credential $cred | `
Set-AzureRmVMSourceImage -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2016-Datacenter -Version latest | `
Add-AzureRmVMNetworkInterface -Id $nic.Id

# Create a virtual machine
New-AzureRmVM -ResourceGroupName $resourceGroup -Location $location -VM $vmConfig

Mit dieser Anleitung konntet ihr hoffentlich eure VM erstellen und konfigurieren :-)

Johannes Huber

Administrator bei ITnator

Schreibt über Probleme aus der Administration von Servern, Clients und vielen weiteren IT-Komponenten.

0 Kommentare

Kommentar schreiben

Kommentare erscheinen nach unserer Prüfung. Gespeichert werden Name und Text, siehe Datenschutz.