how to set bash variable in azure correct ?

2024-05-09T05:41:18.4333333+00:00

Hello , i had created the vitual VMs before , i want to create a bash variable in this command :

IPADDRESS="$(az vm list-ip-addresses --resource-group "[learn-create-subscription]" --name my-vm --query "[].virtualMachine.network.publicIpAddresses[*].ipAddress" --output tsv)"

i receipted an error :

'IPADDRESS=$(az vm list-ip-addresses --resource-group [learn-create-subscription] --name my-vm --query [].virtualMachine.network.publicIpAddresses[*].ipAddress --output tsv)' is misspelled or not recognized by the system.

how can i fix this, it may be wrong a syntax right ? This question is related to the following Learning Module

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,078 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Abdul 1,795 Reputation points Microsoft Vendor
    2024-05-09T07:56:38.48+00:00

    Hi 197CT31523 - TRẦN NGUYỄN MINH THÀNH - K25T-IT1,

    Thank you for reaching out to Q&A forum. Based on the query provided, it's evident that you are encountering difficulties related to azure cloud shell.

    • Can you please confirm whether you encountered any error messages upon completing the Exercise in Unit 3, Task 1, step 2? Ensuring smooth completion is crucial for achieving the expected results in the Configure Network Access (Unit 9) exercise you are currently undertaking.
    • Please navigate to Exercise - Configure network access, activate sandbox, review permissions, accept, etc. Verify in the code blocks that the resource group name as changed to something like learn-3294a2f5-b8ec-2def-ca62-49e23701bd77 instead of [sandbox resource group name].
    • In Task 1, Access your web server, execute the command below to retrieve your VM's IP address, and then store the result as a Bash variable:
    IPADDRESS="$(az vm list-ip-addresses --resource-group "learn-316a3089-2d07-40d4-90a5-9076280d0c6b" --name my-vm --query "[].virtualMachine.network.publicIpAddresses[*].ipAddress" --output tsv)"
    

    We've made several attempts from our side and managed to complete the exercise successfully each time. Below is a screenshot for your reference: vmimage

    Continue the learning process, if you are still running into issues, kindly attach the screenshots for reference and please let us know in the comments. We are happy to assist you.

    If the information is helpful, please Accept Answer & Upvote so that it would be helpful to other community members.

    Thank You.

    0 comments No comments