使用AzureRM Rest api重置VM上的本地管理员用户
我正在使用AzureRM rest api与虚拟机监控程序通信。我需要做的一件事是在VM上重置本地管理员密码,但是我不知道如何重置它 我们可以使用。这对我来说是正确的。以下是我的详细测试信息 1.我们需要在请求头中获取使用AzureRM Rest api重置VM上的本地管理员用户,rest,azure,azure-virtual-machine,azure-resource-manager,Rest,Azure,Azure Virtual Machine,Azure Resource Manager,我正在使用AzureRM rest api与虚拟机监控程序通信。我需要做的一件事是在VM上重置本地管理员密码,但是我不知道如何重置它 我们可以使用。这对我来说是正确的。以下是我的详细测试信息 1.我们需要在请求头中获取 Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz....... Content-Type:application/json 2.在请求正文中添加以下信息 { "properties": { "publisher"
Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUz.......
Content-Type:application/json
2.在请求正文中添加以下信息
{
"properties": {
"publisher": "Microsoft.Compute",
"type": "VMAccessAgent",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"UserName": "local admin" //your local admin
},
"protectedSettings": {
"Password": "your reset passord" //match the password policy
}
},
"location": "East Asia"
}
您还可以使用Azure.NET SDK,该SDK为应用程序提供了一个包装器 我尝试并遇到了一个问题,VM扩展请求顺利通过并成功安装,但密码没有更新 连接fiddler后,我发现库没有正确序列化我的
settings
和protectedSettings
的动态对象。解决方案是将字典传递给VirtualMachineExtensions()
构造函数
之前:
proxy.VirtualMachineExtensions.BeginCreateOrUpdateWithHttpMessagesAsync(
"<resource group>",
"<vm name>",
"<you name it>",
new Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension(
location: "westus",
publisher: "Microsoft.Compute",
virtualMachineExtensionType: "VMAccessAgent",
typeHandlerVersion: "2.0",
autoUpgradeMinorVersion: true,
settings: new
{
UserName: "<username>"
},
protectedSettings: new
{
Password: "<password>"
}));
proxy.VirtualMachineExtensions.begincreateorupdateWithHttpMessageAsync(
"",
"",
"",
新的Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension(
地点:“westus”,
发布者:“Microsoft.Compute”,
VirtualMachineeExtensionType:“VMAccessAgent”,
typeHandlerVersion:“2.0”,
自动升级MinorVersion:true,
设置:新建
{
用户名:“
},
protectedSettings:新建
{
密码:“
}));
之后:
proxy.VirtualMachineExtensions.BeginCreateOrUpdateWithHttpMessagesAsync(
"<resource group>",
"<vm name>",
"<you name it>",
new Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension(
location: "westus",
publisher: "Microsoft.Compute",
virtualMachineExtensionType: "VMAccessAgent",
typeHandlerVersion: "2.0",
autoUpgradeMinorVersion: true,
settings: new Dictionary<string, string>()
{
{ "UserName", "<username>" }
},
protectedSettings: new Dictionary<string, string>()
{
{"PassWord", "<password>" }
}));
proxy.VirtualMachineExtensions.begincreateorupdateWithHttpMessageAsync(
"",
"",
"",
新的Microsoft.Azure.Management.Compute.Models.VirtualMachineExtension(
地点:“westus”,
发布者:“Microsoft.Compute”,
VirtualMachineeExtensionType:“VMAccessAgent”,
typeHandlerVersion:“2.0”,
自动升级MinorVersion:true,
设置:新建字典()
{
{“用户名”,“用户名”}
},
protectedSettings:新字典()
{
{“密码”,“密码”}
}));
从屏幕截图中,我看到您正在使用名为tomtest的扩展名,您从哪里获得该名称?我们可以随意使用该扩展名,如果该扩展名不存在,则将为我们创建一个新的扩展名。http方法是Put
。如果对此线程有任何问题,请随时通知我。是否可以使用应用程序注册请求重置密码?根据你的回答,我在SO中提出了一个问题。但是还不能让它为我工作。我可以通过实际设置确切的扩展名来解决我的问题:enablevmaccess
,所以我最后的URL是这样的:https://management.azure.com/subscriptions/MySubscr/resourceGroups/MyRG/providers/Microsoft.Compute/virtualMachines/MyVM/extensions/enablevmaccess?api-version=2020-12-01
您有关于此线程的任何更新吗?