# Provide values for the variables # Provide a name for your resource group that would all your used in creating your FushionHub VM $resourceGroup = 'testfhb33' # Provide values the Azure location where you would like the FusionHub VM to be created. # A location list can be found here https://azure.microsoft.com/en-gb/global-infrastructure/locations/, you will enter here name under the heading region $location = 'uk south' # Provide a name for the storage account $storageaccount = 'fhbstorageaccount33' # Locally redundant storage (LRS) replicates your data three times within a single physical location in the primary region. # LRS provides at least 99.999999999% (11 nines) durability of objects over a given year. LRS is the lowest-cost redundancy # option and offers the least durability compared to other options. This option is sufficent for FusionHub $storageType = 'Standard_LRS' # Provide a name for the container where the FusionHub VHD will be located in the storage account. $containername = 'fhbcontainer' # Provide the full location on your PC for the FusionHub VDH $localPath = 'D:\Downloads\fusionhub-8.0.1-build1644\FusionHub\VHD\fusionhub.vhd' # Unless you have changed the default name of the FusionHub VHD (Not recommended) the one below is the # correct default as currently provided by Peplink $vhdName = 'fusionhub.vhd' #Provide the subscription Id where Managed Disks will be created $subscriptionId = '01508fa3-2635-40c1-821f-3dc3c720e8fe' #Provide the name of the Managed Disk $diskName = 'testdiskfhb' #Provide the size of the disks in GB. It should be greater than the VHD file size. $diskSize = '4' #Provide the URI of the VHD file (page blob) in a storage account. Please not that this is NOT the SAS URI of the storage container where VHD file is stored. #e.g. https://contosostorageaccount1.blob.core.windows.net/vhds/contosovhd123.vhd #Note: VHD file can be deleted as soon as Managed Disk is created. $sourceVHDURI = 'https://fhbstorageaccount33.blob.core.windows.net/fhbcontainer/fusionhub.vhd' #Provide the resource Id of the storage account where VHD file is stored. #e.g. /subscriptions/6472s1g8-h217-446b-b509-314e17e1efb0/resourceGroups/MDDemo/providers/Microsoft.Storage/storageAccounts/contosostorageaccount #This is an optional parameter if you are creating managed disk in the same subscription $storageAccountId = '/subscriptions/01508fa3-2635-40c1-821f-3dc3c720e8fe/resourceGroups/testfhb33/providers/Microsoft.Storage/storageAccounts/fhbstorageaccount33' # Provide a name for the Subnet $subnetName = 'fhbSubnet' # Provide a name for the Virtual Network $vnetName = 'fhbVnet' # Provide a name for the Network Security Group $nsgName = 'fhbNsg' # Provide a name for the rule that will control access to the VM via SSH $ruleName = 'fhbRdpRule' #Provide the name of an existing virtual network where virtual machine will be created $virtualNetworkName = 'fhbVnet' #Provide the name of the virtual machine $virtualMachineName = 'testfhbVM' #Provide the size of the virtual machine #e.g. Standard_DS3 #Get all the vm sizes in a region using below script: #e.g. Get-AzureRmVMSize -Location ukwest $virtualMachineSize = 'Basic_A0' #Connect to Azure Connect-AzAccount Set-Item Env:\SuppressAzurePowerShellBreakingChangeWarnings "true" # Upload the VHD New-AzResourceGroup -Name $resourceGroup -Location $location New-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccount -Location $location ` -SkuName $storageType -Kind "Storage" $urlOfUploadedImageVhd = ('https://' + $storageaccount + '.blob.core.windows.net/' + $containername + '/' + $vhdName) Add-AzVhd -ResourceGroupName $resourceGroup -Destination $urlOfUploadedImageVhd ` -LocalFilePath $localPath # Note: Uploading the VHD may take awhile! #Create a managed disk from VHD #Set the context to the subscription Id where Managed Disk will be created Select-AzSubscription -SubscriptionId $SubscriptionId $diskConfig = New-AzDiskConfig -AccountType $storageType -Location $location -CreateOption Import -StorageAccountId $storageAccountId -SourceUri $sourceVHDURI New-AzDisk -Disk $diskConfig -ResourceGroupName $resourceGroup -DiskName $diskName # Create the networking resources $singleSubnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24 $vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroup -Location $location ` -AddressPrefix 10.0.0.0/16 -Subnet $singleSubnet $rdpRule = New-AzNetworkSecurityRuleConfig -Name $ruleName -Description 'Allow SSH' -Access Allow ` -Protocol Tcp -Direction Inbound -Priority 110 -SourceAddressPrefix Internet -SourcePortRange * ` -DestinationAddressPrefix * -DestinationPortRange 22 $nsg = New-AzNetworkSecurityGroup -ResourceGroupName $resourceGroup -Location $location ` -Name $nsgName -SecurityRules $rdpRule $vnet = Get-AzVirtualNetwork -ResourceGroupName $resourceGroup -Name $vnetName #Create Fushion Hub VM #Set the context to the subscription Id where the managed disk is located Select-AzSubscription -SubscriptionId $SubscriptionId #Get the Managed Disk based on the resource group and the disk name $disk = Get-AzDisk -ResourceGroupName $resourceGroup -DiskName $diskName #Initialize virtual machine configuration $VirtualMachine = New-AzVMConfig -VMName $virtualMachineName -VMSize $virtualMachineSize #Use the Managed Disk Resource Id to attach it to the virtual machine. Please change the OS type to linux if OS disk has linux OS $VirtualMachine = Set-AzVMOSDisk -VM $VirtualMachine -ManagedDiskId $disk.Id -CreateOption Attach -Linux #Create a public IP for the VM $publicIp = New-AzPublicIpAddress -Name ($VirtualMachineName.ToLower() + '_ip') -ResourceGroupName $resourceGroup -Location $Location -AllocationMethod Dynamic #Get the virtual network where virtual machine will be hosted $vnet = Get-AzVirtualNetwork -Name $virtualNetworkName -ResourceGroupName $resourceGroup # Create NIC in the first subnet of the virtual network $nic = New-AzNetworkInterface -Name ($VirtualMachineName.ToLower() + '_nic') -ResourceGroupName $resourceGroup -Location $Location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $publicIp.Id $VirtualMachine = Add-AzVMNetworkInterface -VM $VirtualMachine -Id $nic.Id #Create the virtual machine with Managed Disk New-AzVM -VM $VirtualMachine -ResourceGroupName $resourceGroup -Location $Location