Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure vm password reset using python #35598

Closed
vaishnavav99 opened this issue May 13, 2024 · 4 comments
Closed

azure vm password reset using python #35598

vaishnavav99 opened this issue May 13, 2024 · 4 comments
Assignees
Labels
Compute - VM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@vaishnavav99
Copy link

vaishnavav99 commented May 13, 2024

I am trying to reset azure vm (both windows and linux) password using python as part of automation.Does azure.mgmt.compute module support VM password rotation. If so please help me with a basic snippet.

when ever I try to do :

compute_client.virtual_machines.begin_update( resource_group_name, vm_name, { 'osProfile': { 'adminPassword': new_password } } ).wait()

Password is getting reset but am not able to login with old or new password

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels May 13, 2024
@xiangyan99 xiangyan99 added Compute - VM Mgmt This issue is related to a management-plane library. and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels May 13, 2024
@github-actions github-actions bot added the needs-team-attention This issue needs attention from Azure service team or SDK team label May 13, 2024
@xiangyan99
Copy link
Member

Thanks for the feedback, we’ll investigate asap.

@msyyc
Copy link
Member

msyyc commented May 14, 2024

Add @ChenxiJiang333 for help on this issue

@ChenxiJiang333
Copy link
Member

ChenxiJiang333 commented May 16, 2024

Hi @vaishnavav99 You can use the following code to reset the password.
For linux:

from azure.mgmt.compute.models import VirtualMachineExtension
response = client.virtual_machine_extensions.begin_create_or_update(
    resource_group_name={resource_group_name}, 
    vm_name={vm_name}, 
    vm_extension_name='enablevmaccess', 
    extension_parameters=VirtualMachineExtension(
        location={location}, 
        protected_settings={'username': {username}, 'password': {password}}))

For Windows:

response = client.virtual_machine_extensions.begin_create_or_update(
    resource_group_name={resource_group_name}, 
    vm_name={vm_name}, 
    vm_extension_name='enablevmaccess', 
    extension_parameters=VirtualMachineExtension(
        location={location}, 
        publisher='Microsoft.Compute',
        type_properties_type='VMAccessAgent', 
        type_handler_version='2.4', 
        protected_settings={'password': {password}}, 
        settings={'userName': {username}}))

@vaishnavav99
Copy link
Author

Hi @ChenxiJiang333 ,
Thanks, it worked for me.

Thanks @xiangyan99 @msyyc .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compute - VM customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants