为什么New-AzureRmVM会给实体名称错误?

时间:2016-02-05 22:16:19

标签: regex azure azure-powershell

从PowerShell ISE运行此代码时

New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VM

我收到此错误

New-AzureRmVM : The entity name is invalid according to its validation rule: ^[^_\W][\w-._]{0,79}(?<![-.])$.
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 'my-operation-id'
At line:1 char:1
+ New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VM
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureRmVM], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

$ ResourceGroupName包含我的资源组名称,&#34; foobar.com&#34;在这个例子中。

$ Location包含&#34; East US 2&#34;。

$ VM包含我在下面的VM配置

ResourceGroupName        : 
Id                       : 
Name                     : foobar
Type                     : 
Location                 : 
Tags                     : null
AvailabilitySetReference : null
DiagnosticsProfile       : {
                             "bootDiagnostics": {
                               "enabled": true,
                               "storageUri": "https://foobar.blob.core.windows.net/"
                             }
                           }
Extensions               : null
HardwareProfile          : {
                             "vmSize": "Basic_A0"
                           }
InstanceView             : null
NetworkProfile           : {
                             "networkInterfaces": [
                               {
                                 "properties.primary": null,
                                 "id": "/subscriptions/my-sub-id/resourceGroups/foobar.com/providers/Microsoft.Network/n
                           etworkInterfaces/foobar"
                               }
                             ]
                           }
OSProfile                : {
                             "computerName": "foobar",
                             "adminUsername": "admin",
                             "adminPassword": "password",
                             "customData": null,
                             "windowsConfiguration": {
                               "provisionVMAgent": true,
                               "enableAutomaticUpdates": true,
                               "timeZone": "UTC-05:00",
                               "additionalUnattendContent": null,
                               "winRM": null
                             },
                             "linuxConfiguration": null,
                             "secrets": null
                           }
Plan                     : null
ProvisioningState        : 
StorageProfile           : {
                             "imageReference": {
                               "publisher": "MicrosoftWindowsServer",
                               "offer": "WindowsServer",
                               "sku": "Windows-Server-Technical-Preview",
                               "version": "latest"
                             },
                             "osDisk": {
                               "osType": null,
                               "encryptionSettings": null,
                               "name": "OS Disk",
                               "vhd": {
                                 "uri": "https://foobar.blob.core.windows.net/vhds/foobar-os.vhd"
                               },
                               "image": null,
                               "caching": null,
                               "createOption": "fromImage",
                               "diskSizeGB": null
                             },
                             "dataDisks": [
                               {
                                 "lun": 0,
                                 "name": "Data Disk",
                                 "vhd": {
                                   "uri": "https://foobar.blob.core.windows.net/vhds/foobar-data.vhd"
                                 },
                                 "image": null,
                                 "caching": null,
                                 "createOption": "empty",
                                 "diskSizeGB": 20
                               }
                             ]
                           }
DataDiskNames            : {Data Disk}
NetworkInterfaceIDs      : {/subscriptions/my-sub-id/resourceGroups/foobar.com/providers/Microsoft.Network/networkInterf
                           aces/foobar}

任何人都可以告诉我它所指的实体名称是什么?它是VM的名称,其中一个存储位置的名称等吗? 据我所知,一切都与正则表达式匹配,所以我不明白为什么我会收到这个错误。谷歌搜索命令名称只会带来一些点击,而且根本没有提到有关实体名称的任何内容。

1 个答案:

答案 0 :(得分:2)

没关系,我通过反复试验弄明白了。数据和操作系统磁盘显然不能在名称中包含空格。如果更好地记录Azure PS模块,它将会有所帮助。