diff --git a/src/ResourceManager/ResourceManager.csproj b/src/ResourceManager/ResourceManager.csproj
index af0affccf4..e763c8cd0f 100644
--- a/src/ResourceManager/ResourceManager.csproj
+++ b/src/ResourceManager/ResourceManager.csproj
@@ -52,159 +52,160 @@
true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
True
True
Resources.resx
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ResourceManager/AccessTokenExtensions.cs b/src/ResourceManager/Version2016_09_01/AccessTokenExtensions.cs
similarity index 100%
rename from src/ResourceManager/AccessTokenExtensions.cs
rename to src/ResourceManager/Version2016_09_01/AccessTokenExtensions.cs
diff --git a/src/ResourceManager/ArgumentCompleters/LocationCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/LocationCompleter.cs
similarity index 100%
rename from src/ResourceManager/ArgumentCompleters/LocationCompleter.cs
rename to src/ResourceManager/Version2016_09_01/ArgumentCompleters/LocationCompleter.cs
diff --git a/src/ResourceManager/ArgumentCompleters/PSArgumentCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/PSArgumentCompleter.cs
similarity index 100%
rename from src/ResourceManager/ArgumentCompleters/PSArgumentCompleter.cs
rename to src/ResourceManager/Version2016_09_01/ArgumentCompleters/PSArgumentCompleter.cs
diff --git a/src/ResourceManager/ArgumentCompleters/ResourceGroupCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceGroupCompleter.cs
similarity index 100%
rename from src/ResourceManager/ArgumentCompleters/ResourceGroupCompleter.cs
rename to src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceGroupCompleter.cs
diff --git a/src/ResourceManager/ArgumentCompleters/ResourceIdCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceIdCompleter.cs
similarity index 100%
rename from src/ResourceManager/ArgumentCompleters/ResourceIdCompleter.cs
rename to src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceIdCompleter.cs
diff --git a/src/ResourceManager/ArgumentCompleters/ResourceNameCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceNameCompleter.cs
similarity index 100%
rename from src/ResourceManager/ArgumentCompleters/ResourceNameCompleter.cs
rename to src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceNameCompleter.cs
diff --git a/src/ResourceManager/ArgumentCompleters/ResourceTypeCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceTypeCompleter.cs
similarity index 100%
rename from src/ResourceManager/ArgumentCompleters/ResourceTypeCompleter.cs
rename to src/ResourceManager/Version2016_09_01/ArgumentCompleters/ResourceTypeCompleter.cs
diff --git a/src/ResourceManager/ArgumentCompleters/ScopeCompleter.cs b/src/ResourceManager/Version2016_09_01/ArgumentCompleters/ScopeCompleter.cs
similarity index 100%
rename from src/ResourceManager/ArgumentCompleters/ScopeCompleter.cs
rename to src/ResourceManager/Version2016_09_01/ArgumentCompleters/ScopeCompleter.cs
diff --git a/src/ResourceManager/AzureRMCmdlet.cs b/src/ResourceManager/Version2016_09_01/AzureRMCmdlet.cs
similarity index 100%
rename from src/ResourceManager/AzureRMCmdlet.cs
rename to src/ResourceManager/Version2016_09_01/AzureRMCmdlet.cs
diff --git a/src/ResourceManager/AzureRMConstants.cs b/src/ResourceManager/Version2016_09_01/AzureRMConstants.cs
similarity index 100%
rename from src/ResourceManager/AzureRMConstants.cs
rename to src/ResourceManager/Version2016_09_01/AzureRMConstants.cs
diff --git a/src/ResourceManager/AzureRmLongRunningCmdlet.cs b/src/ResourceManager/Version2016_09_01/AzureRmLongRunningCmdlet.cs
similarity index 100%
rename from src/ResourceManager/AzureRmLongRunningCmdlet.cs
rename to src/ResourceManager/Version2016_09_01/AzureRmLongRunningCmdlet.cs
diff --git a/src/ResourceManager/AzureRmProfileProvider.cs b/src/ResourceManager/Version2016_09_01/AzureRmProfileProvider.cs
similarity index 100%
rename from src/ResourceManager/AzureRmProfileProvider.cs
rename to src/ResourceManager/Version2016_09_01/AzureRmProfileProvider.cs
diff --git a/src/ResourceManager/Generated/DeploymentOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/DeploymentOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/DeploymentOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/DeploymentOperations.cs
diff --git a/src/ResourceManager/Generated/DeploymentOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/DeploymentOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/DeploymentOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/DeploymentOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/DeploymentsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/DeploymentsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/DeploymentsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/DeploymentsOperations.cs
diff --git a/src/ResourceManager/Generated/DeploymentsOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/DeploymentsOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/DeploymentsOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/DeploymentsOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/FeatureClient.cs b/src/ResourceManager/Version2016_09_01/Generated/FeatureClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/FeatureClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/FeatureClient.cs
diff --git a/src/ResourceManager/Generated/FeaturesOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/FeaturesOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/FeaturesOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/FeaturesOperations.cs
diff --git a/src/ResourceManager/Generated/FeaturesOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/FeaturesOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/FeaturesOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/FeaturesOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/IDeploymentOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IDeploymentOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IDeploymentOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IDeploymentOperations.cs
diff --git a/src/ResourceManager/Generated/IDeploymentsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IDeploymentsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IDeploymentsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IDeploymentsOperations.cs
diff --git a/src/ResourceManager/Generated/IFeatureClient.cs b/src/ResourceManager/Version2016_09_01/Generated/IFeatureClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/IFeatureClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IFeatureClient.cs
diff --git a/src/ResourceManager/Generated/IFeaturesOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IFeaturesOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IFeaturesOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IFeaturesOperations.cs
diff --git a/src/ResourceManager/Generated/IManagementLinkClient.cs b/src/ResourceManager/Version2016_09_01/Generated/IManagementLinkClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/IManagementLinkClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IManagementLinkClient.cs
diff --git a/src/ResourceManager/Generated/IManagementLockClient.cs b/src/ResourceManager/Version2016_09_01/Generated/IManagementLockClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/IManagementLockClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IManagementLockClient.cs
diff --git a/src/ResourceManager/Generated/IManagementLocksOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IManagementLocksOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IManagementLocksOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IManagementLocksOperations.cs
diff --git a/src/ResourceManager/Generated/IPolicyAssignmentsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IPolicyAssignmentsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IPolicyAssignmentsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IPolicyAssignmentsOperations.cs
diff --git a/src/ResourceManager/Generated/IPolicyClient.cs b/src/ResourceManager/Version2016_09_01/Generated/IPolicyClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/IPolicyClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IPolicyClient.cs
diff --git a/src/ResourceManager/Generated/IPolicyDefinitionsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IPolicyDefinitionsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IPolicyDefinitionsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IPolicyDefinitionsOperations.cs
diff --git a/src/ResourceManager/Generated/IProvidersOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IProvidersOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IProvidersOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IProvidersOperations.cs
diff --git a/src/ResourceManager/Generated/IResourceGroupsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IResourceGroupsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IResourceGroupsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IResourceGroupsOperations.cs
diff --git a/src/ResourceManager/Generated/IResourceLinksOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IResourceLinksOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IResourceLinksOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IResourceLinksOperations.cs
diff --git a/src/ResourceManager/Generated/IResourceManagementClient.cs b/src/ResourceManager/Version2016_09_01/Generated/IResourceManagementClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/IResourceManagementClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IResourceManagementClient.cs
diff --git a/src/ResourceManager/Generated/IResourcesOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/IResourcesOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/IResourcesOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/IResourcesOperations.cs
diff --git a/src/ResourceManager/Generated/ISubscriptionClient.cs b/src/ResourceManager/Version2016_09_01/Generated/ISubscriptionClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/ISubscriptionClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ISubscriptionClient.cs
diff --git a/src/ResourceManager/Generated/ISubscriptionsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ISubscriptionsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ISubscriptionsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ISubscriptionsOperations.cs
diff --git a/src/ResourceManager/Generated/ITagsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ITagsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ITagsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ITagsOperations.cs
diff --git a/src/ResourceManager/Generated/ITenantsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ITenantsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ITenantsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ITenantsOperations.cs
diff --git a/src/ResourceManager/Generated/ManagementLinkClient.cs b/src/ResourceManager/Version2016_09_01/Generated/ManagementLinkClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/ManagementLinkClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ManagementLinkClient.cs
diff --git a/src/ResourceManager/Generated/ManagementLockClient.cs b/src/ResourceManager/Version2016_09_01/Generated/ManagementLockClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/ManagementLockClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ManagementLockClient.cs
diff --git a/src/ResourceManager/Generated/ManagementLocksOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ManagementLocksOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ManagementLocksOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ManagementLocksOperations.cs
diff --git a/src/ResourceManager/Generated/ManagementLocksOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/ManagementLocksOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/ManagementLocksOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ManagementLocksOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/Models/AliasPathType.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/AliasPathType.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/AliasPathType.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/AliasPathType.cs
diff --git a/src/ResourceManager/Generated/Models/AliasType.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/AliasType.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/AliasType.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/AliasType.cs
diff --git a/src/ResourceManager/Generated/Models/BasicDependency.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/BasicDependency.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/BasicDependency.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/BasicDependency.cs
diff --git a/src/ResourceManager/Generated/Models/DebugSetting.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DebugSetting.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DebugSetting.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DebugSetting.cs
diff --git a/src/ResourceManager/Generated/Models/Dependency.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Dependency.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Dependency.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Dependency.cs
diff --git a/src/ResourceManager/Generated/Models/Deployment.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Deployment.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Deployment.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Deployment.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentExportResult.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentExportResult.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentExportResult.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentExportResult.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentExtended.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentExtended.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentExtended.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentExtended.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentExtendedFilter.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentExtendedFilter.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentExtendedFilter.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentExtendedFilter.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentMode.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentMode.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentMode.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentMode.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentOperation.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentOperation.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentOperation.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentOperation.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentOperationProperties.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentOperationProperties.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentOperationProperties.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentOperationProperties.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentProperties.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentProperties.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentProperties.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentProperties.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentPropertiesExtended.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentPropertiesExtended.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentPropertiesExtended.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentPropertiesExtended.cs
diff --git a/src/ResourceManager/Generated/Models/DeploymentValidateResult.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentValidateResult.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/DeploymentValidateResult.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/DeploymentValidateResult.cs
diff --git a/src/ResourceManager/Generated/Models/ExportTemplateRequest.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ExportTemplateRequest.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ExportTemplateRequest.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ExportTemplateRequest.cs
diff --git a/src/ResourceManager/Generated/Models/FeatureProperties.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/FeatureProperties.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/FeatureProperties.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/FeatureProperties.cs
diff --git a/src/ResourceManager/Generated/Models/FeatureResult.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/FeatureResult.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/FeatureResult.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/FeatureResult.cs
diff --git a/src/ResourceManager/Generated/Models/Filter.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Filter.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Filter.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Filter.cs
diff --git a/src/ResourceManager/Generated/Models/GenericResource.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/GenericResource.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/GenericResource.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/GenericResource.cs
diff --git a/src/ResourceManager/Generated/Models/GenericResourceFilter.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/GenericResourceFilter.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/GenericResourceFilter.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/GenericResourceFilter.cs
diff --git a/src/ResourceManager/Generated/Models/HttpMessage.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/HttpMessage.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/HttpMessage.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/HttpMessage.cs
diff --git a/src/ResourceManager/Generated/Models/Identity.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Identity.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Identity.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Identity.cs
diff --git a/src/ResourceManager/Generated/Models/Location.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Location.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Location.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Location.cs
diff --git a/src/ResourceManager/Generated/Models/LockLevel.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/LockLevel.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/LockLevel.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/LockLevel.cs
diff --git a/src/ResourceManager/Generated/Models/ManagementLockObject.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ManagementLockObject.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ManagementLockObject.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ManagementLockObject.cs
diff --git a/src/ResourceManager/Generated/Models/ManagementLockOwner.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ManagementLockOwner.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ManagementLockOwner.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ManagementLockOwner.cs
diff --git a/src/ResourceManager/Generated/Models/Page.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Page.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Page.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Page.cs
diff --git a/src/ResourceManager/Generated/Models/Page1.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Page1.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Page1.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Page1.cs
diff --git a/src/ResourceManager/Generated/Models/PageEnumerable.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/PageEnumerable.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/PageEnumerable.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/PageEnumerable.cs
diff --git a/src/ResourceManager/Generated/Models/PageEnumerator.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/PageEnumerator.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/PageEnumerator.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/PageEnumerator.cs
diff --git a/src/ResourceManager/Generated/Models/ParametersLink.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ParametersLink.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ParametersLink.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ParametersLink.cs
diff --git a/src/ResourceManager/Generated/Models/Plan.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Plan.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Plan.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Plan.cs
diff --git a/src/ResourceManager/Generated/Models/PolicyAssignment.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/PolicyAssignment.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/PolicyAssignment.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/PolicyAssignment.cs
diff --git a/src/ResourceManager/Generated/Models/PolicyDefinition.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/PolicyDefinition.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/PolicyDefinition.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/PolicyDefinition.cs
diff --git a/src/ResourceManager/Generated/Models/Provider.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Provider.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Provider.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Provider.cs
diff --git a/src/ResourceManager/Generated/Models/ProviderResourceType.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ProviderResourceType.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ProviderResourceType.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ProviderResourceType.cs
diff --git a/src/ResourceManager/Generated/Models/RegistrationState.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/RegistrationState.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/RegistrationState.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/RegistrationState.cs
diff --git a/src/ResourceManager/Generated/Models/Resource.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Resource.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Resource.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Resource.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceGroup.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroup.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceGroup.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroup.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceGroupExportResult.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroupExportResult.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceGroupExportResult.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroupExportResult.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceGroupFilter.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroupFilter.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceGroupFilter.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroupFilter.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceGroupProperties.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroupProperties.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceGroupProperties.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceGroupProperties.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceIdentityType.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceIdentityType.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceIdentityType.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceIdentityType.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceLink.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceLink.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceLink.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceLink.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceLinkFilter.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceLinkFilter.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceLinkFilter.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceLinkFilter.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceLinkProperties.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceLinkProperties.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceLinkProperties.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceLinkProperties.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceManagementErrorWithDetails.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceManagementErrorWithDetails.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceManagementErrorWithDetails.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceManagementErrorWithDetails.cs
diff --git a/src/ResourceManager/Generated/Models/ResourceProviderOperationDisplayProperties.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourceProviderOperationDisplayProperties.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourceProviderOperationDisplayProperties.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourceProviderOperationDisplayProperties.cs
diff --git a/src/ResourceManager/Generated/Models/ResourcesMoveInfo.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/ResourcesMoveInfo.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/ResourcesMoveInfo.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/ResourcesMoveInfo.cs
diff --git a/src/ResourceManager/Generated/Models/Sku.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Sku.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Sku.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Sku.cs
diff --git a/src/ResourceManager/Generated/Models/SubResource.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/SubResource.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/SubResource.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/SubResource.cs
diff --git a/src/ResourceManager/Generated/Models/Subscription.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/Subscription.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/Subscription.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/Subscription.cs
diff --git a/src/ResourceManager/Generated/Models/SubscriptionPolicies.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/SubscriptionPolicies.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/SubscriptionPolicies.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/SubscriptionPolicies.cs
diff --git a/src/ResourceManager/Generated/Models/SubscriptionState.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/SubscriptionState.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/SubscriptionState.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/SubscriptionState.cs
diff --git a/src/ResourceManager/Generated/Models/TagCount.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/TagCount.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/TagCount.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/TagCount.cs
diff --git a/src/ResourceManager/Generated/Models/TagDetails.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/TagDetails.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/TagDetails.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/TagDetails.cs
diff --git a/src/ResourceManager/Generated/Models/TagValue.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/TagValue.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/TagValue.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/TagValue.cs
diff --git a/src/ResourceManager/Generated/Models/TargetResource.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/TargetResource.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/TargetResource.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/TargetResource.cs
diff --git a/src/ResourceManager/Generated/Models/TemplateLink.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/TemplateLink.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/TemplateLink.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/TemplateLink.cs
diff --git a/src/ResourceManager/Generated/Models/TenantIdDescription.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/TenantIdDescription.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/TenantIdDescription.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/TenantIdDescription.cs
diff --git a/src/ResourceManager/Generated/Models/policyType.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/policyType.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/policyType.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/policyType.cs
diff --git a/src/ResourceManager/Generated/Models/spendingLimit.cs b/src/ResourceManager/Version2016_09_01/Generated/Models/spendingLimit.cs
similarity index 100%
rename from src/ResourceManager/Generated/Models/spendingLimit.cs
rename to src/ResourceManager/Version2016_09_01/Generated/Models/spendingLimit.cs
diff --git a/src/ResourceManager/Generated/PolicyAssignmentsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/PolicyAssignmentsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/PolicyAssignmentsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/PolicyAssignmentsOperations.cs
diff --git a/src/ResourceManager/Generated/PolicyAssignmentsOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/PolicyAssignmentsOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/PolicyAssignmentsOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/PolicyAssignmentsOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/PolicyClient.cs b/src/ResourceManager/Version2016_09_01/Generated/PolicyClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/PolicyClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/PolicyClient.cs
diff --git a/src/ResourceManager/Generated/PolicyDefinitionsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/PolicyDefinitionsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/PolicyDefinitionsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/PolicyDefinitionsOperations.cs
diff --git a/src/ResourceManager/Generated/PolicyDefinitionsOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/PolicyDefinitionsOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/PolicyDefinitionsOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/PolicyDefinitionsOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/ProvidersOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ProvidersOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ProvidersOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ProvidersOperations.cs
diff --git a/src/ResourceManager/Generated/ProvidersOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/ProvidersOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/ProvidersOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ProvidersOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/ResourceGroupsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ResourceGroupsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ResourceGroupsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ResourceGroupsOperations.cs
diff --git a/src/ResourceManager/Generated/ResourceGroupsOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/ResourceGroupsOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/ResourceGroupsOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ResourceGroupsOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/ResourceLinksOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ResourceLinksOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ResourceLinksOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ResourceLinksOperations.cs
diff --git a/src/ResourceManager/Generated/ResourceLinksOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/ResourceLinksOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/ResourceLinksOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ResourceLinksOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/ResourceManagementClient.cs b/src/ResourceManager/Version2016_09_01/Generated/ResourceManagementClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/ResourceManagementClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ResourceManagementClient.cs
diff --git a/src/ResourceManager/Generated/ResourcesOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/ResourcesOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/ResourcesOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ResourcesOperations.cs
diff --git a/src/ResourceManager/Generated/ResourcesOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/ResourcesOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/ResourcesOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/ResourcesOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/SubscriptionClient.cs b/src/ResourceManager/Version2016_09_01/Generated/SubscriptionClient.cs
similarity index 100%
rename from src/ResourceManager/Generated/SubscriptionClient.cs
rename to src/ResourceManager/Version2016_09_01/Generated/SubscriptionClient.cs
diff --git a/src/ResourceManager/Generated/SubscriptionsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/SubscriptionsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/SubscriptionsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/SubscriptionsOperations.cs
diff --git a/src/ResourceManager/Generated/SubscriptionsOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/SubscriptionsOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/SubscriptionsOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/SubscriptionsOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/TagsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/TagsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/TagsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/TagsOperations.cs
diff --git a/src/ResourceManager/Generated/TagsOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/TagsOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/TagsOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/TagsOperationsExtensions.cs
diff --git a/src/ResourceManager/Generated/TenantsOperations.cs b/src/ResourceManager/Version2016_09_01/Generated/TenantsOperations.cs
similarity index 100%
rename from src/ResourceManager/Generated/TenantsOperations.cs
rename to src/ResourceManager/Version2016_09_01/Generated/TenantsOperations.cs
diff --git a/src/ResourceManager/Generated/TenantsOperationsExtensions.cs b/src/ResourceManager/Version2016_09_01/Generated/TenantsOperationsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Generated/TenantsOperationsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Generated/TenantsOperationsExtensions.cs
diff --git a/src/ResourceManager/GlobalSuppressions.cs b/src/ResourceManager/Version2016_09_01/GlobalSuppressions.cs
similarity index 100%
rename from src/ResourceManager/GlobalSuppressions.cs
rename to src/ResourceManager/Version2016_09_01/GlobalSuppressions.cs
diff --git a/src/ResourceManager/PaginatedResponseHelper.cs b/src/ResourceManager/Version2016_09_01/PaginatedResponseHelper.cs
similarity index 100%
rename from src/ResourceManager/PaginatedResponseHelper.cs
rename to src/ResourceManager/Version2016_09_01/PaginatedResponseHelper.cs
diff --git a/src/ResourceManager/Paging/GenericPageEnumerable.cs b/src/ResourceManager/Version2016_09_01/Paging/GenericPageEnumerable.cs
similarity index 100%
rename from src/ResourceManager/Paging/GenericPageEnumerable.cs
rename to src/ResourceManager/Version2016_09_01/Paging/GenericPageEnumerable.cs
diff --git a/src/ResourceManager/Paging/GenericPageEnumerator.cs b/src/ResourceManager/Version2016_09_01/Paging/GenericPageEnumerator.cs
similarity index 100%
rename from src/ResourceManager/Paging/GenericPageEnumerator.cs
rename to src/ResourceManager/Version2016_09_01/Paging/GenericPageEnumerator.cs
diff --git a/src/ResourceManager/RPRegistrationDelegatingHandler.cs b/src/ResourceManager/Version2016_09_01/RPRegistrationDelegatingHandler.cs
similarity index 100%
rename from src/ResourceManager/RPRegistrationDelegatingHandler.cs
rename to src/ResourceManager/Version2016_09_01/RPRegistrationDelegatingHandler.cs
diff --git a/src/ResourceManager/ResponseWithContinuation.cs b/src/ResourceManager/Version2016_09_01/ResponseWithContinuation.cs
similarity index 100%
rename from src/ResourceManager/ResponseWithContinuation.cs
rename to src/ResourceManager/Version2016_09_01/ResponseWithContinuation.cs
diff --git a/src/ResourceManager/ServiceClientTracingInterceptor.cs b/src/ResourceManager/Version2016_09_01/ServiceClientTracingInterceptor.cs
similarity index 100%
rename from src/ResourceManager/ServiceClientTracingInterceptor.cs
rename to src/ResourceManager/Version2016_09_01/ServiceClientTracingInterceptor.cs
diff --git a/src/ResourceManager/Tags/PSTag.cs b/src/ResourceManager/Version2016_09_01/Tags/PSTag.cs
similarity index 100%
rename from src/ResourceManager/Tags/PSTag.cs
rename to src/ResourceManager/Version2016_09_01/Tags/PSTag.cs
diff --git a/src/ResourceManager/Tags/PSTagValue.cs b/src/ResourceManager/Version2016_09_01/Tags/PSTagValue.cs
similarity index 100%
rename from src/ResourceManager/Tags/PSTagValue.cs
rename to src/ResourceManager/Version2016_09_01/Tags/PSTagValue.cs
diff --git a/src/ResourceManager/Tags/PSTagValuePair.cs b/src/ResourceManager/Version2016_09_01/Tags/PSTagValuePair.cs
similarity index 100%
rename from src/ResourceManager/Tags/PSTagValuePair.cs
rename to src/ResourceManager/Version2016_09_01/Tags/PSTagValuePair.cs
diff --git a/src/ResourceManager/Tags/TagsClient.cs b/src/ResourceManager/Version2016_09_01/Tags/TagsClient.cs
similarity index 100%
rename from src/ResourceManager/Tags/TagsClient.cs
rename to src/ResourceManager/Version2016_09_01/Tags/TagsClient.cs
diff --git a/src/ResourceManager/Tags/TagsConversionHelper.cs b/src/ResourceManager/Version2016_09_01/Tags/TagsConversionHelper.cs
similarity index 100%
rename from src/ResourceManager/Tags/TagsConversionHelper.cs
rename to src/ResourceManager/Version2016_09_01/Tags/TagsConversionHelper.cs
diff --git a/src/ResourceManager/Tags/TagsExtensions.cs b/src/ResourceManager/Version2016_09_01/Tags/TagsExtensions.cs
similarity index 100%
rename from src/ResourceManager/Tags/TagsExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Tags/TagsExtensions.cs
diff --git a/src/ResourceManager/Utilities/Models/DeploymentVariable.cs b/src/ResourceManager/Version2016_09_01/Utilities/Models/DeploymentVariable.cs
similarity index 100%
rename from src/ResourceManager/Utilities/Models/DeploymentVariable.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/Models/DeploymentVariable.cs
diff --git a/src/ResourceManager/Utilities/Models/FilterResourcesOptions.cs b/src/ResourceManager/Version2016_09_01/Utilities/Models/FilterResourcesOptions.cs
similarity index 100%
rename from src/ResourceManager/Utilities/Models/FilterResourcesOptions.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/Models/FilterResourcesOptions.cs
diff --git a/src/ResourceManager/Utilities/Models/GenericResource.cs b/src/ResourceManager/Version2016_09_01/Utilities/Models/GenericResource.cs
similarity index 100%
rename from src/ResourceManager/Utilities/Models/GenericResource.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/Models/GenericResource.cs
diff --git a/src/ResourceManager/Utilities/Models/Location.cs b/src/ResourceManager/Version2016_09_01/Utilities/Models/Location.cs
similarity index 100%
rename from src/ResourceManager/Utilities/Models/Location.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/Models/Location.cs
diff --git a/src/ResourceManager/Utilities/Models/ResourceGroupDeployment.cs b/src/ResourceManager/Version2016_09_01/Utilities/Models/ResourceGroupDeployment.cs
similarity index 100%
rename from src/ResourceManager/Utilities/Models/ResourceGroupDeployment.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/Models/ResourceGroupDeployment.cs
diff --git a/src/ResourceManager/Utilities/Models/ResourceIdentifier.cs b/src/ResourceManager/Version2016_09_01/Utilities/Models/ResourceIdentifier.cs
similarity index 100%
rename from src/ResourceManager/Utilities/Models/ResourceIdentifier.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/Models/ResourceIdentifier.cs
diff --git a/src/ResourceManager/Utilities/ResourceManagementClientExtensions.cs b/src/ResourceManager/Version2016_09_01/Utilities/ResourceManagementClientExtensions.cs
similarity index 100%
rename from src/ResourceManager/Utilities/ResourceManagementClientExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/ResourceManagementClientExtensions.cs
diff --git a/src/ResourceManager/Utilities/ResourcesExtensions.cs b/src/ResourceManager/Version2016_09_01/Utilities/ResourcesExtensions.cs
similarity index 100%
rename from src/ResourceManager/Utilities/ResourcesExtensions.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/ResourcesExtensions.cs
diff --git a/src/ResourceManager/Utilities/SubscriptionAndTenantHelper.cs b/src/ResourceManager/Version2016_09_01/Utilities/SubscriptionAndTenantHelper.cs
similarity index 100%
rename from src/ResourceManager/Utilities/SubscriptionAndTenantHelper.cs
rename to src/ResourceManager/Version2016_09_01/Utilities/SubscriptionAndTenantHelper.cs
diff --git a/src/ResourceManager/Version2018_05_01/DeploymentOperations.cs b/src/ResourceManager/Version2018_05_01/DeploymentOperations.cs
new file mode 100644
index 0000000000..536c0a6081
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/DeploymentOperations.cs
@@ -0,0 +1,1290 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// DeploymentOperations operations.
+ ///
+ internal partial class DeploymentOperations : IServiceOperations, IDeploymentOperations
+ {
+ ///
+ /// Initializes a new instance of the DeploymentOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal DeploymentOperations(ResourceManagementClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the ResourceManagementClient
+ ///
+ public ResourceManagementClient Client { get; private set; }
+
+ ///
+ /// 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 with the operation to get.
+ ///
+ ///
+ /// 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 with the operation to get.
+ ///
+ ///
+ /// 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>> ListAtSubscriptionScopeNextWithHttpMessagesAsync(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, "ListAtSubscriptionScopeNext", 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>> 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;
+ }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/DeploymentOperationsExtensions.cs b/src/ResourceManager/Version2018_05_01/DeploymentOperationsExtensions.cs
new file mode 100644
index 0000000000..07d2050012
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/DeploymentOperationsExtensions.cs
@@ -0,0 +1,265 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for DeploymentOperations.
+ ///
+ public static partial class DeploymentOperationsExtensions
+ {
+ ///
+ /// 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 GetAtSubscriptionScope(this IDeploymentOperations operations, string deploymentName, string operationId)
+ {
+ return operations.GetAtSubscriptionScopeAsync(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 GetAtSubscriptionScopeAsync(this IDeploymentOperations operations, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetAtSubscriptionScopeWithHttpMessagesAsync(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 with the operation to get.
+ ///
+ ///
+ /// The number of results to return.
+ ///
+ public static IPage ListAtSubscriptionScope(this IDeploymentOperations operations, string deploymentName, int? top = default(int?))
+ {
+ return operations.ListAtSubscriptionScopeAsync(deploymentName, top).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets all deployments operations for a deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the deployment with the operation to get.
+ ///
+ ///
+ /// The number of results to return.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAtSubscriptionScopeAsync(this IDeploymentOperations operations, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, top, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a deployments operation.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment.
+ ///
+ ///
+ /// The ID of the operation to get.
+ ///
+ public static DeploymentOperation Get(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, string operationId)
+ {
+ return operations.GetAsync(resourceGroupName, deploymentName, operationId).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets a deployments operation.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment.
+ ///
+ ///
+ /// The ID of the operation to get.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, string operationId, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, 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 resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment with the operation to get.
+ ///
+ ///
+ /// The number of results to return.
+ ///
+ public static IPage List(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, int? top = default(int?))
+ {
+ return operations.ListAsync(resourceGroupName, deploymentName, top).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets all deployments operations for a deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment with the operation to get.
+ ///
+ ///
+ /// The number of results to return.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, int? top = default(int?), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, deploymentName, top, 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 ListAtSubscriptionScopeNext(this IDeploymentOperations operations, string nextPageLink)
+ {
+ return operations.ListAtSubscriptionScopeNextAsync(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> ListAtSubscriptionScopeNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListAtSubscriptionScopeNextWithHttpMessagesAsync(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 ListNext(this IDeploymentOperations operations, string nextPageLink)
+ {
+ return operations.ListNextAsync(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> ListNextAsync(this IDeploymentOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/DeploymentsOperations.cs b/src/ResourceManager/Version2018_05_01/DeploymentsOperations.cs
new file mode 100644
index 0000000000..87c7d1718b
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/DeploymentsOperations.cs
@@ -0,0 +1,3992 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Azure.OData;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// DeploymentsOperations operations.
+ ///
+ internal partial class DeploymentsOperations : IServiceOperations, IDeploymentsOperations
+ {
+ ///
+ /// Initializes a new instance of the DeploymentsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal DeploymentsOperations(ResourceManagementClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the ResourceManagementClient
+ ///
+ public ResourceManagementClient Client { get; private set; }
+
+ ///
+ /// 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 to delete.
+ ///
+ ///
+ /// 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 to check.
+ ///
+ ///
+ /// 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> CheckExistenceAtSubscriptionScopeWithHttpMessagesAsync(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, "CheckExistenceAtSubscriptionScope", 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("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 && (int)_statusCode != 404)
+ {
+ 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;
+ _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();
+ }
+ 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.
+ ///
+ ///
+ /// 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 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, 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, "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}").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("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 resources partially deployed.
+ ///
+ ///
+ /// The name of the deployment to cancel.
+ ///
+ ///
+ /// 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 CancelAtSubscriptionScopeWithHttpMessagesAsync(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, "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}/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)
+ {
+ _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 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> ValidateAtSubscriptionScopeWithHttpMessagesAsync(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, "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}/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)
+ {
+ _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 && (int)_statusCode != 400)
+ {
+ 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 == 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);
+ }
+ return _result;
+ }
+
+ ///
+ /// Exports the template used for specified deployment.
+ ///
+ ///
+ /// The name of the deployment from which to get the template.
+ ///
+ ///
+ /// 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> ExportTemplateAtSubscriptionScopeWithHttpMessagesAsync(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, "ExportTemplateAtSubscriptionScope", 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();
+ _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 subscription.
+ ///
+ ///
+ /// 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>> ListAtSubscriptionScopeWithHttpMessagesAsync(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;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("odataQuery", odataQuery);
+ 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/").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)));
+ }
+ 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.
+ /// 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 to delete.
+ ///
+ ///
+ /// 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 to check.
+ ///
+ ///
+ /// 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)
+ {
+ 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 && (int)_statusCode != 404)
+ {
+ 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;
+ _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();
+ }
+ 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 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, 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 to cancel.
+ ///
+ ///
+ /// 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 && (int)_statusCode != 400)
+ {
+ 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 == 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);
+ }
+ 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 from which to get the template.
+ ///
+ ///
+ /// 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 name of the deployment to delete.
+ ///
+ ///
+ /// 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 to delete.
+ ///
+ ///
+ /// 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 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>> ListAtSubscriptionScopeNextWithHttpMessagesAsync(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, "ListAtSubscriptionScopeNext", 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 for a resource group.
+ ///
+ ///
+ /// 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>> ListByResourceGroupNextWithHttpMessagesAsync(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, "ListByResourceGroupNext", 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;
+ }
+
+ }
+}
diff --git a/src/ResourceManager/Version2018_05_01/DeploymentsOperationsExtensions.cs b/src/ResourceManager/Version2018_05_01/DeploymentsOperationsExtensions.cs
new file mode 100644
index 0000000000..2c452ea3af
--- /dev/null
+++ b/src/ResourceManager/Version2018_05_01/DeploymentsOperationsExtensions.cs
@@ -0,0 +1,1018 @@
+//
+// 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.Internal.ResourceManager.Version2018_05_01
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Azure.OData;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for DeploymentsOperations.
+ ///
+ 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 name of the deployment to delete.
+ ///
+ public static void DeleteAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName)
+ {
+ operations.DeleteAtSubscriptionScopeAsync(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 to delete.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.DeleteAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Checks whether the deployment exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the deployment to check.
+ ///
+ public static bool CheckExistenceAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName)
+ {
+ return operations.CheckExistenceAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Checks whether the deployment exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the deployment to check.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ 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;
+ }
+ }
+
+ ///
+ /// Deploys resources at subscription 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 CreateOrUpdateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters)
+ {
+ return operations.CreateOrUpdateAtSubscriptionScopeAsync(deploymentName, parameters).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Deploys resources at subscription 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 CreateOrUpdateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CreateOrUpdateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, parameters, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the deployment to get.
+ ///
+ public static DeploymentExtended GetAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName)
+ {
+ return operations.GetAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets a deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the deployment to get.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetAtSubscriptionScopeWithHttpMessagesAsync(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 to cancel.
+ ///
+ public static void CancelAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName)
+ {
+ operations.CancelAtSubscriptionScopeAsync(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 to cancel.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CancelAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.CancelAtSubscriptionScopeWithHttpMessagesAsync(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 ValidateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName, Deployment parameters)
+ {
+ return operations.ValidateAtSubscriptionScopeAsync(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 ValidateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ValidateAtSubscriptionScopeWithHttpMessagesAsync(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 from which to get the template.
+ ///
+ public static DeploymentExportResult ExportTemplateAtSubscriptionScope(this IDeploymentsOperations operations, string deploymentName)
+ {
+ return operations.ExportTemplateAtSubscriptionScopeAsync(deploymentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Exports the template used for specified deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the deployment from which to get the template.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ExportTemplateAtSubscriptionScopeAsync(this IDeploymentsOperations operations, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ExportTemplateAtSubscriptionScopeWithHttpMessagesAsync(deploymentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Get all the deployments for a subscription.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ public static IPage ListAtSubscriptionScope(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery))
+ {
+ return operations.ListAtSubscriptionScopeAsync(odataQuery).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get all the deployments for a subscription.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// OData parameters to apply to the operation.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAtSubscriptionScopeAsync(this IDeploymentsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListAtSubscriptionScopeWithHttpMessagesAsync(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.
+ /// 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 operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group with the deployment to delete. The name is
+ /// case insensitive.
+ ///
+ ///
+ /// The name of the deployment to delete.
+ ///
+ public static void Delete(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName)
+ {
+ operations.DeleteAsync(resourceGroupName, 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.
+ /// 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 operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group with the deployment to delete. The name is
+ /// case insensitive.
+ ///
+ ///
+ /// The name of the deployment to delete.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// Checks whether the deployment exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group with the deployment to check. The name is
+ /// case insensitive.
+ ///
+ ///
+ /// The name of the deployment to check.
+ ///
+ public static bool CheckExistence(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName)
+ {
+ return operations.CheckExistenceAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Checks whether the deployment exists.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group with the deployment to check. The name is
+ /// case insensitive.
+ ///
+ ///
+ /// The name of the deployment to check.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ 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;
+ }
+ }
+
+ ///
+ /// Deploys resources to a resource group.
+ ///
+ ///
+ /// 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 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.
+ ///
+ public static DeploymentExtended CreateOrUpdate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters)
+ {
+ return operations.CreateOrUpdateAsync(resourceGroupName, deploymentName, parameters).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Deploys resources to a resource group.
+ ///
+ ///
+ /// 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 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 cancellation token.
+ ///
+ public static async Task CreateOrUpdateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Gets a deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment to get.
+ ///
+ public static DeploymentExtended Get(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName)
+ {
+ return operations.GetAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Gets a deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment to get.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, 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 resource group partially deployed.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment to cancel.
+ ///
+ public static void Cancel(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName)
+ {
+ operations.CancelAsync(resourceGroupName, 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 resource group partially deployed.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment to cancel.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CancelAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.CancelWithHttpMessagesAsync(resourceGroupName, 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 resource group the template will be deployed to. The name
+ /// is case insensitive.
+ ///
+ ///
+ /// The name of the deployment.
+ ///
+ ///
+ /// Parameters to validate.
+ ///
+ public static DeploymentValidateResult Validate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters)
+ {
+ return operations.ValidateAsync(resourceGroupName, 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 resource group the template will be deployed to. The name
+ /// is case insensitive.
+ ///
+ ///
+ /// The name of the deployment.
+ ///
+ ///
+ /// Parameters to validate.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ValidateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ValidateWithHttpMessagesAsync(resourceGroupName, 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 resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment from which to get the template.
+ ///
+ public static DeploymentExportResult ExportTemplate(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName)
+ {
+ return operations.ExportTemplateAsync(resourceGroupName, deploymentName).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Exports the template used for specified deployment.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The name of the resource group. The name is case insensitive.
+ ///
+ ///
+ /// The name of the deployment from which to get the template.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task ExportTemplateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ExportTemplateWithHttpMessagesAsync(resourceGroupName, deploymentName, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///