My theory was right, it was due to the repositories not being the ones Azure uses by default after any deployment, to solve the problem I followed this documentation to add the repository, then I added it to my custom script and now it's working properly: https://learn.microsoft.com/en-us/windows-server/administration/linux-package-repository-for-microsoft-software
Repository behavior with Custom Script Extension for installing packages in Linux

Hello everyone,
Currently I am trying to deploy an Ubuntu VM that installs nginx during creation using the Custom Script Extension but I get an error saying that the machine was unable to find the package, here is the complete output I'm getting:
Custom Script Extension Output:
{
"status": "Failed",
"error": {
"code": "VMExtensionProvisioningError",
"message": "VM has reported a failure when processing extension 'webserver-config'. Error message: \"Enable failed: failed to execute command: command terminated with exit status=100
[stdout]
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2083 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [8628 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [338 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [12.5 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [820 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [165 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [17.6 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [22.9 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [5488 B]
Get:14 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [516 B]
Get:15 http://archive.ubuntu.com/ubuntu focal/universe Translation-en [5124 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal/universe amd64 c-n-f Metadata [265 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [144 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal/multiverse Translation-en [104 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 c-n-f Metadata [9136 B]
Get:20 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2465 kB]
Get:21 http://archive.ubuntu.com/ubuntu focal-updates/main Translation-en [420 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [16.4 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1714 kB]
Get:24 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1047 kB]
Get:25 http://archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [247 kB]
Get:26 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [24.2 kB]
Get:27 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [25.1 kB]
Get:28 http://archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [7408 B]
Get:29 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 c-n-f Metadata [592 B]
Get:30 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [45.7 kB]
Get:31 http://archive.ubuntu.com/ubuntu focal-backports/main Translation-en [16.3 kB]
Get:32 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 c-n-f Metadata [1420 B]
Get:33 http://archive.ubuntu.com/ubuntu focal-backports/restricted amd64 c-n-f Metadata [116 B]
Get:34 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [24.9 kB]
Get:35 http://archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [16.3 kB]
Get:36 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [880 B]
Get:37 http://archive.ubuntu.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 24.1 MB in 7s (3499 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
[stderr]
E: Unable to locate package nginx
\"\r
\r
More information on troubleshooting is available at https://aka.ms/VMExtensionCSELinuxTroubleshoot "
}
}
#############################################################################################################
Manual repository update output:
Hit:1 http://azure.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://azure.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://azure.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:4 http://azure.archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:5 http://azure.archive.ubuntu.com/ubuntu focal/universe amd64 Packages [8628 kB]
Get:6 http://azure.archive.ubuntu.com/ubuntu focal/universe Translation-en [5124 kB]
Get:7 http://azure.archive.ubuntu.com/ubuntu focal/universe amd64 c-n-f Metadata [265 kB]
Get:8 http://azure.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [144 kB]
Get:9 http://azure.archive.ubuntu.com/ubuntu focal/multiverse Translation-en [104 kB]
Get:10 http://azure.archive.ubuntu.com/ubuntu focal/multiverse amd64 c-n-f Metadata [9136 B]
Get:11 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [2465 kB]
Get:12 http://azure.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [420 kB]
Get:13 http://azure.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [16.4 kB]
Get:14 http://azure.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [1714 kB]
Get:15 http://azure.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 c-n-f Metadata [612 B]
Get:16 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1047 kB]
Get:17 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [247 kB]
Get:18 http://azure.archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [24.2 kB]
Get:19 http://azure.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [25.3 kB]
Get:20 http://azure.archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [7408 B]
Get:21 http://azure.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 c-n-f Metadata [592 B]
Get:22 http://azure.archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [45.7 kB]
Get:23 http://azure.archive.ubuntu.com/ubuntu focal-backports/main Translation-en [16.3 kB]
Get:24 http://azure.archive.ubuntu.com/ubuntu focal-backports/main amd64 c-n-f Metadata [1420 B]
Get:25 http://azure.archive.ubuntu.com/ubuntu focal-backports/restricted amd64 c-n-f Metadata [116 B]
Get:26 http://azure.archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [24.9 kB]
Get:27 http://azure.archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [16.3 kB]
Get:28 http://azure.archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [880 B]
Get:29 http://azure.archive.ubuntu.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B]
Get:30 http://azure.archive.ubuntu.com/ubuntu focal-security/main amd64 Packages [2083 kB]
Get:31 http://azure.archive.ubuntu.com/ubuntu focal-security/main Translation-en [338 kB]
Get:32 http://azure.archive.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [12.5 kB]
Get:33 http://azure.archive.ubuntu.com/ubuntu focal-security/universe amd64 Packages [820 kB]
Get:34 http://azure.archive.ubuntu.com/ubuntu focal-security/universe Translation-en [165 kB]
Get:35 http://azure.archive.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [17.6 kB]
Get:36 http://azure.archive.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [22.9 kB]
Get:37 http://azure.archive.ubuntu.com/ubuntu focal-security/multiverse Translation-en [5488 B]
Get:38 http://azure.archive.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [516 B]
Fetched 24.1 MB in 5s (4753 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
10 packages can be upgraded. Run 'apt list --upgradable' to see them.
The error is pretty obvious, but what I don't understand is why the machine is updating the repositories from http://archive.ubuntu.com/, when I run "sudo apt update" after the machine is deployed they changed to http://azure.archive.ubuntu.com/. The script I'm running is very simple, it's just a "sudo apt-get update" -y followed by "sudo apt-get install nginx -y" Does anyone know why is it working this way? Is there a workaround to get the repository updated properly to install packages during the VM deployment with the Custom Script Extension?
Azure Virtual Machines
Azure
2 answers
Sort by: Most helpful
-
-
deherman-MSFT 38,021 Reputation points Microsoft Employee Moderator
2023-04-07T19:15:12.0866667+00:00 @Ariel Gonzalez We are glad you were able to resolve your issue. Thank you very much for posting your solution. This will help future community members. Have a great day!