Issue with Custom Nginx Command on VM in Azure Sandbox.

Ashish Shilvant 5 Reputation points
2024-01-13T16:26:43+00:00

I'm having trouble running a custom script command to configure Nginx on a VM in the Azure Sandbox. The error message says "Enable failed: failed to execute command: command terminated with exit status=1". Full error details and code snippets are provided in the question. Any suggestions on how to troubleshoot and resolve this issue?

Code: VMExtensionProvisioningError
Message: VM has reported a failure when processing extension 'customScript' (publisher 'Microsoft.Azure.Extensions' and type 'customScript'). Error message: "Enable failed: failed to execute command: command terminated with exit status=1
[stdout]
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [109 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages [14.1 MB]
Get:6 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [1062 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/universe Translation-en [5652 kB]
Get:8 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [201 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [1244 kB]
Get:10 http://security.ubuntu.com/ubuntu jammy-security/restricted Translation-en [203 kB]
Get:11 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [826 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy/universe amd64 c-n-f Metadata [286 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 Packages [217 kB]
Get:14 http://security.ubuntu.com/ubuntu jammy-security/universe Translation-en [156 kB]
Get:15 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 c-n-f Metadata [16.8 kB]
Get:16 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 Packages [37.1 kB]
Get:17 http://archive.ubuntu.com/ubuntu jammy/multiverse Translation-en [112 kB]
Get:18 http://security.ubuntu.com/ubuntu jammy-security/multiverse Translation-en [7476 B]
Get:19 http://security.ubuntu.com/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [260 B]
Get:20 http://archive.ubuntu.com/ubuntu jammy/multiverse amd64 c-n-f Metadata [8372 B]
Get:21 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1277 kB]
Get:22 http://archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [261 kB]
Get:23 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [1272 kB]
Get:24 http://archive.ubuntu.com/ubuntu jammy-updates/restricted Translation-en [207 kB]
Get:25 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1023 kB]
Get:26 http://archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [228 kB]
Get:27 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 c-n-f Metadata [22.1 kB]
Get:28 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [42.1 kB]
Get:29 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse Translation-en [10.1 kB]
Get:30 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 c-n-f Metadata [472 B]
Get:31 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 Packages [41.7 kB]
Get:32 http://archive.ubuntu.com/ubuntu jammy-backports/main Translation-en [10.5 kB]
Get:33 http://archive.ubuntu.com/ubuntu jammy-backports/main amd64 c-n-f Metadata [388 B]
Get:34 http://archive.ubuntu.com/ubuntu jammy-backports/restricted amd64 c-n-f Metadata [116 B]
Get:35 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [24.3 kB]
Get:36 http://archive.ubuntu.com/ubuntu jammy-backports/universe Translation-en [16.5 kB]
Get:37 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 c-n-f Metadata [644 B]
Get:38 http://archive.ubuntu.com/ubuntu jammy-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 28.9 MB in 6s (4587 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  fontconfig-config fonts-dejavu-core libdeflate0 libfontconfig1 libgd3
  libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-geoip2
  libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip2 libtiff5
  libwebp7 libxpm4 nginx-common nginx-core
Suggested packages:
  libgd-tools fcgiwrap nginx-doc ssl-cert
<html><body><h2>Welcome to Azure! My name is my-vm.</h2></body></html>

[stderr]
 - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jammy-security_universe_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jammy-security_universe_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jammy-security_restricted_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jammy-security_restricted_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jammy-security_main_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_jammy-security_main_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-backports_universe_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-backports_universe_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-backports_main_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-backports_main_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_multiverse_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_multiverse_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_universe_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_universe_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_restricted_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_restricted_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_main_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy-updates_main_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_multiverse_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_multiverse_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_universe_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_universe_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_restricted_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_restricted_binary-amd64_Packages - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_main_i18n_Translation-en - open (2: No such file or directory)
E: Could not open file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_jammy_main_binary-amd64_Packages - open (2: No such file or directory)
tee: /var/www/html/index.html: No such file or directory
". More information on troubleshooting is available at https://aka.ms/vmextensionlinuxtroubleshoot. 
Azure | Azure Training
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-01-15T10:49:44.94+00:00

    Hi

    Thank you for reaching out to us on the Microsoft Q&A forum. Based on our understanding of the issue, you're practicing the following Learning Path:

    TopicAZ-900

    Learning PathAzure Fundamentals: Describe Azure architecture and services.

    ModuleDescribe Azure compute and networking services

    Unit3 of 14 Exercise - Create an Azure Virtual Machine

    Please follow these troubleshooting steps to resolve the issue:

    1. Activate a new sandbox and create a new VM as mentioned in the Exercise (step1 at Create a Linux VM and install Nginx).

    2. After step 1, please make a note of Public IP address that was assigned to VM.

    3.Before moving into step2, connect to the newly created VM using ssh command in cloud shell. Please run the following command to connect VM:

    ssh azureuser@<VM public ip address> nginx1

    4. The system gives you to prompt Yes/No. Enter Yes.

    5.  Please run the following commands one after another in cloud shell.

    sudo apt-get update
    
    
    sudo apt-get install -y nginx
    
    echo "<html><body><h2>Welcome to Azure! My name is $(hostname).</h2></body></html>" | sudo tee -a /var/www/html/index.html
    

    nginx2

    · Exit 

    After completing the step 5, continue your module from step2 of Task 1: Create a Linux virtual machine and install Nginx at module 3 of 14.

    If the issue persists, please reach out to us and we'll be glad to assist you.

    If the information provided has been helpful to you then please accept the answer by clicking the Accept Answer or Upvote on the post. We value your feedback, and it will help us to assist others who might have a similar query. Thank you for your contribution in enhancing Microsoft Q&A.

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.