2017-09-26 7 views
0

devtest 랩에 업로드 한 VHD에서 사용자 정의 이미지를 만들려고합니다.devTestLabs의 Python Azure SDK를 사용하여 사용자 정의 이미지 만들기

나는 그렇게하려면 다음 코드를 사용하고 있습니다 :

from azure.mgmt.storage import StorageManagementClient 
.... 
credentials = ServicePrincipalCredentials(client_id = '##', tenant = '##', secret = "##") 
resource_client = DevTestLabsClient(credentials, subscriptID) 

.... 
custom_image_properties = CustomImagePropertiesCustom(CustomImageOsType.windows, config.CustomImage.Name, True) 
custom_image = CustomImage(vhd = custom_image_properties) 
resource_client.custom_images.create_or_update(rgName,labName, imageName, custom_image) 

그것은 나에게 다음과 같은 오류가 발생합니다 : 가의 값 URI라는 이름의 참고 ImageName 구문 분석하지 못했습니다 '## customImageName를 ##'.

내가 뭘 잘못하고 있는지 알려주시겠습니까? 그리고 API의 VHD 경로를 입력해야 할 곳은 어디입니까? 경로를 취하는 인수를 찾을 수 없습니다!

+0

진행 상황이 있습니까? 내 대답이 도움이됩니까? –

답변

0

다음 오류가 발생합니다. 이미지 이름이 인 URI를 '## customImageName ##'으로 구문 분석하지 못했습니다.

오류 메시지에 따르면 imagename 값이 URI 인 것으로 보입니다.

이미지 이름은 문자열이어야합니다.

create_or_update(resource_group_name, lab_name, name, custom_image, custom_headers=None, raw=False, **operation_config) 


Parameters: 
resource_group_name (str) – The name of the resource group. 
lab_name (str) – The name of the lab. 
name (str) – The name of the custom image. 

자세한 내용은 link을 참조하십시오. 그런데


, 당신은 전체 스크립트 :

0

난 당신이 제공하는 코드 custom image를 만들려고을 게시하시기 바랍니다 수있는이 문제를 더 효율성 문제를 해결하는.

from azure.common.credentials import ServicePrincipalCredentials 
from azure.mgmt.devtestlabs import DevTestLabsClient 
from azure.mgmt.devtestlabs.models.custom_image_properties_custom import CustomImagePropertiesCustom 
from azure.mgmt.devtestlabs.models.custom_image import CustomImage 
from azure.mgmt.devtestlabs.models.dev_test_labs_client_enums import CustomImageOsType 

client_id = <your client id> 
tenant = <your tenant id> 
secret = <your secret id> 
subscriptID = <your subcript id> 
imageName='jaygong.vhd' 
name=<your custom image name as you want> 
rgName = <your resource name> 
labName = <your lab name> 

credentials = ServicePrincipalCredentials(client_id=client_id, tenant=tenant , secret=secret) 
resource_client = DevTestLabsClient(credentials, subscriptID) 
custom_image_properties = CustomImagePropertiesCustom(CustomImageOsType.windows, imageName, True) 
custom_image = CustomImage(vhd = custom_image_properties) 
resource_client.custom_images.create_or_update(rgName,labName, name, custom_image) 

다음 문제를 재현합니다.

E:\Python27\python.exe E:/PythonWorkSpace/CreateVM/Create.py 
Traceback (most recent call last): 
    File "E:/PythonWorkSpace/CreateVM/Create.py", line 19, in <module> 
    resource_client.custom_images.create_or_update(rgName,labName, imageName, custom_image) 
    File "E:\Python27\lib\site-packages\azure\mgmt\devtestlabs\operations\custom_images_operations.py", line 293, in create_or_update 
    get_long_running_status, long_running_operation_timeout) 
    File "E:\Python27\lib\site-packages\msrestazure\azure_operation.py", line 350, in __init__ 
    raise CloudError(self._response) 
msrestazure.azure_exceptions.CloudError: Azure Error: InvalidUrlProvided 
Message: Failed to parse URI named ImageName with value of 'aaa'. 

Process finished with exit code 1 

은 조사 후, 나는 단지 당신의 VHD 이름 위의 imageName 매개 변수, 그것은 스토리지 이름에 VHD 파일의 complete url 있어야 것을 발견했다. 나는 성공적으로 imageName 다음 생성 된 사용자 정의 이미지의 값을 변경

https://<your storage account>.blob.core.windows.net/<your container name>/<your vhd file name> 

: 같은 같습니다.

enter image description here

는 you.Any 우려, 내가 kown 수 있도록 주시기 바랍니다 도움이되기를 바랍니다.