首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Java获取云服务(托管服务)诊断数据?

如何使用Java获取云服务(托管服务)诊断数据?
EN

Stack Overflow用户
提问于 2016-08-30 13:13:45
回答 1查看 113关注 0票数 0

如何使用Java或Rest获取云服务(托管服务)诊断数据?

我们可以从Azure获得DiagnosticsConnectionString的角色,并使用它可以查询到WADPerformanceCounter表(Storage )。

在执行时获取以下异常:

query:java.util.NoSuchElementException:枚举结果时发生错误,检查原始异常以获得详细信息。在com.microsoft.azure.storage.core.LazySegmentedIterator.hasNe‌​xt(LazySegmentedIter‌​ator.java:113) at TestStorage.main(TestStorage.java:225)引起的: com.microsoft.azure.storage.table.TableServiceException:坏请求

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-31 10:09:20

@Prit,你的问题中没有任何代码,所以我找不出是什么引起的问题。

因此,我在这里张贴我的步骤和代码,作为帮助参考。

  1. 将云服务的一个角色的DIAGNOSTICS CONNECTION STRINGS复制到Azure管理门户上的Cloud的选项卡CONFIGURE,其格式类似于DefaultEndpointsProtocol=https;AccountName=<storage-account-name>;AccountKey=<storage-key>
  2. 使用GUI工具Micorsoft Azure Storage Explorer查找和查看表WADPerformanceCounter

  1. Java中检索所有诊断数据的代码,如下所示。 导入com.microsoft.azure.storage.CloudStorageAccount;导入com.microsoft.azure.storage.table.CloudTable;导入com.microsoft.azure.storage.table.CloudTableClient;导入com.microsoft.azure.storage.table.TableQuery;导入com.microsoft.azure.storage.table.TableServiceEntity;公共类WADPerformanceCounterReader {公共静态最终字符串storageConnectionString = "DefaultEndpointsProtocol=https;"+ "AccountName=;"+ "AccountKey=";公共静态空主(String[] args) {从连接字符串中尝试{ //检索存储帐户。CloudStorageAccount.parse(storageConnectionString);//创建表客户机。tableClient.getTableReference("WADPerformanceCountersTable");tableClient = storageAccount.createCloudTableClient();CloudTable cloudTable = TableQuery.from(TableServiceEntity.class);for (TableServiceEntity实体:cloudTable.execute(查询)){ System.out.println(entity.getPartitionKey()+"\t"+entity.getRowKey());}} catch (异常e) { //输出堆栈跟踪。e.printStackTrace();}}

希望能帮上忙。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39228519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档