mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-11 12:07:09 +00:00
committed by
GitHub
parent
d09a712b71
commit
8077d7b42b
@@ -12,8 +12,8 @@ Function CreateAzureVMFromPackerTemplate {
|
||||
.PARAMETER ResourceGroupName
|
||||
The Azure resource group name where the Azure virtual machine will be created.
|
||||
|
||||
.PARAMETER TemplatFilePath
|
||||
The path for the json template generated by packer during image generation locally.
|
||||
.PARAMETER ManagedImageName
|
||||
The name of the managed image to be used to create the virtual machine.
|
||||
|
||||
.PARAMETER VirtualMachineName
|
||||
The name of the virtual machine to be generated.
|
||||
@@ -36,7 +36,7 @@ Function CreateAzureVMFromPackerTemplate {
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $ResourceGroupName,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $TemplateFilePath,
|
||||
[string] $ManagedImageName,
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $VirtualMachineName,
|
||||
[Parameter(Mandatory = $True)]
|
||||
@@ -52,7 +52,7 @@ Function CreateAzureVMFromPackerTemplate {
|
||||
$vnetName = $env:UserName + "vnet-" + $guid
|
||||
$subnetName = $env:UserName + "subnet-" + $guid
|
||||
$nicName = $env:UserName + "nic-" + $guid
|
||||
$publicIpName = $env:UserName + "pip-" + $guid
|
||||
$publicIpName = $env:UserName + "pip-" + $guid
|
||||
|
||||
Write-Host "Creating a virtual network and subnet"
|
||||
($vnet = az network vnet create -g $ResourceGroupName -l $AzureLocation -n $vnetName --address-prefixes 10.0.0.0/16 --subnet-name $subnetName --subnet-prefixes 10.0.1.0/24 --subscription $subscriptionId -o json)
|
||||
@@ -70,7 +70,16 @@ Function CreateAzureVMFromPackerTemplate {
|
||||
az network nic ip-config update -g $ResourceGroupName -n ipconfig1 --nic-name $nicName --public-ip-address $publicIpId --subscription $subscriptionId
|
||||
|
||||
Write-Host "`nCreating the VM"
|
||||
az deployment group create -g $ResourceGroupName -n $VirtualMachineName --subscription $subscriptionId --template-file $templateFilePath --parameters vmSize=$vmSize vmName=$VirtualMachineName adminUserName=$AdminUsername adminPassword=$AdminPassword networkInterfaceId=$networkId
|
||||
az vm create `
|
||||
--resource-group $ResourceGroupName `
|
||||
--name $VirtualMachineName `
|
||||
--image $ManagedImageName `
|
||||
--size $vmSize `
|
||||
--admin-username $AdminUsername `
|
||||
--admin-password $AdminPassword `
|
||||
--nics $networkId `
|
||||
--subscription $subscriptionId `
|
||||
--location $AzureLocation
|
||||
|
||||
Write-Host "`nCreated in ${ResourceGroupName}:`n vnet ${vnetName}`n subnet ${subnetName}`n nic ${nicName}`n publicip ${publicIpName}`n vm ${VirtualMachineName}"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user