Skip to content

Commit

Permalink
Merge pull request #23 from AlexanderSehr/users/alsehr/deployTest
Browse files Browse the repository at this point in the history
[Fixes] Diverse fixes & updates regarding permissions & agent pool registration
  • Loading branch information
AlexanderSehr authored Feb 20, 2023
2 parents 3eab840 + 8bf7608 commit c503b60
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .azuredevops/azureDevOpsScaleSet/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ variables:
orchestrationFunctionsPath: 'constructs/azureDevOpsScaleSet/scripts'
sharedOrchestrationFunctionsPath: 'sharedScripts'
location: westeurope
#endregion
#endregion
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ jobs:
$functionInput = @{
TemplateFilePath = Join-Path '$(deploymentFilesPath)' '${{ parameters.environment }}.imageTemplate.bicep'
ImageTemplateName = $env:IMAGETEMPATENAME # template deployment output
ImageTemplateName = $env:IMAGETEMPLATENAME # template deployment output
}
Write-Verbose "Invoke task with" -Verbose
Expand Down
2 changes: 1 addition & 1 deletion .azuredevops/azureImageBuilder/variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ variables:
# StorageAccount related
# ----------------------
uploadsPath: 'constructs/azureImageBuilder/scripts/Uploads'
#endregion
#endregion
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function Sync-ElasticPool {
$env:AZURE_DEVOPS_EXT_PAT = $PAT
}

$getVMSSUri = 'https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachineScaleSets/{2}?api-version=2022-11-01' -f (Get-AzContext).Subscription.Id, $VMSSResourceGroupName, $VMSSName
$getVMSSUri = 'https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachineScaleSets/{2}?api-version=2022-11-01' -f (Get-AzContext).Subscription.id, $VMSSResourceGroupName, $VMSSName
$vmss = (Invoke-AzRestMethod -Method 'GET' -Uri $getVMSSUri).Content | ConvertFrom-Json -AsHashtable
if ($vmss.Keys -contains 'error') {
throw $vmss.error.message
Expand All @@ -117,7 +117,7 @@ function Sync-ElasticPool {
}

$elasticPools = Get-ElasticPool -Organization $Organization -Project $project
if (-not ($elasticPool = $elasticPools | Where-Object { $_.azureId -eq $vmss.Id })) {
if (-not ($elasticPool = $elasticPools | Where-Object { $_.azureId -eq $vmss.id })) {
Write-Verbose "Agent pool for scale set [$VMSSName] in resource group [$VMSSResourceGroupName] not registered, creating new." -Verbose
$inputObject = @{
Organization = $Organization
Expand Down Expand Up @@ -160,12 +160,12 @@ function Sync-ElasticPool {
} else {
Write-Verbose ('The agent pool [{0}] exists and is registered in project [{1}].' -f $poolInProjectScope.name, $Project) -Verbose
}
Write-Verbose ('An agent pool [{0}] with ID [{1}] for scale set [{2}] in resource group [{3}] already exists in organization [{4}]. Updating.' -f $AgentPoolProperties.ScaleSetPoolName, $elasticPool.poolId, $vmss.Name, $vmss.ResourceGroupName, $Organization) -Verbose
Write-Verbose ('An agent pool [{0}] with ID [{1}] for scale set [{2}] in resource group [{3}] already exists in organization [{4}]. Updating.' -f $AgentPoolProperties.ScaleSetPoolName, $elasticPool.poolId, $vmss.name, $VMSSResourceGroupName, $Organization) -Verbose

$inputObject = @{
Organization = $Organization
ScaleSetPoolId = $elasticPool.poolId
VMSSResourceID = $vmss.Id
VMSSResourceID = $vmss.id
VMSSOSType = $vmss.properties.virtualMachineProfile.storageProfile.osDisk.osType
}
if ($AgentPoolProperties.ContainsKey('MaxCapacity')) { $inputObject['MaxCapacity'] = $AgentPoolProperties.MaxCapacity }
Expand Down
Loading

0 comments on commit c503b60

Please # to comment.