通过Azure流水线注册Linux虚拟机至环境时config.sh执行失败
config.sh Execution via Azure VM Custom Script Extension Hey there, sorry to hear you're stuck getting your VM registered via the config.sh script through the Azure Custom Script Extension. Let's break down some common fixes and troubleshooting steps since the specific error details weren't included in your question:
1. First, grab the actual error details
The Custom Script Extension logs on Linux will tell you exactly what's going wrong. Check these log files on your VM:
/var/log/azure/custom-script/extension.log/var/log/azure/Microsoft.CPlat.Core.CustomScriptExtension/*/extension.log
These logs will show if the script failed to download, had permission issues, or threw a specific error during execution.
2. Ensure the script has execution permissions
Sometimes when the config.sh script is deployed via the extension, it might not have executable permissions. Modify your extension command to add a permission check first:
chmod +x ./config.sh && ./config.sh --environment --environmentname "myEnvironment" --acceptteeeula --agent $HOSTNAME --url myUrl --work _work --projectname 'routing' --auth PAT --token myToken --unattended
3. Double-check your parameter values and spelling
A lot of script failures come from typos or invalid parameters:
--url myUrl: Make sure this is a valid Azure DevOps organization URL (e.g.,https://dev.azure.com/your-organization-name). Don't leave it as the placeholdermyUrl.$HOSTNAME: Verify this variable resolves correctly in the extension's execution context. Try replacing it with a fixed agent name (likemy-linux-agent) to rule out variable issues.--acceptteeeula: Check if this is a typo—some versions of the Azure DevOps agent script use--acceptTeeEula(camel case) or--accept-eulainstead of all lowercase with extra 'e's.- PAT Token: Confirm your Personal Access Token has the right permissions: it needs Agent Pool (Read & Manage) and Project (Contribute) permissions, and hasn't expired or been revoked.
4. Verify network connectivity from the VM
Your VM needs to reach Azure DevOps and any other required endpoints:
- Test access to your Azure DevOps URL with
curl -v https://your-devops-urlfrom the VM's terminal. - Ensure your VM's NSG rules allow outbound traffic to HTTPS (port 443) for Azure DevOps domains.
- If your script is hosted in Azure Blob Storage, confirm the VM can access that storage account (check firewall settings on the storage account if it's restricted).
5. Test the script manually first
SSH into your VM and run the config.sh command directly. This will let you see the exact error message in real-time, bypassing the Custom Script Extension layer. If it fails manually, you'll know the issue is with the script or parameters, not the extension itself.
6. Check the extension's deployment status
Use the Azure CLI to get detailed status on the extension deployment:
az vm extension show --resource-group <your-resource-group> --vm-name <your-vm-name> --name CustomScriptExtension
Look for the provisioningState and statusMessage fields—they often include helpful error context.
内容的提问来源于stack exchange,提问作者Marlena

