mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 03:57:32 +00:00
Fix az cli warnings (#5803)
This commit is contained in:
committed by
GitHub
parent
e38f75e512
commit
86e4ccb246
@@ -28,7 +28,7 @@ Function CreateAzureVMFromPackerTemplate {
|
|||||||
The location where the Azure virtual machine will be provisioned. Example: "eastus"
|
The location where the Azure virtual machine will be provisioned. Example: "eastus"
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
CreateAzureVMFromPackerTemplate -SubscriptionId {YourSubscriptionId} -ResourceGroupName {ResourceGroupName} -TemplateFile "C:\BuildVmImages\temporaryTemplate.json" -VirtualMachineName "testvm1" -AdminUsername "shady1" -AdminPassword "SomeSecurePassword1" -AzureLocation "eastus"
|
CreateAzureVMFromPackerTemplate -SubscriptionId {YourSubscriptionId} -ResourceGroupName {ResourceGroupName} -TemplateFile "C:\BuildVmImages\temporaryTemplate.json" -VirtualMachineName "testvm1" -AdminUsername "shady1" -AdminPassword "SomeSecurePassword1" -AzureLocation "eastus"
|
||||||
#>
|
#>
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $True)]
|
[Parameter(Mandatory = $True)]
|
||||||
@@ -63,14 +63,14 @@ Function CreateAzureVMFromPackerTemplate {
|
|||||||
$networkId = ($nic | ConvertFrom-Json).NewNIC.id
|
$networkId = ($nic | ConvertFrom-Json).NewNIC.id
|
||||||
|
|
||||||
Write-Host "`nCreating a public IP address"
|
Write-Host "`nCreating a public IP address"
|
||||||
($publicIp = az network public-ip create -g $ResourceGroupName -l $AzureLocation -n $publicIpName --allocation-method Static --sku Standard --version IPv4 --subscription $subscriptionId -o json)
|
($publicIp = az network public-ip create -g $ResourceGroupName -l $AzureLocation -n $publicIpName --allocation-method Static --sku Basic --version IPv4 --subscription $subscriptionId -o json)
|
||||||
$publicIpId = ($publicIp | ConvertFrom-Json).publicIp.id
|
$publicIpId = ($publicIp | ConvertFrom-Json).publicIp.id
|
||||||
|
|
||||||
Write-Host "`nAdding the public IP to the NIC"
|
Write-Host "`nAdding the public IP to the NIC"
|
||||||
az network nic ip-config update -g $ResourceGroupName -n ipconfig1 --nic-name $nicName --public-ip-address $publicIpId --subscription $subscriptionId
|
az network nic ip-config update -g $ResourceGroupName -n ipconfig1 --nic-name $nicName --public-ip-address $publicIpId --subscription $subscriptionId
|
||||||
|
|
||||||
Write-Host "`nCreating the VM"
|
Write-Host "`nCreating the VM"
|
||||||
az group deployment create -g $ResourceGroupName -n $VirtualMachineName --subscription $subscriptionId --template-file $templateFilePath --parameters vmSize=$vmSize vmName=$VirtualMachineName adminUserName=$AdminUsername adminPassword=$AdminPassword networkInterfaceId=$networkId
|
az deployment group create -g $ResourceGroupName -n $VirtualMachineName --subscription $subscriptionId --template-file $templateFilePath --parameters vmSize=$vmSize vmName=$VirtualMachineName adminUserName=$AdminUsername adminPassword=$AdminPassword networkInterfaceId=$networkId
|
||||||
|
|
||||||
Write-Host "`nCreated in ${ResourceGroupName}:`n vnet ${vnetName}`n subnet ${subnetName}`n nic ${nicName}`n publicip ${publicIpName}`n vm ${VirtualMachineName}"
|
Write-Host "`nCreated in ${ResourceGroupName}:`n vnet ${vnetName}`n subnet ${subnetName}`n nic ${nicName}`n publicip ${publicIpName}`n vm ${VirtualMachineName}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ $TempResourceGroupName = "${ResourcesNamePrefix}_${Image}"
|
|||||||
|
|
||||||
$groupExist = az group exists --name $TempResourceGroupName --subscription $SubscriptionId
|
$groupExist = az group exists --name $TempResourceGroupName --subscription $SubscriptionId
|
||||||
if ($groupExist -eq "true") {
|
if ($groupExist -eq "true") {
|
||||||
$osDiskName = az group deployment list --resource-group $TempResourceGroupName --query "[].properties.parameters.osDiskName.value" -o tsv
|
$osDiskName = az deployment group list --resource-group $TempResourceGroupName --query "[].properties.parameters.osDiskName.value" -o tsv
|
||||||
Write-Host "Found a match, deleting temporary files"
|
Write-Host "Found a match, deleting temporary files"
|
||||||
az group delete --name $TempResourceGroupName --subscription $SubscriptionId --yes | Out-Null
|
az group delete --name $TempResourceGroupName --subscription $SubscriptionId --yes | Out-Null
|
||||||
Write-Host "Temporary group was deleted successfully"
|
Write-Host "Temporary group was deleted successfully"
|
||||||
|
|||||||
Reference in New Issue
Block a user