2016-02-10 7 views
5

किसी को भी अब कैसे एक वीएम नया नीला पोर्टल में एक मौजूदा VHD से बनाने के लिए करता है?मौजूदा VHD से वीएम बनाएं: पूर्वावलोकन पोर्टल

मैं portal.azure.com में इस कार्यक्षमता पर कैसे manage.windowsazure.com में ऐसा करने के बारे में जानकारी के बहुत सारे है, लेकिन कुछ भी नहीं मिल सकता है।

उत्तर

5

यह पोर्टल में सचमुच नहीं किया जा सकता। आपको शक्तिशक्ति का उपयोग करना होगा।

  1. संग्रहण खाता बनाएं। उदाहरण के लिए पोर्टल में।

  2. VHD azure पर अपलोड करें। ऐसा करने के लिए, Login-AzureRmAccount साथ प्रवेश करने के बाद powershell में निम्नलिखित लाइन को चलाने (< के बीच पैरामीटर बदल> और अपने हार्डडिस्क पर VHD के लिए पथ):

    Add-AzurermVhd -Destination "https://<StorageAccountName>.blob.core.windows.net/<containerName>/<vhdname>.vhd" -LocalFilePath "D:\Virtual Machines\myharddisk.vhd" -ResourceGroupName "<ResourceGroupName" -Overwrite 
    
  3. एक हाथ टेम्पलेट बनाएँ। एकाधिक संभावनाएं आप क्या कर सकते हैं।

    • बनाया दृश्य स्टूडियो में एक नई परियोजना 2015
    • निम्नलिखित परियोजना चुनें:: बादल उदाहरण के लिए मैं क्या किया है, Azure Quickstart templates से एक खाका चुनें उदाहरण 101

