From a7fbc3402b9d520eab73871abfe2f968a9eefa30 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Wed, 10 Mar 2021 12:51:27 -0800 Subject: [PATCH 1/3] Remove reference for Azure.Identity --- .../src/Azure.ResourceManager.Core.csproj | 1 - .../src/AzureResourceManagerClient.cs | 11 ----------- .../Proto.Client/src/Proto.Client.csproj | 4 ++++ .../Proto.Client/src/Scenarios/DefaultSubscription.cs | 2 +- .../Proto.Client/src/Scenarios/ShutdownVmsByName.cs | 3 ++- .../Scenarios/ShutdownVmsByNameAcrossSubscriptions.cs | 5 +++-- 6 files changed, 10 insertions(+), 16 deletions(-) diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Azure.ResourceManager.Core.csproj b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Azure.ResourceManager.Core.csproj index 364c9d64f576c..0309ec812fdce 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Azure.ResourceManager.Core.csproj +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Azure.ResourceManager.Core.csproj @@ -14,7 +14,6 @@ - diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs index 84c2d79d08a63..ad9c31fe61173 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using Azure.Core; -using Azure.Identity; using System; using System.Collections.Generic; using System.Globalization; @@ -31,16 +30,6 @@ protected AzureResourceManagerClient() { } - /// - /// Initializes a new instance of the class - /// with as credential. - /// - /// The client parameters to use in these operations. - public AzureResourceManagerClient(AzureResourceManagerClientOptions options = default) - : this(null, null, new DefaultAzureCredential(), options) - { - } - /// /// Initializes a new instance of the class. /// diff --git a/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj b/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj index 57df41d88b2fd..c90c11809b32c 100644 --- a/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj +++ b/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj @@ -16,4 +16,8 @@ + + + + diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/DefaultSubscription.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/DefaultSubscription.cs index b2a3692a0c416..b10efaac99972 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/DefaultSubscription.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/DefaultSubscription.cs @@ -17,7 +17,7 @@ public override void Execute() Console.WriteLine("Found correct subscription"); - client = new AzureResourceManagerClient(); + client = new AzureResourceManagerClient(new DefaultAzureCredential()); sub = client.DefaultSubscription; diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByName.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByName.cs index e86d36e0837e5..746810e2f5e58 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByName.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByName.cs @@ -1,6 +1,7 @@ using Proto.Compute; using Azure.ResourceManager.Core; using System; +using Azure.Identity; namespace Proto.Client { @@ -11,7 +12,7 @@ public override void Execute() var createMultipleVms = new CreateMultipleVms(Context); createMultipleVms.Execute(); - var sub = new AzureResourceManagerClient().GetSubscriptionOperations(Context.SubscriptionId); + var sub = new AzureResourceManagerClient(new DefaultAzureCredential()).GetSubscriptionOperations(Context.SubscriptionId); foreach(var armResource in sub.ListVirtualMachinesByName("-e")) { diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossSubscriptions.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossSubscriptions.cs index 263ccdaa88154..0a1f642049980 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossSubscriptions.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossSubscriptions.cs @@ -3,6 +3,7 @@ using Azure.ResourceManager.Core; using System; using System.Threading.Tasks; +using Azure.Identity; namespace Proto.Client { @@ -10,7 +11,7 @@ class ShutdownVmsByNameAcrossSubscriptions : Scenario { public async void ShutdownAsync() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); await foreach (var subscription in client.GetSubscriptionContainer().ListAsync()) { @@ -40,7 +41,7 @@ public async override void Execute() #endregion - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); foreach (var sub in client.GetSubscriptionContainer().List()) { await foreach (var armResource in sub.ListVirtualMachinesByNameAsync("-e")) From ebb5df8ae06d057617b79217abdbe3f4bda9513c Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Thu, 11 Mar 2021 10:22:36 -0800 Subject: [PATCH 2/3] fixing ArmClient construction in proto client --- sdk/resourcemanager/Proto.Client/src/Program.cs | 3 ++- sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj | 2 +- .../Proto.Client/src/Scenarios/AddTagToGeneric.cs | 3 ++- sdk/resourcemanager/Proto.Client/src/Scenarios/All.cs | 3 ++- .../Proto.Client/src/Scenarios/CheckResourceExists.cs | 3 ++- .../src/Scenarios/CheckResourceGroupContainerAsync.cs | 3 ++- .../Proto.Client/src/Scenarios/CheckResourceGroupOpsAsync.cs | 3 ++- .../Proto.Client/src/Scenarios/ClientOverrides.cs | 5 +++-- .../Proto.Client/src/Scenarios/CreateMultipleVms.cs | 3 ++- .../src/Scenarios/CreateSingleVMCheckLocation.cs | 3 ++- .../Proto.Client/src/Scenarios/CreateSingleVmExample.cs | 3 ++- .../Proto.Client/src/Scenarios/CreateSingleVmExampleAsync.cs | 3 ++- .../Proto.Client/src/Scenarios/DeleteGeneric.cs | 3 ++- .../Proto.Client/src/Scenarios/GenericEntityLoop.cs | 3 ++- .../Proto.Client/src/Scenarios/GetByContainerAsync.cs | 3 ++- .../Proto.Client/src/Scenarios/GetByContainers.cs | 3 ++- .../Proto.Client/src/Scenarios/GetFromOperations.cs | 5 +++-- .../Proto.Client/src/Scenarios/GetSubscription.cs | 3 ++- .../Proto.Client/src/Scenarios/GetVMTaskExamples.cs | 3 ++- .../Proto.Client/src/Scenarios/ListByNameExpanded.cs | 3 ++- .../Proto.Client/src/Scenarios/RoleAssignment.cs | 3 ++- .../Proto.Client/src/Scenarios/SetTagsOnVm.cs | 3 ++- .../Proto.Client/src/Scenarios/ShutdownVmsByLINQ.cs | 5 +++-- .../src/Scenarios/ShutdownVmsByNameAcrossResourceGroups.cs | 3 ++- .../Proto.Client/src/Scenarios/ShutdownVmsByTag.cs | 3 ++- .../Proto.Client/src/Scenarios/StartCreateSingleVmExample.cs | 3 ++- .../src/Scenarios/StartCreateSingleVmExampleAsync.cs | 3 ++- .../Proto.Client/src/Scenarios/StartFromVm.cs | 3 ++- .../Proto.Client/src/Scenarios/StartStopVm.cs | 3 ++- .../Proto.Client/src/Scenarios/SubscriptionExists.cs | 3 ++- .../Proto.Client/src/Scenarios/UseParentLocation.cs | 3 ++- .../Proto.Client/src/Scenarios/VmModelBuilder.cs | 3 ++- 32 files changed, 66 insertions(+), 35 deletions(-) diff --git a/sdk/resourcemanager/Proto.Client/src/Program.cs b/sdk/resourcemanager/Proto.Client/src/Program.cs index 380b481f7f9cc..b51b5dc99f81b 100644 --- a/sdk/resourcemanager/Proto.Client/src/Program.cs +++ b/sdk/resourcemanager/Proto.Client/src/Program.cs @@ -1,5 +1,6 @@ using Azure.ResourceManager.Core; using System; +using Azure.Identity; namespace Proto.Client { @@ -18,7 +19,7 @@ static void Main(string[] args) foreach (var rgId in Scenario.CleanUp) { ResourceIdentifier id = new ResourceIdentifier(rgId); - var rg = new AzureResourceManagerClient().GetSubscriptionOperations(id.Subscription).GetResourceGroupOperations(id.ResourceGroup); + var rg = new AzureResourceManagerClient(new DefaultAzureCredential()).GetSubscriptionOperations(id.Subscription).GetResourceGroupOperations(id.ResourceGroup); Console.WriteLine($"--------Deleting {rg.Id.Name}--------"); try { diff --git a/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj b/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj index c90c11809b32c..b707c2e0e25ca 100644 --- a/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj +++ b/sdk/resourcemanager/Proto.Client/src/Proto.Client.csproj @@ -17,7 +17,7 @@ - + diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/AddTagToGeneric.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/AddTagToGeneric.cs index 29890198bdac3..4e59f4c8f967e 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/AddTagToGeneric.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/AddTagToGeneric.cs @@ -1,6 +1,7 @@ using Azure.ResourceManager.Core; using Proto.Compute; using System; +using Azure.Identity; namespace Proto.Client { @@ -11,7 +12,7 @@ public override void Execute() var createVm = new CreateSingleVmExample(Context); createVm.Execute(); - var rgOp = new AzureResourceManagerClient().GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); + var rgOp = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); foreach (var genericOp in rgOp.GetVirtualMachineContainer().ListAsGenericResource(Context.VmName)) { Console.WriteLine($"Adding tag to {genericOp.Id}"); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/All.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/All.cs index c7ae7aeaa86af..0e81b3bf995e5 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/All.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/All.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using Azure.Identity; namespace Proto.Client { @@ -28,7 +29,7 @@ public override void Execute() foreach (var rgId in CleanUp) { ResourceIdentifier id = new ResourceIdentifier(rgId); - var rg = new AzureResourceManagerClient().GetResourceGroupOperations(rgId); + var rg = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(rgId); Console.WriteLine($"--------Deleting {rg.Id.Name}--------"); try { diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs index c5988fe7c6eb5..d4e228aea34aa 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs @@ -1,6 +1,7 @@ using Azure.ResourceManager.Core; using Proto.Compute; using System; +using Azure.Identity; namespace Proto.Client { @@ -8,7 +9,7 @@ class CheckResourceExists : Scenario { public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subOp = client.DefaultSubscription; var rgContainer = subOp.GetResourceGroupContainer(); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupContainerAsync.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupContainerAsync.cs index 2269e23e534b9..45f6e21484657 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupContainerAsync.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupContainerAsync.cs @@ -2,6 +2,7 @@ using Proto.Compute; using System; using System.Threading.Tasks; +using Azure.Identity; namespace Proto.Client { @@ -18,7 +19,7 @@ public override void Execute() private async System.Threading.Tasks.Task ExecuteAsync() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupOpsAsync.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupOpsAsync.cs index b0263b2c00e16..410fc85a1bc8b 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupOpsAsync.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceGroupOpsAsync.cs @@ -2,6 +2,7 @@ using Proto.Compute; using System; using System.Threading.Tasks; +using Azure.Identity; namespace Proto.Client { @@ -18,7 +19,7 @@ public override void Execute() private async System.Threading.Tasks.Task ExecuteAsync() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/ClientOverrides.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/ClientOverrides.cs index 44e31dc3c1090..5fbe7bb1f1102 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/ClientOverrides.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/ClientOverrides.cs @@ -4,6 +4,7 @@ using Azure.Core.Pipeline; using System.Threading; using System.Diagnostics; +using Azure.Identity; namespace Proto.Client { @@ -18,8 +19,8 @@ public override void Execute() var dummyPolicy2 = new dummyPolicy2(); options1.AddPolicy(dummyPolicy1, HttpPipelinePosition.PerCall); options2.AddPolicy(dummyPolicy2, HttpPipelinePosition.PerCall); - var client1 = new AzureResourceManagerClient(options1); - var client2 = new AzureResourceManagerClient(options2); + var client1 = new AzureResourceManagerClient(new DefaultAzureCredential(), options1); + var client2 = new AzureResourceManagerClient(new DefaultAzureCredential(), options2); Console.WriteLine("-----Client 1-----"); foreach (var sub in client1.GetSubscriptionContainer().List()) diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateMultipleVms.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateMultipleVms.cs index b3eed9cac93e2..5093383ebfae1 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateMultipleVms.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateMultipleVms.cs @@ -3,6 +3,7 @@ using Proto.Network; using System; using System.Collections.Generic; +using Azure.Identity; namespace Proto.Client { @@ -14,7 +15,7 @@ public CreateMultipleVms(ScenarioContext context) : base(context) { } public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVMCheckLocation.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVMCheckLocation.cs index 0308cbbbf9c7b..a8bc519c4e34f 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVMCheckLocation.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVMCheckLocation.cs @@ -3,6 +3,7 @@ using Proto.Network; using System; using System.Linq; +using Azure.Identity; namespace Proto.Client { @@ -14,7 +15,7 @@ public CreateSingleVMCheckLocation(ScenarioContext context) : base(context) { } public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExample.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExample.cs index 7ae8ff1d44db9..6dbf663b01959 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExample.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExample.cs @@ -2,6 +2,7 @@ using Proto.Compute; using Proto.Network; using System; +using Azure.Identity; namespace Proto.Client { @@ -13,7 +14,7 @@ public CreateSingleVmExample(ScenarioContext context) : base(context) { } public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExampleAsync.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExampleAsync.cs index 52218cbec5b69..7b06687a3016a 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExampleAsync.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CreateSingleVmExampleAsync.cs @@ -2,6 +2,7 @@ using Proto.Compute; using Proto.Network; using System; +using Azure.Identity; namespace Proto.Client { @@ -18,7 +19,7 @@ public override void Execute() private async System.Threading.Tasks.Task ExcuteAsync() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/DeleteGeneric.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/DeleteGeneric.cs index 39a03e5eb8409..38446bc0876a0 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/DeleteGeneric.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/DeleteGeneric.cs @@ -2,6 +2,7 @@ using Azure.ResourceManager.Core; using Proto.Compute; using System; +using Azure.Identity; namespace Proto.Client { @@ -12,7 +13,7 @@ public override void Execute() var createVm = new CreateSingleVmExample(Context); createVm.Execute(); - var rgOp = new AzureResourceManagerClient().GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); + var rgOp = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); foreach(var genericOp in rgOp.GetVirtualMachineContainer().ListAsGenericResource(Context.VmName)) { Console.WriteLine($"Deleting {genericOp.Id}"); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/GenericEntityLoop.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/GenericEntityLoop.cs index 1676cde944b10..0e88b480d23fe 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/GenericEntityLoop.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/GenericEntityLoop.cs @@ -1,6 +1,7 @@ using Proto.Compute; using Azure.ResourceManager.Core; using System; +using Azure.Identity; namespace Proto.Client { @@ -11,7 +12,7 @@ public override void Execute() var createVm = new CreateSingleVmExample(Context); createVm.Execute(); - var rgOp = new AzureResourceManagerClient().GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); + var rgOp = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); foreach(var entity in rgOp.GetVirtualMachineContainer().List()) { Console.WriteLine($"{entity.Id.Name}"); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainerAsync.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainerAsync.cs index 638b89da02b69..170e54833b8e6 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainerAsync.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainerAsync.cs @@ -4,6 +4,7 @@ using System; using System.Diagnostics; using System.Threading.Tasks; +using Azure.Identity; namespace Proto.Client { @@ -18,7 +19,7 @@ private async Task ExecuteAsync() var createMultipleVms = new CreateMultipleVms(Context); createMultipleVms.Execute(); - var sub = new AzureResourceManagerClient().GetSubscriptionOperations(Context.SubscriptionId); + var sub = new AzureResourceManagerClient(new DefaultAzureCredential()).GetSubscriptionOperations(Context.SubscriptionId); var rg = sub.GetResourceGroupOperations(Context.RgName); var virtualMachineContainer = rg.GetVirtualMachineContainer(); await foreach (var response in virtualMachineContainer.ListAsync()) diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainers.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainers.cs index 602c535c52d16..728e0078606ea 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainers.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetByContainers.cs @@ -3,6 +3,7 @@ using Proto.Network; using System; using System.Diagnostics; +using Azure.Identity; namespace Proto.Client { @@ -13,7 +14,7 @@ public override void Execute() var createMultipleVms = new CreateMultipleVms(Context); createMultipleVms.Execute(); - var sub = new AzureResourceManagerClient().GetSubscriptionOperations(Context.SubscriptionId); + var sub = new AzureResourceManagerClient(new DefaultAzureCredential()).GetSubscriptionOperations(Context.SubscriptionId); var rg = sub.GetResourceGroupOperations(Context.RgName); var virtualMachineContainer = rg.GetVirtualMachineContainer(); foreach (var response in virtualMachineContainer.List()) diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetFromOperations.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetFromOperations.cs index a8b5cbaf027c0..784bffb586165 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetFromOperations.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetFromOperations.cs @@ -1,4 +1,5 @@ -using Azure.ResourceManager.Core; +using Azure.Identity; +using Azure.ResourceManager.Core; using Proto.Compute; using Proto.Network; @@ -11,7 +12,7 @@ public override void Execute() var createVm = new CreateSingleVmExample(Context); createVm.Execute(); - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); var resourceGroup = subscription.GetResourceGroupOperations(Context.RgName).Get().Value; diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetSubscription.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetSubscription.cs index a60e07d9dac77..ed7224a890488 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetSubscription.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetSubscription.cs @@ -1,6 +1,7 @@ using Azure.ResourceManager.Core; using System; using System.Diagnostics; +using Azure.Identity; namespace Proto.Client { @@ -10,7 +11,7 @@ public override void Execute() { var sandboxId = "db1ab6f0-4769-4b27-930e-01e2ef9c123c"; var expectDisplayName = "Azure SDK sandbox"; - var subOp = new AzureResourceManagerClient().GetSubscriptionOperations(sandboxId); + var subOp = new AzureResourceManagerClient(new DefaultAzureCredential()).GetSubscriptionOperations(sandboxId); var result = subOp.Get(); Debug.Assert(expectDisplayName == result.Value.Data.DisplayName); Console.WriteLine("Passed, got " + result.Value.Data.DisplayName); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetVMTaskExamples.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetVMTaskExamples.cs index 925854a92448a..e57d966c58645 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/GetVMTaskExamples.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/GetVMTaskExamples.cs @@ -4,6 +4,7 @@ using Proto.Network; using System; using System.Linq; +using Azure.Identity; namespace Proto.Client { @@ -18,7 +19,7 @@ public override void Execute() var createVm = new CreateSingleVmExample(Context); createVm.Execute(); - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); var resourceGroup = subscription.GetResourceGroupOperations(Context.RgName); var vmId = resourceGroup.GetVirtualMachineOperations(Context.VmName).Id; diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/ListByNameExpanded.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/ListByNameExpanded.cs index 41835b7557365..3461a268504ec 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/ListByNameExpanded.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/ListByNameExpanded.cs @@ -3,6 +3,7 @@ using Proto.Network; using System; using System.Threading.Tasks; +using Azure.Identity; namespace Proto.Client { @@ -13,7 +14,7 @@ public override void Execute() var createMultipleVms = new CreateMultipleVms(Context); createMultipleVms.Execute(); - var rg = new AzureResourceManagerClient().GetResourceGroupOperations(Context.SubscriptionId, Context.RgName).Get().Value; + var rg = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(Context.SubscriptionId, Context.RgName).Get().Value; foreach (var availabilitySet in rg.GetAvailabilitySetContainer().ListAsGenericResource(Environment.UserName)) { Console.WriteLine($"--------AvailabilitySet operation id--------: {availabilitySet.Id}"); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/RoleAssignment.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/RoleAssignment.cs index 0b840914f8e2c..7e595363e21b5 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/RoleAssignment.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/RoleAssignment.cs @@ -3,6 +3,7 @@ using Proto.Compute; using Proto.Network; using System; +using Azure.Identity; namespace Proto.Client { @@ -10,7 +11,7 @@ class RoleAssignment : Scenario { public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/SetTagsOnVm.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/SetTagsOnVm.cs index f4d978ae48cae..b81f88140d375 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/SetTagsOnVm.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/SetTagsOnVm.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Linq; using System.Threading.Tasks; +using Azure.Identity; using Azure.ResourceManager.Core; using Proto.Compute; @@ -31,7 +32,7 @@ private void DumpDictionary(IDictionary dic) private async Task ExecuteAsync() { // Update Tag for a known resource - var rgOp = new AzureResourceManagerClient().GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); + var rgOp = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); var vmOp = rgOp.GetVirtualMachineOperations(Context.VmName); Console.WriteLine($"Adding tags to {vmOp.Id.Name}"); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByLINQ.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByLINQ.cs index c0b0fda0dc4c1..44aa073a79bfb 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByLINQ.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByLINQ.cs @@ -2,6 +2,7 @@ using Azure.ResourceManager.Core; using System; using System.Linq; +using Azure.Identity; namespace Proto.Client { @@ -12,7 +13,7 @@ public override void Execute() var createMultipleVms = new CreateMultipleVms(Context); createMultipleVms.Execute(); - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); foreach (var sub in client.GetSubscriptionContainer().List()) { var vmList = sub.ListVirtualMachines(); @@ -25,7 +26,7 @@ public override void Execute() } } - var resourceGroup = new AzureResourceManagerClient().GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); + var resourceGroup = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(Context.SubscriptionId, Context.RgName); resourceGroup.GetVirtualMachineContainer().List().Select(vm => { diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossResourceGroups.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossResourceGroups.cs index d9842ab8bdb8c..4c8c10bd10b70 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossResourceGroups.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByNameAcrossResourceGroups.cs @@ -3,6 +3,7 @@ using System; using System.Text.RegularExpressions; using System.Threading.Tasks; +using Azure.Identity; namespace Proto.Client { @@ -19,7 +20,7 @@ public override void Execute() context = new ScenarioContext(); } - var subscription = new AzureResourceManagerClient().GetSubscriptionOperations(Context.SubscriptionId); + var subscription = new AzureResourceManagerClient(new DefaultAzureCredential()).GetSubscriptionOperations(Context.SubscriptionId); Regex reg = new Regex($"{Context.VmName}.*-e"); Parallel.ForEach(subscription.ListVirtualMachines(), vm => diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByTag.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByTag.cs index 6f3d771daf06b..1b4a9fa35562d 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByTag.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/ShutdownVmsByTag.cs @@ -2,6 +2,7 @@ using Azure.ResourceManager.Core; using System; using System.Linq; +using Azure.Identity; namespace Proto.Client { @@ -12,7 +13,7 @@ public override void Execute() var createMultipleVms = new CreateMultipleVms(Context); createMultipleVms.Execute(); - var rg = new AzureResourceManagerClient().GetResourceGroupOperations(Context.SubscriptionId, Context.RgName).Get().Value; + var rg = new AzureResourceManagerClient(new DefaultAzureCredential()).GetResourceGroupOperations(Context.SubscriptionId, Context.RgName).Get().Value; //set tags on random vms Random rand = new Random(Environment.TickCount); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExample.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExample.cs index 69c7507675c19..a8d40b9cf7b85 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExample.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExample.cs @@ -2,6 +2,7 @@ using Proto.Compute; using Proto.Network; using System; +using Azure.Identity; namespace Proto.Client { @@ -18,7 +19,7 @@ public override void Execute() private async System.Threading.Tasks.Task ExcuteAsync() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExampleAsync.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExampleAsync.cs index 86937eae74768..dcd8947de2be8 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExampleAsync.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartCreateSingleVmExampleAsync.cs @@ -2,6 +2,7 @@ using Proto.Compute; using Proto.Network; using System; +using Azure.Identity; namespace Proto.Client { @@ -17,7 +18,7 @@ public override void Execute() } private async System.Threading.Tasks.Task ExecuteAsync() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartFromVm.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartFromVm.cs index f8aa2100cf50c..9224e1feeaf35 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartFromVm.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartFromVm.cs @@ -1,6 +1,7 @@ using Proto.Compute; using Azure.ResourceManager.Core; using System; +using Azure.Identity; namespace Proto.Client { @@ -10,7 +11,7 @@ public override void Execute() { var createVm = new CreateSingleVmExample(Context); createVm.Execute(); - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); //retrieve from lowest level, doesn't give ability to walk up and down the container structure var vmOp = client.GetResourceOperations(Context.SubscriptionId, Context.RgName, Context.VmName); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartStopVm.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartStopVm.cs index 4f6dd70d71825..17b8557cc1b2d 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/StartStopVm.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/StartStopVm.cs @@ -1,6 +1,7 @@ using Proto.Compute; using Azure.ResourceManager.Core; using System; +using Azure.Identity; namespace Proto.Client { @@ -11,7 +12,7 @@ public override void Execute() var createVm = new CreateSingleVmExample(Context); createVm.Execute(); - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); var resourceGroup = subscription.GetResourceGroupOperations(Context.RgName); var vm = resourceGroup.GetVirtualMachineOperations(Context.VmName); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/SubscriptionExists.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/SubscriptionExists.cs index 41ab8df56a553..fc6964efd3081 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/SubscriptionExists.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/SubscriptionExists.cs @@ -1,5 +1,6 @@ using Azure.ResourceManager.Core; using System; +using Azure.Identity; namespace Proto.Client { @@ -7,7 +8,7 @@ class SubscriptionExists : Scenario { public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); if(client.GetSubscriptionContainer().DoesExist(Context.SubscriptionId)) { Console.WriteLine($"Found {Context.SubscriptionId}"); diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/UseParentLocation.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/UseParentLocation.cs index 636586e3a67a3..107ceaf0e115f 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/UseParentLocation.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/UseParentLocation.cs @@ -2,6 +2,7 @@ using Proto.Compute; using Proto.Network; using System; +using Azure.Identity; namespace Proto.Client { @@ -9,7 +10,7 @@ class UseParentLocation : Scenario { public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/VmModelBuilder.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/VmModelBuilder.cs index 2f71a2cda5f21..cda7d55e554d7 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/VmModelBuilder.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/VmModelBuilder.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; +using Azure.Identity; using Proto.Compute; using Azure.ResourceManager.Core; using Proto.Network; @@ -19,7 +20,7 @@ public override void Execute() private Task CreateVmWithBuilderAsync() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); var subscription = client.GetSubscriptionOperations(Context.SubscriptionId); // Create Resource Group From c94bae4e752da30a32597d1f7005f29fec734d55 Mon Sep 17 00:00:00 2001 From: Allen Zhang Date: Thu, 11 Mar 2021 10:51:58 -0800 Subject: [PATCH 3/3] resync and fix build error --- .../Proto.Client/src/Scenarios/TenantResource.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/TenantResource.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/TenantResource.cs index 538b22744a410..36f5a850857d7 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/TenantResource.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/TenantResource.cs @@ -2,6 +2,7 @@ using System; using Proto.Billing; using System.Diagnostics; +using Azure.Identity; namespace Proto.Client { @@ -9,7 +10,7 @@ class TenantResource : Scenario { public override void Execute() { - var client = new AzureResourceManagerClient(); + var client = new AzureResourceManagerClient(new DefaultAzureCredential()); TenantOperations tenant = client.Tenant; string testAccount = "3984c6f4-2d2a-4b04-93ce-43cf4824b698:e2f1492a-a492-468d-909f-bf7fe6662c01_2019-05-31"; BillingAccountOperations billingAccountOperations = tenant.GetBillingAccountsOperations(testAccount);