如何使用 azure .Net SDK/Fluent API/REST API 根据 azure 中的区域获取时区?

问题描述

我正在使用带有 .Net 核心的 ARM 模板对 VM 进行自动关闭现在我想显示时区下拉列表,azure 门户显示基于部署在哪个区域的 VM。 我附上了截图。

enter image description here

解决方法

REST API 端点

https://management.azure.com/subscriptions/{yourSubscriptionId}/resourceGroups/{yourResourceGroup}/providers/Microsoft.Compute/virtualMachines/{yourVMName}?$expand=instanceView&api-version=2020-12-01

应该返回一些东西,包括:

        "osProfile": {
            "computerName": "computername","adminUsername": "adminusername","windowsConfiguration": {
                "provisionVMAgent": true,"enableAutomaticUpdates": true,"patchSettings": {
                    "patchMode": "AutomaticByOS"
                }
            },

现在,您在那里看不到 timeZone - REST API 文档说它应该在 windowsConfiguration 下。我推测它可能丢失了,因为我没有改变任何东西,而且它是默认的。

你也可以运行

$vm = Get-AzVM -Name {vmName}
$vm.OSProfile.WindowsConfiguration

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...