Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report]: VMSS #4539

Open
Jackmt9 opened this issue Apr 19, 2024 · 0 comments
Open

[Bug Report]: VMSS #4539

Jackmt9 opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Jackmt9
Copy link

Jackmt9 commented Apr 19, 2024

Describe the bug

When configuring a custom script on a VMSS, it is explicitly using a SAS token for the storage account. This SAS code seems to expire after about a day. On top of that, when using this module for a self-hosted agent I am facing many issues, especially with the custom script. This needs to be addressed. Also there should be a way to add the devops extension via code as well (see below). While it isn't necessary since devops automatically configures it - it would be nice.

// resource resDevOpsAgent 'Microsoft.Compute/virtualMachineScaleSets/extensions@2021-07-01' = {
// name: 'Microsoft.Azure.DevOps.Pipelines.Agent'
// parent: resVirtualMachineScaleSet
// properties: {
// publisher: 'Microsoft.VisualStudio.Services'
// type: 'TeamServicesAgent'
// typeHandlerVersion: '1.31'
// autoUpgradeMinorVersion: false
// }
// }

To reproduce

Run code below and add a document to the storage account. Configure a devops agent using this vmss.

Code snippet

// This should be configured as a self-hosted agent in Azure DevOps. For more information, see here: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/scale-set-agents?view=azure-devops
module modVirtualMachineScaleSet 'br/reference:carml/res/compute/virtual-machine-scale-set/main:1.0' = {
  name: 'Vmss-${uniqueString(deployment().name)}'
  params: {
    name: virtualMachineScaleSet.name
    tags: general.tags
    adminUsername: 'vmssadmin'
    adminPassword: '' // secret value
    imageReference: {
      publisher: 'MicrosoftWindowsServer'
      offer: 'WindowsServer'
      sku: '2022-datacenter-azure-edition'
      version: 'latest'
    }
    encryptionAtHost: false
    osDisk: {
      createOption: 'FromImage'
      diskSizeGB: 127
      managedDisk: {
        storageAccountType: 'StandardSSD_LRS'
      }
    }
    extensionCustomScriptConfig: {
      enabled: true
      fileData: [
        {
          storageAccountId: modStorageAccount.outputs.resourceId
          uri: 'https://${virtualMachineScaleSet.storageAccount.name}.blob.${environment().suffixes.storage}/scripts/customScript.ps1'
        }
      ]
      protectedSettings: {
        commandToExecute: 'powershell -ExecutionPolicy Unrestricted -Command "& ./customScript.ps1"'
      }
    }
    osType: 'Windows'
    skuName: 'Standard_D2s_v3'
    skuCapacity: 1
    singlePlacementGroup: false
    scaleSetFaultDomain: 1
    nicConfigurations: [
      {
        nicSuffix: '.nic'
        ipConfigurations: [
          {
            name: '${virtualMachineScaleSet.name}-defaultIpConfiguration'
            properties: {
              primary: true
              subnet: {
                id: virtualMachineSubnetId
              }
              privateIPAddressVersion: 'IPv4'
            }
          }
        ]
      }
    ]
    // diagnosticSettings: [
    //   {
    //     workspaceResourceId: resourceId(
    //       logAnalytics.resourceGroup,
    //       'Microsoft.OperationalInsights/workspaces',
    //       logAnalytics.name
    //     )
    //   }
    // ]
  }
  dependsOn: [resStorageUpload]
}

Relevant log output

No response

@Jackmt9 Jackmt9 added the bug Something isn't working label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Needs triage
Development

No branches or pull requests

2 participants