mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-15 22:36:46 +00:00
update docs and pass github access token
This commit is contained in:
11
help/CreateImageAndAzureResources.md
Normal file
11
help/CreateImageAndAzureResources.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Build an image.
|
||||||
|
|
||||||
|
## Create required Azure resources and generate an image
|
||||||
|
|
||||||
|
1. Generating required Azure resources and running a packer build for a targeted image is automated [here](../helpers/GenerateResourcesAndImage.ps1).
|
||||||
|
|
||||||
|
## Create a VM based on the template created by Packer
|
||||||
|
|
||||||
|
1. At the end of the output from running Packer above is a URL to the VM resource template with a read access token. It ends with `.json` plus a query string. Note this URL. For now, it seems like there is an [Az CLI bug](https://github.com/Azure/azure-cli/issues/5899) with specifying the template through a URI. So download the template locally and note the path of the template file.
|
||||||
|
1. Generating the required Azure resources and creating the VM is automated [here](../helpers/CreateAzureVMFromPackerTemplate.ps1).
|
||||||
|
1. After the VM is created, remote into it using its public IP address. You can test the installed tools or install the Azure Pipelines agent and connect it to your Azure DevOps organization.
|
||||||
@@ -61,6 +61,9 @@ Function GenerateResourcesAndImage {
|
|||||||
.PARAMETER Force
|
.PARAMETER Force
|
||||||
Delete the resource group if it exists without user confirmation.
|
Delete the resource group if it exists without user confirmation.
|
||||||
|
|
||||||
|
.PARAMETER GithubFeedToken
|
||||||
|
GitHub PAT to download tool packages from GitHub Package Registry
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
GenerateResourcesAndImage -SubscriptionId {YourSubscriptionId} -ResourceGroupName "shsamytest1" -ImageGenerationRepositoryRoot "C:\virtual-environments" -ImageType Ubuntu1604 -AzureLocation "East US"
|
GenerateResourcesAndImage -SubscriptionId {YourSubscriptionId} -ResourceGroupName "shsamytest1" -ImageGenerationRepositoryRoot "C:\virtual-environments" -ImageType Ubuntu1604 -AzureLocation "East US"
|
||||||
#>
|
#>
|
||||||
@@ -77,10 +80,18 @@ Function GenerateResourcesAndImage {
|
|||||||
[string] $AzureLocation,
|
[string] $AzureLocation,
|
||||||
[Parameter(Mandatory = $False)]
|
[Parameter(Mandatory = $False)]
|
||||||
[int] $SecondsToWaitForServicePrincipalSetup = 30,
|
[int] $SecondsToWaitForServicePrincipalSetup = 30,
|
||||||
|
[Parameter(Mandatory = $True)]
|
||||||
|
[string] $GithubFeedToken,
|
||||||
[Parameter(Mandatory = $False)]
|
[Parameter(Mandatory = $False)]
|
||||||
[Switch] $Force
|
[Switch] $Force
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (([string]::IsNullOrEmpty($version)))
|
||||||
|
{
|
||||||
|
Write-Error "You have to specify valid GitHub PAT to dowload tool packages from GitHub Package Registry"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
$builderScriptPath = Get-PackerTemplatePath -RepositoryRoot $ImageGenerationRepositoryRoot -ImageType $ImageType
|
$builderScriptPath = Get-PackerTemplatePath -RepositoryRoot $ImageGenerationRepositoryRoot -ImageType $ImageType
|
||||||
$ServicePrincipalClientSecret = $env:UserName + [System.GUID]::NewGuid().ToString().ToUpper();
|
$ServicePrincipalClientSecret = $env:UserName + [System.GUID]::NewGuid().ToString().ToUpper();
|
||||||
$InstallPassword = $env:UserName + [System.GUID]::NewGuid().ToString().ToUpper();
|
$InstallPassword = $env:UserName + [System.GUID]::NewGuid().ToString().ToUpper();
|
||||||
@@ -155,5 +166,16 @@ Function GenerateResourcesAndImage {
|
|||||||
$tenantId = $sub.TenantId
|
$tenantId = $sub.TenantId
|
||||||
# "", "Note this variable-setting script for running Packer with these Azure resources in the future:", "==============================================================================================", "`$spClientId = `"$spClientId`"", "`$ServicePrincipalClientSecret = `"$ServicePrincipalClientSecret`"", "`$SubscriptionId = `"$SubscriptionId`"", "`$tenantId = `"$tenantId`"", "`$spObjectId = `"$spObjectId`"", "`$AzureLocation = `"$AzureLocation`"", "`$ResourceGroupName = `"$ResourceGroupName`"", "`$storageAccountName = `"$storageAccountName`"", "`$install_password = `"$install_password`"", ""
|
# "", "Note this variable-setting script for running Packer with these Azure resources in the future:", "==============================================================================================", "`$spClientId = `"$spClientId`"", "`$ServicePrincipalClientSecret = `"$ServicePrincipalClientSecret`"", "`$SubscriptionId = `"$SubscriptionId`"", "`$tenantId = `"$tenantId`"", "`$spObjectId = `"$spObjectId`"", "`$AzureLocation = `"$AzureLocation`"", "`$ResourceGroupName = `"$ResourceGroupName`"", "`$storageAccountName = `"$storageAccountName`"", "`$install_password = `"$install_password`"", ""
|
||||||
|
|
||||||
packer.exe build -on-error=ask -var "client_id=$($spClientId)" -var "client_secret=$($ServicePrincipalClientSecret)" -var "subscription_id=$($SubscriptionId)" -var "tenant_id=$($tenantId)" -var "object_id=$($spObjectId)" -var "location=$($AzureLocation)" -var "resource_group=$($ResourceGroupName)" -var "storage_account=$($storageAccountName)" -var "install_password=$($InstallPassword)" $builderScriptPath
|
packer.exe build -on-error=ask `
|
||||||
|
-var "client_id=$($spClientId)" `
|
||||||
|
-var "client_secret=$($ServicePrincipalClientSecret)" `
|
||||||
|
-var "subscription_id=$($SubscriptionId)" `
|
||||||
|
-var "tenant_id=$($tenantId)" `
|
||||||
|
-var "object_id=$($spObjectId)" `
|
||||||
|
-var "location=$($AzureLocation)" `
|
||||||
|
-var "resource_group=$($ResourceGroupName)" `
|
||||||
|
-var "storage_account=$($storageAccountName)" `
|
||||||
|
-var "install_password=$($InstallPassword)" `
|
||||||
|
-var "github_feed_token=$($GithubFeedToken)" `
|
||||||
|
$builderScriptPath
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user