azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Create an azure VM via python with init script

Open Marwen-TAALLAH opened this issue 2 years ago • 4 comments

Related command

No response

Resource Provider

virtual machine

Description of Feature or Work Requested

I am trying to create a virtual machine on azure via python and having it execute a script on launching time (init script). For this purpose, I am using the custom_data as follows:

custom_data

the custom_data is created this way:

init_script

For the variables inside the init_script: WORKER_SCRIPT_PATH : is the string path to my shell script (an sh file) and the other variables are simple strings.

Now after I execute the script, everything seems to work fine and the VM is created but when I check on azure, I don't find he script!

empty_user_data

AM i missing something?

Minimum API Version Required

N/A

Swagger PR link / SDK link

N/A

Request Example

No response

Target Date

22/09/2022

Additional context

No response

Marwen-TAALLAH avatar Sep 20 '22 14:09 Marwen-TAALLAH

@zhoxing-ms for awareness

yonzhan avatar Sep 20 '22 22:09 yonzhan

@Marwen-TAALLAH Since this is a Python SDK related issue, so I transfer this issue into the azure-sdk-for-python repo

zhoxing-ms avatar Sep 21 '22 03:09 zhoxing-ms

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Sep 21 '22 15:09 ghost

I will make the investigation soon.

msyyc avatar Sep 22 '22 02:09 msyyc

Hi @Marwen-TAALLAH

After my investigation, it will not be displayed on the portal after the script is created. You need to query the running status of the script through the following code.

result = list(compute_client.virtual_machine_run_commands.list_by_virtual_machine(
        resource_group_name=GROUP_NAME,
        vm_name=VIRTUAL_MACHINE_NAME
    ))
    for item in result:
        print(item)

Hope it can help you

Wzb123456789 avatar Oct 12 '22 13:10 Wzb123456789

@Marwen-TAALLAH Could you please let us know if you had a chance to look at the above comment ?

navba-MSFT avatar Oct 19 '22 03:10 navba-MSFT

Hi @Marwen-TAALLAH. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost avatar Oct 19 '22 04:10 ghost

Hi @Marwen-TAALLAH, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

ghost avatar Oct 26 '22 10:10 ghost