2015-11-02 49 views
0

在Azure資源組java API中,沒有基於請求標識獲取操作狀態的功能。現在在sdk中獲得操作狀態的方法是什麼?Azure根據請求標識獲取操作狀態java sdk

類似的功能存在於服務管理API喜歡這裏的服務管理客戶端: http://azure.github.io/azure-sdk-for-java/com/microsoft/azure/management/compute/VirtualMachineOperations.html

我看到類似的功能: http://azure.github.io/azure-sdk-for-java/com/microsoft/windowsazure/management/compute/ComputeManagementClient.html#getOperationStatus-java.lang.String-

類似的功能不會像客戶端存在

LongRunningOperationResponse getLongRunningOperationStatus(java.lang.String operationStatusLink)

獲取操作狀態操作返回指定操作的狀態。

如何生成operationStatusLink?

回答

0

我查了Azure的參考文檔,我發現Asynchronous Request (classic) REST參考具有Get Operation Status REST API需要什麼服務管理<subscription-id><request-id>和請求頭x-ms-version。請參閱https://msdn.microsoft.com/en-us/library/azure/ee460783.aspx

然後,我回顧了Azure SDK的JavaDocs,發現類com.microsoft.windowsazure.core.OperationStatusResponsecom.microsoft.windowsazure.core.AzureAsyncOperationResponse。他們有函數getStatus()什麼返回Enum com.microsoft.windowsazure.core.OperationStatus之一。 詳細請參考http://azure.github.io/azure-sdk-for-java/com/microsoft/windowsazure/core/OperationStatusResponse.htmlhttp://azure.github.io/azure-sdk-for-java/com/microsoft/azure/management/network/models/AzureAsyncOperationResponse.htmlhttp://azure.github.io/azure-sdk-for-java/com/microsoft/windowsazure/core/OperationStatus.html

它們用於Azure服務管理。所以,你需要從maven的回購azure-svc-mgmthttp://mvnrepository.com/artifact/com.microsoft.azure/azure-svc-mgmt/0.9.0導入這些類,請參閱下面的Maven的配置:

<dependency> 
    <groupId>com.microsoft.azure</groupId> 
    <artifactId>azure-svc-mgmt</artifactId> 
    <version>0.9.0</version> 
</dependency> 

而使用類com.microsoft.windowsazure.management.ManagementClient的功能OperationStatusResponse getOperationStatus(String requestId)獲取對象OperationStatusResponse得到你想要的。請參閱http://azure.github.io/azure-sdk-for-java/com/microsoft/windowsazure/management/ManagementClient.html

最好的問候。

+0

我正在使用基於資源管理器的API。我所做的認證是基於在AD中創建的應用程序。在這種情況下,當我嘗試使用上述服務SDK時,出現以下錯誤,我使用的是相同的配置對象:SEVERE:null com.microsoft.windowsazure.exception.ServiceException:ForbiddenError:服務器失敗驗證請求。驗證證書是否有效並與此訂閱相關聯。 \t在com.microsoft.windowsazure.exception.ServiceException.createFromXml(ServiceException.java:208) \t在 – Squid

+0

@Squid有服務管理2種身份驗證方法:使用AAD和使用管理證書(推薦),請參考https://msdn.microsoft.com/en-us/library/azure/ee460782.aspx。這些線程我已經回答可以幫助您解決問題.http://stackoverflow.com/questions/33082328/azure-java-sdk-serviceexception-forbiddenerror,http://stackoverflow.com/questions/33127506/azure-retrieving-虛擬機從天青-java-sdk和http://stackoverflow.com/questions/33239530/azure-free-trial-account-not-able-to-authenticate-via-java-sdk。 –