首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用powershell创建蔚蓝VM的推荐方法是什么?

使用powershell创建蔚蓝VM的推荐方法是什么?
EN

Stack Overflow用户
提问于 2015-12-09 06:45:12
回答 3查看 517关注 0票数 1

( 1)我正在尝试用power-shell在蔚蓝中创建am。创建VM有多种方法。推荐的方法是什么?

2)如果VM是使用资源管理器创建的,则无法在当前门户中找到它。只有预览门户才能将VM区分为“虚拟机(经典)”和“虚拟机”。当我单击“虚拟机”和创建的VM时,它没有显示捕获VM的选项。如何捕获使用资源管理器powershell创建的VM (在门户中)?

3)如果订阅有两种类型的VM (经典和ARM),如何收集这两种VM类型的库存?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-12-09 09:43:02

ANS 1.您的方法取决于您的需求。如果您需要经典VM,可以使用ASM()方法来旋转VM。如果您要使用ARM(Azure Resource )方法,请遵循ARM cmdlet。我建议ARM,因为它是最新的,根据MS,他们将折旧ASM是未来。

ANS 2.新门户没有捕获vm选项。这个选项只适用于经典的vms。相反,它具有相同的功能,您可以选择一个vhd并使用json模板从其中创建一个vm。

ANS 3.几乎所有的资源都列在新的门户中,而新的vms却不能在旧的门户中看到。如果您使用的是最新的PS (1.0.1),甚至不需要切换。我推荐powershell,因为输出数据是详细的。

票数 0
EN

Stack Overflow用户

发布于 2015-12-09 07:28:42

首先-使用预览门户(portal.azure.com),新一代VM只在这里可用.使用预览门户创建的VMs是新一代VM,必须使用资源管理器Cmdlets创建,尝试将特定解决方案的VM分组到资源组中,然后可以作为逻辑单元管理和部署资源组。所以是的,首先创建一个资源组,然后创建属于这个资源的vm,更好的方法是创建一个模板并将所有vm添加到该模板中并从模板中部署。遵循这个https://azure.microsoft.com/en-us/documentation/articles/powershell-azure-resource-manager/

票数 0
EN

Stack Overflow用户

发布于 2016-08-15 06:47:48

经典的VM可以由Azure服务模型(ASM) cmdlet创建。请参阅下面的代码片段。

代码语言:javascript
复制
Function New-VMByASM 
{ 
    [CmdletBinding()] 
    Param 
    ( 

        [Parameter(Mandatory=$true)][String] $VMName, 
        [Parameter(Mandatory=$false)][String] $VMLabelPattern = "*Windows Server 2012 Datacenter*", 

        [Parameter(Mandatory=$false)] 
        [ValidateSet("North Europe", "East US", "South Central US", "Central US", "East US 2", "West US", "West Europe", "Southeast Asia", "East Asia", "Japan West", "Japan East")] 
        [String]$Location = "East Asia", 

        [Parameter(Mandatory=$false)] 
        [ValidateSet("ExtraSmall", "Small", "Medium", "Large", "ExtraLarge", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "Basic_A0", "Basic_A1", "Basic_A2", "Basic_A3", "Basic_A4", "Standard_D1", "Standard_D2", "Standard_D3", "Standard_D4", "Standard_D11", "Standard_D12", "Standard_D13", "Standard_D14", "Standard_D1_v2", "Standard_D2_v2", "Standard_D3_v2", "Standard_D4_v2", "Standard_D5_v2", "Standard_D11_v2", "Standard_D12_v2", "Standard_D13_v2", "Standard_D14_v2", "Standard_DS1", "Standard_DS2", "Standard_DS3", "Standard_DS4", "Standard_DS11", "Standard_DS12", "Standard_DS13", "Standard_DS14", "Standard_DS1_v2", "Standard_DS2_v2", "Standard_DS3_v2", "Standard_DS4_v2", "Standard_DS5_v2", "Standard_DS11_v2", "Standard_DS12_v2", "Standard_DS13_v2", "Standard_DS14_v2", "Standard_G1", "Standard_G2", "Standard_G3", "Standard_G4", "Standard_G5", "Standard_GS1", "Standard_GS2", "Standard_GS3", "Standard_GS4", "Standard_GS5", "Standard_F1", "Standard_F2", "Standard_F4", "Standard_F8", "Standard_F16", "Standard_F1s", "Standard_F2s", "Standard_F4s", "Standard_F8s", "Standard_F16s")] 
        [String]$VMSize = "Basic_A0" 
    ) 
    # 1. Login Azure by admin account 
    Add-AzureAccount 
    # 
    # 2. Select subscription name 
    $subscriptionName = Get-AzureSubscription | Select -ExpandProperty SubscriptionName 
    # 
    # 3. Create storage account 
    $storageAccountName = $VMName  
    # here we use VMName to play the storage account name and create it, you can choose your name or use existed one to replace the storage account creation operation 
    New-AzureStorageAccount -StorageAccountName $storageAccountName -Location $Location | Out-Null 
    # 
    # 4. Select subscription name and storage account name for current context 
    Select-AzureSubscription -SubscriptionName $subscriptionName -Current | Out-Null 
    Set-AzureSubscription -SubscriptionName $subscriptionName -CurrentStorageAccountName $storageAccountName | Out-Null 
    # 
    # 5. Select a VM image name 
    $label = $VMLabelPattern 
    # take care, please ensure the VM image location resides to the same location of your storage account and service below 
    $imageName = Get-AzureVMImage | where { $_.Label -like $label } | sort PublishedDate -Descending | select -ExpandProperty ImageName -First 1 
    # 
    # 6. Create cloud service 
    $svcName = $VMName 
    # here we use VMName to play the service name and create it, you can choose your name or use existed one to replace the service creation operation 
    New-AzureService -ServiceName $svcName -Location $Location | Out-Null 
    # 
    # 7. Build command set 
    $vmConfig = New-AzureVMConfig -Name $VMName -InstanceSize $VMSize -ImageName $imageName 
    # 
    # 8. Set local admin of this vm 
    $cred=Get-Credential -Message "Type the name and password of the local administrator account." 
    $vmConfig | Add-AzureProvisioningConfig -Windows -AdminUsername $cred.Username -Password $cred.GetNetworkCredential().Password 
    # 
    # 9. Execute the final cmdlet to create the VM 
    New-AzureVM -ServiceName $svcName -VMs $vmConfig | Out-Null 
} 

New-VMByASM -VMName $VMName -Location $StorageLocation 
Write-Host "Done"

更多详细信息请阅读此示例文章https://gallery.technet.microsoft.com/How-to-create-Azure-VM-by-b894d750

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34172336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档