プレビューバージョンであるMicrosoft.Azure.Management.ServiceBus Libaryがあり、100%互換性があります.Netcore。ここではdetailをもっと得ることができます。
Preparetion:
Registry Azure Active Directory application and assign Role
ステップ:
.NETのコアコンソールプロジェクトを作成し、次のコードを追加します。アズールporatalから
var tenantId = "tenantid";
var context = new AuthenticationContext($"https://login.windows.net/{tenantId}");
var clientId = "Client";
var clientSecret = "Secret";
var subscriptionId = "subscriptionId";
var result = context.AcquireTokenAsync(
"https://management.core.windows.net/",
new ClientCredential(clientId, clientSecret)).Result;
var creds = new TokenCredentials(result.AccessToken);
var sbClient = new ServiceBusManagementClient(creds)
{
SubscriptionId = subscriptionId
};
var queueParams = new QueueCreateOrUpdateParameters()
{
Location = "East Asia",
EnablePartitioning = true
};
var queue = sbClient.Queues.ListAll("groupname", "namespace").ToList().FirstOrDefault(x => x.Name.Equals("queuename"));
var messagecount = queue.MessageCount;
、我々は、キュー内のメッセージを確認
Project.jsonファイル:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.Azure.Management.ServiceBus": "0.2.0-preview",
"Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.9",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
これは、Azureのサービスを見ていませんバスコードスニペットではなく、ストレージキュー。 –
確かに、ServiceBusのQueueにあるアイテムの数を取得するための同等の機能は何ですか? – w2olves
Google "azure service bus queue get message count"と文字通り、最初の結果はあなたの質問に対する答えです:D http://stackoverflow.com/questions/16254951/determining-how-many-messages-are-on- the-azure-service-bus-queue –