0x3bfc
0x3bfc

Reputation: 3171

How can i copy community image on azure using python api or CLI of azure

I did not find any documentation for how to copy vhd on azure using python api, can anyone help me... also i have tried to create instance from image on the vmdepot community but when i run the following command i got this error:

$ azure vm create instanceahmed -o vmdepot-14776-1-1 -l "West US" ahmed P@ssw0rd --ssh 22 --verbose
......
verbose: Creating VM
verbose: Deleting image
info:    VM image deleted: vmdepot-14776-1-1-c5febcb3
verbose: Uri : http://portalvhdsf4048vkh9c007.blob.core.windows.net/vm-images/community- 23970-525c8c75-8901-4870-a937-7277414a6eaa-1.vhd
info:    Blob deleted: http://portalvhdsf4048vkh9c007.blob.core.windows.net/vm- images/community-23970-525c8c75-8901-4870-a937-7277414a6eaa-1.vhd
info:    vm create command OK

Upvotes: 0

Views: 852

Answers (2)

0x3bfc
0x3bfc

Reputation: 3171

I tried to do what "-o" do with Azure with these steps:

  1. Get the URL of your image on the community:

    http://vmdepoteastus.blob.core.windows.net/linux-community-store/community-23970-525c8c75-8901-4870-a937-7277414a6eaa-1.vhd
    
  2. Create a new affinity group if you have one skip this point:

    $ azure account affinity-group create mystoragegroup --location "West US"
    
  3. Create a new storage account if you have an account skip this point:

    $ azure storage account create mystorageazure --affinity-group mystoragegroup
    
  4. Get the Primary secret key of new storage account using this command:

    $ azure account storage keys list mystorageazure
    output:
    data:    Primary:  Your SECRET STORAGE KEY
    
  5. Create new account storage inside this storage account:

    $ azure storage container create  --permission Blob  -a mystorageazure  -k  Your SECRET STORAGE KEY  mycontainerazure
    
  6. Upload your image to the your account storage container:

    $ azure vm disk upload --verbose http://vmdepoteastus.blob.core.windows.net/linux-community-store/community-23970-525c8c75-8901-4870-a937-7277414a6eaa-1.vhd http://mystorageazure.blob.core.windows.net/mycontainerazure/elastichpcvm.vhd  Your SECRET STORAGE KEY
    
  7. Create your local image:

    $ azure vm image create mystorageimage --location "West US" --blob-url http://mystorageazure.blob.core.windows.net/mycontainerazure/elastichpcvm.vhd --os linux
    
  8. Create your virtual machine using your local image:

    $ azure vm create mystoragemachine  mystorageimage ahmed P@ssw0rd --location "West US" --ssh 22
    

Upvotes: 2

Amar Zavery -  MSFT
Amar Zavery - MSFT

Reputation: 411

This seems to me like the cli issue. Can you please tell us

  • what version of the azure cli are you using. To get the version execute: azure -v
  • Can you provide us the version of publishsettings.xml file you are currently using? You can get the publishsettings xml file by executing: azure account download

Upvotes: -1

Related Questions