-
Notifications
You must be signed in to change notification settings - Fork 192
/
Utilities.cs
executable file
·3193 lines (2920 loc) · 162 KB
/
Utilities.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using Microsoft.Azure.Management.AppService.Fluent;
using Microsoft.Azure.Management.AppService.Fluent.Models;
using Microsoft.Azure.Management.Compute.Fluent;
using Microsoft.Azure.Management.ContainerRegistry.Fluent;
using Microsoft.Azure.Management.ContainerRegistry.Fluent.Models;
using Microsoft.Azure.Management.ContainerService.Fluent;
using Microsoft.Azure.Management.ContainerService.Fluent.Models;
using Microsoft.Azure.Management.KeyVault.Fluent;
using Microsoft.Azure.Management.Network.Fluent;
using Microsoft.Azure.Management.Redis.Fluent;
using Microsoft.Azure.Management.Storage.Fluent;
using Microsoft.Azure.Management.Storage.Fluent.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Azure.Management.Sql.Fluent;
using Microsoft.Azure.Management.TrafficManager.Fluent;
using Microsoft.Azure.Management.Dns.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using System.Diagnostics;
using System.IO;
using Newtonsoft.Json.Linq;
using System.Net.Http;
using CoreFtp;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage;
using Renci.SshNet;
using Microsoft.Azure.Management.Search.Fluent;
using Microsoft.Azure.Management.Search.Fluent.Models;
using Microsoft.Azure.Management.ServiceBus.Fluent;
using Microsoft.Azure.ServiceBus;
using System.Threading;
using System.Net.Http.Headers;
using Microsoft.Azure.Management.BatchAI.Fluent;
using Microsoft.Azure.Management.CosmosDB.Fluent;
using Microsoft.Azure.Management.CosmosDB.Fluent.Models;
using Microsoft.Azure.Management.Compute.Fluent.Models;
using Microsoft.Azure.Management.Graph.RBAC.Fluent;
using Microsoft.Azure.Management.Graph.RBAC.Fluent.Models;
using Microsoft.Azure.Management.Network.Fluent.Models;
using Microsoft.Azure.Management.ContainerInstance.Fluent;
using Microsoft.Azure.Management.Locks.Fluent;
using Microsoft.Azure.Management.Msi.Fluent;
using Microsoft.Azure.Management.Eventhub.Fluent;
using Microsoft.Azure.Management.Monitor.Fluent;
using Microsoft.Azure.Management.PrivateDns.Fluent;
namespace Microsoft.Azure.Management.Samples.Common
{
public static class Utilities
{
public static bool IsRunningMocked { get; set; }
public static Action<string> LoggerMethod { get; set; }
public static Func<string> PauseMethod { get; set; }
public static string ProjectPath { get; set; }
static Utilities()
{
LoggerMethod = Console.WriteLine;
PauseMethod = Console.ReadLine;
ProjectPath = ".";
}
public static void Log(string message)
{
LoggerMethod.Invoke(message);
}
public static void Log(object obj)
{
if (obj != null)
{
LoggerMethod.Invoke(obj.ToString());
}
else
{
LoggerMethod.Invoke("(null)");
}
}
public static void Log()
{
Utilities.Log("");
}
public static string ReadLine()
{
return PauseMethod.Invoke();
}
// Print resource group info.
public static void PrintResourceGroup(IResourceGroup resource)
{
StringBuilder info = new StringBuilder();
info.Append("Resource Group: ").Append(resource.Id)
.Append("\n\tName: ").Append(resource.Name)
.Append("\n\tRegion: ").Append(resource.Region)
.Append("\n\tTags: ").Append(resource.Tags.ToString());
Log(info.ToString());
}
// Print UserAssigned MSI info.
public static void PrintIdentity(IIdentity resource)
{
StringBuilder info = new StringBuilder();
info.Append("Identity: ").Append(resource.Id)
.Append("\n\tName: ").Append(resource.Name)
.Append("\n\tRegion: ").Append(resource.Region)
.Append("\n\tTags: ").Append(resource.Tags.ToString())
.Append("\n\tService Principal Id: ").Append(resource.PrincipalId)
.Append("\n\tClient Id: ").Append(resource.ClientId)
.Append("\n\tTenant Id: ").Append(resource.TenantId)
.Append("\n\tClient Secret Url: ").Append(resource.ClientSecretUrl);
Log(info.ToString());
}
// Print app gateway info
public static void PrintAppGateway(IApplicationGateway resource)
{
var info = new StringBuilder();
info.Append("App gateway: ").Append(resource.Id)
.Append("Name: ").Append(resource.Name)
.Append("\n\tResource group: ").Append(resource.ResourceGroupName)
.Append("\n\tRegion: ").Append(resource.Region)
.Append("\n\tTags: ").Append(resource.Tags.ToString())
.Append("\n\tSKU: ").Append(resource.Sku.ToString())
.Append("\n\tOperational state: ").Append(resource.OperationalState)
.Append("\n\tInternet-facing? ").Append(resource.IsPublic)
.Append("\n\tInternal? ").Append(resource.IsPrivate)
.Append("\n\tDefault private IP address: ").Append(resource.PrivateIPAddress)
.Append("\n\tPrivate IP address allocation method: ").Append(resource.PrivateIPAllocationMethod)
.Append("\n\tDisabled SSL protocols: ").Append(resource.DisabledSslProtocols);
// Show IP configs
var ipConfigs = resource.IPConfigurations;
info.Append("\n\tIP configurations: ").Append(ipConfigs.Count);
foreach (var ipConfig in ipConfigs.Values)
{
info.Append("\n\t\tName: ").Append(ipConfig.Name)
.Append("\n\t\t\tNetwork id: ").Append(ipConfig.NetworkId)
.Append("\n\t\t\tSubnet name: ").Append(ipConfig.SubnetName);
}
// Show frontends
var frontends = resource.Frontends;
info.Append("\n\tFrontends: ").Append(frontends.Count);
foreach (var frontend in frontends.Values)
{
info.Append("\n\t\tName: ").Append(frontend.Name)
.Append("\n\t\t\tPublic? ").Append(frontend.IsPublic);
if (frontend.IsPublic)
{
// Show public frontend info
info.Append("\n\t\t\tPublic IP address ID: ").Append(frontend.PublicIPAddressId);
}
if (frontend.IsPrivate)
{
// Show private frontend info
info.Append("\n\t\t\tPrivate IP address: ").Append(frontend.PrivateIPAddress)
.Append("\n\t\t\tPrivate IP allocation method: ").Append(frontend.PrivateIPAllocationMethod)
.Append("\n\t\t\tSubnet name: ").Append(frontend.SubnetName)
.Append("\n\t\t\tVirtual network ID: ").Append(frontend.NetworkId);
}
}
// Show backends
var backends = resource.Backends;
info.Append("\n\tBackends: ").Append(backends.Count);
foreach (var backend in backends.Values)
{
info.Append("\n\t\tName: ").Append(backend.Name)
.Append("\n\t\t\tAssociated NIC IP configuration IDs: ").Append(string.Join(", ", backend.BackendNicIPConfigurationNames.Keys.ToArray()));
// Show addresses
var addresses = backend.Addresses;
info.Append("\n\t\t\tAddresses: ").Append(addresses.Count);
foreach (var address in addresses)
{
info.Append("\n\t\t\t\tFQDN: ").Append(address.Fqdn)
.Append("\n\t\t\t\tIP: ").Append(address.IpAddress);
}
}
// Show backend HTTP configurations
var httpConfigs = resource.BackendHttpConfigurations;
info.Append("\n\tHTTP Configurations: ").Append(httpConfigs.Count);
foreach (var httpConfig in httpConfigs.Values)
{
info.Append("\n\t\tName: ").Append(httpConfig.Name)
.Append("\n\t\t\tCookie based affinity: ").Append(httpConfig.CookieBasedAffinity)
.Append("\n\t\t\tPort: ").Append(httpConfig.Port)
.Append("\n\t\t\tRequest timeout in seconds: ").Append(httpConfig.RequestTimeout)
.Append("\n\t\t\tProtocol: ").Append(httpConfig.Protocol.ToString())
.Append("\n\t\tHost header: ").Append(httpConfig.HostHeader)
.Append("\n\t\tHost header comes from backend? ").Append(httpConfig.IsHostHeaderFromBackend)
.Append("\n\t\tConnection draining timeout in seconds: ").Append(httpConfig.ConnectionDrainingTimeoutInSeconds)
.Append("\n\t\tAffinity cookie name: ").Append(httpConfig.AffinityCookieName)
.Append("\n\t\tPath: ").Append(httpConfig.Path);
var probe = httpConfig.Probe;
if (probe != null)
{
info.Append("\n\t\tProbe: " + probe.Name);
}
}
// Show SSL certificates
var sslCerts = resource.SslCertificates;
info.Append("\n\tSSL certificates: ").Append(sslCerts.Count);
foreach (var cert in sslCerts.Values)
{
info.Append("\n\t\tName: ").Append(cert.Name)
.Append("\n\t\t\tCert data: ").Append(cert.PublicData);
}
// Show redirect configurations
var redirects = resource.RedirectConfigurations;
info.Append("\n\tRedirect configurations: ").Append(redirects.Count);
foreach (IApplicationGatewayRedirectConfiguration redirect in redirects.Values)
{
info.Append("\n\t\tName: ").Append(redirect.Name)
.Append("\n\t\tTarget URL: ").Append(redirect.Type)
.Append("\n\t\tTarget URL: ").Append(redirect.TargetUrl)
.Append("\n\t\tTarget listener: ").Append(redirect.TargetListener?.Name)
.Append("\n\t\tIs path included? ").Append(redirect.IsPathIncluded)
.Append("\n\t\tIs query string included? ").Append(redirect.IsQueryStringIncluded)
.Append("\n\t\tReferencing request routing rules: ").Append(string.Join(", ", redirect.RequestRoutingRules.Keys.ToArray()));
}
// Show HTTP listeners
var listeners = resource.Listeners;
info.Append("\n\tHTTP listeners: ").Append(listeners.Count);
foreach (var listener in listeners.Values)
{
info.Append("\n\t\tName: ").Append(listener.Name)
.Append("\n\t\t\tHost name: ").Append(listener.HostName)
.Append("\n\t\t\tServer name indication required? ").Append(listener.RequiresServerNameIndication)
.Append("\n\t\t\tAssociated frontend name: ").Append(listener.Frontend.Name)
.Append("\n\t\t\tFrontend port name: ").Append(listener.FrontendPortName)
.Append("\n\t\t\tFrontend port number: ").Append(listener.FrontendPortNumber)
.Append("\n\t\t\tProtocol: ").Append(listener.Protocol.ToString());
if (listener.SslCertificate != null)
{
info.Append("\n\t\t\tAssociated SSL certificate: ").Append(listener.SslCertificate.Name);
}
}
// Show request routing rules
var rules = resource.RequestRoutingRules;
info.Append("\n\tRequest routing rules: ").Append(rules.Count);
foreach (var rule in rules.Values)
{
info.Append("\n\t\tName: ").Append(rule.Name)
.Append("\n\t\t\tType: ").Append(rule.RuleType.ToString())
.Append("\n\t\t\tPublic IP address ID: ").Append(rule.PublicIPAddressId)
.Append("\n\t\t\tHost name: ").Append(rule.HostName)
.Append("\n\t\t\tServer name indication required? ").Append(rule.RequiresServerNameIndication)
.Append("\n\t\t\tFrontend port: ").Append(rule.FrontendPort)
.Append("\n\t\t\tFrontend protocol: ").Append(rule.FrontendProtocol.ToString())
.Append("\n\t\t\tBackend port: ").Append(rule.BackendPort)
.Append("\n\t\t\tCookie based affinity enabled? ").Append(rule.CookieBasedAffinity)
.Append("\n\t\tRedirect configuration: ").Append(rule.RedirectConfiguration?.Name ?? "(none)");
// Show backend addresses
var addresses = rule.BackendAddresses;
info.Append("\n\t\t\tBackend addresses: ").Append(addresses.Count);
foreach (var address in addresses)
{
info.Append("\n\t\t\t\t")
.Append(address.Fqdn)
.Append(" [").Append(address.IpAddress).Append("]");
}
info
// Show SSL cert
.Append("\n\t\t\tSSL certificate name: ").Append(rule.SslCertificate?.Name ?? "(none)")
// Show backend
.Append("\n\t\t\tAssociated backend address pool: ").Append(rule.Backend?.Name ?? "(none)")
// Show backend HTTP settings config
.Append("\n\t\t\tAssociated backend HTTP settings configuration: ").Append(rule.BackendHttpConfiguration?.Name ?? "(none)")
// Show frontend listener
.Append("\n\t\t\tAssociated frontend listener: ").Append(rule.Listener?.Name ?? "(none)");
}
// Show probes
var probes = resource.Probes;
info.Append("\n\tProbes: ").Append(probes.Count);
foreach (var probe in probes.Values)
{
info.Append("\n\t\tName: ").Append(probe.Name)
.Append("\n\t\tProtocol:").Append(probe.Protocol.ToString())
.Append("\n\t\tInterval in seconds: ").Append(probe.TimeBetweenProbesInSeconds)
.Append("\n\t\tRetries: ").Append(probe.RetriesBeforeUnhealthy)
.Append("\n\t\tTimeout: ").Append(probe.TimeoutInSeconds)
.Append("\n\t\tHost: ").Append(probe.Host)
.Append("\n\t\tHealthy HTTP response status code ranges: ").Append(probe.HealthyHttpResponseStatusCodeRanges)
.Append("\n\t\tHealthy HTTP response body contents: ").Append(probe.HealthyHttpResponseBodyContents);
}
Utilities.Log(info.ToString());
}
public static void Print(ITopicAuthorizationRule topicAuthorizationRule)
{
StringBuilder builder = new StringBuilder()
.Append("Service bus topic authorization rule: ").Append(topicAuthorizationRule.Id)
.Append("\n\tName: ").Append(topicAuthorizationRule.Name)
.Append("\n\tResourceGroupName: ").Append(topicAuthorizationRule.ResourceGroupName)
.Append("\n\tNamespace Name: ").Append(topicAuthorizationRule.NamespaceName)
.Append("\n\tTopic Name: ").Append(topicAuthorizationRule.TopicName);
var rights = topicAuthorizationRule.Rights;
builder.Append("\n\tNumber of access rights in queue: ").Append(rights.Count);
foreach (var right in rights)
{
builder.Append("\n\t\tAccessRight: ")
.Append("\n\t\t\tName :").Append(right.ToString());
}
Log(builder.ToString());
}
public static void Print(IDiagnosticSetting resource)
{
StringBuilder info = new StringBuilder("Diagnostic Setting: ")
.Append("\n\tId: ").Append(resource.Id)
.Append("\n\tAssociated resource Id: ").Append(resource.ResourceId)
.Append("\n\tName: ").Append(resource.Name)
.Append("\n\tStorage Account Id: ").Append(resource.StorageAccountId)
.Append("\n\tEventHub Namespace Autorization Rule Id: ").Append(resource.EventHubAuthorizationRuleId)
.Append("\n\tEventHub name: ").Append(resource.EventHubName)
.Append("\n\tLog Analytics workspace Id: ").Append(resource.WorkspaceId);
if (resource.Logs != null && resource.Logs.Any())
{
info.Append("\n\tLog Settings: ");
foreach (var ls in resource.Logs)
{
info.Append("\n\t\tCategory: ").Append(ls.Category);
info.Append("\n\t\tRetention policy: ");
if (ls.RetentionPolicy != null)
{
info.Append(ls.RetentionPolicy.Days + " days");
}
else
{
info.Append("NONE");
}
}
}
if (resource.Metrics != null && resource.Metrics.Any())
{
info.Append("\n\tMetric Settings: ");
foreach (var ls in resource.Metrics)
{
info.Append("\n\t\tCategory: ").Append(ls.Category);
info.Append("\n\t\tTimegrain: ").Append(ls.TimeGrain);
info.Append("\n\t\tRetention policy: ");
if (ls.RetentionPolicy != null)
{
info.Append(ls.RetentionPolicy.Days + " days");
}
else
{
info.Append("NONE");
}
}
}
Log(info.ToString());
}
public static void Print(ISearchService searchService)
{
var adminKeys = searchService.GetAdminKeys();
var queryKeys = searchService.ListQueryKeys();
StringBuilder builder = new StringBuilder()
.Append("Service bus subscription: ").Append(searchService.Id)
.Append("\n\tResource group: ").Append(searchService.ResourceGroupName)
.Append("\n\tRegion: ").Append(searchService.Region)
.Append("\n\tSku: ").Append(searchService.Sku.Name)
.Append("\n\tStatus: ").Append(searchService.Status)
.Append("\n\tProvisioning State: ").Append(searchService.ProvisioningState)
.Append("\n\tHosting Mode: ").Append(searchService.HostingMode)
.Append("\n\tReplicas: ").Append(searchService.ReplicaCount)
.Append("\n\tPartitions: ").Append(searchService.PartitionCount)
.Append("\n\tPrimary Admin Key: ").Append(adminKeys.PrimaryKey)
.Append("\n\tSecondary Admin Key: ").Append(adminKeys.SecondaryKey)
.Append("\n\tQuery keys:");
foreach (IQueryKey queryKey in queryKeys)
{
builder.Append("\n\t\tKey name: ").Append(queryKey.Name);
builder.Append("\n\t\t Value: ").Append(queryKey.Key);
}
Log(builder.ToString());
}
public static void Print(ServiceBus.Fluent.ISubscription serviceBusSubscription)
{
StringBuilder builder = new StringBuilder()
.Append("Service bus subscription: ").Append(serviceBusSubscription.Id)
.Append("\n\tName: ").Append(serviceBusSubscription.Name)
.Append("\n\tResourceGroupName: ").Append(serviceBusSubscription.ResourceGroupName)
.Append("\n\tCreatedAt: ").Append(serviceBusSubscription.CreatedAt)
.Append("\n\tUpdatedAt: ").Append(serviceBusSubscription.UpdatedAt)
.Append("\n\tAccessedAt: ").Append(serviceBusSubscription.AccessedAt)
.Append("\n\tActiveMessageCount: ").Append(serviceBusSubscription.ActiveMessageCount)
.Append("\n\tDeadLetterMessageCount: ").Append(serviceBusSubscription.DeadLetterMessageCount)
.Append("\n\tDefaultMessageTtlDuration: ").Append(serviceBusSubscription.DefaultMessageTtlDuration)
.Append("\n\tIsBatchedOperationsEnabled: ").Append(serviceBusSubscription.IsBatchedOperationsEnabled)
.Append("\n\tDeleteOnIdleDurationInMinutes: ").Append(serviceBusSubscription.DeleteOnIdleDurationInMinutes)
.Append("\n\tScheduledMessageCount: ").Append(serviceBusSubscription.ScheduledMessageCount)
.Append("\n\tStatus: ").Append(serviceBusSubscription.Status)
.Append("\n\tTransferMessageCount: ").Append(serviceBusSubscription.TransferMessageCount)
.Append("\n\tIsDeadLetteringEnabledForExpiredMessages: ").Append(serviceBusSubscription.IsDeadLetteringEnabledForExpiredMessages)
.Append("\n\tIsSessionEnabled: ").Append(serviceBusSubscription.IsSessionEnabled)
.Append("\n\tLockDurationInSeconds: ").Append(serviceBusSubscription.LockDurationInSeconds)
.Append("\n\tMaxDeliveryCountBeforeDeadLetteringMessage: ").Append(serviceBusSubscription.MaxDeliveryCountBeforeDeadLetteringMessage)
.Append("\n\tIsDeadLetteringEnabledForFilterEvaluationFailedMessages: ").Append(serviceBusSubscription.IsDeadLetteringEnabledForFilterEvaluationFailedMessages)
.Append("\n\tTransferMessageCount: ").Append(serviceBusSubscription.TransferMessageCount)
.Append("\n\tTransferDeadLetterMessageCount: ").Append(serviceBusSubscription.TransferDeadLetterMessageCount);
Log(builder.ToString());
}
public static void Print(ITopic topic)
{
StringBuilder builder = new StringBuilder()
.Append("Service bus topic: ").Append(topic.Id)
.Append("\n\tName: ").Append(topic.Name)
.Append("\n\tResourceGroupName: ").Append(topic.ResourceGroupName)
.Append("\n\tCreatedAt: ").Append(topic.CreatedAt)
.Append("\n\tUpdatedAt: ").Append(topic.UpdatedAt)
.Append("\n\tAccessedAt: ").Append(topic.AccessedAt)
.Append("\n\tActiveMessageCount: ").Append(topic.ActiveMessageCount)
.Append("\n\tCurrentSizeInBytes: ").Append(topic.CurrentSizeInBytes)
.Append("\n\tDeadLetterMessageCount: ").Append(topic.DeadLetterMessageCount)
.Append("\n\tDefaultMessageTtlDuration: ").Append(topic.DefaultMessageTtlDuration)
.Append("\n\tDuplicateMessageDetectionHistoryDuration: ").Append(topic.DuplicateMessageDetectionHistoryDuration)
.Append("\n\tIsBatchedOperationsEnabled: ").Append(topic.IsBatchedOperationsEnabled)
.Append("\n\tIsDuplicateDetectionEnabled: ").Append(topic.IsDuplicateDetectionEnabled)
.Append("\n\tIsExpressEnabled: ").Append(topic.IsExpressEnabled)
.Append("\n\tIsPartitioningEnabled: ").Append(topic.IsPartitioningEnabled)
.Append("\n\tDeleteOnIdleDurationInMinutes: ").Append(topic.DeleteOnIdleDurationInMinutes)
.Append("\n\tMaxSizeInMB: ").Append(topic.MaxSizeInMB)
.Append("\n\tScheduledMessageCount: ").Append(topic.ScheduledMessageCount)
.Append("\n\tStatus: ").Append(topic.Status)
.Append("\n\tTransferMessageCount: ").Append(topic.TransferMessageCount)
.Append("\n\tSubscriptionCount: ").Append(topic.SubscriptionCount)
.Append("\n\tTransferDeadLetterMessageCount: ").Append(topic.TransferDeadLetterMessageCount);
Log(builder.ToString());
}
public static void Print(IAuthorizationKeys keys)
{
StringBuilder builder = new StringBuilder()
.Append("Authorization keys: ")
.Append("\n\tPrimaryKey: ").Append(keys.PrimaryKey)
.Append("\n\tPrimaryConnectionString: ").Append(keys.PrimaryConnectionString)
.Append("\n\tSecondaryKey: ").Append(keys.SecondaryKey)
.Append("\n\tSecondaryConnectionString: ").Append(keys.SecondaryConnectionString);
Log(builder.ToString());
}
public static void Print(INamespaceAuthorizationRule namespaceAuthorizationRule)
{
StringBuilder builder = new StringBuilder()
.Append("Service bus queue authorization rule: ").Append(namespaceAuthorizationRule.Id)
.Append("\n\tName: ").Append(namespaceAuthorizationRule.Name)
.Append("\n\tResourceGroupName: ").Append(namespaceAuthorizationRule.ResourceGroupName)
.Append("\n\tNamespace Name: ").Append(namespaceAuthorizationRule.NamespaceName);
var rights = namespaceAuthorizationRule.Rights;
builder.Append("\n\tNumber of access rights in queue: ").Append(rights.Count());
foreach (var right in rights)
{
builder.Append("\n\t\tAccessRight: ")
.Append("\n\t\t\tName :").Append(right.ToString());
}
Log(builder.ToString());
}
public static void Print(IQueue queue)
{
StringBuilder builder = new StringBuilder()
.Append("Service bus Queue: ").Append(queue.Id)
.Append("\n\tName: ").Append(queue.Name)
.Append("\n\tResourceGroupName: ").Append(queue.ResourceGroupName)
.Append("\n\tCreatedAt: ").Append(queue.CreatedAt)
.Append("\n\tUpdatedAt: ").Append(queue.UpdatedAt)
.Append("\n\tAccessedAt: ").Append(queue.AccessedAt)
.Append("\n\tActiveMessageCount: ").Append(queue.ActiveMessageCount)
.Append("\n\tCurrentSizeInBytes: ").Append(queue.CurrentSizeInBytes)
.Append("\n\tDeadLetterMessageCount: ").Append(queue.DeadLetterMessageCount)
.Append("\n\tDefaultMessageTtlDuration: ").Append(queue.DefaultMessageTtlDuration)
.Append("\n\tDuplicateMessageDetectionHistoryDuration: ").Append(queue.DuplicateMessageDetectionHistoryDuration)
.Append("\n\tIsBatchedOperationsEnabled: ").Append(queue.IsBatchedOperationsEnabled)
.Append("\n\tIsDeadLetteringEnabledForExpiredMessages: ").Append(queue.IsDeadLetteringEnabledForExpiredMessages)
.Append("\n\tIsDuplicateDetectionEnabled: ").Append(queue.IsDuplicateDetectionEnabled)
.Append("\n\tIsExpressEnabled: ").Append(queue.IsExpressEnabled)
.Append("\n\tIsPartitioningEnabled: ").Append(queue.IsPartitioningEnabled)
.Append("\n\tIsSessionEnabled: ").Append(queue.IsSessionEnabled)
.Append("\n\tDeleteOnIdleDurationInMinutes: ").Append(queue.DeleteOnIdleDurationInMinutes)
.Append("\n\tMaxDeliveryCountBeforeDeadLetteringMessage: ").Append(queue.MaxDeliveryCountBeforeDeadLetteringMessage)
.Append("\n\tMaxSizeInMB: ").Append(queue.MaxSizeInMB)
.Append("\n\tMessageCount: ").Append(queue.MessageCount)
.Append("\n\tScheduledMessageCount: ").Append(queue.ScheduledMessageCount)
.Append("\n\tStatus: ").Append(queue.Status)
.Append("\n\tTransferMessageCount: ").Append(queue.TransferMessageCount)
.Append("\n\tLockDurationInSeconds: ").Append(queue.LockDurationInSeconds)
.Append("\n\tTransferDeadLetterMessageCount: ").Append(queue.TransferDeadLetterMessageCount);
Utilities.Log(builder.ToString());
}
public static void Print(IManagementLock l)
{
StringBuilder info = new StringBuilder();
info.Append("\nLock ID: ").Append(l.Id)
.Append("\nLocked resource ID: ").Append(l.LockedResourceId)
.Append("\nLevel: ").Append(l.Level);
Utilities.Log(info.ToString());
}
public static void Print(IServiceBusNamespace serviceBusNamespace)
{
var builder = new StringBuilder()
.Append("Service bus Namespace: ").Append(serviceBusNamespace.Id)
.Append("\n\tName: ").Append(serviceBusNamespace.Name)
.Append("\n\tRegion: ").Append(serviceBusNamespace.RegionName)
.Append("\n\tResourceGroupName: ").Append(serviceBusNamespace.ResourceGroupName)
.Append("\n\tCreatedAt: ").Append(serviceBusNamespace.CreatedAt)
.Append("\n\tUpdatedAt: ").Append(serviceBusNamespace.UpdatedAt)
.Append("\n\tDnsLabel: ").Append(serviceBusNamespace.DnsLabel)
.Append("\n\tFQDN: ").Append(serviceBusNamespace.Fqdn)
.Append("\n\tSku: ")
.Append("\n\t\tCapacity: ").Append(serviceBusNamespace.Sku.Capacity)
.Append("\n\t\tSkuName: ").Append(serviceBusNamespace.Sku.Name)
.Append("\n\t\tTier: ").Append(serviceBusNamespace.Sku.Tier);
Utilities.Log(builder.ToString());
}
public static void PrintVirtualMachineCustomImage(IVirtualMachineCustomImage image)
{
var builder = new StringBuilder().Append("Virtual machine custom image: ").Append(image.Id)
.Append("Name: ").Append(image.Name)
.Append("\n\tResource group: ").Append(image.ResourceGroupName)
.Append("\n\tCreated from virtual machine: ").Append(image.SourceVirtualMachineId);
builder.Append("\n\tOS disk image: ")
.Append("\n\t\tOperating system: ").Append(image.OSDiskImage.OsType)
.Append("\n\t\tOperating system state: ").Append(image.OSDiskImage.OsState)
.Append("\n\t\tCaching: ").Append(image.OSDiskImage.Caching)
.Append("\n\t\tSize (GB): ").Append(image.OSDiskImage.DiskSizeGB);
if (image.IsCreatedFromVirtualMachine)
{
builder.Append("\n\t\tSource virtual machine: ").Append(image.SourceVirtualMachineId);
}
if (image.OSDiskImage.ManagedDisk != null)
{
builder.Append("\n\t\tSource managed disk: ").Append(image.OSDiskImage.ManagedDisk.Id);
}
if (image.OSDiskImage.Snapshot != null)
{
builder.Append("\n\t\tSource snapshot: ").Append(image.OSDiskImage.Snapshot.Id);
}
if (image.OSDiskImage.BlobUri != null)
{
builder.Append("\n\t\tSource un-managed vhd: ").Append(image.OSDiskImage.BlobUri);
}
if (image.DataDiskImages != null)
{
foreach (var diskImage in image.DataDiskImages.Values)
{
builder.Append("\n\tDisk Image (Lun) #: ").Append(diskImage.Lun)
.Append("\n\t\tCaching: ").Append(diskImage.Caching)
.Append("\n\t\tSize (GB): ").Append(diskImage.DiskSizeGB);
if (image.IsCreatedFromVirtualMachine)
{
builder.Append("\n\t\tSource virtual machine: ").Append(image.SourceVirtualMachineId);
}
if (diskImage.ManagedDisk != null)
{
builder.Append("\n\t\tSource managed disk: ").Append(diskImage.ManagedDisk.Id);
}
if (diskImage.Snapshot != null)
{
builder.Append("\n\t\tSource snapshot: ").Append(diskImage.Snapshot.Id);
}
if (diskImage.BlobUri != null)
{
builder.Append("\n\t\tSource un-managed vhd: ").Append(diskImage.BlobUri);
}
}
}
Log(builder.ToString());
}
public static void PrintVirtualMachine(IVirtualMachine virtualMachine)
{
var storageProfile = new StringBuilder().Append("\n\tStorageProfile: ");
if (virtualMachine.StorageProfile.ImageReference != null)
{
storageProfile.Append("\n\t\tImageReference:");
storageProfile.Append("\n\t\t\tPublisher: ").Append(virtualMachine.StorageProfile.ImageReference.Publisher);
storageProfile.Append("\n\t\t\tOffer: ").Append(virtualMachine.StorageProfile.ImageReference.Offer);
storageProfile.Append("\n\t\t\tSKU: ").Append(virtualMachine.StorageProfile.ImageReference.Sku);
storageProfile.Append("\n\t\t\tVersion: ").Append(virtualMachine.StorageProfile.ImageReference.Version);
}
if (virtualMachine.StorageProfile.OsDisk != null)
{
storageProfile.Append("\n\t\tOSDisk:");
storageProfile.Append("\n\t\t\tOSType: ").Append(virtualMachine.StorageProfile.OsDisk.OsType);
storageProfile.Append("\n\t\t\tName: ").Append(virtualMachine.StorageProfile.OsDisk.Name);
storageProfile.Append("\n\t\t\tCaching: ").Append(virtualMachine.StorageProfile.OsDisk.Caching);
storageProfile.Append("\n\t\t\tCreateOption: ").Append(virtualMachine.StorageProfile.OsDisk.CreateOption);
storageProfile.Append("\n\t\t\tDiskSizeGB: ").Append(virtualMachine.StorageProfile.OsDisk.DiskSizeGB);
if (virtualMachine.StorageProfile.OsDisk.Image != null)
{
storageProfile.Append("\n\t\t\tImage Uri: ").Append(virtualMachine.StorageProfile.OsDisk.Image.Uri);
}
if (virtualMachine.StorageProfile.OsDisk.Vhd != null)
{
storageProfile.Append("\n\t\t\tVhd Uri: ").Append(virtualMachine.StorageProfile.OsDisk.Vhd.Uri);
}
if (virtualMachine.StorageProfile.OsDisk.EncryptionSettings != null)
{
storageProfile.Append("\n\t\t\tEncryptionSettings: ");
storageProfile.Append("\n\t\t\t\tEnabled: ").Append(virtualMachine.StorageProfile.OsDisk.EncryptionSettings.Enabled);
storageProfile.Append("\n\t\t\t\tDiskEncryptionKey Uri: ").Append(virtualMachine
.StorageProfile
.OsDisk
.EncryptionSettings
.DiskEncryptionKey.SecretUrl);
storageProfile.Append("\n\t\t\t\tKeyEncryptionKey Uri: ").Append(virtualMachine
.StorageProfile
.OsDisk
.EncryptionSettings
.KeyEncryptionKey.KeyUrl);
}
}
if (virtualMachine.StorageProfile.DataDisks != null)
{
var i = 0;
foreach (var disk in virtualMachine.StorageProfile.DataDisks)
{
storageProfile.Append("\n\t\tDataDisk: #").Append(i++);
storageProfile.Append("\n\t\t\tName: ").Append(disk.Name);
storageProfile.Append("\n\t\t\tCaching: ").Append(disk.Caching);
storageProfile.Append("\n\t\t\tCreateOption: ").Append(disk.CreateOption);
storageProfile.Append("\n\t\t\tDiskSizeGB: ").Append(disk.DiskSizeGB);
storageProfile.Append("\n\t\t\tLun: ").Append(disk.Lun);
if (virtualMachine.IsManagedDiskEnabled)
{
if (disk.ManagedDisk != null)
{
storageProfile.Append("\n\t\t\tManaged Disk Id: ").Append(disk.ManagedDisk.Id);
}
}
else
{
if (disk.Vhd.Uri != null)
{
storageProfile.Append("\n\t\t\tVhd Uri: ").Append(disk.Vhd.Uri);
}
}
if (disk.Image != null)
{
storageProfile.Append("\n\t\t\tImage Uri: ").Append(disk.Image.Uri);
}
}
}
StringBuilder osProfile;
if (virtualMachine.OSProfile != null)
{
osProfile = new StringBuilder().Append("\n\tOSProfile: ");
osProfile.Append("\n\t\tComputerName:").Append(virtualMachine.OSProfile.ComputerName);
if (virtualMachine.OSProfile.WindowsConfiguration != null)
{
osProfile.Append("\n\t\t\tWindowsConfiguration: ");
osProfile.Append("\n\t\t\t\tProvisionVMAgent: ")
.Append(virtualMachine.OSProfile.WindowsConfiguration.ProvisionVMAgent);
osProfile.Append("\n\t\t\t\tEnableAutomaticUpdates: ")
.Append(virtualMachine.OSProfile.WindowsConfiguration.EnableAutomaticUpdates);
osProfile.Append("\n\t\t\t\tTimeZone: ")
.Append(virtualMachine.OSProfile.WindowsConfiguration.TimeZone);
}
if (virtualMachine.OSProfile.LinuxConfiguration != null)
{
osProfile.Append("\n\t\t\tLinuxConfiguration: ");
osProfile.Append("\n\t\t\t\tDisablePasswordAuthentication: ")
.Append(virtualMachine.OSProfile.LinuxConfiguration.DisablePasswordAuthentication);
}
}
else
{
osProfile = new StringBuilder().Append("\n\tOSProfile: null");
}
var networkProfile = new StringBuilder().Append("\n\tNetworkProfile: ");
foreach (var networkInterfaceId in virtualMachine.NetworkInterfaceIds)
{
networkProfile.Append("\n\t\tId:").Append(networkInterfaceId);
}
var msi = new StringBuilder().Append("\n\tMSI: ");
msi.Append("\n\t\tMSI enabled:").Append(virtualMachine.IsManagedServiceIdentityEnabled);
msi.Append("\n\t\tMSI Active Directory Service Principal Id:").Append(virtualMachine.SystemAssignedManagedServiceIdentityPrincipalId);
msi.Append("\n\t\tMSI Active Directory Tenant Id:").Append(virtualMachine.SystemAssignedManagedServiceIdentityTenantId);
Utilities.Log(new StringBuilder().Append("Virtual Machine: ").Append(virtualMachine.Id)
.Append("Name: ").Append(virtualMachine.Name)
.Append("\n\tResource group: ").Append(virtualMachine.ResourceGroupName)
.Append("\n\tRegion: ").Append(virtualMachine.Region)
.Append("\n\tTags: ").Append(FormatDictionary(virtualMachine.Tags))
.Append("\n\tHardwareProfile: ")
.Append("\n\t\tSize: ").Append(virtualMachine.Size)
.Append(storageProfile)
.Append(osProfile)
.Append(networkProfile)
.Append(msi)
.ToString());
}
public static void PrintStorageAccountKeys(IReadOnlyList<StorageAccountKey> storageAccountKeys)
{
foreach (var storageAccountKey in storageAccountKeys)
{
Utilities.Log($"Key {storageAccountKey.KeyName} = {storageAccountKey.Value}");
}
}
public static void PrintStorageAccount(IStorageAccount storageAccount)
{
Utilities.Log($"{storageAccount.Name} created @ {storageAccount.CreationTime}");
}
public static string CreateRandomName(string namePrefix)
{
return SdkContext.RandomResourceName(namePrefix, 30);
}
public static void PrintAvailabilitySet(IAvailabilitySet resource)
{
Utilities.Log(new StringBuilder().Append("Availability Set: ").Append(resource.Id)
.Append("Name: ").Append(resource.Name)
.Append("\n\tResource group: ").Append(resource.ResourceGroupName)
.Append("\n\tRegion: ").Append(resource.Region)
.Append("\n\tTags: ").Append(FormatDictionary(resource.Tags))
.Append("\n\tFault domain count: ").Append(resource.FaultDomainCount)
.Append("\n\tUpdate domain count: ").Append(resource.UpdateDomainCount)
.ToString());
}
public static void PrintNetworkSecurityGroup(INetworkSecurityGroup resource)
{
var nsgOutput = new StringBuilder();
nsgOutput.Append("NSG: ").Append(resource.Id)
.Append("Name: ").Append(resource.Name)
.Append("\n\tResource group: ").Append(resource.ResourceGroupName)
.Append("\n\tRegion: ").Append(resource.RegionName)
.Append("\n\tTags: ").Append(FormatDictionary(resource.Tags));
// Output security rules
foreach (var rule in resource.SecurityRules.Values)
{
nsgOutput.Append("\n\tRule: ").Append(rule.Name)
.Append("\n\t\tAccess: ").Append(rule.Access)
.Append("\n\t\tDirection: ").Append(rule.Direction)
.Append("\n\t\tFrom address: ").Append(rule.SourceAddressPrefix)
.Append("\n\t\tFrom port range: ").Append(rule.SourcePortRange)
.Append("\n\t\tTo address: ").Append(rule.DestinationAddressPrefix)
.Append("\n\t\tTo port: ").Append(rule.DestinationPortRange)
.Append("\n\t\tProtocol: ").Append(rule.Protocol)
.Append("\n\t\tPriority: ").Append(rule.Priority);
}
Utilities.Log(nsgOutput.ToString());
}
public static void PrintVirtualNetwork(INetwork network)
{
var info = new StringBuilder();
info.Append("Network: ").Append(network.Id)
.Append("Name: ").Append(network.Name)
.Append("\n\tResource group: ").Append(network.ResourceGroupName)
.Append("\n\tRegion: ").Append(network.Region)
.Append("\n\tTags: ").Append(FormatDictionary(network.Tags))
.Append("\n\tAddress spaces: ").Append(FormatCollection(network.AddressSpaces))
.Append("\n\tDNS server IPs: ").Append(FormatCollection(network.DnsServerIPs));
// Output subnets
foreach (var subnet in network.Subnets.Values)
{
info.Append("\n\tSubnet: ").Append(subnet.Name)
.Append("\n\t\tAddress prefix: ").Append(subnet.AddressPrefix);
// Output associated NSG
var subnetNsg = subnet.GetNetworkSecurityGroup();
if (subnetNsg != null)
{
info.Append("\n\t\tNetwork security group: ").Append(subnetNsg.Id);
}
// Output associated route table
var routeTable = subnet.GetRouteTable();
if (routeTable != null)
{
info.Append("\n\tRoute table ID: ").Append(routeTable.Id);
}
}
// Output peerings
foreach (var peering in network.Peerings.List())
{
info.Append("\n\tPeering: ").Append(peering.Name)
.Append("\n\t\tRemote network ID: ").Append(peering.RemoteNetworkId)
.Append("\n\t\tPeering state: ").Append(peering.State)
.Append("\n\t\tIs traffic forwarded from remote network allowed? ").Append(peering.IsTrafficForwardingFromRemoteNetworkAllowed)
.Append("\n\t\tGateway use: ").Append(peering.GatewayUse);
}
Utilities.Log(info.ToString());
}
public static void PrintIPAddress(IPublicIPAddress publicIPAddress)
{
Utilities.Log(new StringBuilder().Append("Public IP Address: ").Append(publicIPAddress.Id)
.Append("Name: ").Append(publicIPAddress.Name)
.Append("\n\tResource group: ").Append(publicIPAddress.ResourceGroupName)
.Append("\n\tRegion: ").Append(publicIPAddress.Region)
.Append("\n\tTags: ").Append(FormatDictionary(publicIPAddress.Tags))
.Append("\n\tIP Address: ").Append(publicIPAddress.IPAddress)
.Append("\n\tLeaf domain label: ").Append(publicIPAddress.LeafDomainLabel)
.Append("\n\tFQDN: ").Append(publicIPAddress.Fqdn)
.Append("\n\tReverse FQDN: ").Append(publicIPAddress.ReverseFqdn)
.Append("\n\tIdle timeout (minutes): ").Append(publicIPAddress.IdleTimeoutInMinutes)
.Append("\n\tIP allocation method: ").Append(publicIPAddress.IPAllocationMethod)
.ToString());
}
public static void PrintNetworkInterface(INetworkInterface resource)
{
var info = new StringBuilder();
info.Append("NetworkInterface: ").Append(resource.Id)
.Append("Name: ").Append(resource.Name)
.Append("\n\tResource group: ").Append(resource.ResourceGroupName)
.Append("\n\tRegion: ").Append(resource.Region)
.Append("\n\tTags: ").Append(FormatDictionary(resource.Tags))
.Append("\n\tInternal DNS name label: ").Append(resource.InternalDnsNameLabel)
.Append("\n\tInternal FQDN: ").Append(resource.InternalFqdn)
.Append("\n\tInternal domain name suffix: ").Append(resource.InternalDomainNameSuffix)
.Append("\n\tNetwork security group: ").Append(resource.NetworkSecurityGroupId)
.Append("\n\tApplied DNS servers: ").Append(FormatCollection(resource.AppliedDnsServers))
.Append("\n\tDNS server IPs: ");
// Output dns servers
foreach (var dnsServerIp in resource.DnsServers)
{
info.Append("\n\t\t").Append(dnsServerIp);
}
info.Append("\n\t IP forwarding enabled: ").Append(resource.IsIPForwardingEnabled)
.Append("\n\tAccelerated networking enabled: ").Append(resource.IsAcceleratedNetworkingEnabled)
.Append("\n\tMAC Address:").Append(resource.MacAddress)
.Append("\n\tPrivate IP:").Append(resource.PrimaryPrivateIP)
.Append("\n\tPrivate allocation method:").Append(resource.PrimaryPrivateIPAllocationMethod)
.Append("\n\tPrimary virtual network ID: ").Append(resource.PrimaryIPConfiguration.NetworkId)
.Append("\n\tPrimary subnet name:").Append(resource.PrimaryIPConfiguration.SubnetName);
Utilities.Log(info.ToString());
}
public static void PrintLoadBalancer(ILoadBalancer loadBalancer)
{
var info = new StringBuilder();
info.Append("Load balancer: ").Append(loadBalancer.Id)
.Append("Name: ").Append(loadBalancer.Name)
.Append("\n\tResource group: ").Append(loadBalancer.ResourceGroupName)
.Append("\n\tRegion: ").Append(loadBalancer.Region)
.Append("\n\tTags: ").Append(FormatDictionary(loadBalancer.Tags))
.Append("\n\tBackends: ").Append(FormatCollection(loadBalancer.Backends.Keys));
// Show public IP addresses
info.Append("\n\tPublic IP address IDs: ")
.Append(loadBalancer.PublicIPAddressIds.Count);
foreach (var pipId in loadBalancer.PublicIPAddressIds)
{
info.Append("\n\t\tPIP id: ").Append(pipId);
}
// Show TCP probes
info.Append("\n\tTCP probes: ")
.Append(loadBalancer.TcpProbes.Count);
foreach (var probe in loadBalancer.TcpProbes.Values)
{
info.Append("\n\t\tProbe name: ").Append(probe.Name)
.Append("\n\t\t\tPort: ").Append(probe.Port)
.Append("\n\t\t\tInterval in seconds: ").Append(probe.IntervalInSeconds)
.Append("\n\t\t\tRetries before unhealthy: ").Append(probe.NumberOfProbes);
// Show associated load balancing rules
info.Append("\n\t\t\tReferenced from load balancing rules: ")
.Append(probe.LoadBalancingRules.Count);
foreach (var rule in probe.LoadBalancingRules.Values)
{
info.Append("\n\t\t\t\tName: ").Append(rule.Name);
}
}
// Show HTTP probes
info.Append("\n\tHTTP probes: ")
.Append(loadBalancer.HttpProbes.Count);
foreach (var probe in loadBalancer.HttpProbes.Values)
{
info.Append("\n\t\tProbe name: ").Append(probe.Name)
.Append("\n\t\t\tPort: ").Append(probe.Port)
.Append("\n\t\t\tInterval in seconds: ").Append(probe.IntervalInSeconds)
.Append("\n\t\t\tRetries before unhealthy: ").Append(probe.NumberOfProbes)
.Append("\n\t\t\tHTTP request path: ").Append(probe.RequestPath);
// Show associated load balancing rules
info.Append("\n\t\t\tReferenced from load balancing rules: ")
.Append(probe.LoadBalancingRules.Count);
foreach (var rule in probe.LoadBalancingRules.Values)
{
info.Append("\n\t\t\t\tName: ").Append(rule.Name);
}
}
// Show HTTPS probes
info.Append("\n\tHTTPS probes: ")
.Append(loadBalancer.HttpsProbes.Count);
foreach (var probe in loadBalancer.HttpsProbes.Values)
{
info.Append("\n\t\tProbe name: ").Append(probe.Name)
.Append("\n\t\t\tPort: ").Append(probe.Port)
.Append("\n\t\t\tInterval in seconds: ").Append(probe.IntervalInSeconds)
.Append("\n\t\t\tRetries before unhealthy: ").Append(probe.NumberOfProbes)
.Append("\n\t\t\tHTTPS request path: ").Append(probe.RequestPath);
// Show associated load balancing rules
info.Append("\n\t\t\tReferenced from load balancing rules: ")
.Append(probe.LoadBalancingRules.Count);
foreach (var rule in probe.LoadBalancingRules.Values)
{
info.Append("\n\t\t\t\tName: ").Append(rule.Name);
}
}
// Show load balancing rules
info.Append("\n\tLoad balancing rules: ")
.Append(loadBalancer.LoadBalancingRules.Count);
foreach (var rule in loadBalancer.LoadBalancingRules.Values)
{
info.Append("\n\t\tLB rule name: ").Append(rule.Name)
.Append("\n\t\t\tProtocol: ").Append(rule.Protocol)
.Append("\n\t\t\tFloating IP enabled? ").Append(rule.FloatingIPEnabled)
.Append("\n\t\t\tIdle timeout in minutes: ").Append(rule.IdleTimeoutInMinutes)
.Append("\n\t\t\tLoad distribution method: ").Append(rule.LoadDistribution);
var frontend = rule.Frontend;
info.Append("\n\t\t\tFrontend: ");
if (frontend != null)
{
info.Append(frontend.Name);
}
else
{
info.Append("(None)");
}
info.Append("\n\t\t\tFrontend port: ").Append(rule.FrontendPort);
var backend = rule.Backend;
info.Append("\n\t\t\tBackend: ");
if (backend != null)
{
info.Append(backend.Name);
}