2014-05-21 5 views
1

가상 시스템을 관리하기 위해 Windows Azure SDK for Node.js - Compute Management 자습서를 수행하고 있습니다.노드 sdk를 사용하여 Azure로 인증하는 동안 오류가 발생했습니다 :

azure account cert export에서 <Subscription GUID>.pem까지 pem 파일을 다운로드했습니다.

var subscriptionId ="<Subscription GUID>"; 
var pem = "<Subscription GUID>.pem"; 

var computeManagementClient = computeManagement.createComputeManagementClient(computeManagement.createCertificateCloudCredentials({ 
    subscriptionId: subscriptionId, 
    pem: fs.readFileSync(pem) 
})); 

을 내가 Node.js를에서 실행할 때 오류를 생성합니다 :

스크립트는 현재 포함

C:\Apps\azure\node_modules\azure-mgmt-compute\node_modules\azure-common\lib\util\validate.js:416 
    throw new Error('Required argument ' + name + ' for function ' + func + ' is 
     ^
Error: Required argument credentials.pem for function CertificateCloudCredentials is not defined 
    at throwMissingArgument (C:\Apps\azure\node_modules\azure-mgmt-compute\node_modules\azure-common\lib\util\validate.js:416:9) 
    at ArgumentValidator._.extend.string (C:\Apps\azure\node_modules\azure-mgmt-compute\node_modules\azure-common\lib\util\validate.js:426:7) 
    at C:\Apps\azure\node_modules\azure-mgmt-compute\node_modules\azure-common\lib\services\credentials\certificateCloudCredentials.js:35:9 
    at Object.validateArgs (C:\Apps\azure\node_modules\azure-mgmt-compute\node_modules\azure-common\lib\util\validate.js:478:3) 
    at new CertificateCloudCredentials (C:\Apps\azure\node_modules\azure-mgmt-compute\node_modules\azure-common\lib\services\credentials\certificateCloudCredentials.js:32:14) 
    at Object.exports.createCertificateCloudCredentials (C:\Apps\azure\node_modules\azure-mgmt-compute\lib\compute.js:54:10) 
    at Object.<anonymous> (C:\Apps\azure\setup.js:14:97) 
    at Module._compile (module.js:456:26) 
    at Object.Module._extensions..js (module.js:474:10) 
    at Module.load (module.js:356:32) 

답변

5

문제는 pem: fs.readFileSync(pem) 함께. SDK가 노드 버퍼를 문자열로 변환하지 않습니다. issue on Github이 있습니다.

pem: fs.readFileSync(pem).toString() 

까지

버퍼에 고정형이다 toString

관련 문제