Cloud Shell에서 하면 최초 인증작업 필요없음.

 

 

 

$location = 'koreacentral'
$vmName = 'testcompevm1'
$rgName = 'RGeastus2'
$nicName = 'comp-test-ccc-vm01-nic'
$pipName = 'comp-test-ccc-vm01-pip'
$azureVmOsDiskName = 'comp-test-ccc-vm01-osdisk'
$datadiskName = 'comp-test-ccc-vm01-disk'


$adminName = 'bigcccmgr01'
$VMAdminPassword = 'cccP@a!xtnV7X'
$vmSize = 'Standard_B1ms'

$vnetName = 'vnet01'
$subnet1Name = 'default'


# 1번
# public ip address
$pip = New-AzureRmPublicIpAddress -Name $pipName -ResourceGroupName $rgName -Location $location -AllocationMethod Static


# 2번
# vnet 확인
$vnet = Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $rgName

# 3번
# 서브넷 config
$subnetconfig = Get-AzureRmVirtualNetworkSubnetConfig -Name $subnet1Name -VirtualNetwork $vnet

# 4번
#계정정보
$password = $VMAdminPassword | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object PSCredential ($adminName, $password)
$vm = New-AzureRmVMConfig -VMName $VMName -VMSize $vmSize


# 5번
#nic 생성
$nic = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgName -Location $location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id

# 6번
#vm 준비
$vm = Set-AzureRmVMOperatingSystem -VM $vm -Windows -ComputerName $vmName -Credential $cred
$vm = Set-AzureRmVMSourceImage -VM $vm -PublisherName 'MicrosoftWindowsServer' -Offer 'WindowsServer' -Skus '2012-R2-Datacenter' -Version 'latest'
$vm = Set-AzureRmVMOSDisk -VM $vm -StorageAccountType 'Standard_LRS' -Name $azureVmOsDiskName -CreateOption FromImage
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic.Id



New-AzureRmVM -ResourceGroupName $rgName -Location $location -VM $vm
$VirtualMachine = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName
$vmDataDisk01Config = New-AzureRmDiskConfig -SkuName Standard_LRS -Location $location -CreateOption Empty -DiskSizeGB 50
$vmDataDisk01 = New-AzureRmDisk -DiskName $datadiskName -Disk $vmDataDisk01Config -ResourceGroupName $rgName
$VirtualMachine = Add-AzureRmVMDataDisk -VM $VirtualMachine -Name $datadiskName -Lun 0 -CreateOption Attach -ManagedDiskId $vmDataDisk01.Id

Update-AzureRmVM -ResourceGroupName $rgName -VM $VirtualMachine




+ Recent posts