From e4098acaba83b0a45be8e88c2e962d1f7dffa38e Mon Sep 17 00:00:00 2001 From: Tian Ouyang Date: Tue, 6 Aug 2019 23:39:22 +0000 Subject: [PATCH 1/2] Generated code for 2019-07-01 version of Microsoft.Resources swagger. --- .../AzSdk.RP.props | 2 +- .../AzSdk.RP.props | 2 +- .../AzSdk.RP.props | 2 +- .../AzSdk.RP.props | 2 +- .../src/Generated/DeploymentOperations.cs | 1390 ++++- .../DeploymentOperationsExtensions.cs | 240 + .../src/Generated/DeploymentsOperations.cs | 4979 ++++++++++++++--- .../DeploymentsOperationsExtensions.cs | 1001 +++- .../src/Generated/IDeploymentOperations.cs | 150 + .../src/Generated/IDeploymentsOperations.cs | 594 +- .../src/Generated/IProvidersOperations.cs | 77 + .../Generated/IResourceGroupsOperations.cs | 2 +- .../src/Generated/IResourcesOperations.cs | 4 +- .../Models/DeploymentValidateResult.cs | 10 +- .../Generated/Models/ErrorAdditionalInfo.cs | 59 + .../src/Generated/Models/ErrorResponse.cs | 54 +- .../Models/ResourceGroupExportResult.cs | 8 +- .../src/Generated/ProvidersOperations.cs | 572 +- .../ProvidersOperationsExtensions.cs | 122 + .../src/Generated/ResourceGroupsOperations.cs | 7 +- .../ResourceGroupsOperationsExtensions.cs | 11 +- .../src/Generated/ResourceManagementClient.cs | 2 +- .../src/Generated/ResourcesOperations.cs | 16 +- .../ResourcesOperationsExtensions.cs | 22 +- .../SdkInfo_ResourceManagementClient.cs | 20 +- ...oft.Azure.Management.Resource.Tests.csproj | 3 + .../DeploymentTests.ScenarioTests.cs | 217 + .../ScenarioTests/tenant_level_template.json | 120 + ...DeploymentWithScope_AtManagementGroup.json | 429 ++ .../DeploymentWithScope_AtResourceGroup.json | 441 ++ .../DeploymentWithScope_AtSubscription.json | 549 ++ .../DeploymentWithScope_AtTenant.json | 429 ++ .../TenantLevelDeployment.json | 429 ++ 33 files changed, 11074 insertions(+), 891 deletions(-) create mode 100644 sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorAdditionalInfo.cs create mode 100644 sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/tenant_level_template.json create mode 100644 sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtManagementGroup.json create mode 100644 sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtResourceGroup.json create mode 100644 sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtSubscription.json create mode 100644 sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtTenant.json create mode 100644 sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/TenantLevelDeployment.json diff --git a/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props b/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props index 39645fa6dc05..18663f026f3a 100644 --- a/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props +++ b/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props @@ -1,7 +1,7 @@ - + Attestation_2018-09-01-preview; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props b/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props index eaa19d759acb..e7c4a3c5c92a 100644 --- a/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props +++ b/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props @@ -1,7 +1,7 @@ - Fabric.Admin_2018-10-01;Fabric.Admin_2016-05-01; + Fabric.Admin_2016-05-01; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props b/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props index 3d2b4e3b39d7..ef440086fa07 100644 --- a/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props +++ b/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props @@ -1,7 +1,7 @@  - Compute_2019-03-01;Compute_2018-09-30;Compute_2019-04-01;ContainerService_2017-01-31; + Compute_2019-03-01;Compute_2018-09-30;Compute_2019-07-01;Compute_2019-04-01;ContainerService_2017-01-31; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/AzSdk.RP.props b/sdk/resources/Microsoft.Azure.Management.Resource/AzSdk.RP.props index 31d20d0e6d91..4368520001a4 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/AzSdk.RP.props +++ b/sdk/resources/Microsoft.Azure.Management.Resource/AzSdk.RP.props @@ -1,7 +1,7 @@  - Features_2015-12-01;ManagementLinkClient_2016-09-01;Resources_2016-09-01;Authorization_2016-09-01;Authorization_2018-05-01;Management_2018-05-01;PolicyClient_2018-05-01;Management_2019-05-01;ResourceManagementClient_2019-05-01;Resources_2019-05-01;SubscriptionClient_2016-06-01; + Features_2015-12-01;ManagementLinkClient_2016-09-01;Resources_2016-09-01;Authorization_2016-09-01;Authorization_2018-05-01;Management_2018-05-01;PolicyClient_2018-05-01;Management_2019-07-01;ResourceManagementClient_2019-07-01;Resources_2019-07-01;SubscriptionClient_2016-06-01; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperations.cs index 2efa87c56a09..452cf9680121 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperations.cs @@ -53,8 +53,8 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// Gets a deployments operation. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -83,22 +83,11 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) + if (scope == null) { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (deploymentName == null) { @@ -134,16 +123,16 @@ internal DeploymentOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("operationId", operationId); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); List _queryParameters = new List(); @@ -279,8 +268,8 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// Gets all deployments operations for a deployment. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -309,22 +298,11 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListAtScopeWithHttpMessagesAsync(string scope, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) + if (scope == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) - { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (deploymentName == null) { @@ -356,16 +334,16 @@ internal DeploymentOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("top", top); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); List _queryParameters = new List(); if (top != null) @@ -531,7 +509,7 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -560,10 +538,6 @@ internal DeploymentOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -574,14 +548,13 @@ internal DeploymentOperations(ResourceManagementClient client) tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("operationId", operationId); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -742,7 +715,7 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListAtTenantScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -767,10 +740,6 @@ internal DeploymentOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -781,13 +750,12 @@ internal DeploymentOperations(ResourceManagementClient client) tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("top", top); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (top != null) { @@ -925,8 +893,8 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// Gets a deployments operation. /// - /// - /// The name of the resource group. The name is case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -955,25 +923,21 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (deploymentName == null) @@ -1003,10 +967,6 @@ internal DeploymentOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1014,19 +974,18 @@ internal DeploymentOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("operationId", operationId); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -1160,8 +1119,8 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// Gets all deployments operations for a deployment. /// - /// - /// The name of the resource group. The name is case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -1190,25 +1149,21 @@ internal DeploymentOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (deploymentName == null) @@ -1234,10 +1189,6 @@ internal DeploymentOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1245,18 +1196,17 @@ internal DeploymentOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("top", top); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (top != null) { @@ -1391,6 +1341,1242 @@ internal DeploymentOperations(ResourceManagementClient client) return _result; } + /// + /// Gets a deployments operation. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets a deployments operation. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (operationId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("operationId", operationId); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations/{operationId}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{operationId}", System.Uri.EscapeDataString(operationId)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(string resourceGroupName, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("top", top); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/deployments/{deploymentName}/operations").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListAtScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtScopeNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScopeNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + /// /// Gets all deployments operations for a deployment. /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperationsExtensions.cs index 4063313643e0..d3dc9398f3f9 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperationsExtensions.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentOperationsExtensions.cs @@ -21,6 +21,178 @@ namespace Microsoft.Azure.Management.ResourceManager /// public static partial class DeploymentOperationsExtensions { + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + public static DeploymentOperation GetAtScope(this IDeploymentOperations operations, string scope, string deploymentName, string operationId) + { + return operations.GetAtScopeAsync(scope, deploymentName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtScopeAsync(this IDeploymentOperations operations, string scope, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtScopeWithHttpMessagesAsync(scope, deploymentName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + public static IPage ListAtScope(this IDeploymentOperations operations, string scope, string deploymentName, int? top = default(int?)) + { + return operations.ListAtScopeAsync(scope, deploymentName, top).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeAsync(this IDeploymentOperations operations, string scope, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeWithHttpMessagesAsync(scope, deploymentName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + public static DeploymentOperation GetAtTenantScope(this IDeploymentOperations operations, string deploymentName, string operationId) + { + return operations.GetAtTenantScopeAsync(deploymentName, operationId).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployments operation. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtTenantScopeAsync(this IDeploymentOperations operations, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtTenantScopeWithHttpMessagesAsync(deploymentName, operationId, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + public static IPage ListAtTenantScope(this IDeploymentOperations operations, string deploymentName, int? top = default(int?)) + { + return operations.ListAtTenantScopeAsync(deploymentName, top).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeAsync(this IDeploymentOperations operations, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeWithHttpMessagesAsync(deploymentName, top, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Gets a deployments operation. /// @@ -285,6 +457,74 @@ public static DeploymentOperation Get(this IDeploymentOperations operations, str } } + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtScopeNext(this IDeploymentOperations operations, string nextPageLink) + { + return operations.ListAtScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtTenantScopeNext(this IDeploymentOperations operations, string nextPageLink) + { + return operations.ListAtTenantScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Gets all deployments operations for a deployment. /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperations.cs index a3bb5b962fce..4d1560179cb8 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperations.cs @@ -65,8 +65,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// status of 204 on success. If the asynchronous request failed, the URI in /// the Location header returns an error-level status code. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -77,18 +77,18 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// The cancellation token. /// - public async Task DeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task DeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send request - AzureOperationResponse _response = await BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + AzureOperationResponse _response = await BeginDeleteAtScopeWithHttpMessagesAsync(scope, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } /// /// Checks whether the deployment exists. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -111,22 +111,11 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CheckExistenceAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) + if (scope == null) { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (deploymentName == null) { @@ -158,15 +147,15 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); List _queryParameters = new List(); if (Client.ApiVersion != null) @@ -231,7 +220,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -266,10 +255,9 @@ internal DeploymentsOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; - _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); @@ -282,14 +270,14 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deploys resources at management group scope. + /// Deploys resources at a given scope. /// /// /// You can provide the template and parameters directly in the request or link /// to JSON files. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -303,18 +291,18 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// The cancellation token. /// - public async Task> CreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> CreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + AzureOperationResponse _response = await BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } /// /// Gets a deployment. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -340,22 +328,11 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) + if (scope == null) { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (deploymentName == null) { @@ -387,15 +364,15 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); List _queryParameters = new List(); if (Client.ApiVersion != null) @@ -536,8 +513,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// Canceled. Canceling a template deployment stops the currently running /// template deployment and leaves the resources partially deployed. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -560,22 +537,11 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task CancelAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CancelAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) + if (scope == null) { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (deploymentName == null) { @@ -607,15 +573,15 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CancelAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); List _queryParameters = new List(); if (Client.ApiVersion != null) @@ -733,8 +699,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// Validates whether the specified template is syntactically correct and will /// be accepted by Azure Resource Manager.. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -763,22 +729,11 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ValidateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ValidateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) + if (scope == null) { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (deploymentName == null) { @@ -818,16 +773,16 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ValidateAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ValidateAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); List _queryParameters = new List(); if (Client.ApiVersion != null) @@ -898,7 +853,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) + if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -958,24 +913,6 @@ internal DeploymentsOperations(ResourceManagementClient client) throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - // Deserialize Response - if ((int)_statusCode == 400) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); @@ -986,8 +923,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// Exports the template used for specified deployment. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// The name of the deployment. @@ -1013,22 +950,11 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ExportTemplateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ExportTemplateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) + if (scope == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) - { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (deploymentName == null) { @@ -1060,15 +986,15 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); List _queryParameters = new List(); if (Client.ApiVersion != null) @@ -1201,10 +1127,10 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Get all the deployments for a management group. + /// Get all the deployments at the given scope. /// - /// - /// The management group ID. + /// + /// The scope of a deployment. /// /// /// OData parameters to apply to the operation. @@ -1230,22 +1156,11 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListAtScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) + if (scope == null) { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); } if (Client.ApiVersion == null) { @@ -1259,14 +1174,14 @@ internal DeploymentsOperations(ResourceManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("odataQuery", odataQuery); - tracingParameters.Add("groupId", groupId); + tracingParameters.Add("scope", scope); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListAtScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); List _queryParameters = new List(); if (odataQuery != null) { @@ -1428,10 +1343,10 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// The cancellation token. /// - public async Task DeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task DeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send request - AzureOperationResponse _response = await BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + AzureOperationResponse _response = await BeginDeleteAtTenantScopeWithHttpMessagesAsync(deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } @@ -1459,7 +1374,7 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CheckExistenceAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -1484,10 +1399,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1497,13 +1408,12 @@ internal DeploymentsOperations(ResourceManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -1567,7 +1477,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -1602,10 +1512,9 @@ internal DeploymentsOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; - _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); @@ -1618,7 +1527,7 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deploys resources at subscription scope. + /// Deploys resources at tenant scope. /// /// /// You can provide the template and parameters directly in the request or link @@ -1636,10 +1545,10 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// The cancellation token. /// - public async Task> CreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> CreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + AzureOperationResponse _response = await BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } @@ -1670,7 +1579,7 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -1695,10 +1604,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1708,13 +1613,12 @@ internal DeploymentsOperations(ResourceManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -1875,7 +1779,7 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task CancelAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CancelAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -1900,10 +1804,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -1913,13 +1813,12 @@ internal DeploymentsOperations(ResourceManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CancelAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -2063,7 +1962,7 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ValidateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ValidateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -2096,10 +1995,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -2110,13 +2005,12 @@ internal DeploymentsOperations(ResourceManagementClient client) tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ValidateAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ValidateAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -2186,7 +2080,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) + if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -2246,24 +2140,6 @@ internal DeploymentsOperations(ResourceManagementClient client) throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - // Deserialize Response - if ((int)_statusCode == 400) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); @@ -2298,7 +2174,7 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ExportTemplateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ExportTemplateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -2323,10 +2199,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -2336,13 +2208,12 @@ internal DeploymentsOperations(ResourceManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -2474,7 +2345,7 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Get all the deployments for a subscription. + /// Get all the deployments at the tenant scope. /// /// /// OData parameters to apply to the operation. @@ -2500,16 +2371,12 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListAtSubscriptionScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListAtTenantScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -2519,12 +2386,11 @@ internal DeploymentsOperations(ResourceManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("odataQuery", odataQuery); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/").ToString(); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/").ToString(); List _queryParameters = new List(); if (odataQuery != null) { @@ -2668,19 +2534,17 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// /// A template deployment that is currently running cannot be deleted. Deleting - /// a template deployment removes the associated deployment operations. - /// Deleting a template deployment does not affect the state of the resource - /// group. This is an asynchronous operation that returns a status of 202 until - /// the template deployment is successfully deleted. The Location response - /// header contains the URI that is used to obtain the status of the process. - /// While the process is running, a call to the URI in the Location header - /// returns a status of 202. When the process finishes, the URI in the Location - /// header returns a status of 204 on success. If the asynchronous request - /// failed, the URI in the Location header returns an error-level status code. + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. /// - /// - /// The name of the resource group with the deployment to delete. The name is - /// case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -2691,19 +2555,18 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// The cancellation token. /// - public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task DeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send request - AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + AzureOperationResponse _response = await BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } /// /// Checks whether the deployment exists. /// - /// - /// The name of the resource group with the deployment to check. The name is - /// case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -2726,25 +2589,21 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (deploymentName == null) @@ -2770,10 +2629,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -2781,17 +2636,16 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "CheckExistence", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -2855,7 +2709,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -2890,10 +2744,9 @@ internal DeploymentsOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; - _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); @@ -2906,15 +2759,14 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deploys resources to a resource group. + /// Deploys resources at management group scope. /// /// /// You can provide the template and parameters directly in the request or link /// to JSON files. /// - /// - /// The name of the resource group to deploy the resources to. The name is case - /// insensitive. The resource group must already exist. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -2928,18 +2780,18 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// The cancellation token. /// - public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> CreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { // Send Request - AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + AzureOperationResponse _response = await BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); } /// /// Gets a deployment. /// - /// - /// The name of the resource group. The name is case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -2965,25 +2817,21 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (deploymentName == null) @@ -3009,10 +2857,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -3020,17 +2864,16 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -3168,10 +3011,10 @@ internal DeploymentsOperations(ResourceManagementClient client) /// You can cancel a deployment only if the provisioningState is Accepted or /// Running. After the deployment is canceled, the provisioningState is set to /// Canceled. Canceling a template deployment stops the currently running - /// template deployment and leaves the resource group partially deployed. + /// template deployment and leaves the resources partially deployed. /// - /// - /// The name of the resource group. The name is case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -3194,25 +3037,21 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task CancelWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CancelAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (deploymentName == null) @@ -3238,10 +3077,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -3249,17 +3084,16 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Cancel", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -3376,9 +3210,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// Validates whether the specified template is syntactically correct and will /// be accepted by Azure Resource Manager.. /// - /// - /// The name of the resource group the template will be deployed to. The name - /// is case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -3407,25 +3240,21 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ValidateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ValidateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (deploymentName == null) @@ -3459,10 +3288,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -3470,18 +3295,17 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "Validate", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ValidateAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -3551,7 +3375,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 400) + if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -3611,24 +3435,6 @@ internal DeploymentsOperations(ResourceManagementClient client) throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - // Deserialize Response - if ((int)_statusCode == 400) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); @@ -3639,8 +3445,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// Exports the template used for specified deployment. /// - /// - /// The name of the resource group. The name is case insensitive. + /// + /// The management group ID. /// /// /// The name of the deployment. @@ -3666,25 +3472,21 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> ExportTemplateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ExportTemplateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (deploymentName == null) @@ -3710,10 +3512,6 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -3721,17 +3519,16 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ExportTemplate", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -3863,11 +3660,10 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Get all the deployments for a resource group. + /// Get all the deployments for a management group. /// - /// - /// The name of the resource group with the deployments to get. The name is - /// case insensitive. + /// + /// The management group ID. /// /// /// OData parameters to apply to the operation. @@ -3893,35 +3689,27 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListAtManagementGroupScopeWithHttpMessagesAsync(string groupId, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) + if (groupId == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); } - if (resourceGroupName != null) + if (groupId != null) { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) + if (groupId.Length > 90) { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + if (groupId.Length < 1) { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); } } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } - if (Client.SubscriptionId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); - } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -3930,15 +3718,14 @@ internal DeploymentsOperations(ResourceManagementClient client) _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("odataQuery", odataQuery); - tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("groupId", groupId); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListAtManagementGroupScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); List _queryParameters = new List(); if (odataQuery != null) { @@ -4091,19 +3878,35 @@ internal DeploymentsOperations(ResourceManagementClient client) /// status of 204 on success. If the asynchronous request failed, the URI in /// the Location header returns an error-level status code. /// - /// - /// The management group ID. - /// /// /// The name of the deployment. /// /// - /// Headers that will be added to request. + /// The headers that will be added to request. /// /// /// The cancellation token. /// - /// + public async Task DeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// /// Thrown when the operation returned an invalid status code /// /// @@ -4115,23 +3918,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) - { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } - } if (deploymentName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); @@ -4155,6 +3943,10 @@ internal DeploymentsOperations(ResourceManagementClient client) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -4162,16 +3954,15 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistenceAtSubscriptionScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -4184,7 +3975,7 @@ internal DeploymentsOperations(ResourceManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.Method = new HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -4227,7 +4018,7 @@ internal DeploymentsOperations(ResourceManagementClient client) ServiceClientTracing.SendRequest(_invocationId, _httpRequest); } cancellationToken.ThrowIfCancellationRequested(); - _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); if (_shouldTrace) { ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); @@ -4235,7 +4026,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -4285,15 +4076,12 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deploys resources at management group scope. + /// Deploys resources at subscription scope. /// /// /// You can provide the template and parameters directly in the request or link /// to JSON files. /// - /// - /// The management group ID. - /// /// /// The name of the deployment. /// @@ -4301,6 +4089,25 @@ internal DeploymentsOperations(ResourceManagementClient client) /// Additional parameters supplied to the operation. /// /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// The name of the deployment. + /// + /// /// Headers that will be added to request. /// /// @@ -4321,23 +4128,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (groupId == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); - } - if (groupId != null) - { - if (groupId.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); - } - if (groupId.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "groupId", 1); - } - } if (deploymentName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); @@ -4357,18 +4149,14 @@ internal DeploymentsOperations(ResourceManagementClient client) throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); } } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; string _invocationId = null; @@ -4376,17 +4164,15 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("groupId", groupId); tracingParameters.Add("deploymentName", deploymentName); - tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtManagementGroupScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtSubscriptionScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); if (Client.ApiVersion != null) { @@ -4399,7 +4185,7 @@ internal DeploymentsOperations(ResourceManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -4430,12 +4216,6 @@ internal DeploymentsOperations(ResourceManagementClient client) // Serialize Request string _requestContent = null; - if(parameters != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } // Set Credentials if (Client.Credentials != null) { @@ -4456,7 +4236,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) + if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -4516,24 +4296,6 @@ internal DeploymentsOperations(ResourceManagementClient client) throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); @@ -4542,18 +4304,13 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deletes a deployment from the deployment history. + /// Cancels a currently running template deployment. /// /// - /// A template deployment that is currently running cannot be deleted. Deleting - /// a template deployment removes the associated deployment operations. This is - /// an asynchronous operation that returns a status of 202 until the template - /// deployment is successfully deleted. The Location response header contains - /// the URI that is used to obtain the status of the process. While the process - /// is running, a call to the URI in the Location header returns a status of - /// 202. When the process finishes, the URI in the Location header returns a - /// status of 204 on success. If the asynchronous request failed, the URI in - /// the Location header returns an error-level status code. + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. /// /// /// The name of the deployment. @@ -4576,7 +4333,7 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CancelAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -4614,11 +4371,11 @@ internal DeploymentsOperations(ResourceManagementClient client) Dictionary tracingParameters = new Dictionary(); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "CancelAtSubscriptionScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); @@ -4633,7 +4390,7 @@ internal DeploymentsOperations(ResourceManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -4684,7 +4441,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -4734,17 +4491,14 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deploys resources at subscription scope. + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. /// - /// - /// You can provide the template and parameters directly in the request or link - /// to JSON files. - /// /// /// The name of the deployment. /// /// - /// Additional parameters supplied to the operation. + /// Parameters to validate. /// /// /// Headers that will be added to request. @@ -4767,7 +4521,7 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ValidateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (deploymentName == null) { @@ -4814,11 +4568,11 @@ internal DeploymentsOperations(ResourceManagementClient client) tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("parameters", parameters); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtSubscriptionScope", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ValidateAtSubscriptionScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); @@ -4833,7 +4587,7 @@ internal DeploymentsOperations(ResourceManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -4890,7 +4644,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) + if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -4925,7 +4679,7 @@ internal DeploymentsOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -4938,25 +4692,7 @@ internal DeploymentsOperations(ResourceManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); - } - catch (JsonException ex) - { - _httpRequest.Dispose(); - if (_httpResponse != null) - { - _httpResponse.Dispose(); - } - throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); - } - } - // Deserialize Response - if ((int)_statusCode == 201) - { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try - { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -4976,24 +4712,8 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deletes a deployment from the deployment history. + /// Exports the template used for specified deployment. /// - /// - /// A template deployment that is currently running cannot be deleted. Deleting - /// a template deployment removes the associated deployment operations. - /// Deleting a template deployment does not affect the state of the resource - /// group. This is an asynchronous operation that returns a status of 202 until - /// the template deployment is successfully deleted. The Location response - /// header contains the URI that is used to obtain the status of the process. - /// While the process is running, a call to the URI in the Location header - /// returns a status of 202. When the process finishes, the URI in the Location - /// header returns a status of 204 on success. If the asynchronous request - /// failed, the URI in the Location header returns an error-level status code. - /// - /// - /// The name of the resource group with the deployment to delete. The name is - /// case insensitive. - /// /// /// The name of the deployment. /// @@ -5006,6 +4726,9 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// Thrown when the operation returned an invalid status code /// + /// + /// Thrown when unable to deserialize the response + /// /// /// Thrown when a required parameter is null /// @@ -5015,27 +4738,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> ExportTemplateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (resourceGroupName != null) - { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); - } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); - } - } if (deploymentName == null) { throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); @@ -5070,15 +4774,13 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("deploymentName", deploymentName); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplateAtSubscriptionScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); @@ -5093,7 +4795,7 @@ internal DeploymentsOperations(ResourceManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.Method = new HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -5144,7 +4846,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204) + if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -5179,13 +4881,31 @@ internal DeploymentsOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } if (_shouldTrace) { ServiceClientTracing.Exit(_invocationId, _result); @@ -5194,21 +4914,10 @@ internal DeploymentsOperations(ResourceManagementClient client) } /// - /// Deploys resources to a resource group. + /// Get all the deployments for a subscription. /// - /// - /// You can provide the template and parameters directly in the request or link - /// to JSON files. - /// - /// - /// The name of the resource group to deploy the resources to. The name is case - /// insensitive. The resource group must already exist. - /// - /// - /// The name of the deployment. - /// - /// - /// Additional parameters supplied to the operation. + /// + /// OData parameters to apply to the operation. /// /// /// Headers that will be added to request. @@ -5231,54 +4940,8 @@ internal DeploymentsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task>> ListAtSubscriptionScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (resourceGroupName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); - } - if (resourceGroupName != null) - { - if (resourceGroupName.Length > 90) - { - throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); - } - if (resourceGroupName.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); - } - if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); - } - } - if (deploymentName == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); - } - if (deploymentName != null) - { - if (deploymentName.Length > 64) - { - throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); - } - if (deploymentName.Length < 1) - { - throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); - } - if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) - { - throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); - } - } - if (parameters == null) - { - throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); - } - if (parameters != null) - { - parameters.Validate(); - } if (Client.ApiVersion == null) { throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); @@ -5294,19 +4957,23 @@ internal DeploymentsOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("resourceGroupName", resourceGroupName); - tracingParameters.Add("deploymentName", deploymentName); - tracingParameters.Add("parameters", parameters); + tracingParameters.Add("odataQuery", odataQuery); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "ListAtSubscriptionScope", tracingParameters); } // Construct URL var _baseUrl = Client.BaseUri.AbsoluteUri; - var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); - _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); - _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/").ToString(); _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } if (Client.ApiVersion != null) { _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); @@ -5318,7 +4985,7 @@ internal DeploymentsOperations(ResourceManagementClient client) // Create HTTP transport objects var _httpRequest = new HttpRequestMessage(); HttpResponseMessage _httpResponse = null; - _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.Method = new HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) @@ -5349,12 +5016,6 @@ internal DeploymentsOperations(ResourceManagementClient client) // Serialize Request string _requestContent = null; - if(parameters != null) - { - _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); - _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); - _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); - } // Set Credentials if (Client.Credentials != null) { @@ -5375,7 +5036,7 @@ internal DeploymentsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 200 && (int)_statusCode != 201) + if ((int)_statusCode != 200) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -5410,7 +5071,7 @@ internal DeploymentsOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse>(); _result.Request = _httpRequest; _result.Response = _httpResponse; if (_httpResponse.Headers.Contains("x-ms-request-id")) @@ -5423,7 +5084,7 @@ internal DeploymentsOperations(ResourceManagementClient client) _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { @@ -5435,13 +5096,3985 @@ internal DeploymentsOperations(ResourceManagementClient client) throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); } } - // Deserialize Response - if ((int)_statusCode == 201) + if (_shouldTrace) { - _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); - try + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, deploymentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the resource group with the deployment to check. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) { - _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CheckExistence", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("HEAD"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Gets a deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resource group partially deployed. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task CancelWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Cancel", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/cancel").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The name of the resource group the template will be deployed to. The name + /// is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ValidateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Validate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/validate").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ExportTemplateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ExportTemplate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}/exportTemplate").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("POST"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all the deployments for a resource group. + /// + /// + /// The name of the resource group with the deployments to get. The name is + /// case insensitive. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (scope == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "scope"); + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("scope", scope); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "{scope}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{scope}", System.Uri.EscapeDataString(scope)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deploys resources at management group scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The management group ID. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (groupId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "groupId"); + } + if (groupId != null) + { + if (groupId.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "groupId", 90); + } + if (groupId.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "groupId", 1); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("groupId", groupId); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtManagementGroupScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDeleteAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deploys resources at subscription scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdateAtSubscriptionScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. + /// Deleting a template deployment does not affect the state of the resource + /// group. This is an asynchronous operation that returns a status of 202 until + /// the template deployment is successfully deleted. The Location response + /// header contains the URI that is used to obtain the status of the process. + /// While the process is running, a call to the URI in the Location header + /// returns a status of 202. When the process finishes, the URI in the Location + /// header returns a status of 204 on success. If the asynchronous request + /// failed, the URI in the Location header returns an error-level status code. + /// + /// + /// The name of the resource group with the deployment to delete. The name is + /// case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 202 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Deploys resources to a resource group. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The name of the resource group to deploy the resources to. The name is case + /// insensitive. The resource group must already exist. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceGroupName != null) + { + if (resourceGroupName.Length > 90) + { + throw new ValidationException(ValidationRules.MaxLength, "resourceGroupName", 90); + } + if (resourceGroupName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "resourceGroupName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "resourceGroupName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (deploymentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "deploymentName"); + } + if (deploymentName != null) + { + if (deploymentName.Length > 64) + { + throw new ValidationException(ValidationRules.MaxLength, "deploymentName", 64); + } + if (deploymentName.Length < 1) + { + throw new ValidationException(ValidationRules.MinLength, "deploymentName", 1); + } + if (!System.Text.RegularExpressions.Regex.IsMatch(deploymentName, "^[-\\w\\._\\(\\)]+$")) + { + throw new ValidationException(ValidationRules.Pattern, "deploymentName", "^[-\\w\\._\\(\\)]+$"); + } + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + if (parameters != null) + { + parameters.Validate(); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deployments/{deploymentName}").ToString(); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{deploymentName}", System.Uri.EscapeDataString(deploymentName)); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(parameters != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(parameters, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListAtScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtScopeNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScopeNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } catch (JsonException ex) { diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperationsExtensions.cs index 3c9b17d84fd9..05b63fe1c938 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperationsExtensions.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/DeploymentsOperationsExtensions.cs @@ -22,6 +22,692 @@ namespace Microsoft.Azure.Management.ResourceManager /// public static partial class DeploymentsOperationsExtensions { + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + public static void DeleteAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + operations.DeleteAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + public static void CheckExistenceAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + operations.CheckExistenceAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CheckExistenceAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended CreateOrUpdateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters) + { + return operations.CreateOrUpdateAtScopeAsync(scope, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExtended GetAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + return operations.GetAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + public static void CancelAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + operations.CancelAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CancelAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult ValidateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters) + { + return operations.ValidateAtScopeAsync(scope, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExportResult ExportTemplateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + return operations.ExportTemplateAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtScope(this IDeploymentsOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtScopeAsync(scope, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeAsync(this IDeploymentsOperations operations, string scope, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeWithHttpMessagesAsync(scope, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void DeleteAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.DeleteAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void CheckExistenceAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.CheckExistenceAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Checks whether the deployment exists. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CheckExistenceAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CheckExistenceAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended CreateOrUpdateAtTenantScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters) + { + return operations.CreateOrUpdateAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExtended GetAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.GetAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Gets a deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void CancelAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.CancelAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is Accepted or + /// Running. After the deployment is canceled, the provisioningState is set to + /// Canceled. Canceling a template deployment stops the currently running + /// template deployment and leaves the resources partially deployed. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task CancelAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CancelAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + public static DeploymentValidateResult ValidateAtTenantScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters) + { + return operations.ValidateAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Validates whether the specified template is syntactically correct and will + /// be accepted by Azure Resource Manager.. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The cancellation token. + /// + public static async Task ValidateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ValidateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static DeploymentExportResult ExportTemplateAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + return operations.ExportTemplateAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Exports the template used for specified deployment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task ExportTemplateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ExportTemplateAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListAtTenantScope(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAtTenantScopeAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeAsync(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Deletes a deployment from the deployment history. /// @@ -93,9 +779,9 @@ public static void DeleteAtManagementGroupScope(this IDeploymentsOperations oper /// /// The name of the deployment. /// - public static bool CheckExistenceAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) + public static void CheckExistenceAtManagementGroupScope(this IDeploymentsOperations operations, string groupId, string deploymentName) { - return operations.CheckExistenceAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); + operations.CheckExistenceAtManagementGroupScopeAsync(groupId, deploymentName).GetAwaiter().GetResult(); } /// @@ -113,12 +799,9 @@ public static bool CheckExistenceAtManagementGroupScope(this IDeploymentsOperati /// /// The cancellation token. /// - public static async Task CheckExistenceAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task CheckExistenceAtManagementGroupScopeAsync(this IDeploymentsOperations operations, string groupId, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } + (await operations.CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(groupId, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// @@ -454,9 +1137,9 @@ public static void DeleteAtSubscriptionScope(this IDeploymentsOperations operati /// /// The name of the deployment. /// - public static bool CheckExistenceAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) + public static void CheckExistenceAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName) { - return operations.CheckExistenceAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); + operations.CheckExistenceAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult(); } /// @@ -471,12 +1154,9 @@ public static bool CheckExistenceAtSubscriptionScope(this IDeploymentsOperations /// /// The cancellation token. /// - public static async Task CheckExistenceAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task CheckExistenceAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } + (await operations.CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// @@ -790,9 +1470,9 @@ public static void Delete(this IDeploymentsOperations operations, string resourc /// /// The name of the deployment. /// - public static bool CheckExistence(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) + public static void CheckExistence(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName) { - return operations.CheckExistenceAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); + operations.CheckExistenceAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult(); } /// @@ -811,12 +1491,9 @@ public static bool CheckExistence(this IDeploymentsOperations operations, string /// /// The cancellation token. /// - public static async Task CheckExistenceAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task CheckExistenceAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } + (await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// @@ -1096,6 +1773,220 @@ public static DeploymentExportResult ExportTemplate(this IDeploymentsOperations } } + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + public static void BeginDeleteAtScope(this IDeploymentsOperations operations, string scope, string deploymentName) + { + operations.BeginDeleteAtScopeAsync(scope, deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteAtScopeWithHttpMessagesAsync(scope, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended BeginCreateOrUpdateAtScope(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters) + { + return operations.BeginCreateOrUpdateAtScopeAsync(scope, deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtScopeAsync(this IDeploymentsOperations operations, string scope, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(scope, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + public static void BeginDeleteAtTenantScope(this IDeploymentsOperations operations, string deploymentName) + { + operations.BeginDeleteAtTenantScopeAsync(deploymentName).GetAwaiter().GetResult(); + } + + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. Deleting + /// a template deployment removes the associated deployment operations. This is + /// an asynchronous operation that returns a status of 202 until the template + /// deployment is successfully deleted. The Location response header contains + /// the URI that is used to obtain the status of the process. While the process + /// is running, a call to the URI in the Location header returns a status of + /// 202. When the process finishes, the URI in the Location header returns a + /// status of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteAtTenantScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + public static DeploymentExtended BeginCreateOrUpdateAtTenantScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters) + { + return operations.BeginCreateOrUpdateAtTenantScopeAsync(deploymentName, parameters).GetAwaiter().GetResult(); + } + + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request or link + /// to JSON files. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAtTenantScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Deletes a deployment from the deployment history. /// @@ -1429,6 +2320,74 @@ public static DeploymentExtended BeginCreateOrUpdate(this IDeploymentsOperations } } + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtScopeNext(this IDeploymentsOperations operations, string nextPageLink) + { + return operations.ListAtScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the given scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtScopeNextAsync(this IDeploymentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtTenantScopeNext(this IDeploymentsOperations operations, string nextPageLink) + { + return operations.ListAtTenantScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeNextAsync(this IDeploymentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Get all the deployments for a management group. /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentOperations.cs index 4d99b073dd53..1ef109d1ed63 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentOperations.cs @@ -23,6 +23,112 @@ namespace Microsoft.Azure.Management.ResourceManager /// public partial interface IDeploymentOperations { + /// + /// Gets a deployments operation. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtScopeWithHttpMessagesAsync(string scope, string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployments operation. + /// + /// + /// The name of the deployment. + /// + /// + /// The ID of the operation to get. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, string operationId, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The number of results to return. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtTenantScopeWithHttpMessagesAsync(string deploymentName, int? top = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Gets a deployments operation. /// @@ -206,6 +312,50 @@ public partial interface IDeploymentOperations /// /// Thrown when a required parameter is null /// + Task>> ListAtScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all deployments operations for a deployment. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// Task>> ListAtManagementGroupScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Gets all deployments operations for a deployment. diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentsOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentsOperations.cs index a833a4c63447..9903fa4f75bc 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentsOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IDeploymentsOperations.cs @@ -24,6 +24,424 @@ namespace Microsoft.Azure.Management.ResourceManager /// public partial interface IDeploymentsOperations { + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether the deployment exists. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task CheckExistenceAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is + /// Accepted or Running. After the deployment is canceled, the + /// provisioningState is set to Canceled. Canceling a template + /// deployment stops the currently running template deployment and + /// leaves the resources partially deployed. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task CancelAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ValidateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Exports the template used for specified deployment. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ExportTemplateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments at the given scope. + /// + /// + /// The scope of a deployment. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtScopeWithHttpMessagesAsync(string scope, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Checks whether the deployment exists. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task CheckExistenceAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Cancels a currently running template deployment. + /// + /// + /// You can cancel a deployment only if the provisioningState is + /// Accepted or Running. After the deployment is canceled, the + /// provisioningState is set to Canceled. Canceling a template + /// deployment stops the currently running template deployment and + /// leaves the resources partially deployed. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task CancelAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Validates whether the specified template is syntactically correct + /// and will be accepted by Azure Resource Manager.. + /// + /// + /// The name of the deployment. + /// + /// + /// Parameters to validate. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ValidateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Exports the template used for specified deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ExportTemplateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtTenantScopeWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Deletes a deployment from the deployment history. /// @@ -79,7 +497,7 @@ public partial interface IDeploymentsOperations /// /// Thrown when a required parameter is null /// - Task> CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task CheckExistenceAtManagementGroupScopeWithHttpMessagesAsync(string groupId, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Deploys resources at management group scope. /// @@ -294,7 +712,7 @@ public partial interface IDeploymentsOperations /// /// Thrown when a required parameter is null /// - Task> CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Deploys resources at subscription scope. /// @@ -501,7 +919,7 @@ public partial interface IDeploymentsOperations /// /// Thrown when a required parameter is null /// - Task> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Deploys resources to a resource group. /// @@ -685,6 +1103,132 @@ public partial interface IDeploymentsOperations /// of 204 on success. If the asynchronous request failed, the URI in /// the Location header returns an error-level status code. /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at a given scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The scope of a deployment. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateAtScopeWithHttpMessagesAsync(string scope, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// + /// + /// The name of the deployment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteAtTenantScopeWithHttpMessagesAsync(string deploymentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deploys resources at tenant scope. + /// + /// + /// You can provide the template and parameters directly in the request + /// or link to JSON files. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> BeginCreateOrUpdateAtTenantScopeWithHttpMessagesAsync(string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Deletes a deployment from the deployment history. + /// + /// + /// A template deployment that is currently running cannot be deleted. + /// Deleting a template deployment removes the associated deployment + /// operations. This is an asynchronous operation that returns a status + /// of 202 until the template deployment is successfully deleted. The + /// Location response header contains the URI that is used to obtain + /// the status of the process. While the process is running, a call to + /// the URI in the Location header returns a status of 202. When the + /// process finishes, the URI in the Location header returns a status + /// of 204 on success. If the asynchronous request failed, the URI in + /// the Location header returns an error-level status code. + /// /// /// The management group ID. /// @@ -867,6 +1411,50 @@ public partial interface IDeploymentsOperations /// Task> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string deploymentName, Deployment parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Get all the deployments at the given scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get all the deployments at the tenant scope. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Get all the deployments for a management group. /// /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IProvidersOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IProvidersOperations.cs index f6e2c667380b..07b8a896ce04 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IProvidersOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IProvidersOperations.cs @@ -97,6 +97,35 @@ public partial interface IProvidersOperations /// Task>> ListWithHttpMessagesAsync(int? top = default(int?), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Gets all resource providers for the tenant. + /// + /// + /// The number of results to return. If null is passed returns all + /// providers. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource + /// provider metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtTenantScopeWithHttpMessagesAsync(int? top = default(int?), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Gets the specified resource provider. /// /// @@ -123,6 +152,32 @@ public partial interface IProvidersOperations /// Task> GetWithHttpMessagesAsync(string resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// + /// Gets the specified resource provider at the tenant level. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property + /// aliases in response, use $expand=resourceTypes/aliases. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetAtTenantScopeWithHttpMessagesAsync(string resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// /// Gets all resource providers for a subscription. /// /// @@ -144,5 +199,27 @@ public partial interface IProvidersOperations /// Thrown when a required parameter is null /// Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourceGroupsOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourceGroupsOperations.cs index 3f10639f516e..f8f0d95f245a 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourceGroupsOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourceGroupsOperations.cs @@ -43,7 +43,7 @@ public partial interface IResourceGroupsOperations /// /// Thrown when a required parameter is null /// - Task> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task CheckExistenceWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Creates or updates a resource group. /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourcesOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourcesOperations.cs index 382e3a1c5953..d0136a5c2660 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourcesOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/IResourcesOperations.cs @@ -168,7 +168,7 @@ public partial interface IResourcesOperations /// /// Thrown when a required parameter is null /// - Task> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Deletes a resource. /// @@ -347,7 +347,7 @@ public partial interface IResourcesOperations /// /// Thrown when a required parameter is null /// - Task> CheckExistenceByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + Task CheckExistenceByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); /// /// Deletes a resource by ID. /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/DeploymentValidateResult.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/DeploymentValidateResult.cs index 8105bb8697de..a54cd677fd12 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/DeploymentValidateResult.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/DeploymentValidateResult.cs @@ -29,12 +29,10 @@ public DeploymentValidateResult() /// /// Initializes a new instance of the DeploymentValidateResult class. /// - /// Validation error. /// The template deployment /// properties. - public DeploymentValidateResult(ResourceManagementErrorWithDetails error = default(ResourceManagementErrorWithDetails), DeploymentPropertiesExtended properties = default(DeploymentPropertiesExtended)) + public DeploymentValidateResult(DeploymentPropertiesExtended properties = default(DeploymentPropertiesExtended)) { - Error = error; Properties = properties; CustomInit(); } @@ -44,12 +42,6 @@ public DeploymentValidateResult() /// partial void CustomInit(); - /// - /// Gets or sets validation error. - /// - [JsonProperty(PropertyName = "error")] - public ResourceManagementErrorWithDetails Error { get; set; } - /// /// Gets or sets the template deployment properties. /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorAdditionalInfo.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorAdditionalInfo.cs new file mode 100644 index 000000000000..87c3a1a6fd3b --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorAdditionalInfo.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.ResourceManager.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource management error additional info. + /// + public partial class ErrorAdditionalInfo + { + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + public ErrorAdditionalInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ErrorAdditionalInfo class. + /// + /// The additional info type. + /// The additional info. + public ErrorAdditionalInfo(string type = default(string), object info = default(object)) + { + Type = type; + Info = info; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the additional info type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets the additional info. + /// + [JsonProperty(PropertyName = "info")] + public object Info { get; private set; } + + } +} diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorResponse.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorResponse.cs index 62013d09a06d..7c33b473287e 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorResponse.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ErrorResponse.cs @@ -11,11 +11,12 @@ namespace Microsoft.Azure.Management.ResourceManager.Models { using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; using System.Linq; /// - /// Error reponse indicates Azure Resource Manager is not able to process - /// the incoming request. The reason is provided in the error message. + /// The resource management error response. /// public partial class ErrorResponse { @@ -30,15 +31,18 @@ public ErrorResponse() /// /// Initializes a new instance of the ErrorResponse class. /// - /// Http status code. - /// Error code. - /// Error message indicating why the - /// operation failed. - public ErrorResponse(string httpStatus = default(string), string errorCode = default(string), string errorMessage = default(string)) + /// The error code. + /// The error message. + /// The error target. + /// The error details. + /// The error additional info. + public ErrorResponse(string code = default(string), string message = default(string), string target = default(string), IList details = default(IList), IList additionalInfo = default(IList)) { - HttpStatus = httpStatus; - ErrorCode = errorCode; - ErrorMessage = errorMessage; + Code = code; + Message = message; + Target = target; + Details = details; + AdditionalInfo = additionalInfo; CustomInit(); } @@ -48,22 +52,34 @@ public ErrorResponse() partial void CustomInit(); /// - /// Gets or sets http status code. + /// Gets the error code. /// - [JsonProperty(PropertyName = "httpStatus")] - public string HttpStatus { get; set; } + [JsonProperty(PropertyName = "code")] + public string Code { get; private set; } /// - /// Gets or sets error code. + /// Gets the error message. /// - [JsonProperty(PropertyName = "errorCode")] - public string ErrorCode { get; set; } + [JsonProperty(PropertyName = "message")] + public string Message { get; private set; } /// - /// Gets or sets error message indicating why the operation failed. + /// Gets the error target. /// - [JsonProperty(PropertyName = "errorMessage")] - public string ErrorMessage { get; set; } + [JsonProperty(PropertyName = "target")] + public string Target { get; private set; } + + /// + /// Gets the error details. + /// + [JsonProperty(PropertyName = "details")] + public IList Details { get; private set; } + + /// + /// Gets the error additional info. + /// + [JsonProperty(PropertyName = "additionalInfo")] + public IList AdditionalInfo { get; private set; } } } diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ResourceGroupExportResult.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ResourceGroupExportResult.cs index 86c8207f9988..482acb38db85 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ResourceGroupExportResult.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/Models/ResourceGroupExportResult.cs @@ -30,8 +30,8 @@ public ResourceGroupExportResult() /// Initializes a new instance of the ResourceGroupExportResult class. /// /// The template content. - /// The error. - public ResourceGroupExportResult(object template = default(object), ResourceManagementErrorWithDetails error = default(ResourceManagementErrorWithDetails)) + /// The template export error. + public ResourceGroupExportResult(object template = default(object), ErrorResponse error = default(ErrorResponse)) { Template = template; Error = error; @@ -50,10 +50,10 @@ public ResourceGroupExportResult() public object Template { get; set; } /// - /// Gets or sets the error. + /// Gets or sets the template export error. /// [JsonProperty(PropertyName = "error")] - public ResourceManagementErrorWithDetails Error { get; set; } + public ErrorResponse Error { get; set; } } } diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperations.cs index 757773397d80..e303b6a18381 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperations.cs @@ -621,6 +621,198 @@ internal ProvidersOperations(ResourceManagementClient client) return _result; } + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The number of results to return. If null is passed returns all providers. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListAtTenantScopeWithHttpMessagesAsync(int? top = default(int?), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("top", top); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers").ToString(); + List _queryParameters = new List(); + if (top != null) + { + _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"')))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + /// /// Gets the specified resource provider. /// @@ -818,10 +1010,14 @@ internal ProvidersOperations(ResourceManagementClient client) } /// - /// Gets all resource providers for a subscription. + /// Gets the specified resource provider at the tenant level. /// - /// - /// The NextLink from the previous successful call to List operation. + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. /// /// /// Headers that will be added to request. @@ -844,11 +1040,15 @@ internal ProvidersOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task> GetAtTenantScopeWithHttpMessagesAsync(string resourceProviderNamespace, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { - if (nextPageLink == null) + if (resourceProviderNamespace == null) { - throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + throw new ValidationException(ValidationRules.CannotBeNull, "resourceProviderNamespace"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); } // Tracing bool _shouldTrace = ServiceClientTracing.IsEnabled; @@ -857,9 +1057,365 @@ internal ProvidersOperations(ResourceManagementClient client) { _invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary tracingParameters = new Dictionary(); - tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("expand", expand); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); tracingParameters.Add("cancellationToken", cancellationToken); - ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + ServiceClientTracing.Enter(_invocationId, this, "GetAtTenantScope", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/{resourceProviderNamespace}").ToString(); + _url = _url.Replace("{resourceProviderNamespace}", System.Uri.EscapeDataString(resourceProviderNamespace)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all resource providers for a subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListAtTenantScopeNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListAtTenantScopeNext", tracingParameters); } // Construct URL string _url = "{nextLink}"; diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperationsExtensions.cs index 817cdd9fe274..d399635951d7 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperationsExtensions.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ProvidersOperationsExtensions.cs @@ -135,6 +135,52 @@ public static Provider Register(this IProvidersOperations operations, string res } } + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The number of results to return. If null is passed returns all providers. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + public static IPage ListAtTenantScope(this IProvidersOperations operations, int? top = default(int?), string expand = default(string)) + { + return operations.ListAtTenantScopeAsync(top, expand).GetAwaiter().GetResult(); + } + + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The number of results to return. If null is passed returns all providers. + /// + /// + /// The properties to include in the results. For example, use + /// &$expand=metadata in the query string to retrieve resource provider + /// metadata. To include property aliases in response, use + /// $expand=resourceTypes/aliases. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeAsync(this IProvidersOperations operations, int? top = default(int?), string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeWithHttpMessagesAsync(top, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Gets the specified resource provider. /// @@ -177,6 +223,48 @@ public static Provider Register(this IProvidersOperations operations, string res } } + /// + /// Gets the specified resource provider at the tenant level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + public static Provider GetAtTenantScope(this IProvidersOperations operations, string resourceProviderNamespace, string expand = default(string)) + { + return operations.GetAtTenantScopeAsync(resourceProviderNamespace, expand).GetAwaiter().GetResult(); + } + + /// + /// Gets the specified resource provider at the tenant level. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// The $expand query parameter. For example, to include property aliases in + /// response, use $expand=resourceTypes/aliases. + /// + /// + /// The cancellation token. + /// + public static async Task GetAtTenantScopeAsync(this IProvidersOperations operations, string resourceProviderNamespace, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetAtTenantScopeWithHttpMessagesAsync(resourceProviderNamespace, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + /// /// Gets all resource providers for a subscription. /// @@ -211,5 +299,39 @@ public static IPage ListNext(this IProvidersOperations operations, str } } + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListAtTenantScopeNext(this IProvidersOperations operations, string nextPageLink) + { + return operations.ListAtTenantScopeNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Gets all resource providers for the tenant. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAtTenantScopeNextAsync(this IProvidersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListAtTenantScopeNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + } } diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperations.cs index c17c550a3e77..d579381247d4 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperations.cs @@ -75,7 +75,7 @@ internal ResourceGroupsOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CheckExistenceWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceGroupName == null) { @@ -183,7 +183,7 @@ internal ResourceGroupsOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -218,10 +218,9 @@ internal ResourceGroupsOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; - _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperationsExtensions.cs index 75d30fd419cf..ea0b51a3cd70 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperationsExtensions.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceGroupsOperationsExtensions.cs @@ -31,9 +31,9 @@ public static partial class ResourceGroupsOperationsExtensions /// /// The name of the resource group to check. The name is case insensitive. /// - public static bool CheckExistence(this IResourceGroupsOperations operations, string resourceGroupName) + public static void CheckExistence(this IResourceGroupsOperations operations, string resourceGroupName) { - return operations.CheckExistenceAsync(resourceGroupName).GetAwaiter().GetResult(); + operations.CheckExistenceAsync(resourceGroupName).GetAwaiter().GetResult(); } /// @@ -48,12 +48,9 @@ public static bool CheckExistence(this IResourceGroupsOperations operations, str /// /// The cancellation token. /// - public static async Task CheckExistenceAsync(this IResourceGroupsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task CheckExistenceAsync(this IResourceGroupsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } + (await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceManagementClient.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceManagementClient.cs index 987ba41b2d1c..7bf5af09ee3e 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceManagementClient.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourceManagementClient.cs @@ -358,7 +358,7 @@ private void Initialize() Tags = new TagsOperations(this); DeploymentOperations = new DeploymentOperations(this); BaseUri = new System.Uri("https://management.azure.com"); - ApiVersion = "2019-05-10"; + ApiVersion = "2019-07-01"; AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperations.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperations.cs index 89b32c52a858..b9bf4048c98a 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperations.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperations.cs @@ -557,7 +557,7 @@ internal ResourcesOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CheckExistenceWithHttpMessagesAsync(string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceGroupName == null) { @@ -690,7 +690,7 @@ internal ResourcesOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -725,10 +725,9 @@ internal ResourcesOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; - _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); @@ -1123,7 +1122,7 @@ internal ResourcesOperations(ResourceManagementClient client) /// /// A response object containing the response body and response headers. /// - public async Task> CheckExistenceByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + public async Task CheckExistenceByIdWithHttpMessagesAsync(string resourceId, string apiVersion, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { if (resourceId == null) { @@ -1212,7 +1211,7 @@ internal ResourcesOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 204 && (int)_statusCode != 404) + if ((int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try @@ -1247,10 +1246,9 @@ internal ResourcesOperations(ResourceManagementClient client) throw ex; } // Create Result - var _result = new AzureOperationResponse(); + var _result = new AzureOperationResponse(); _result.Request = _httpRequest; _result.Response = _httpResponse; - _result.Body = _statusCode == System.Net.HttpStatusCode.NoContent; if (_httpResponse.Headers.Contains("x-ms-request-id")) { _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); @@ -1887,7 +1885,7 @@ internal ResourcesOperations(ResourceManagementClient client) HttpStatusCode _statusCode = _httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string _responseContent = null; - if ((int)_statusCode != 202 && (int)_statusCode != 204 && (int)_statusCode != 409) + if ((int)_statusCode != 202 && (int)_statusCode != 204) { var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); try diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperationsExtensions.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperationsExtensions.cs index 409feb86556d..87840df6033f 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperationsExtensions.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/ResourcesOperationsExtensions.cs @@ -231,9 +231,9 @@ public static void ValidateMoveResources(this IResourcesOperations operations, s /// /// The API version to use for the operation. /// - public static bool CheckExistence(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion) + public static void CheckExistence(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion) { - return operations.CheckExistenceAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).GetAwaiter().GetResult(); + operations.CheckExistenceAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion).GetAwaiter().GetResult(); } /// @@ -264,12 +264,9 @@ public static bool CheckExistence(this IResourcesOperations operations, string r /// /// The cancellation token. /// - public static async Task CheckExistenceAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task CheckExistenceAsync(this IResourcesOperations operations, string resourceGroupName, string resourceProviderNamespace, string parentResourcePath, string resourceType, string resourceName, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } + (await operations.CheckExistenceWithHttpMessagesAsync(resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// @@ -559,9 +556,9 @@ public static GenericResource Get(this IResourcesOperations operations, string r /// /// The API version to use for the operation. /// - public static bool CheckExistenceById(this IResourcesOperations operations, string resourceId, string apiVersion) + public static void CheckExistenceById(this IResourcesOperations operations, string resourceId, string apiVersion) { - return operations.CheckExistenceByIdAsync(resourceId, apiVersion).GetAwaiter().GetResult(); + operations.CheckExistenceByIdAsync(resourceId, apiVersion).GetAwaiter().GetResult(); } /// @@ -581,12 +578,9 @@ public static bool CheckExistenceById(this IResourcesOperations operations, stri /// /// The cancellation token. /// - public static async Task CheckExistenceByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) + public static async Task CheckExistenceByIdAsync(this IResourcesOperations operations, string resourceId, string apiVersion, CancellationToken cancellationToken = default(CancellationToken)) { - using (var _result = await operations.CheckExistenceByIdWithHttpMessagesAsync(resourceId, apiVersion, null, cancellationToken).ConfigureAwait(false)) - { - return _result.Body; - } + (await operations.CheckExistenceByIdWithHttpMessagesAsync(resourceId, apiVersion, null, cancellationToken).ConfigureAwait(false)).Dispose(); } /// diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/SdkInfo_ResourceManagementClient.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/SdkInfo_ResourceManagementClient.cs index 418a22842fb8..2024866e9615 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/SdkInfo_ResourceManagementClient.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Generated/SdkInfo_ResourceManagementClient.cs @@ -19,16 +19,16 @@ public static IEnumerable> ApiInfo_ResourceManagem { return new Tuple[] { - new Tuple("Management", "DeploymentOperations", "2019-05-10"), - new Tuple("Management", "Deployments", "2019-05-10"), - new Tuple("ResourceManagementClient", "DeploymentOperations", "2019-05-10"), - new Tuple("ResourceManagementClient", "Providers", "2019-05-10"), - new Tuple("ResourceManagementClient", "ResourceGroups", "2019-05-10"), - new Tuple("ResourceManagementClient", "Resources", "2019-05-10"), - new Tuple("ResourceManagementClient", "Tags", "2019-05-10"), - new Tuple("Resources", "DeploymentOperations", "2019-05-10"), - new Tuple("Resources", "Deployments", "2019-05-10"), - new Tuple("Resources", "Operations", "2019-05-10"), + new Tuple("Management", "DeploymentOperations", "2019-07-01"), + new Tuple("Management", "Deployments", "2019-07-01"), + new Tuple("ResourceManagementClient", "DeploymentOperations", "2019-07-01"), + new Tuple("ResourceManagementClient", "Providers", "2019-07-01"), + new Tuple("ResourceManagementClient", "ResourceGroups", "2019-07-01"), + new Tuple("ResourceManagementClient", "Resources", "2019-07-01"), + new Tuple("ResourceManagementClient", "Tags", "2019-07-01"), + new Tuple("Resources", "DeploymentOperations", "2019-07-01"), + new Tuple("Resources", "Deployments", "2019-07-01"), + new Tuple("Resources", "Operations", "2019-07-01"), }.AsEnumerable(); } } diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj b/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj index db4276c8b0ae..fb4f3858f7a5 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj @@ -38,6 +38,9 @@ Always + + Always + Always diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/DeploymentTests.ScenarioTests.cs b/sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/DeploymentTests.ScenarioTests.cs index 859d278076ae..3030a63b47da 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/DeploymentTests.ScenarioTests.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/DeploymentTests.ScenarioTests.cs @@ -485,5 +485,222 @@ public void ManagementGroupLevelDeployment() Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); } } + + [Fact] + public void TenantLevelDeployment() + { + var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.Created }; + + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + var client = GetResourceManagementClient(context, handler); + string deploymentName = TestUtilities.GenerateName("csharpsdktest"); + + var parameters = new Deployment + { + Properties = new DeploymentProperties() + { + Template = JObject.Parse(File.ReadAllText(Path.Combine("ScenarioTests", "tenant_level_template.json"))), + Parameters = + JObject.Parse("{'managementGroupId': {'value': 'tiano-mgtest01'}}"), + Mode = DeploymentMode.Incremental, + }, + Location = "East US 2" + }; + + //Validate + var validationResult = client.Deployments.ValidateAtTenantScope(deploymentName, parameters); + + //Assert + Assert.Null(validationResult.Error); + Assert.NotNull(validationResult.Properties); + Assert.NotNull(validationResult.Properties.Providers); + + //Put deployment + var deploymentResult = client.Deployments.CreateOrUpdateAtTenantScope(deploymentName, parameters); + + var deployment = client.Deployments.GetAtTenantScope(deploymentName); + Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); + + var deploymentOperations = client.DeploymentOperations.ListAtTenantScope(deploymentName); + Assert.Equal(4, deploymentOperations.Count()); + } + } + + [Fact] + public void DeploymentWithScope_AtTenant() + { + var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.Created }; + + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + var client = GetResourceManagementClient(context, handler); + string deploymentName = TestUtilities.GenerateName("csharpsdktest"); + + var parameters = new Deployment + { + Properties = new DeploymentProperties() + { + Template = JObject.Parse(File.ReadAllText(Path.Combine("ScenarioTests", "tenant_level_template.json"))), + Parameters = + JObject.Parse("{'managementGroupId': {'value': 'tiano-mgtest01'}}"), + Mode = DeploymentMode.Incremental, + }, + Location = "East US 2" + }; + + //Validate + var validationResult = client.Deployments.ValidateAtScope(scope: "", deploymentName: deploymentName, parameters: parameters); + + //Assert + Assert.Null(validationResult.Error); + Assert.NotNull(validationResult.Properties); + Assert.NotNull(validationResult.Properties.Providers); + + //Put deployment + var deploymentResult = client.Deployments.CreateOrUpdateAtScope(scope: "", deploymentName: deploymentName, parameters: parameters); + + var deployment = client.Deployments.GetAtScope(scope: "", deploymentName: deploymentName); + Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); + + var deploymentOperations = client.DeploymentOperations.ListAtScope(scope: "", deploymentName: deploymentName); + Assert.Equal(4, deploymentOperations.Count()); + } + } + + [Fact] + public void DeploymentWithScope_AtManagementGroup() + { + var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.Created }; + + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + var client = GetResourceManagementClient(context, handler); + string groupId = "tiano-mgtest01"; + string deploymentName = TestUtilities.GenerateName("csharpsdktest"); + + var parameters = new Deployment + { + Properties = new DeploymentProperties() + { + Template = JObject.Parse(File.ReadAllText(Path.Combine("ScenarioTests", "management_group_level_template.json"))), + Parameters = + JObject.Parse("{'storageAccountName': {'value': 'tianosatestgl'}}"), + Mode = DeploymentMode.Incremental, + }, + Location = "East US" + }; + + var managementGroupScope = $"/providers/Microsoft.Management/managementGroups/{groupId}"; + + //Validate + var validationResult = client.Deployments.ValidateAtScope(scope: managementGroupScope, deploymentName: deploymentName, parameters: parameters); + + //Assert + Assert.Null(validationResult.Error); + Assert.NotNull(validationResult.Properties); + Assert.NotNull(validationResult.Properties.Providers); + + //Put deployment + var deploymentResult = client.Deployments.CreateOrUpdateAtScope(scope: managementGroupScope, deploymentName: deploymentName, parameters: parameters); + + var deployment = client.Deployments.GetAtScope(scope: managementGroupScope, deploymentName: deploymentName); + Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); + + var deploymentOperations = client.DeploymentOperations.ListAtScope(scope: managementGroupScope, deploymentName: deploymentName); + Assert.Equal(4, deploymentOperations.Count()); + } + } + + [Fact] + public void DeploymentWithScope_AtSubscription() + { + var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.Created }; + + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + var client = GetResourceManagementClient(context, handler); + string groupName = "SDK-test"; + string deploymentName = TestUtilities.GenerateName("csmd"); + + var parameters = new Deployment + { + Properties = new DeploymentProperties() + { + Template = JObject.Parse(File.ReadAllText(Path.Combine("ScenarioTests", "subscription_level_template.json"))), + Parameters = + JObject.Parse("{'storageAccountName': {'value': 'armbuilddemo1803'}}"), + Mode = DeploymentMode.Incremental, + }, + Location = "WestUS" + }; + + client.ResourceGroups.CreateOrUpdate(groupName, new ResourceGroup { Location = "WestUS" }); + + var subscriptionScope = $"/subscriptions/{client.SubscriptionId}"; + + //Validate + var validationResult = client.Deployments.ValidateAtScope(scope: subscriptionScope, deploymentName: deploymentName, parameters: parameters); + + //Assert + Assert.Null(validationResult.Error); + Assert.NotNull(validationResult.Properties); + Assert.NotNull(validationResult.Properties.Providers); + + //Put deployment + var deploymentResult = client.Deployments.CreateOrUpdateAtScope(scope: subscriptionScope, deploymentName: deploymentName, parameters: parameters); + + var deployment = client.Deployments.GetAtScope(scope: subscriptionScope, deploymentName: deploymentName); + Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); + + var deploymentOperations = client.DeploymentOperations.ListAtScope(scope: subscriptionScope, deploymentName: deploymentName); + Assert.Equal(4, deploymentOperations.Count()); + } + } + + [Fact] + public void DeploymentWithScope_AtResourceGroup() + { + var handler = new RecordedDelegatingHandler() { StatusCodeToReturn = HttpStatusCode.Created }; + + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + var client = GetResourceManagementClient(context, handler); + string groupName = "SDK-test-01"; + string deploymentName = TestUtilities.GenerateName("csmd"); + + var parameters = new Deployment + { + Properties = new DeploymentProperties() + { + Template = JObject.Parse(File.ReadAllText(Path.Combine("ScenarioTests", "simple-storage-account.json"))), + Parameters = + JObject.Parse("{'storageAccountName': {'value': 'tianotest105'}}"), + Mode = DeploymentMode.Incremental, + } + }; + + client.ResourceGroups.CreateOrUpdate(groupName, new ResourceGroup { Location = "WestUS" }); + + var resourceGroupScope = $"/subscriptions/{client.SubscriptionId}/resourceGroups/{groupName}"; + + //Validate + var validationResult = client.Deployments.ValidateAtScope(scope: resourceGroupScope, deploymentName: deploymentName, parameters: parameters); + + //Assert + Assert.Null(validationResult.Error); + Assert.NotNull(validationResult.Properties); + Assert.NotNull(validationResult.Properties.Providers); + + //Put deployment + var deploymentResult = client.Deployments.CreateOrUpdateAtScope(scope: resourceGroupScope, deploymentName: deploymentName, parameters: parameters); + + var deployment = client.Deployments.GetAtScope(scope: resourceGroupScope, deploymentName: deploymentName); + Assert.Equal("Succeeded", deployment.Properties.ProvisioningState); + + var deploymentOperations = client.DeploymentOperations.ListAtScope(scope: resourceGroupScope, deploymentName: deploymentName); + Assert.Equal(2, deploymentOperations.Count()); + } + } } } diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/tenant_level_template.json b/sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/tenant_level_template.json new file mode 100644 index 000000000000..1fa57c5ededf --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/ScenarioTests/tenant_level_template.json @@ -0,0 +1,120 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "managementGroupId": { + "type": "string", + "defaultValue": "tiano-mgtest01" + }, + "subscriptionId": { + "type": "string", + "defaultValue": "89ec4d1d-dcc7-4a3f-a701-0a5d074c8505" + }, + "roleDefinitionId": { + "type": "string", + "defaultValue": "0cb07228-4614-4814-ac1a-c4e39793ce59" + } + }, + "variables": { + "managementGroupScope": "[concat('Microsoft.Management/managementGroups/', parameters('managementGroupId'))]", + "managementGroupFullyQualifiedId": "[concat('/providers/', variables('managementGroupScope'))]" + }, + "resources": [ + { + "type": "Microsoft.Authorization/roleDefinitions", + "name": "[parameters('roleDefinitionId')]", + "apiVersion": "2018-07-01", + "properties": { + "roleName": "Tiano SDK Test Role", + "description": "something", + "type": "CustomRole", + "permissions": [ + { + "actions": [ + "Microsoft.Storage/*/read" + ], + "notActions": [ + + ] + } + ], + "assignableScopes": [ + "[variables('managementGroupFullyQualifiedId')]" + ] + } + }, + { + "type": "Microsoft.Resources/deployments", + "name": "mg-nested", + "apiVersion": "2019-07-01", + "location": "West US", + "scope": "[variables('managementGroupScope')]", + "properties": { + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + + }, + "variables": { + + }, + "resources": [ + { + "type": "Microsoft.Authorization/policyDefinitions", + "name": "policy2", + "apiVersion": "2016-12-01", + "properties": { + "policyType": "Custom", + "parameters": { + + }, + "policyRule": { + "if": { + "field": "location", + "equals": "northeurope" + }, + "then": { + "effect": "deny" + } + } + } + } + ] + }, + "mode": "Incremental" + } + }, + { + "type": "Microsoft.Resources/deployments", + "name": "sub-nested", + "apiVersion": "2019-07-01", + "location": "East US", + "subscriptionId": "[parameters('subscriptionId')]", + "properties": { + "template": { + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + + }, + "variables": { + + }, + "resources": [ + { + "type": "Microsoft.Resources/resourceGroups", + "name": "sdk-testrg", + "apiVersion": "2019-07-01", + "location": "East US 2", + "properties": { + + } + } + ] + }, + "mode": "Incremental" + } + } + ] +} \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtManagementGroup.json b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtManagementGroup.json new file mode 100644 index 000000000000..b9393d77f053 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtManagementGroup.json @@ -0,0 +1,429 @@ +{ + "Entries": [ + { + "RequestUri": "/%2Fproviders%2FMicrosoft.Management%2FmanagementGroups%2Ftiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/validate?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5NYW5hZ2VtZW50JTJGbWFuYWdlbWVudEdyb3VwcyUyRnRpYW5vLW1ndGVzdDAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q2MDcxL3ZhbGlkYXRlP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"location\": \"East US\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"tianosatestgl\"\r\n }\r\n },\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Authorization/policyAssignments\",\r\n \"name\": \"location-lock\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"dependsOn\": [\r\n \"policy2\"\r\n ],\r\n \"properties\": {\r\n \"scope\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01\",\r\n \"policyDefinitionId\": \"[concat('/providers/Microsoft.Management/managementGroups/tiano-mgtest01/', 'providers/', 'Microsoft.Authorization/policyDefinitions/', 'policy2')]\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"sdktest-subnested\",\r\n \"apiVersion\": \"2018-05-01\",\r\n \"location\": \"West US\",\r\n \"subscriptionId\": \"fb3a3d6b-44c8-44f5-88c9-b20917c9b96b\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"name\": \"rg-001\",\r\n \"apiVersion\": \"2018-05-01\",\r\n \"location\": \"East US 2 EUAP\",\r\n \"properties\": {}\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"rg-nested\",\r\n \"apiVersion\": \"2017-05-10\",\r\n \"resourceGroup\": \"rg-001\",\r\n \"dependsOn\": [\r\n \"rg-001\"\r\n ],\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"name\": \"[parameters('storageAccountName')]\",\r\n \"apiVersion\": \"2015-06-15\",\r\n \"location\": \"East US\",\r\n \"properties\": {\r\n \"accountType\": \"Standard_LRS\"\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"value\": \"tianosatestgl\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "ee2022e1-4e57-4202-9729-ee488da2ae3d" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "3734" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:45:30 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "c43022fa-76f4-4c6d-9f25-eeb6898ea768" + ], + "x-ms-correlation-request-id": [ + "c43022fa-76f4-4c6d-9f25-eeb6898ea768" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T224530Z:c43022fa-76f4-4c6d-9f25-eeb6898ea768" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "2063" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071\",\r\n \"name\": \"csharpsdktest6071\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus\",\r\n \"properties\": {\r\n \"templateHash\": \"8177151422603797865\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianosatestgl\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:45:29.7477841Z\",\r\n \"duration\": \"PT0S\",\r\n \"correlationId\": \"c43022fa-76f4-4c6d-9f25-eeb6898ea768\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ],\r\n \"validatedResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/sdktest-subnested\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/rg-001\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/rg-001/providers/Microsoft.Resources/deployments/rg-nested\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/rg-001/providers/Microsoft.Storage/storageAccounts/tianosatestgl\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fproviders%2FMicrosoft.Management%2FmanagementGroups%2Ftiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5NYW5hZ2VtZW50JTJGbWFuYWdlbWVudEdyb3VwcyUyRnRpYW5vLW1ndGVzdDAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q2MDcxP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"East US\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"tianosatestgl\"\r\n }\r\n },\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Authorization/policyAssignments\",\r\n \"name\": \"location-lock\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"dependsOn\": [\r\n \"policy2\"\r\n ],\r\n \"properties\": {\r\n \"scope\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01\",\r\n \"policyDefinitionId\": \"[concat('/providers/Microsoft.Management/managementGroups/tiano-mgtest01/', 'providers/', 'Microsoft.Authorization/policyDefinitions/', 'policy2')]\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"sdktest-subnested\",\r\n \"apiVersion\": \"2018-05-01\",\r\n \"location\": \"West US\",\r\n \"subscriptionId\": \"fb3a3d6b-44c8-44f5-88c9-b20917c9b96b\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"name\": \"rg-001\",\r\n \"apiVersion\": \"2018-05-01\",\r\n \"location\": \"East US 2 EUAP\",\r\n \"properties\": {}\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"rg-nested\",\r\n \"apiVersion\": \"2017-05-10\",\r\n \"resourceGroup\": \"rg-001\",\r\n \"dependsOn\": [\r\n \"rg-001\"\r\n ],\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"name\": \"[parameters('storageAccountName')]\",\r\n \"apiVersion\": \"2015-06-15\",\r\n \"location\": \"East US\",\r\n \"properties\": {\r\n \"accountType\": \"Standard_LRS\"\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"value\": \"tianosatestgl\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "96c85077-7787-4f44-813e-39e83ed10ae3" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "3734" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:45:32 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Azure-AsyncOperation": [ + "https://management.azure.com/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operationStatuses/08586364753547628998?api-version=2019-07-01" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "02c09615-b6d6-4840-805d-3ac6657efd2f" + ], + "x-ms-correlation-request-id": [ + "02c09615-b6d6-4840-805d-3ac6657efd2f" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T224532Z:02c09615-b6d6-4840-805d-3ac6657efd2f" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1295" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071\",\r\n \"name\": \"csharpsdktest6071\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus\",\r\n \"properties\": {\r\n \"templateHash\": \"8177151422603797865\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianosatestgl\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Accepted\",\r\n \"timestamp\": \"2019-08-06T22:45:32.3523736Z\",\r\n \"duration\": \"PT1.6376568S\",\r\n \"correlationId\": \"02c09615-b6d6-4840-805d-3ac6657efd2f\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operationStatuses/08586364753547628998?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3RpYW5vLW1ndGVzdDAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q2MDcxL29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzUzNTQ3NjI4OTk4P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:46:02 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "5826427f-94b8-4aa6-835f-ff99c1965cb5" + ], + "x-ms-correlation-request-id": [ + "5826427f-94b8-4aa6-835f-ff99c1965cb5" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T224602Z:5826427f-94b8-4aa6-835f-ff99c1965cb5" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "20" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Running\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operationStatuses/08586364753547628998?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3RpYW5vLW1ndGVzdDAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q2MDcxL29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzUzNTQ3NjI4OTk4P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:46:32 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11998" + ], + "x-ms-request-id": [ + "5dde50e7-ec36-4e20-abd0-74cad2eb3744" + ], + "x-ms-correlation-request-id": [ + "5dde50e7-ec36-4e20-abd0-74cad2eb3744" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T224633Z:5dde50e7-ec36-4e20-abd0-74cad2eb3744" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "22" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Succeeded\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fproviders%2FMicrosoft.Management%2FmanagementGroups%2Ftiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5NYW5hZ2VtZW50JTJGbWFuYWdlbWVudEdyb3VwcyUyRnRpYW5vLW1ndGVzdDAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q2MDcxP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:46:33 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11997" + ], + "x-ms-request-id": [ + "d2c7545a-3382-4019-9084-946017735441" + ], + "x-ms-correlation-request-id": [ + "d2c7545a-3382-4019-9084-946017735441" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T224633Z:d2c7545a-3382-4019-9084-946017735441" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1813" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071\",\r\n \"name\": \"csharpsdktest6071\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus\",\r\n \"properties\": {\r\n \"templateHash\": \"8177151422603797865\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianosatestgl\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:46:31.038577Z\",\r\n \"duration\": \"PT1M0.3238602S\",\r\n \"correlationId\": \"02c09615-b6d6-4840-805d-3ac6657efd2f\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/rg-001\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/rg-001/providers/Microsoft.Storage/storageAccounts/tianosatestgl\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fproviders%2FMicrosoft.Management%2FmanagementGroups%2Ftiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5NYW5hZ2VtZW50JTJGbWFuYWdlbWVudEdyb3VwcyUyRnRpYW5vLW1ndGVzdDAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q2MDcxP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "f9cab3b3-a8b8-4111-b9f2-91485f225dfe" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:46:33 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11996" + ], + "x-ms-request-id": [ + "694cbda3-48a8-4fc7-982c-f46be4db2a44" + ], + "x-ms-correlation-request-id": [ + "694cbda3-48a8-4fc7-982c-f46be4db2a44" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T224633Z:694cbda3-48a8-4fc7-982c-f46be4db2a44" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1813" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071\",\r\n \"name\": \"csharpsdktest6071\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus\",\r\n \"properties\": {\r\n \"templateHash\": \"8177151422603797865\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianosatestgl\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:46:31.038577Z\",\r\n \"duration\": \"PT1M0.3238602S\",\r\n \"correlationId\": \"02c09615-b6d6-4840-805d-3ac6657efd2f\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/rg-001\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/rg-001/providers/Microsoft.Storage/storageAccounts/tianosatestgl\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fproviders%2FMicrosoft.Management%2FmanagementGroups%2Ftiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operations?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnByb3ZpZGVycyUyRk1pY3Jvc29mdC5NYW5hZ2VtZW50JTJGbWFuYWdlbWVudEdyb3VwcyUyRnRpYW5vLW1ndGVzdDAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q2MDcxL29wZXJhdGlvbnM/YXBpLXZlcnNpb249MjAxOS0wNy0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "d904ed90-8525-40aa-89cc-ad498e5453f8" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:46:33 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11995" + ], + "x-ms-request-id": [ + "9385eb76-c953-4f95-8dda-b9be1cb202f4" + ], + "x-ms-correlation-request-id": [ + "9385eb76-c953-4f95-8dda-b9be1cb202f4" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T224633Z:9385eb76-c953-4f95-8dda-b9be1cb202f4" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "2612" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operations/C4BD8862752210C1\",\r\n \"operationId\": \"C4BD8862752210C1\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:46:30.885437Z\",\r\n \"duration\": \"PT54.9222844S\",\r\n \"trackingId\": \"f6b392bf-dcdd-4a3a-9840-4371d92593cc\",\r\n \"serviceRequestId\": \"67cc7858-0f70-4ff6-91e0-9ad292054cac\",\r\n \"statusCode\": \"OK\",\r\n \"targetResource\": {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/sdktest-subnested\",\r\n \"resourceType\": \"Microsoft.Resources/deployments\",\r\n \"resourceName\": \"sdktest-subnested\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operations/EC5EC028160C085A\",\r\n \"operationId\": \"EC5EC028160C085A\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:45:38.5961615Z\",\r\n \"duration\": \"PT0.1579109S\",\r\n \"trackingId\": \"4f228d3e-6a5e-43e9-9ca0-dd565df9fc7e\",\r\n \"serviceRequestId\": \"eastus2:aa8e8772-cf6f-4637-98bd-cfe9ea58ce9d\",\r\n \"statusCode\": \"Created\",\r\n \"targetResource\": {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operations/8DA0DF42F92BC438\",\r\n \"operationId\": \"8DA0DF42F92BC438\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:45:38.1886163Z\",\r\n \"duration\": \"PT2.2254637S\",\r\n \"trackingId\": \"25accd28-4e46-494e-bf8f-45f924b2a65c\",\r\n \"serviceRequestId\": \"eastus2:7ec1cb0c-0dda-460c-9504-336039cf440b\",\r\n \"statusCode\": \"Created\",\r\n \"targetResource\": {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/csharpsdktest6071/operations/08586364753547628998\",\r\n \"operationId\": \"08586364753547628998\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"EvaluateDeploymentOutput\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:46:31.0117399Z\",\r\n \"duration\": \"PT0.0782949S\",\r\n \"trackingId\": \"4237f208-7b60-4aa2-b5a5-661f4d565101\",\r\n \"statusCode\": \"OK\",\r\n \"statusMessage\": null\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": { + "DeploymentWithScope_AtManagementGroup": [ + "csharpsdktest6071" + ] + }, + "Variables": { + "SubscriptionId": "fb3a3d6b-44c8-44f5-88c9-b20917c9b96b" + } +} \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtResourceGroup.json b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtResourceGroup.json new file mode 100644 index 000000000000..3deb737bb13d --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtResourceGroup.json @@ -0,0 +1,441 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourcegroups/SDK-test-01?api-version=2019-07-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZmIzYTNkNmItNDRjOC00NGY1LTg4YzktYjIwOTE3YzliOTZiL3Jlc291cmNlZ3JvdXBzL1NESy10ZXN0LTAxP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"WestUS\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "3848e487-2b75-4020-9466-45e6800dd2db" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "28" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 23:15:53 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-request-id": [ + "634c6f8b-ee85-498e-8a20-7949b0cb93f1" + ], + "x-ms-correlation-request-id": [ + "634c6f8b-ee85-498e-8a20-7949b0cb93f1" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T231553Z:634c6f8b-ee85-498e-8a20-7949b0cb93f1" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "219" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01\",\r\n \"name\": \"SDK-test-01\",\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"location\": \"westus\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b%2FresourceGroups%2FSDK-test-01/providers/Microsoft.Resources/deployments/csmd2718/validate?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIlMkZyZXNvdXJjZUdyb3VwcyUyRlNESy10ZXN0LTAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQyNzE4L3ZhbGlkYXRlP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"string\"\r\n }\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"name\": \"[parameters('storageAccountName')]\",\r\n \"apiVersion\": \"2015-06-15\",\r\n \"location\": \"[resourceGroup().location]\",\r\n \"properties\": {\r\n \"accountType\": \"Standard_LRS\"\r\n }\r\n }\r\n ],\r\n \"outputs\": {}\r\n },\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"value\": \"tianotest105\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "8f65f087-9fe6-48b1-8fb7-3123320ed4a4" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "788" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 23:15:54 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-request-id": [ + "4c9c4473-7e17-4fc4-b6a3-d55681e84670" + ], + "x-ms-correlation-request-id": [ + "4c9c4473-7e17-4fc4-b6a3-d55681e84670" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T231554Z:4c9c4473-7e17-4fc4-b6a3-d55681e84670" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "806" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718\",\r\n \"name\": \"csmd2718\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"properties\": {\r\n \"templateHash\": \"12333207102593257247\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianotest105\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T23:15:53.8400436Z\",\r\n \"duration\": \"PT0S\",\r\n \"correlationId\": \"4c9c4473-7e17-4fc4-b6a3-d55681e84670\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Storage\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"storageAccounts\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"validatedResources\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Storage/storageAccounts/tianotest105\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b%2FresourceGroups%2FSDK-test-01/providers/Microsoft.Resources/deployments/csmd2718?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIlMkZyZXNvdXJjZUdyb3VwcyUyRlNESy10ZXN0LTAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQyNzE4P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"string\"\r\n }\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"name\": \"[parameters('storageAccountName')]\",\r\n \"apiVersion\": \"2015-06-15\",\r\n \"location\": \"[resourceGroup().location]\",\r\n \"properties\": {\r\n \"accountType\": \"Standard_LRS\"\r\n }\r\n }\r\n ],\r\n \"outputs\": {}\r\n },\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"value\": \"tianotest105\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "83a5c18d-842f-4ea9-950d-cae391fb08f7" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "788" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 23:15:54 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Azure-AsyncOperation": [ + "https://management.azure.com/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourcegroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718/operationStatuses/08586364735310552648?api-version=2019-07-01" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1198" + ], + "x-ms-request-id": [ + "41e05785-d9a2-4733-972e-a59d7151b5e9" + ], + "x-ms-correlation-request-id": [ + "41e05785-d9a2-4733-972e-a59d7151b5e9" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T231554Z:41e05785-d9a2-4733-972e-a59d7151b5e9" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "645" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718\",\r\n \"name\": \"csmd2718\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"properties\": {\r\n \"templateHash\": \"12333207102593257247\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianotest105\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Accepted\",\r\n \"timestamp\": \"2019-08-06T23:15:54.5560555Z\",\r\n \"duration\": \"PT0.1337126S\",\r\n \"correlationId\": \"41e05785-d9a2-4733-972e-a59d7151b5e9\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Storage\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"storageAccounts\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": []\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourcegroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718/operationStatuses/08586364735310552648?api-version=2019-07-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZmIzYTNkNmItNDRjOC00NGY1LTg4YzktYjIwOTE3YzliOTZiL3Jlc291cmNlZ3JvdXBzL1NESy10ZXN0LTAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQyNzE4L29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzM1MzEwNTUyNjQ4P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 23:16:23 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "6ef0b865-5667-48fa-9d38-45806afae328" + ], + "x-ms-correlation-request-id": [ + "6ef0b865-5667-48fa-9d38-45806afae328" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T231624Z:6ef0b865-5667-48fa-9d38-45806afae328" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "22" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Succeeded\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b%2FresourceGroups%2FSDK-test-01/providers/Microsoft.Resources/deployments/csmd2718?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIlMkZyZXNvdXJjZUdyb3VwcyUyRlNESy10ZXN0LTAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQyNzE4P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 23:16:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "8c363113-7aa9-48a5-8f0c-4cd4e1ef93df" + ], + "x-ms-correlation-request-id": [ + "8c363113-7aa9-48a5-8f0c-4cd4e1ef93df" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T231624Z:8c363113-7aa9-48a5-8f0c-4cd4e1ef93df" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "825" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718\",\r\n \"name\": \"csmd2718\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"properties\": {\r\n \"templateHash\": \"12333207102593257247\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianotest105\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T23:16:19.9118597Z\",\r\n \"duration\": \"PT25.4895168S\",\r\n \"correlationId\": \"41e05785-d9a2-4733-972e-a59d7151b5e9\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Storage\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"storageAccounts\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"outputs\": {},\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Storage/storageAccounts/tianotest105\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b%2FresourceGroups%2FSDK-test-01/providers/Microsoft.Resources/deployments/csmd2718?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIlMkZyZXNvdXJjZUdyb3VwcyUyRlNESy10ZXN0LTAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQyNzE4P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "94a48079-a56d-4685-97bc-a2ede2476f2f" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 23:16:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11997" + ], + "x-ms-request-id": [ + "9f4a182b-e585-4897-abe4-8e80e3d99363" + ], + "x-ms-correlation-request-id": [ + "9f4a182b-e585-4897-abe4-8e80e3d99363" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T231624Z:9f4a182b-e585-4897-abe4-8e80e3d99363" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "825" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718\",\r\n \"name\": \"csmd2718\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"properties\": {\r\n \"templateHash\": \"12333207102593257247\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"tianotest105\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T23:16:19.9118597Z\",\r\n \"duration\": \"PT25.4895168S\",\r\n \"correlationId\": \"41e05785-d9a2-4733-972e-a59d7151b5e9\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Storage\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"storageAccounts\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"outputs\": {},\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Storage/storageAccounts/tianotest105\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b%2FresourceGroups%2FSDK-test-01/providers/Microsoft.Resources/deployments/csmd2718/operations?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIlMkZyZXNvdXJjZUdyb3VwcyUyRlNESy10ZXN0LTAxL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQyNzE4L29wZXJhdGlvbnM/YXBpLXZlcnNpb249MjAxOS0wNy0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "9ea4faaa-5dc8-4a76-adc8-cd73f0d97f7b" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 23:16:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11996" + ], + "x-ms-request-id": [ + "2365a3e9-3a04-4db3-b918-286fe7f2ae2f" + ], + "x-ms-correlation-request-id": [ + "2365a3e9-3a04-4db3-b918-286fe7f2ae2f" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T231625Z:2365a3e9-3a04-4db3-b918-286fe7f2ae2f" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1198" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718/operations/829AE8037D46643D\",\r\n \"operationId\": \"829AE8037D46643D\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T23:16:18.6741907Z\",\r\n \"duration\": \"PT23.1243416S\",\r\n \"trackingId\": \"86d4e20e-4e2f-473c-8e06-a316ed293a8c\",\r\n \"serviceRequestId\": \"f222f295-3ac0-4db0-83c4-937d093961e8\",\r\n \"statusCode\": \"OK\",\r\n \"targetResource\": {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Storage/storageAccounts/tianotest105\",\r\n \"resourceType\": \"Microsoft.Storage/storageAccounts\",\r\n \"resourceName\": \"tianotest105\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test-01/providers/Microsoft.Resources/deployments/csmd2718/operations/08586364735310552648\",\r\n \"operationId\": \"08586364735310552648\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"EvaluateDeploymentOutput\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T23:16:19.7034594Z\",\r\n \"duration\": \"PT0.6146107S\",\r\n \"trackingId\": \"e80b4970-c038-412f-aa9f-edb4e174fa1e\",\r\n \"statusCode\": \"OK\",\r\n \"statusMessage\": null\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": { + "DeploymentWithScope_AtResourceGroup": [ + "csmd2718" + ] + }, + "Variables": { + "SubscriptionId": "fb3a3d6b-44c8-44f5-88c9-b20917c9b96b" + } +} \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtSubscription.json b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtSubscription.json new file mode 100644 index 000000000000..bc7b267654fc --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtSubscription.json @@ -0,0 +1,549 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourcegroups/SDK-test?api-version=2019-07-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZmIzYTNkNmItNDRjOC00NGY1LTg4YzktYjIwOTE3YzliOTZiL3Jlc291cmNlZ3JvdXBzL1NESy10ZXN0P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"WestUS\"\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "7b4532d0-4600-4f0f-9529-ddda25c16af9" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "28" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:57:33 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-request-id": [ + "33f194fb-bc4f-4b7e-9043-0ee8ee0801b2" + ], + "x-ms-correlation-request-id": [ + "33f194fb-bc4f-4b7e-9043-0ee8ee0801b2" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225733Z:33f194fb-bc4f-4b7e-9043-0ee8ee0801b2" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "213" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test\",\r\n \"name\": \"SDK-test\",\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"location\": \"westus\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/validate?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIvcHJvdmlkZXJzL01pY3Jvc29mdC5SZXNvdXJjZXMvZGVwbG95bWVudHMvY3NtZDQ2NzcvdmFsaWRhdGU/YXBpLXZlcnNpb249MjAxOS0wNy0wMQ==", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"location\": \"WestUS\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"armbuilddemo1801\"\r\n }\r\n },\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Authorization/policyAssignments\",\r\n \"name\": \"location-lock\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"dependsOn\": [\r\n \"policy2\"\r\n ],\r\n \"properties\": {\r\n \"scope\": \"[subscription().id]\",\r\n \"policyDefinitionId\": \"[resourceId('Microsoft.Authorization/policyDefinitions', 'policy2')]\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"rg-nested\",\r\n \"apiVersion\": \"2017-05-10\",\r\n \"resourceGroup\": \"SDK-test\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"name\": \"[parameters('storageAccountName')]\",\r\n \"apiVersion\": \"2015-06-15\",\r\n \"location\": \"East US\",\r\n \"properties\": {\r\n \"accountType\": \"Standard_LRS\"\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"value\": \"armbuilddemo1803\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "2dabef5f-9c8d-4aab-86a5-24267de9efa8" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "2410" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:57:34 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1199" + ], + "x-ms-request-id": [ + "90658edc-ee6d-404c-a20c-1e37bda29af7" + ], + "x-ms-correlation-request-id": [ + "90658edc-ee6d-404c-a20c-1e37bda29af7" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225734Z:90658edc-ee6d-404c-a20c-1e37bda29af7" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1788" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677\",\r\n \"name\": \"csmd4677\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"westus\",\r\n \"properties\": {\r\n \"templateHash\": \"13014011955130352575\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"armbuilddemo1803\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:57:33.7653345Z\",\r\n \"duration\": \"PT0S\",\r\n \"correlationId\": \"90658edc-ee6d-404c-a20c-1e37bda29af7\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ],\r\n \"validatedResources\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test/providers/Microsoft.Resources/deployments/rg-nested\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test/providers/Microsoft.Storage/storageAccounts/armbuilddemo1803\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIvcHJvdmlkZXJzL01pY3Jvc29mdC5SZXNvdXJjZXMvZGVwbG95bWVudHMvY3NtZDQ2Nzc/YXBpLXZlcnNpb249MjAxOS0wNy0wMQ==", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"WestUS\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"armbuilddemo1801\"\r\n }\r\n },\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Authorization/policyAssignments\",\r\n \"name\": \"location-lock\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"dependsOn\": [\r\n \"policy2\"\r\n ],\r\n \"properties\": {\r\n \"scope\": \"[subscription().id]\",\r\n \"policyDefinitionId\": \"[resourceId('Microsoft.Authorization/policyDefinitions', 'policy2')]\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"rg-nested\",\r\n \"apiVersion\": \"2017-05-10\",\r\n \"resourceGroup\": \"SDK-test\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"name\": \"[parameters('storageAccountName')]\",\r\n \"apiVersion\": \"2015-06-15\",\r\n \"location\": \"East US\",\r\n \"properties\": {\r\n \"accountType\": \"Standard_LRS\"\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"value\": \"armbuilddemo1803\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "bb8f15c8-f5fc-4403-afb4-edf1f88665c6" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "2410" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:57:34 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Azure-AsyncOperation": [ + "https://management.azure.com/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operationStatuses/08586364746307161272?api-version=2019-07-01" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1198" + ], + "x-ms-request-id": [ + "e3d5e11d-18b5-4be3-b4cd-c1693fdd4e59" + ], + "x-ms-correlation-request-id": [ + "e3d5e11d-18b5-4be3-b4cd-c1693fdd4e59" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225735Z:e3d5e11d-18b5-4be3-b4cd-c1693fdd4e59" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1241" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677\",\r\n \"name\": \"csmd4677\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"westus\",\r\n \"properties\": {\r\n \"templateHash\": \"13014011955130352575\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"armbuilddemo1803\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Accepted\",\r\n \"timestamp\": \"2019-08-06T22:57:35.0588028Z\",\r\n \"duration\": \"PT0.2973056S\",\r\n \"correlationId\": \"e3d5e11d-18b5-4be3-b4cd-c1693fdd4e59\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operationStatuses/08586364746307161272?api-version=2019-07-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZmIzYTNkNmItNDRjOC00NGY1LTg4YzktYjIwOTE3YzliOTZiL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQ0Njc3L29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzQ2MzA3MTYxMjcyP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:58:04 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "151d316b-204f-4fa4-b733-7316b197cc46" + ], + "x-ms-correlation-request-id": [ + "151d316b-204f-4fa4-b733-7316b197cc46" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225805Z:151d316b-204f-4fa4-b733-7316b197cc46" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "20" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Running\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operationStatuses/08586364746307161272?api-version=2019-07-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZmIzYTNkNmItNDRjOC00NGY1LTg4YzktYjIwOTE3YzliOTZiL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQ0Njc3L29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzQ2MzA3MTYxMjcyP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:58:35 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "4e16f281-e3a4-4b77-9d8c-2289529e98ce" + ], + "x-ms-correlation-request-id": [ + "4e16f281-e3a4-4b77-9d8c-2289529e98ce" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225835Z:4e16f281-e3a4-4b77-9d8c-2289529e98ce" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "20" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Running\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operationStatuses/08586364746307161272?api-version=2019-07-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZmIzYTNkNmItNDRjOC00NGY1LTg4YzktYjIwOTE3YzliOTZiL3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzbWQ0Njc3L29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzQ2MzA3MTYxMjcyP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:59:04 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11997" + ], + "x-ms-request-id": [ + "ce233cf8-6bff-4954-be72-4081c79ec626" + ], + "x-ms-correlation-request-id": [ + "ce233cf8-6bff-4954-be72-4081c79ec626" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225905Z:ce233cf8-6bff-4954-be72-4081c79ec626" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "22" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Succeeded\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIvcHJvdmlkZXJzL01pY3Jvc29mdC5SZXNvdXJjZXMvZGVwbG95bWVudHMvY3NtZDQ2Nzc/YXBpLXZlcnNpb249MjAxOS0wNy0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:59:04 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11996" + ], + "x-ms-request-id": [ + "c7cdc02f-6d4c-4ea2-ae55-26c27e7ccf48" + ], + "x-ms-correlation-request-id": [ + "c7cdc02f-6d4c-4ea2-ae55-26c27e7ccf48" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225905Z:c7cdc02f-6d4c-4ea2-ae55-26c27e7ccf48" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1659" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677\",\r\n \"name\": \"csmd4677\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"westus\",\r\n \"properties\": {\r\n \"templateHash\": \"13014011955130352575\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"armbuilddemo1803\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:58:48.9491535Z\",\r\n \"duration\": \"PT1M14.1876563S\",\r\n \"correlationId\": \"e3d5e11d-18b5-4be3-b4cd-c1693fdd4e59\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test/providers/Microsoft.Storage/storageAccounts/armbuilddemo1803\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIvcHJvdmlkZXJzL01pY3Jvc29mdC5SZXNvdXJjZXMvZGVwbG95bWVudHMvY3NtZDQ2Nzc/YXBpLXZlcnNpb249MjAxOS0wNy0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "a51cbf19-8365-409e-93f0-f7de97202068" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:59:05 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11995" + ], + "x-ms-request-id": [ + "dfc19502-fc6c-4c1a-9190-88fceef756ec" + ], + "x-ms-correlation-request-id": [ + "dfc19502-fc6c-4c1a-9190-88fceef756ec" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225905Z:dfc19502-fc6c-4c1a-9190-88fceef756ec" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1659" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677\",\r\n \"name\": \"csmd4677\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"westus\",\r\n \"properties\": {\r\n \"templateHash\": \"13014011955130352575\",\r\n \"parameters\": {\r\n \"storageAccountName\": {\r\n \"type\": \"String\",\r\n \"value\": \"armbuilddemo1803\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:58:48.9491535Z\",\r\n \"duration\": \"PT1M14.1876563S\",\r\n \"correlationId\": \"e3d5e11d-18b5-4be3-b4cd-c1693fdd4e59\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"policyDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n },\r\n {\r\n \"resourceType\": \"policyAssignments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [\r\n {\r\n \"dependsOn\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n ],\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n ],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test/providers/Microsoft.Storage/storageAccounts/armbuilddemo1803\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/%2Fsubscriptions%2Ffb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operations?api-version=2019-07-01", + "EncodedRequestUri": "LyUyRnN1YnNjcmlwdGlvbnMlMkZmYjNhM2Q2Yi00NGM4LTQ0ZjUtODhjOS1iMjA5MTdjOWI5NmIvcHJvdmlkZXJzL01pY3Jvc29mdC5SZXNvdXJjZXMvZGVwbG95bWVudHMvY3NtZDQ2Nzcvb3BlcmF0aW9ucz9hcGktdmVyc2lvbj0yMDE5LTA3LTAx", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "dc99c4c1-21e4-4fd5-b02d-8e301bdbf4f9" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:59:05 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11994" + ], + "x-ms-request-id": [ + "94e21d36-6861-4c7c-8ce0-db5821ad3b1a" + ], + "x-ms-correlation-request-id": [ + "94e21d36-6861-4c7c-8ce0-db5821ad3b1a" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T225905Z:94e21d36-6861-4c7c-8ce0-db5821ad3b1a" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "2513" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operations/C5E18B4900C96320\",\r\n \"operationId\": \"C5E18B4900C96320\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:57:37.3305373Z\",\r\n \"duration\": \"PT0.5689251S\",\r\n \"trackingId\": \"4181b2f6-02db-4e34-abe7-759554c38247\",\r\n \"serviceRequestId\": \"westus:0e1833f7-2557-4582-b00b-d3e9669822b5\",\r\n \"statusCode\": \"Created\",\r\n \"targetResource\": {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyAssignments/location-lock\",\r\n \"resourceType\": \"Microsoft.Authorization/policyAssignments\",\r\n \"resourceName\": \"location-lock\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operations/E94E5BCFA18DF29D\",\r\n \"operationId\": \"E94E5BCFA18DF29D\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:57:36.7155054Z\",\r\n \"duration\": \"PT1.1378043S\",\r\n \"trackingId\": \"b3d0f4e3-147c-4e00-8dcc-48c621b31983\",\r\n \"serviceRequestId\": \"westus:b2a830c1-e367-40c3-9cb2-80bff2d34606\",\r\n \"statusCode\": \"Created\",\r\n \"targetResource\": {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Authorization/policyDefinitions/policy2\",\r\n \"resourceType\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"resourceName\": \"policy2\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operations/2B2BC710DFB10EC6\",\r\n \"operationId\": \"2B2BC710DFB10EC6\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:58:47.1572677Z\",\r\n \"duration\": \"PT1M11.5795666S\",\r\n \"trackingId\": \"a0fa2cc0-f051-4346-af4c-df76cd6d8c6d\",\r\n \"serviceRequestId\": \"31d9ecfa-c633-4a56-9627-d7016c0d7778\",\r\n \"statusCode\": \"OK\",\r\n \"targetResource\": {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/resourceGroups/SDK-test/providers/Microsoft.Resources/deployments/rg-nested\",\r\n \"resourceType\": \"Microsoft.Resources/deployments\",\r\n \"resourceName\": \"rg-nested\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/subscriptions/fb3a3d6b-44c8-44f5-88c9-b20917c9b96b/providers/Microsoft.Resources/deployments/csmd4677/operations/08586364746307161272\",\r\n \"operationId\": \"08586364746307161272\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"EvaluateDeploymentOutput\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:58:48.7351637Z\",\r\n \"duration\": \"PT1.0631973S\",\r\n \"trackingId\": \"0ce6bf08-e73f-483f-b16c-794232242836\",\r\n \"statusCode\": \"OK\",\r\n \"statusMessage\": null\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": { + "DeploymentWithScope_AtSubscription": [ + "csmd4677" + ] + }, + "Variables": { + "SubscriptionId": "fb3a3d6b-44c8-44f5-88c9-b20917c9b96b" + } +} \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtTenant.json b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtTenant.json new file mode 100644 index 000000000000..60f3fae840a4 --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/DeploymentWithScope_AtTenant.json @@ -0,0 +1,429 @@ +{ + "Entries": [ + { + "RequestUri": "//providers/Microsoft.Resources/deployments/csharpsdktest8195/validate?api-version=2019-07-01", + "EncodedRequestUri": "Ly9wcm92aWRlcnMvTWljcm9zb2Z0LlJlc291cmNlcy9kZXBsb3ltZW50cy9jc2hhcnBzZGt0ZXN0ODE5NS92YWxpZGF0ZT9hcGktdmVyc2lvbj0yMDE5LTA3LTAx", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"location\": \"East US 2\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"variables\": {\r\n \"managementGroupScope\": \"[concat('Microsoft.Management/managementGroups/', parameters('managementGroupId'))]\",\r\n \"managementGroupFullyQualifiedId\": \"[concat('/providers/', variables('managementGroupScope'))]\"\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/roleDefinitions\",\r\n \"name\": \"[parameters('roleDefinitionId')]\",\r\n \"apiVersion\": \"2018-07-01\",\r\n \"properties\": {\r\n \"roleName\": \"Tiano SDK Test Role\",\r\n \"description\": \"something\",\r\n \"type\": \"CustomRole\",\r\n \"permissions\": [\r\n {\r\n \"actions\": [\r\n \"Microsoft.Storage/*/read\"\r\n ],\r\n \"notActions\": []\r\n }\r\n ],\r\n \"assignableScopes\": [\r\n \"[variables('managementGroupFullyQualifiedId')]\"\r\n ]\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"mg-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"West US\",\r\n \"scope\": \"[variables('managementGroupScope')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"sub-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US\",\r\n \"subscriptionId\": \"[parameters('subscriptionId')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"name\": \"sdk-testrg\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US 2\",\r\n \"properties\": {}\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"value\": \"tiano-mgtest01\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "18e1be4f-9c9e-42ad-a1d8-f37859374641" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "3898" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:36:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "1d4ddd45-aa49-48a4-888a-7ed83e53536e" + ], + "x-ms-correlation-request-id": [ + "1d4ddd45-aa49-48a4-888a-7ed83e53536e" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T223624Z:1d4ddd45-aa49-48a4-888a-7ed83e53536e" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1464" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195\",\r\n \"name\": \"csharpsdktest8195\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:36:24.3860878Z\",\r\n \"duration\": \"PT0S\",\r\n \"correlationId\": \"1d4ddd45-aa49-48a4-888a-7ed83e53536e\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"validatedResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/mg-nested\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/providers/Microsoft.Resources/deployments/sub-nested\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/resourceGroups/sdk-testrg\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "//providers/Microsoft.Resources/deployments/csharpsdktest8195?api-version=2019-07-01", + "EncodedRequestUri": "Ly9wcm92aWRlcnMvTWljcm9zb2Z0LlJlc291cmNlcy9kZXBsb3ltZW50cy9jc2hhcnBzZGt0ZXN0ODE5NT9hcGktdmVyc2lvbj0yMDE5LTA3LTAx", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"East US 2\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"variables\": {\r\n \"managementGroupScope\": \"[concat('Microsoft.Management/managementGroups/', parameters('managementGroupId'))]\",\r\n \"managementGroupFullyQualifiedId\": \"[concat('/providers/', variables('managementGroupScope'))]\"\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/roleDefinitions\",\r\n \"name\": \"[parameters('roleDefinitionId')]\",\r\n \"apiVersion\": \"2018-07-01\",\r\n \"properties\": {\r\n \"roleName\": \"Tiano SDK Test Role\",\r\n \"description\": \"something\",\r\n \"type\": \"CustomRole\",\r\n \"permissions\": [\r\n {\r\n \"actions\": [\r\n \"Microsoft.Storage/*/read\"\r\n ],\r\n \"notActions\": []\r\n }\r\n ],\r\n \"assignableScopes\": [\r\n \"[variables('managementGroupFullyQualifiedId')]\"\r\n ]\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"mg-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"West US\",\r\n \"scope\": \"[variables('managementGroupScope')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"sub-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US\",\r\n \"subscriptionId\": \"[parameters('subscriptionId')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"name\": \"sdk-testrg\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US 2\",\r\n \"properties\": {}\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"value\": \"tiano-mgtest01\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "f346854b-89c5-402c-8a3d-7dd03c605a49" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "3898" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:36:26 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Azure-AsyncOperation": [ + "https://management.azure.com/providers/Microsoft.Resources/deployments/csharpsdktest8195/operationStatuses/08586364759006983376?api-version=2019-07-01" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "82753aec-f6f2-4ada-9d7c-8e871ffea97e" + ], + "x-ms-correlation-request-id": [ + "82753aec-f6f2-4ada-9d7c-8e871ffea97e" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T223626Z:82753aec-f6f2-4ada-9d7c-8e871ffea97e" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "892" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195\",\r\n \"name\": \"csharpsdktest8195\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Accepted\",\r\n \"timestamp\": \"2019-08-06T22:36:26.2548963Z\",\r\n \"duration\": \"PT1.4756145S\",\r\n \"correlationId\": \"82753aec-f6f2-4ada-9d7c-8e871ffea97e\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": []\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest8195/operationStatuses/08586364759006983376?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q4MTk1L29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzU5MDA2OTgzMzc2P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:36:56 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "d1e69bd9-a029-42cf-b1e7-406a431bf3f3" + ], + "x-ms-correlation-request-id": [ + "d1e69bd9-a029-42cf-b1e7-406a431bf3f3" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T223656Z:d1e69bd9-a029-42cf-b1e7-406a431bf3f3" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "20" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Running\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest8195/operationStatuses/08586364759006983376?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3Q4MTk1L29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzU5MDA2OTgzMzc2P2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:37:26 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11998" + ], + "x-ms-request-id": [ + "a358dec7-16d5-48c7-846a-f3f2cd4a53d8" + ], + "x-ms-correlation-request-id": [ + "a358dec7-16d5-48c7-846a-f3f2cd4a53d8" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T223727Z:a358dec7-16d5-48c7-846a-f3f2cd4a53d8" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "22" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Succeeded\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "//providers/Microsoft.Resources/deployments/csharpsdktest8195?api-version=2019-07-01", + "EncodedRequestUri": "Ly9wcm92aWRlcnMvTWljcm9zb2Z0LlJlc291cmNlcy9kZXBsb3ltZW50cy9jc2hhcnBzZGt0ZXN0ODE5NT9hcGktdmVyc2lvbj0yMDE5LTA3LTAx", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:37:26 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11997" + ], + "x-ms-request-id": [ + "80afa4cb-2dd7-470a-b45b-657983ce111b" + ], + "x-ms-correlation-request-id": [ + "80afa4cb-2dd7-470a-b45b-657983ce111b" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T223727Z:80afa4cb-2dd7-470a-b45b-657983ce111b" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1231" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195\",\r\n \"name\": \"csharpsdktest8195\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:37:00.8939749Z\",\r\n \"duration\": \"PT36.1146931S\",\r\n \"correlationId\": \"82753aec-f6f2-4ada-9d7c-8e871ffea97e\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/resourceGroups/sdk-testrg\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "//providers/Microsoft.Resources/deployments/csharpsdktest8195?api-version=2019-07-01", + "EncodedRequestUri": "Ly9wcm92aWRlcnMvTWljcm9zb2Z0LlJlc291cmNlcy9kZXBsb3ltZW50cy9jc2hhcnBzZGt0ZXN0ODE5NT9hcGktdmVyc2lvbj0yMDE5LTA3LTAx", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "6ef123d5-fa77-43d9-90eb-c6f6f7d96e93" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:37:26 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11996" + ], + "x-ms-request-id": [ + "fb56ae9a-e286-495d-accc-662657209bc8" + ], + "x-ms-correlation-request-id": [ + "fb56ae9a-e286-495d-accc-662657209bc8" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T223727Z:fb56ae9a-e286-495d-accc-662657209bc8" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1231" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195\",\r\n \"name\": \"csharpsdktest8195\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:37:00.8939749Z\",\r\n \"duration\": \"PT36.1146931S\",\r\n \"correlationId\": \"82753aec-f6f2-4ada-9d7c-8e871ffea97e\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/resourceGroups/sdk-testrg\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "//providers/Microsoft.Resources/deployments/csharpsdktest8195/operations?api-version=2019-07-01", + "EncodedRequestUri": "Ly9wcm92aWRlcnMvTWljcm9zb2Z0LlJlc291cmNlcy9kZXBsb3ltZW50cy9jc2hhcnBzZGt0ZXN0ODE5NS9vcGVyYXRpb25zP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "c38fd3d9-207a-415f-81ab-c68651559774" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:37:26 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11995" + ], + "x-ms-request-id": [ + "1376dda2-eaa1-4343-ada7-f5180a2a0276" + ], + "x-ms-correlation-request-id": [ + "1376dda2-eaa1-4343-ada7-f5180a2a0276" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T223727Z:1376dda2-eaa1-4343-ada7-f5180a2a0276" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "2290" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195/operations/55C3F6D29BAA5001\",\r\n \"operationId\": \"55C3F6D29BAA5001\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:36:58.1338698Z\",\r\n \"duration\": \"PT28.3147437S\",\r\n \"trackingId\": \"1924866d-f5fd-4a2f-87d9-f1d3a746f208\",\r\n \"serviceRequestId\": \"740dbbcc-6e4f-4098-8b66-674c5268fcf1\",\r\n \"statusCode\": \"OK\",\r\n \"targetResource\": {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/mg-nested\",\r\n \"resourceType\": \"Microsoft.Resources/deployments\",\r\n \"resourceName\": \"mg-nested\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195/operations/1861FE2FF8A6CC60\",\r\n \"operationId\": \"1861FE2FF8A6CC60\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:36:31.0682498Z\",\r\n \"duration\": \"PT1.2491237S\",\r\n \"trackingId\": \"ee64a4b6-3c57-4723-8b06-b4d4021096aa\",\r\n \"serviceRequestId\": \"3d595bcc-9661-4311-a014-d56f3d6b9b4b\",\r\n \"statusCode\": \"Created\",\r\n \"targetResource\": {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\",\r\n \"resourceType\": \"Microsoft.Authorization/roleDefinitions\",\r\n \"resourceName\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195/operations/591DE40DACECA9F1\",\r\n \"operationId\": \"591DE40DACECA9F1\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:37:00.7211973Z\",\r\n \"duration\": \"PT30.9020712S\",\r\n \"trackingId\": \"0cc8ce7d-9bdb-4187-b017-0cbb712d6146\",\r\n \"serviceRequestId\": \"5230790f-3124-48b4-85e8-2b47f64958a1\",\r\n \"statusCode\": \"OK\",\r\n \"targetResource\": {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/providers/Microsoft.Resources/deployments/sub-nested\",\r\n \"resourceType\": \"Microsoft.Resources/deployments\",\r\n \"resourceName\": \"sub-nested\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest8195/operations/08586364759006983376\",\r\n \"operationId\": \"08586364759006983376\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"EvaluateDeploymentOutput\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:37:00.8767461Z\",\r\n \"duration\": \"PT0.1053389S\",\r\n \"trackingId\": \"0e201f85-e339-480d-b3bb-645249ad4ec1\",\r\n \"statusCode\": \"OK\",\r\n \"statusMessage\": null\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": { + "DeploymentWithScope_AtTenant": [ + "csharpsdktest8195" + ] + }, + "Variables": { + "SubscriptionId": "89ec4d1d-dcc7-4a3f-a701-0a5d074c8505" + } +} \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/TenantLevelDeployment.json b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/TenantLevelDeployment.json new file mode 100644 index 000000000000..f3620300b4ee --- /dev/null +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/SessionRecords/ResourceGroups.Tests.LiveDeploymentTests/TenantLevelDeployment.json @@ -0,0 +1,429 @@ +{ + "Entries": [ + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest2450/validate?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3QyNDUwL3ZhbGlkYXRlP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "POST", + "RequestBody": "{\r\n \"location\": \"East US 2\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"variables\": {\r\n \"managementGroupScope\": \"[concat('Microsoft.Management/managementGroups/', parameters('managementGroupId'))]\",\r\n \"managementGroupFullyQualifiedId\": \"[concat('/providers/', variables('managementGroupScope'))]\"\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/roleDefinitions\",\r\n \"name\": \"[parameters('roleDefinitionId')]\",\r\n \"apiVersion\": \"2018-07-01\",\r\n \"properties\": {\r\n \"roleName\": \"Tiano SDK Test Role\",\r\n \"description\": \"something\",\r\n \"type\": \"CustomRole\",\r\n \"permissions\": [\r\n {\r\n \"actions\": [\r\n \"Microsoft.Storage/*/read\"\r\n ],\r\n \"notActions\": []\r\n }\r\n ],\r\n \"assignableScopes\": [\r\n \"[variables('managementGroupFullyQualifiedId')]\"\r\n ]\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"mg-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"West US\",\r\n \"scope\": \"[variables('managementGroupScope')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"sub-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US\",\r\n \"subscriptionId\": \"[parameters('subscriptionId')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"name\": \"sdk-testrg\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US 2\",\r\n \"properties\": {}\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"value\": \"tiano-mgtest01\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "061361da-90c7-4ec4-b713-58497a27cae5" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "3898" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:21:21 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "89bbdc3f-3270-4659-9d00-05678281f7bc" + ], + "x-ms-correlation-request-id": [ + "89bbdc3f-3270-4659-9d00-05678281f7bc" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T222122Z:89bbdc3f-3270-4659-9d00-05678281f7bc" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1464" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450\",\r\n \"name\": \"csharpsdktest2450\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:21:21.5647756Z\",\r\n \"duration\": \"PT0S\",\r\n \"correlationId\": \"89bbdc3f-3270-4659-9d00-05678281f7bc\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"validatedResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/mg-nested\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/providers/Microsoft.Resources/deployments/sub-nested\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/resourceGroups/sdk-testrg\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest2450?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3QyNDUwP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"East US 2\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"variables\": {\r\n \"managementGroupScope\": \"[concat('Microsoft.Management/managementGroups/', parameters('managementGroupId'))]\",\r\n \"managementGroupFullyQualifiedId\": \"[concat('/providers/', variables('managementGroupScope'))]\"\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/roleDefinitions\",\r\n \"name\": \"[parameters('roleDefinitionId')]\",\r\n \"apiVersion\": \"2018-07-01\",\r\n \"properties\": {\r\n \"roleName\": \"Tiano SDK Test Role\",\r\n \"description\": \"something\",\r\n \"type\": \"CustomRole\",\r\n \"permissions\": [\r\n {\r\n \"actions\": [\r\n \"Microsoft.Storage/*/read\"\r\n ],\r\n \"notActions\": []\r\n }\r\n ],\r\n \"assignableScopes\": [\r\n \"[variables('managementGroupFullyQualifiedId')]\"\r\n ]\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"mg-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"West US\",\r\n \"scope\": \"[variables('managementGroupScope')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Authorization/policyDefinitions\",\r\n \"name\": \"policy2\",\r\n \"apiVersion\": \"2016-12-01\",\r\n \"properties\": {\r\n \"policyType\": \"Custom\",\r\n \"parameters\": {},\r\n \"policyRule\": {\r\n \"if\": {\r\n \"field\": \"location\",\r\n \"equals\": \"northeurope\"\r\n },\r\n \"then\": {\r\n \"effect\": \"deny\"\r\n }\r\n }\r\n }\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n },\r\n {\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"name\": \"sub-nested\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US\",\r\n \"subscriptionId\": \"[parameters('subscriptionId')]\",\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {},\r\n \"variables\": {},\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"name\": \"sdk-testrg\",\r\n \"apiVersion\": \"2019-07-01\",\r\n \"location\": \"East US 2\",\r\n \"properties\": {}\r\n }\r\n ]\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n }\r\n ]\r\n },\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"value\": \"tiano-mgtest01\"\r\n }\r\n },\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestHeaders": { + "x-ms-client-request-id": [ + "eb8361e8-b082-4c1b-b72b-f767526c2d37" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "3898" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:21:23 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Azure-AsyncOperation": [ + "https://management.azure.com/providers/Microsoft.Resources/deployments/csharpsdktest2450/operationStatuses/08586364768032509123?api-version=2019-07-01" + ], + "x-ms-ratelimit-remaining-tenant-writes": [ + "1199" + ], + "x-ms-request-id": [ + "1cd28730-875d-4568-8cae-133728e0c934" + ], + "x-ms-correlation-request-id": [ + "1cd28730-875d-4568-8cae-133728e0c934" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T222124Z:1cd28730-875d-4568-8cae-133728e0c934" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "892" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450\",\r\n \"name\": \"csharpsdktest2450\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Accepted\",\r\n \"timestamp\": \"2019-08-06T22:21:23.7201875Z\",\r\n \"duration\": \"PT1.4934711S\",\r\n \"correlationId\": \"1cd28730-875d-4568-8cae-133728e0c934\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": []\r\n }\r\n}", + "StatusCode": 201 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest2450/operationStatuses/08586364768032509123?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3QyNDUwL29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzY4MDMyNTA5MTIzP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:21:53 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11999" + ], + "x-ms-request-id": [ + "08bca4a0-5915-458c-a683-107e67671334" + ], + "x-ms-correlation-request-id": [ + "08bca4a0-5915-458c-a683-107e67671334" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T222154Z:08bca4a0-5915-458c-a683-107e67671334" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "20" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Running\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest2450/operationStatuses/08586364768032509123?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3QyNDUwL29wZXJhdGlvblN0YXR1c2VzLzA4NTg2MzY0NzY4MDMyNTA5MTIzP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:22:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11998" + ], + "x-ms-request-id": [ + "dd6e59a1-51e7-4a3e-ab0d-87ef16e4b4a5" + ], + "x-ms-correlation-request-id": [ + "dd6e59a1-51e7-4a3e-ab0d-87ef16e4b4a5" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T222224Z:dd6e59a1-51e7-4a3e-ab0d-87ef16e4b4a5" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "22" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"status\": \"Succeeded\"\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest2450?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3QyNDUwP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:22:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11997" + ], + "x-ms-request-id": [ + "1ef46b4e-9370-430d-bc82-f7d7041204f7" + ], + "x-ms-correlation-request-id": [ + "1ef46b4e-9370-430d-bc82-f7d7041204f7" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T222224Z:1ef46b4e-9370-430d-bc82-f7d7041204f7" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1231" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450\",\r\n \"name\": \"csharpsdktest2450\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:22:01.5544449Z\",\r\n \"duration\": \"PT39.3277285S\",\r\n \"correlationId\": \"1cd28730-875d-4568-8cae-133728e0c934\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/resourceGroups/sdk-testrg\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest2450?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3QyNDUwP2FwaS12ZXJzaW9uPTIwMTktMDctMDE=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "0a600012-e42f-41b3-8b54-fb9dc76fb549" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:22:24 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11996" + ], + "x-ms-request-id": [ + "5c9a338e-3db3-47e9-9bd9-fac5c42d0f31" + ], + "x-ms-correlation-request-id": [ + "5c9a338e-3db3-47e9-9bd9-fac5c42d0f31" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T222224Z:5c9a338e-3db3-47e9-9bd9-fac5c42d0f31" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "1231" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450\",\r\n \"name\": \"csharpsdktest2450\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"location\": \"eastus2\",\r\n \"properties\": {\r\n \"templateHash\": \"12707336783073826175\",\r\n \"parameters\": {\r\n \"managementGroupId\": {\r\n \"type\": \"String\",\r\n \"value\": \"tiano-mgtest01\"\r\n },\r\n \"subscriptionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"89ec4d1d-dcc7-4a3f-a701-0a5d074c8505\"\r\n },\r\n \"roleDefinitionId\": {\r\n \"type\": \"String\",\r\n \"value\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:22:01.5544449Z\",\r\n \"duration\": \"PT39.3277285S\",\r\n \"correlationId\": \"1cd28730-875d-4568-8cae-133728e0c934\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Authorization\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"roleDefinitions\",\r\n \"locations\": [\r\n null\r\n ]\r\n }\r\n ]\r\n },\r\n {\r\n \"namespace\": \"Microsoft.Resources\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"deployments\",\r\n \"locations\": [\r\n \"westus\",\r\n \"eastus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"outputResources\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Authorization/policyDefinitions/policy2\"\r\n },\r\n {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/resourceGroups/sdk-testrg\"\r\n }\r\n ]\r\n }\r\n}", + "StatusCode": 200 + }, + { + "RequestUri": "/providers/Microsoft.Resources/deployments/csharpsdktest2450/operations?api-version=2019-07-01", + "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuUmVzb3VyY2VzL2RlcGxveW1lbnRzL2NzaGFycHNka3Rlc3QyNDUwL29wZXJhdGlvbnM/YXBpLXZlcnNpb249MjAxOS0wNy0wMQ==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "57b32117-ebbe-4142-bdfe-99d2973f88e0" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.26328.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.17134.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/2.1.0.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Tue, 06 Aug 2019 22:22:25 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-tenant-reads": [ + "11995" + ], + "x-ms-request-id": [ + "3cba49bc-9a12-4ede-9a84-b8323ba9a807" + ], + "x-ms-correlation-request-id": [ + "3cba49bc-9a12-4ede-9a84-b8323ba9a807" + ], + "x-ms-routing-request-id": [ + "WESTUS:20190806T222225Z:3cba49bc-9a12-4ede-9a84-b8323ba9a807" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Content-Length": [ + "2288" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450/operations/55C3F6D29BAA5001\",\r\n \"operationId\": \"55C3F6D29BAA5001\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:22:01.434554Z\",\r\n \"duration\": \"PT34.0685295S\",\r\n \"trackingId\": \"d41ae2d7-f781-4bcf-a23f-b4e05735159d\",\r\n \"serviceRequestId\": \"a278e85e-2671-4f95-a76c-8bdd3b76293c\",\r\n \"statusCode\": \"OK\",\r\n \"targetResource\": {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/tiano-mgtest01/providers/Microsoft.Resources/deployments/mg-nested\",\r\n \"resourceType\": \"Microsoft.Resources/deployments\",\r\n \"resourceName\": \"mg-nested\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450/operations/591DE40DACECA9F1\",\r\n \"operationId\": \"591DE40DACECA9F1\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:21:52.762146Z\",\r\n \"duration\": \"PT25.3961215S\",\r\n \"trackingId\": \"01784f91-d1d0-47e0-8eaf-47788888ce2a\",\r\n \"serviceRequestId\": \"4c2f5803-fd47-4d52-8c0d-6308950afeec\",\r\n \"statusCode\": \"OK\",\r\n \"targetResource\": {\r\n \"id\": \"/subscriptions/89ec4d1d-dcc7-4a3f-a701-0a5d074c8505/providers/Microsoft.Resources/deployments/sub-nested\",\r\n \"resourceType\": \"Microsoft.Resources/deployments\",\r\n \"resourceName\": \"sub-nested\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450/operations/1861FE2FF8A6CC60\",\r\n \"operationId\": \"1861FE2FF8A6CC60\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"Create\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:21:28.5517748Z\",\r\n \"duration\": \"PT1.1857503S\",\r\n \"trackingId\": \"b11e355f-0c2d-408c-9691-d93d416bbd4e\",\r\n \"serviceRequestId\": \"fc624a7d-aae6-4ec8-878f-d0585bf937a4\",\r\n \"statusCode\": \"Created\",\r\n \"targetResource\": {\r\n \"id\": \"/providers/Microsoft.Authorization/roleDefinitions/0cb07228-4614-4814-ac1a-c4e39793ce59\",\r\n \"resourceType\": \"Microsoft.Authorization/roleDefinitions\",\r\n \"resourceName\": \"0cb07228-4614-4814-ac1a-c4e39793ce59\"\r\n }\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Resources/deployments/csharpsdktest2450/operations/08586364768032509123\",\r\n \"operationId\": \"08586364768032509123\",\r\n \"properties\": {\r\n \"provisioningOperation\": \"EvaluateDeploymentOutput\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2019-08-06T22:22:01.5360585Z\",\r\n \"duration\": \"PT0.0692769S\",\r\n \"trackingId\": \"d4af9cb1-22d8-42a8-ad1b-1adb80fa2f17\",\r\n \"statusCode\": \"OK\",\r\n \"statusMessage\": null\r\n }\r\n }\r\n ]\r\n}", + "StatusCode": 200 + } + ], + "Names": { + "TenantLevelDeployment": [ + "csharpsdktest2450" + ] + }, + "Variables": { + "SubscriptionId": "89ec4d1d-dcc7-4a3f-a701-0a5d074c8505" + } +} \ No newline at end of file From 605c9c55f6b12ccf7ff70f6137626ec2d6368965 Mon Sep 17 00:00:00 2001 From: Tian Ouyang Date: Wed, 7 Aug 2019 22:57:11 +0000 Subject: [PATCH 2/2] Fix. --- .../AzSdk.RP.props | 2 +- .../AzSdk.RP.props | 2 +- .../AzSdk.RP.props | 2 +- ...crosoft.Azure.Management.ResourceManager.csproj | 4 ++-- .../src/Properties/AssemblyInfo.cs | 2 +- ...icrosoft.Azure.Management.Resource.Tests.csproj | 14 +------------- 6 files changed, 7 insertions(+), 19 deletions(-) diff --git a/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props b/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props index 18663f026f3a..39645fa6dc05 100644 --- a/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props +++ b/sdk/attestation/Microsoft.Azure.Management.Attestation/AzSdk.RP.props @@ -1,7 +1,7 @@ - Attestation_2018-09-01-preview; + $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props b/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props index e7c4a3c5c92a..eaa19d759acb 100644 --- a/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props +++ b/sdk/azurestack/Microsoft.AzureStack.Management.Fabric.Admin/AzSdk.RP.props @@ -1,7 +1,7 @@ - Fabric.Admin_2016-05-01; + Fabric.Admin_2018-10-01;Fabric.Admin_2016-05-01; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props b/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props index ef440086fa07..3d2b4e3b39d7 100644 --- a/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props +++ b/sdk/compute/Microsoft.Azure.Management.Compute/AzSdk.RP.props @@ -1,7 +1,7 @@  - Compute_2019-03-01;Compute_2018-09-30;Compute_2019-07-01;Compute_2019-04-01;ContainerService_2017-01-31; + Compute_2019-03-01;Compute_2018-09-30;Compute_2019-04-01;ContainerService_2017-01-31; $(PackageTags);$(CommonTags);$(AzureApiTag); \ No newline at end of file diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Microsoft.Azure.Management.ResourceManager.csproj b/sdk/resources/Microsoft.Azure.Management.Resource/src/Microsoft.Azure.Management.ResourceManager.csproj index fc5fc0d1a7d2..3855eefcf67c 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Microsoft.Azure.Management.ResourceManager.csproj +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Microsoft.Azure.Management.ResourceManager.csproj @@ -7,11 +7,11 @@ Microsoft.Azure.Management.ResourceManager Provides resource group and resource management capabilities for Microsoft Azure. Microsoft.Azure.Management.ResourceManager - 2.2.0-preview + 2.3.0-preview Microsoft Azure resource management;resource management;resource groups; diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/src/Properties/AssemblyInfo.cs b/sdk/resources/Microsoft.Azure.Management.Resource/src/Properties/AssemblyInfo.cs index 5010cb67f8a2..2961a88fce9b 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/src/Properties/AssemblyInfo.cs +++ b/sdk/resources/Microsoft.Azure.Management.Resource/src/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ [assembly: AssemblyDescription("Provides Microsoft Azure resource management operations including Resource Groups.")] [assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.1.0.0")] +[assembly: AssemblyFileVersion("2.3.0.0")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Azure .NET SDK")] diff --git a/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj b/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj index fb4f3858f7a5..fad0d1ca237e 100644 --- a/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj +++ b/sdk/resources/Microsoft.Azure.Management.Resource/tests/Microsoft.Azure.Management.Resource.Tests.csproj @@ -29,19 +29,7 @@ - - PreserveNewest - - - PreserveNewest - - - Always - - - Always - - + Always