diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs index 16cc90042c8a..c9c104eff063 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs @@ -4,6 +4,8 @@ using Azure.Core; using System; using System.Globalization; +using System.Threading; +using System.Threading.Tasks; namespace Azure.ResourceManager.Core { @@ -37,29 +39,47 @@ protected ContainerBase(ResourceOperationsBase parent) } /// - /// Gets the parent resource of this resource + /// Gets the parent resource of this resource. /// protected ResourceOperationsBase Parent { get; } /// - /// Returns the resource from Azure if it exists + /// Returns the resource from Azure if it exists. /// /// The name of the resource you want to get. - /// The resource if it existed, null otherwise. /// Whether or not the resource existed. - public virtual bool TryGetValue(string resourceName, out ArmResponse resource) + public virtual TOperations TryGet(string resourceName) { var op = GetOperation(resourceName); try { - resource = op.Get(); - return true; + return op.Get().Value; + } + catch (RequestFailedException e) when (e.Status == 404) + { + return null; + } + } + + /// + /// Returns the resource from Azure if it exists. + /// + /// The name of the resource you want to get. + /// A token to allow the caller to cancel the call to the service. + /// The default value is . + /// Whether or not the resource existed. + public async virtual Task TryGetAsync(string resourceName, CancellationToken cancellationToken = default) + { + var op = GetOperation(resourceName); + + try + { + return (await op.GetAsync(cancellationToken).ConfigureAwait(false)).Value; } catch { - resource = null; - return false; + return null; } } @@ -70,8 +90,7 @@ public virtual bool TryGetValue(string resourceName, out ArmResponse Whether or not the resource existed. public virtual bool DoesExist(string resourceName) { - ArmResponse output; - return TryGetValue(resourceName, out output); + return TryGet(resourceName) == null ? false : true; } /// diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ContainerTryGetTest.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ContainerTryGetTest.cs new file mode 100644 index 000000000000..2a4d95d6c8f6 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/Scenario/ContainerTryGetTest.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +using System; +using System.Threading.Tasks; +using Azure.Identity; +using Azure.Core.TestFramework; +using NUnit.Framework; + +namespace Azure.ResourceManager.Core.Tests +{ + public class ContainerTryGetTest : ResourceManagerTestBase + { + private AzureResourceManagerClient _client; + private ResourceGroupContainer _container; + private ResourceGroup _resourceGroup; + private string _rgName; + + public ContainerTryGetTest(bool isAsync) + : base(isAsync)//, RecordedTestMode.Record) + { + } + + [SetUp] + public void SetUp() + { + _rgName = Recording.GenerateAssetName("CoreRg"); + _client = GetArmClient(); + _container = _client.DefaultSubscription.GetResourceGroupContainer(); + _resourceGroup = _container.Construct(LocationData.WestUS2).CreateOrUpdate(_rgName); + } + + [TestCase] + [RecordedTest] + public void TryGetTest() + { + ResourceGroup result = _container.TryGet(_rgName); + Assert.NotNull(result); + Assert.IsTrue(result.Data.Name == _rgName); + result = _container.TryGet("FakeName"); + Assert.IsNull(result); + } + + [TestCase] + [RecordedTest] + public async Task TryGetAsyncTest() + { + ResourceGroup result = await _container.TryGetAsync(_rgName); + Assert.NotNull(result); + Assert.IsTrue(result.Data.Name == _rgName); + result = await _container.TryGetAsync("FakeName"); + Assert.IsNull(result); + } + + [TestCase] + public void DoesExistTest() + { + Assert.IsTrue(_container.DoesExist(_rgName)); + Assert.IsFalse(_container.DoesExist("FakeName")); + } + } +} diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/DoesExistTest().json b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/DoesExistTest().json new file mode 100644 index 000000000000..fa84ebc974a6 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/DoesExistTest().json @@ -0,0 +1,162 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab?api-version=2019-11-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "e474f748b1211fd65efcc9cee7ca4406", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "403", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:32 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "b6f0759e-923c-457a-831d-d0bfd9013729", + "x-ms-ratelimit-remaining-subscription-reads": "11994", + "x-ms-request-id": "b6f0759e-923c-457a-831d-d0bfd9013729", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084333Z:b6f0759e-923c-457a-831d-d0bfd9013729" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab", + "authorizationSource": "RoleBased", + "managedByTenants": [], + "subscriptionId": "0accec26-d6de-4757-8e74-d080f38eaaab", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "displayName": "ACR - TEST - China Team", + "state": "Enabled", + "subscriptionPolicies": { + "locationPlacementId": "Internal_2014-09-01", + "quotaId": "Internal_2014-09-01", + "spendingLimit": "Off" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg1175?api-version=2019-10-01", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "34", + "Content-Type": "application/json", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "19c2bf17089d38649f10b0584c32c669", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "location": "West US 2", + "tags": {} + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:36 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "a45740e1-3f1b-4f75-b533-76bce716d9a4", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-request-id": "a45740e1-3f1b-4f75-b533-76bce716d9a4", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084336Z:a45740e1-3f1b-4f75-b533-76bce716d9a4" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg1175", + "name": "CoreRg1175", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg1175?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "2f02d6d8e3d8fd54fe196873a757e858", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:36 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "64c8b311-3f2f-484d-9834-36089bff54c7", + "x-ms-ratelimit-remaining-subscription-reads": "11993", + "x-ms-request-id": "64c8b311-3f2f-484d-9834-36089bff54c7", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084336Z:64c8b311-3f2f-484d-9834-36089bff54c7" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg1175", + "name": "CoreRg1175", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/FakeName?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "ccbe1c59735c3f4d933c4510017ed32c", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "100", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:36 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "c0b7113e-2087-4a97-8308-b1f876991be6", + "x-ms-failure-cause": "gateway", + "x-ms-ratelimit-remaining-subscription-reads": "11992", + "x-ms-request-id": "c0b7113e-2087-4a97-8308-b1f876991be6", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084336Z:c0b7113e-2087-4a97-8308-b1f876991be6" + }, + "ResponseBody": { + "error": { + "code": "ResourceGroupNotFound", + "message": "Resource group \u0027FakeName\u0027 could not be found." + } + } + } + ], + "Variables": { + "RandomSeed": "718120926", + "SUBSCRIPTION_ID": "0accec26-d6de-4757-8e74-d080f38eaaab" + } +} \ No newline at end of file diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/DoesExistTest()Async.json b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/DoesExistTest()Async.json new file mode 100644 index 000000000000..597f24655252 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/DoesExistTest()Async.json @@ -0,0 +1,162 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab?api-version=2019-11-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "0fbe578ef97518e5dcdd8a5df490b84a", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "403", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:12 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "1fe5a98a-d25f-46f9-b2cd-ff08b9d784a0", + "x-ms-ratelimit-remaining-subscription-reads": "11991", + "x-ms-request-id": "1fe5a98a-d25f-46f9-b2cd-ff08b9d784a0", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084413Z:1fe5a98a-d25f-46f9-b2cd-ff08b9d784a0" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab", + "authorizationSource": "RoleBased", + "managedByTenants": [], + "subscriptionId": "0accec26-d6de-4757-8e74-d080f38eaaab", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "displayName": "ACR - TEST - China Team", + "state": "Enabled", + "subscriptionPolicies": { + "locationPlacementId": "Internal_2014-09-01", + "quotaId": "Internal_2014-09-01", + "spendingLimit": "Off" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg1178?api-version=2019-10-01", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "34", + "Content-Type": "application/json", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "70352749c0857f2987693d9368751c51", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "location": "West US 2", + "tags": {} + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:14 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "e515fb71-7d8a-4081-9601-3a30d1a62a2d", + "x-ms-ratelimit-remaining-subscription-writes": "1197", + "x-ms-request-id": "e515fb71-7d8a-4081-9601-3a30d1a62a2d", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084414Z:e515fb71-7d8a-4081-9601-3a30d1a62a2d" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg1178", + "name": "CoreRg1178", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg1178?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "adb38169ab78bf4921c73827e08c45e8", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:14 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "01e57633-8fc9-4be1-8550-b7a4e099ab96", + "x-ms-ratelimit-remaining-subscription-reads": "11990", + "x-ms-request-id": "01e57633-8fc9-4be1-8550-b7a4e099ab96", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084414Z:01e57633-8fc9-4be1-8550-b7a4e099ab96" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg1178", + "name": "CoreRg1178", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/FakeName?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "54e300809f2ccd3a2d3f870bbc52af66", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "100", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:14 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "3291c4ac-c0ef-4c75-949d-823255fa2e36", + "x-ms-failure-cause": "gateway", + "x-ms-ratelimit-remaining-subscription-reads": "11989", + "x-ms-request-id": "3291c4ac-c0ef-4c75-949d-823255fa2e36", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084414Z:3291c4ac-c0ef-4c75-949d-823255fa2e36" + }, + "ResponseBody": { + "error": { + "code": "ResourceGroupNotFound", + "message": "Resource group \u0027FakeName\u0027 could not be found." + } + } + } + ], + "Variables": { + "RandomSeed": "1615539813", + "SUBSCRIPTION_ID": "0accec26-d6de-4757-8e74-d080f38eaaab" + } +} \ No newline at end of file diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetAsyncTest().json b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetAsyncTest().json new file mode 100644 index 000000000000..7935e6d50549 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetAsyncTest().json @@ -0,0 +1,162 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab?api-version=2019-11-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "d68d6ad027b2ec67d973dad31c57dbb6", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "403", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:51 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "6743807a-7e87-4c24-988d-ed30f369c7e9", + "x-ms-ratelimit-remaining-subscription-reads": "11998", + "x-ms-request-id": "6743807a-7e87-4c24-988d-ed30f369c7e9", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084352Z:6743807a-7e87-4c24-988d-ed30f369c7e9" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab", + "authorizationSource": "RoleBased", + "managedByTenants": [], + "subscriptionId": "0accec26-d6de-4757-8e74-d080f38eaaab", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "displayName": "ACR - TEST - China Team", + "state": "Enabled", + "subscriptionPolicies": { + "locationPlacementId": "Internal_2014-09-01", + "quotaId": "Internal_2014-09-01", + "spendingLimit": "Off" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg354?api-version=2019-10-01", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "34", + "Content-Type": "application/json", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "d8da6527efc33cf0c724b8c7c04f6f87", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "location": "West US 2", + "tags": {} + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "226", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:54 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "fcf8e26a-2b2c-4935-a865-43decea34ac3", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-request-id": "fcf8e26a-2b2c-4935-a865-43decea34ac3", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084355Z:fcf8e26a-2b2c-4935-a865-43decea34ac3" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg354", + "name": "CoreRg354", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg354?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "62ed47aa747f3a9d042d8a7e1c4be7ea", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "226", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:54 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "8b69b91e-f43a-4d75-94dd-e7ac3b6af48a", + "x-ms-ratelimit-remaining-subscription-reads": "11997", + "x-ms-request-id": "8b69b91e-f43a-4d75-94dd-e7ac3b6af48a", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084355Z:8b69b91e-f43a-4d75-94dd-e7ac3b6af48a" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg354", + "name": "CoreRg354", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/FakeName?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "e9b37889c698e0c179500e8e6ea02c8a", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "100", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:54 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "d86c122b-03b1-4b10-ab94-5fa2431df1f4", + "x-ms-failure-cause": "gateway", + "x-ms-ratelimit-remaining-subscription-reads": "11996", + "x-ms-request-id": "d86c122b-03b1-4b10-ab94-5fa2431df1f4", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084355Z:d86c122b-03b1-4b10-ab94-5fa2431df1f4" + }, + "ResponseBody": { + "error": { + "code": "ResourceGroupNotFound", + "message": "Resource group \u0027FakeName\u0027 could not be found." + } + } + } + ], + "Variables": { + "RandomSeed": "2022059398", + "SUBSCRIPTION_ID": "0accec26-d6de-4757-8e74-d080f38eaaab" + } +} \ No newline at end of file diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetAsyncTest()Async.json b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetAsyncTest()Async.json new file mode 100644 index 000000000000..031474d1b3da --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetAsyncTest()Async.json @@ -0,0 +1,162 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab?api-version=2019-11-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "f7eaea60c33398558d80352c9d7a1c6f", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "403", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:16 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "1eef3f56-117e-4031-bbe8-742c7649eb1a", + "x-ms-ratelimit-remaining-subscription-reads": "11988", + "x-ms-request-id": "1eef3f56-117e-4031-bbe8-742c7649eb1a", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084416Z:1eef3f56-117e-4031-bbe8-742c7649eb1a" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab", + "authorizationSource": "RoleBased", + "managedByTenants": [], + "subscriptionId": "0accec26-d6de-4757-8e74-d080f38eaaab", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "displayName": "ACR - TEST - China Team", + "state": "Enabled", + "subscriptionPolicies": { + "locationPlacementId": "Internal_2014-09-01", + "quotaId": "Internal_2014-09-01", + "spendingLimit": "Off" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg9777?api-version=2019-10-01", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "34", + "Content-Type": "application/json", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "c8587753375eb275534db8cc8768f10f", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "location": "West US 2", + "tags": {} + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:17 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "dc69312a-1c67-4f9c-a1dd-d4351447c565", + "x-ms-ratelimit-remaining-subscription-writes": "1196", + "x-ms-request-id": "dc69312a-1c67-4f9c-a1dd-d4351447c565", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084417Z:dc69312a-1c67-4f9c-a1dd-d4351447c565" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg9777", + "name": "CoreRg9777", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg9777?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "96ec58e62e621f1609f5dd93533fe038", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:17 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "677b8456-73fa-4b7b-a02a-591aeeb6cac2", + "x-ms-ratelimit-remaining-subscription-reads": "11987", + "x-ms-request-id": "677b8456-73fa-4b7b-a02a-591aeeb6cac2", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084417Z:677b8456-73fa-4b7b-a02a-591aeeb6cac2" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg9777", + "name": "CoreRg9777", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/FakeName?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "1d2cd91c8b8528b57438a3e60a891025", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "100", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:17 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "102a58e9-17da-47b2-ad30-d5648a1f4fe5", + "x-ms-failure-cause": "gateway", + "x-ms-ratelimit-remaining-subscription-reads": "11986", + "x-ms-request-id": "102a58e9-17da-47b2-ad30-d5648a1f4fe5", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084417Z:102a58e9-17da-47b2-ad30-d5648a1f4fe5" + }, + "ResponseBody": { + "error": { + "code": "ResourceGroupNotFound", + "message": "Resource group \u0027FakeName\u0027 could not be found." + } + } + } + ], + "Variables": { + "RandomSeed": "1161888214", + "SUBSCRIPTION_ID": "0accec26-d6de-4757-8e74-d080f38eaaab" + } +} \ No newline at end of file diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetTest().json b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetTest().json new file mode 100644 index 000000000000..2a153e38e555 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetTest().json @@ -0,0 +1,162 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab?api-version=2019-11-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "bf298d917c4a9c21e3841a8d26025e53", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "403", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:57 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "0b4917d1-1a04-45ec-acad-563b6ab7ad85", + "x-ms-ratelimit-remaining-subscription-reads": "11995", + "x-ms-request-id": "0b4917d1-1a04-45ec-acad-563b6ab7ad85", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084358Z:0b4917d1-1a04-45ec-acad-563b6ab7ad85" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab", + "authorizationSource": "RoleBased", + "managedByTenants": [], + "subscriptionId": "0accec26-d6de-4757-8e74-d080f38eaaab", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "displayName": "ACR - TEST - China Team", + "state": "Enabled", + "subscriptionPolicies": { + "locationPlacementId": "Internal_2014-09-01", + "quotaId": "Internal_2014-09-01", + "spendingLimit": "Off" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg9464?api-version=2019-10-01", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "34", + "Content-Type": "application/json", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "e8934346dc3ec3265a3d1d3b4581c6bb", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "location": "West US 2", + "tags": {} + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:59 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "abb4dd8f-0870-414f-9a1b-8dcd08c77f72", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-request-id": "abb4dd8f-0870-414f-9a1b-8dcd08c77f72", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084400Z:abb4dd8f-0870-414f-9a1b-8dcd08c77f72" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg9464", + "name": "CoreRg9464", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg9464?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "c4c34c1fe8db5ae289cd72ccc48f3ddb", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:59 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "eb487da5-d4f8-47d2-b656-030005a50cdb", + "x-ms-ratelimit-remaining-subscription-reads": "11994", + "x-ms-request-id": "eb487da5-d4f8-47d2-b656-030005a50cdb", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084400Z:eb487da5-d4f8-47d2-b656-030005a50cdb" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg9464", + "name": "CoreRg9464", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/FakeName?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "6573ff6ff659b5bc6765650c5fe55762", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "100", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:43:59 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "1549eea9-60d8-4637-b302-c6eedef071fb", + "x-ms-failure-cause": "gateway", + "x-ms-ratelimit-remaining-subscription-reads": "11993", + "x-ms-request-id": "1549eea9-60d8-4637-b302-c6eedef071fb", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084400Z:1549eea9-60d8-4637-b302-c6eedef071fb" + }, + "ResponseBody": { + "error": { + "code": "ResourceGroupNotFound", + "message": "Resource group \u0027FakeName\u0027 could not be found." + } + } + } + ], + "Variables": { + "RandomSeed": "357280712", + "SUBSCRIPTION_ID": "0accec26-d6de-4757-8e74-d080f38eaaab" + } +} \ No newline at end of file diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetTest()Async.json b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetTest()Async.json new file mode 100644 index 000000000000..e031cf4a0de1 --- /dev/null +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/tests/SessionRecords/ContainerTryGetTest/TryGetTest()Async.json @@ -0,0 +1,162 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab?api-version=2019-11-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "bbe327fcba17c6783c96daaf95147090", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "403", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:22 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "60643137-916c-41a0-beaf-3925f492dc5c", + "x-ms-ratelimit-remaining-subscription-reads": "11985", + "x-ms-request-id": "60643137-916c-41a0-beaf-3925f492dc5c", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084422Z:60643137-916c-41a0-beaf-3925f492dc5c" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab", + "authorizationSource": "RoleBased", + "managedByTenants": [], + "subscriptionId": "0accec26-d6de-4757-8e74-d080f38eaaab", + "tenantId": "72f988bf-86f1-41af-91ab-2d7cd011db47", + "displayName": "ACR - TEST - China Team", + "state": "Enabled", + "subscriptionPolicies": { + "locationPlacementId": "Internal_2014-09-01", + "quotaId": "Internal_2014-09-01", + "spendingLimit": "Off" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg8072?api-version=2019-10-01", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "Content-Length": "34", + "Content-Type": "application/json", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "eb748011e5124bc6ca16570b21b9ba36", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": { + "location": "West US 2", + "tags": {} + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:23 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "c624c8ff-ff48-4290-89db-c9e563f8d3a0", + "x-ms-ratelimit-remaining-subscription-writes": "1195", + "x-ms-request-id": "c624c8ff-ff48-4290-89db-c9e563f8d3a0", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084423Z:c624c8ff-ff48-4290-89db-c9e563f8d3a0" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg8072", + "name": "CoreRg8072", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/CoreRg8072?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "f3e34ec6763156a7bab6bf06b080a975", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "228", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:23 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "b76c90a2-fbbf-4725-9df4-8b507fc63702", + "x-ms-ratelimit-remaining-subscription-reads": "11984", + "x-ms-request-id": "b76c90a2-fbbf-4725-9df4-8b507fc63702", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084423Z:b76c90a2-fbbf-4725-9df4-8b507fc63702" + }, + "ResponseBody": { + "id": "/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourceGroups/CoreRg8072", + "name": "CoreRg8072", + "type": "Microsoft.Resources/resourceGroups", + "location": "westus2", + "tags": {}, + "properties": { + "provisioningState": "Succeeded" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/0accec26-d6de-4757-8e74-d080f38eaaab/resourcegroups/FakeName?api-version=2019-10-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Authorization": "Sanitized", + "User-Agent": "azsdk-net-ResourceManager.Resources/1.0.0-preview.2 (.NET Framework 4.8.4300.0; Microsoft Windows 10.0.19042 )", + "x-ms-client-request-id": "b4037b2d729116336198f001626ca483", + "x-ms-return-client-request-id": "true" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "100", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 12 Mar 2021 08:44:23 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "34d1f1b6-a4ef-4407-a3df-5e9cc74b3b90", + "x-ms-failure-cause": "gateway", + "x-ms-ratelimit-remaining-subscription-reads": "11983", + "x-ms-request-id": "34d1f1b6-a4ef-4407-a3df-5e9cc74b3b90", + "x-ms-routing-request-id": "SOUTHEASTASIA:20210312T084423Z:34d1f1b6-a4ef-4407-a3df-5e9cc74b3b90" + }, + "ResponseBody": { + "error": { + "code": "ResourceGroupNotFound", + "message": "Resource group \u0027FakeName\u0027 could not be found." + } + } + } + ], + "Variables": { + "RandomSeed": "10635373", + "SUBSCRIPTION_ID": "0accec26-d6de-4757-8e74-d080f38eaaab" + } +} \ No newline at end of file diff --git a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs index d4e228aea34a..a665aa668a18 100644 --- a/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs +++ b/sdk/resourcemanager/Proto.Client/src/Scenarios/CheckResourceExists.cs @@ -25,13 +25,11 @@ public override void Execute() throw new Exception($"The resource group {Context.RgName} should have existed."); Console.WriteLine($"Using try get value to retrieve {Context.RgName}"); - ArmResponse rgOutput; - if(!rgContainer.TryGetValue(Context.RgName, out rgOutput)) + ResourceGroup rgOutput = rgContainer.TryGet(Context.RgName); + if(rgOutput == null) throw new Exception($"The resource group {Context.RgName} should have existed."); - var rg = rgOutput.Value; - - var asetContainer = rg.GetAvailabilitySetContainer(); + var asetContainer = rgOutput.GetAvailabilitySetContainer(); var asetName = Context.VmName + "_aSet"; Console.WriteLine($"Making sure {asetName} doesn't exist yet."); @@ -46,8 +44,8 @@ public override void Execute() throw new Exception($"The availability set {asetName} should have existed."); Console.WriteLine("Using try get value to retrieve the rg"); - ArmResponse asetOutput; - if (!asetContainer.TryGetValue(asetName, out asetOutput)) + AvailabilitySet asetOutput = asetContainer.TryGet(asetName); + if (asetOutput == null) throw new Exception($"The availability set {asetName} should have existed.");