के लिए -> Azure संसाधन समूह

  • निम्न टेम्पलेट चुनें: विंडोज वर्चुअल मशीन

  • कुछ पैरामीटर बदल दिए और आवश्यक सभी चीजें हटा दी गईं। अब यह क्या है: अपलोड किए गए vhd का उपयोग हार्डडिस्क के रूप में Windows वर्चुअल मशीन बनाएं। यह एक पैरामीटर json फ़ाइल अब उपयोग कर रहा है, और भी कुछ चर WindowsVirtualMachine.json यह बिल्कुल पुनर्संशोधित किया जा सकता है में सेट किया जाना है। लेकिन अभी के लिए यह आवश्यक होगा।

  • इस नमूने आप निम्नलिखित निर्देशिका संरचना होनी चाहिए के लिए (विजुअल स्टूडियो यह बनाता है जैसे)

    ProjectDirectory/Scripts/Deploy-AzureResourceGroup.ps1 
    ProjectDirectory/Templates/WindowsVirtualMachine.json 
    ProjectDirectory/Templates/WindowsVirtualMachine.parameters.json 
    

    तैनात-AzureResourceGroup.ps1

    #Requires -Version 3.0 
    #Requires -Module AzureRM.Resources 
    #Requires -Module Azure.Storage 
    
    Param(
        [string] [Parameter(Mandatory=$true)] $ResourceGroupLocation, 
        [string] $ResourceGroupName = 'CreateImage',  
        [string] $TemplateFile = '..\Templates\WindowsVirtualMachine.json', 
        [string] $TemplateParametersFile = '..\Templates\WindowsVirtualMachine.parameters.json' 
    ) 
    
    Import-Module Azure -ErrorAction SilentlyContinue 
    
    try { 
        [Microsoft.Azure.Common.Authentication.AzureSession]::ClientFactory.AddUserAgent("VSAzureTools-$UI$($host.name)".replace(" ","_"), "2.8") 
    } catch { } 
    
    Set-StrictMode -Version 3 
    
    $OptionalParameters = New-Object -TypeName Hashtable 
    $TemplateFile = [System.IO.Path]::Combine($PSScriptRoot, $TemplateFile) 
    $TemplateParametersFile = [System.IO.Path]::Combine($PSScriptRoot, $TemplateParametersFile) 
    
    
    # Create or update the resource group using the specified template file and template parameters file 
    New-AzureRmResourceGroup -Name $ResourceGroupName -Location $ResourceGroupLocation -Verbose -Force -ErrorAction Stop 
    
    New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseName + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')) ` 
                -ResourceGroupName $ResourceGroupName ` 
                -TemplateFile $TemplateFile ` 
                -TemplateParameterFile $TemplateParametersFile ` 
                @OptionalParameters ` 
                -Force -Verbose 
    

    WindowsVirtualMachine.json

    { 
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
        "contentVersion": "1.0.0.0", 
        "parameters": {  
        "dnsNameForPublicIP": { 
         "type": "string", 
         "minLength": 1, 
         "metadata": { 
         "description": "Globally unique DNS Name for the Public IP used to access the Virtual Machine." 
         } 
        } 
        }, 
        "variables": { 
        "OSDiskName": "<vhdNameWithoutExtension>", 
        "vhdStorageContainerName": "<containerName>", 
        "storageAccountName": "<StorageAccountName>", 
        "nicName": "myVMNic", 
        "addressPrefix": "10.0.0.0/16", 
        "subnetName": "Subnet", 
        "subnetPrefix": "10.0.0.0/24", 
        "vhdStorageType": "Standard_LRS", 
        "publicIPAddressName": "myPublicIP", 
        "publicIPAddressType": "Dynamic", 
        "vhdStorageName": "[concat('vhdstorage', uniqueString(resourceGroup().id))]", 
        "vmName": "MyWindowsVM", 
        "vmSize": "Standard_A2", 
        "virtualNetworkName": "MyVNET", 
        "vnetId": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]", 
        "subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]" 
        }, 
        "resources": [ 
        { 
         "type": "Microsoft.Storage/storageAccounts", 
         "name": "[variables('vhdStorageName')]", 
         "apiVersion": "2015-06-15", 
         "location": "[resourceGroup().location]", 
         "tags": { 
         "displayName": "StorageAccount" 
         }, 
         "properties": { 
         "accountType": "[variables('vhdStorageType')]" 
         } 
        }, 
        { 
         "apiVersion": "2015-06-15", 
         "type": "Microsoft.Network/publicIPAddresses", 
         "name": "[variables('publicIPAddressName')]", 
         "location": "[resourceGroup().location]", 
         "tags": { 
         "displayName": "PublicIPAddress" 
         }, 
         "properties": { 
         "publicIPAllocationMethod": "[variables('publicIPAddressType')]", 
         "dnsSettings": { 
          "domainNameLabel": "[parameters('dnsNameForPublicIP')]" 
         } 
         } 
        }, 
        { 
         "apiVersion": "2015-06-15", 
         "type": "Microsoft.Network/virtualNetworks", 
         "name": "[variables('virtualNetworkName')]", 
         "location": "[resourceGroup().location]", 
         "tags": { 
         "displayName": "VirtualNetwork" 
         }, 
         "properties": { 
         "addressSpace": { 
          "addressPrefixes": [ 
          "[variables('addressPrefix')]" 
          ] 
         }, 
         "subnets": [ 
          { 
          "name": "[variables('subnetName')]", 
          "properties": { 
           "addressPrefix": "[variables('subnetPrefix')]" 
          } 
          } 
         ] 
         } 
        }, 
        { 
         "apiVersion": "2015-06-15", 
         "type": "Microsoft.Network/networkInterfaces", 
         "name": "[variables('nicName')]", 
         "location": "[resourceGroup().location]", 
         "tags": { 
         "displayName": "NetworkInterface" 
         }, 
         "dependsOn": [ 
         "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]", 
         "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" 
         ], 
         "properties": { 
         "ipConfigurations": [ 
          { 
          "name": "ipconfig1", 
          "properties": { 
           "privateIPAllocationMethod": "Dynamic", 
           "publicIPAddress": { 
           "id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]" 
           }, 
           "subnet": { 
           "id": "[variables('subnetRef')]" 
           } 
          } 
          } 
         ] 
         } 
        }, 
        { 
         "apiVersion": "2015-06-15", 
         "type": "Microsoft.Compute/virtualMachines", 
         "name": "[variables('vmName')]", 
         "location": "[resourceGroup().location]", 
         "tags": { 
         "displayName": "VirtualMachine" 
         }, 
         "dependsOn": [ 
         "[concat('Microsoft.Storage/storageAccounts/', variables('vhdStorageName'))]", 
         "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" 
         ], 
         "properties": { 
         "hardwareProfile": { 
          "vmSize": "[variables('vmSize')]" 
         },  
         "storageProfile": {   
          "osDisk": { 
          "name": "osdisk", 
          "osType": "Windows", 
          "vhd": { 
           "uri": "[concat('http://', variables('storageAccountName'), '.blob.core.windows.net/', variables('vhdStorageContainerName'), '/', variables('OSDiskName'), '.vhd')]" 
          }, 
          "caching": "ReadWrite", 
          "createOption": "Attach" 
          } 
         }, 
         "networkProfile": { 
          "networkInterfaces": [ 
          { 
           "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]" 
          } 
          ] 
         } 
         }  
        } 
        ] 
    } 
    

    WindowsVirtualMachine.parameters.json

    { 
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", 
        "contentVersion": "1.0.0.0", 
        "parameters": {  
         "dnsNameForPublicIP": { 
          "value": "<someUniqueNameForYourDnsName>" 
         } 
        } 
    } 
    
    1. powershell स्क्रिप्ट निष्पादित एक PowerShell आदेश खोलें और PS1 स्क्रिप्ट को निष्पादित। आपको केवल उस स्थान को पास करना होगा जहां आप वीएम बनना चाहते हैं: (आपको Login-AzureRmAccount के साथ पहले ही लॉग इन होना चाहिए)

      दोनों जेसन फाइलों में पैरामीटर बदलने से पहले!
      .\Deploy-AzureResourceGroup.ps1 "West Europe"

    लॉगिंग आप को बताना चाहिए कि वीएम सफलतापूर्वक बनाया गया है।

    +0

    यह पूरी तरह से काम किया। बहुत धन्यवाद – naylormat

    +0

    यीशु, एज़ूर में एक वीएम तैनात करने के लिए दृश्य स्टूडियो में एक प्रोजेक्ट बनाएं, आपके पास वास्तव में आपके हाथों पर बहुत समय है – 4c74356b41

    3

    आज (अक्टूबर 2016) यह अभी भी नए पोर्टल में नहीं किया जा सकता है।

    लेकिन पूर्णता के लिए: आप पुराने पोर्टल (https://manage.windowsazure.com) में यह कर सकते हैं:

    नया क्लिक करें - कंप्यूट - वर्चुअल मशीन - गैलरी से। बाईं ओर या तो मेरी छवियों या मेरी डिस्क का चयन करें और उस वीएचडी का चयन करें जिसका आप उपयोग करना चाहते हैं। सामान्य रूप से निर्देशों का पालन करें।

    संबंधित मुद्दे