How do I resolve this error, " Unable to locate package nginx"?

Caleb Ala 75 Reputation points
2023-10-02T06:27:38.9266667+00:00

I am trying to configure Nginx on my VM. This is in unit 3 of module 5 (Describe Azure Compute and Network Services) of the Azure900 series. I copied the code and pasted it into the Azure CLI but when i entered it, this error came up:

E: Unable to locate package nginx

tee: /var/www/html/index.html: No such file or directory

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,052 questions
Azure | Azure Training
{count} votes

Accepted answer
  1. shiva patpi 13,366 Reputation points Microsoft Employee Moderator
    2023-10-02T17:44:26.74+00:00

    @Caleb Ala

    Can you try creating the new sandbox and re-run those commands ?

    I just tried and it went through fine with out any issues.

    Below are my screen shots:

    VM Creation went through fine:

    User's image

    Azure Extension set also went through fine:

    User's image

    I just validated the path of nginx , which looks good.

    Please try in a new sandbox environment, it should go through for sure !

    Regards,

    Shiva.

    1 person found this answer helpful.

3 additional answers

Sort by: Most helpful
  1. Olli Kantola 105 Reputation points
    2023-12-28T11:31:35.4533333+00:00

    I solved this same issue by running each line of the bash script on their own:

    az vm extension set \
      --resource-group learn-ffeca64e-2976-420c-a4fe-b83d4a789334 \
      --vm-name my-vm \
      --name customScript \
      --publisher Microsoft.Azure.Extensions \
      --version 2.1 \
      --protected-settings '{"commandToExecute": "sudo apt-get update"}'
    
    
    az vm extension set \
      --resource-group learn-ffeca64e-2976-420c-a4fe-b83d4a789334 \
      --vm-name my-vm \
      --name customScript \
      --publisher Microsoft.Azure.Extensions \
      --version 2.1 \
      --protected-settings '{"commandToExecute": "sudo apt-get install -y nginx"}'
    
    
    az vm extension set \
      --resource-group learn-ffeca64e-2976-420c-a4fe-b83d4a789334 \
      --vm-name my-vm \
      --name customScript \
      --publisher Microsoft.Azure.Extensions \
      --version 2.1 \
      --protected-settings '{"commandToExecute": "echo \"<html><body><h2>Welcome to Azure! My name is $(hostname).</h2></body></html>\" | sudo tee /var/www/html/index.html"}'
    
    
    21 people found this answer helpful.

  2. Lincoln G 5 Reputation points
    2023-10-10T02:56:36.83+00:00

    I ran into the same issue; I ended up SSHing into the VM and installed NGINX with apt install; it worked with no issue when doing it that way. No idea why the extension wouldn't work for me.

    1 person found this answer helpful.
    0 comments No comments

  3. Anonymous
    2023-10-13T14:03:02.17+00:00

    I just ran in to the same issue. I then recreated a new sandbox and again hit the "Enable failed: failed to execute command: command terminated with exit status=1" error, where it was unable to locate the nginx.

    0 comments No comments

Your answer

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