环境:macOS
安装PowerShell
https://github.com/PowerShell/PowerShell/releases
安装azure模块
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
source /Users/macbookair/.zprofile
Azure Networking
使用portal.azure.com 试试AzureNetworking --省略
使用PowerShell 实施AzureNetworking
New-AzResourceGroup -Name RSG-LinuxVNET -Location EastUS --创建资源组
Get-AzResourceGroup -Name RSG-LinuxVNET
Get-AzVirtualNetwork -Name RSG-LinuxVNET
Get-AzVirtualNetwork -Name VNET-Linux
$LinuxVNET = New-AzVirtualNetwork -ResourceGroupName RSG-LinuxVNET -Location EastUS -Name VNET-Linux -AddressPrefix 10.0.0.0/16 --创建虚拟网络
$LinuxSubnet = Add-AzVirtualNetworkSubnetConfig -Name SNET-Linux-1 -AddressPrefix 10.0.0.0/17 -VirtualNetwork $LinuxVNET --创建虚拟子网
Get-AzVirtualnetworkSubnetConfig -Name SNET-Linux -VirtualNetwork $LinuxVNET
$LinuxSubnet | Set-AzVirtualNetwork --虚拟子网绑定虚拟网络
Managed Disks
fault domains --相同子网的资源
UPDATE DOMAINS --相同物理机的子网内资源
availability Sets --夸fault domains和update domians的多组资源
scale sets --
使用powershell创建虚拟机
New-AzResourceGroup -Name rsg-LinuxVms -Location EastUS --创建资源组
$securePassword = ConvertTo-SecureString 'sdfadasf163coM' -AsPlainText -Force --设置密码
$cred = New-Object System.Management.Automation.PSCredential("cloudadmin",$securePassword) --设置用户名和密码
New-AzVM -ResourceGroupName "rsg-LinuxVms" -Name "cloud-simplelinux" -Image "UbuntuLTS" -VirtualNetworkName "VNET-Linux" -SubnetName "SNET-Linux-1" -PublicIpAddressName "cloud-simplelinux-pip" -Credential $cred -OpenPorts 22
--在已有虚拟网的子网下创建虚拟机
$vnet = Get-AzVirtualNetwork -Name "VNET-Linux"
$subnet = Get-AzVirtualNetworkSubnetconfig -Name "SNET-Linux-1" -VirtualNetwork $vnet
$pip = New-AzPublicIpAddress -ResourceGroupName "rsg-LinuxVms" -Location "EastUS" -Name "cloud-linux-pip" -AllocationMethod Dynamic
$nsgRuleSSH = New-AzNetworkSecurityRuleConfig -Name "SSH" -Protocol "TCP" -Direction "Inbound" -Priority 1000 -SourceAddressPrefix * -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 22 -Access "Allow"
$nsg = New-AzNetworkSecurityGroup -ResourceGroupName "rsg-LinuxVms" -Location "EastUS" -Name "could-linux-nsg" -SecurityRules $nsgRuleSSH
$nic = New-AzNetworkInterface -Name "cloud-linux-nic1" -ResourceGroupName "rsg-LinuxVms" -Location "EastUS" -SubnetId $subnet.Id -PublicIpAddressId $pip.Id -NetworksecurityGroupId $nsg.Id
$vmConfig = New-AzVmConfig -VMName "cloud-linux" -VMSize Standard_B1s
$securePassword = ConvertTo-SecureString 'sdfadasf163coM' -AsPlainText -Force --设置密码
$cred = New-Object System.Management.Automation.PSCredential("cloudadmin",$securePassword) --设置用户名和密码
Set-AzVmOperatingSystem -Linux -ComputerName "cloud-linux" -Credential $cred -VM $vmConfig --设置虚拟机
Set-AzVmSourceImage -publisherName "Canonical" -Offer "ubuntuServer" -Skus "16.04-LTS" -Version "latest" -VM $vmConfig --虚拟机选择镜像
Add-AzVMNetworkInterface -Id $nic.Id -VM $vmConfig --给虚拟机选网卡
New-AZVM -ResourceGroupName "rsg-LinuxVms" -Location "EastUS" -VM $vmConfig --初始化虚拟机
使用ARM模板实现自动化
azure devops