/// <summary> /// Creates new deployment using the passed template file which can be user customized or /// from gallery templates. /// </summary> /// <param name="parameters">The create deployment parameters</param> /// <returns>The created deployment instance</returns> public virtual PSResourceGroupDeployment ExecuteDeployment(CreatePSResourceGroupDeploymentParameters parameters) { parameters.DeploymentName = GenerateDeploymentName(parameters); Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode, parameters.DeploymentDebugLogLevel); TemplateValidationInfo validationInfo = CheckBasicDeploymentErrors(parameters.ResourceGroupName, parameters.DeploymentName, deployment); if (validationInfo.Errors.Count != 0) { foreach(var error in validationInfo.Errors) { WriteError(string.Format(ErrorFormat, error.Code, error.Message)); if(!string.IsNullOrEmpty(error.Details)) { DisplayDetailedErrorMessage(error.Details); } } throw new InvalidOperationException("The deployment validation failed."); } else { WriteVerbose(ProjectResources.TemplateValid); } ResourceManagementClient.Deployments.CreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); WriteVerbose(string.Format("Create template deployment '{0}'.", parameters.DeploymentName)); DeploymentExtended result = ProvisionDeploymentStatus(parameters.ResourceGroupName, parameters.DeploymentName, deployment); return result.ToPSResourceGroupDeployment(parameters.ResourceGroupName); }
public override void ExecuteCmdlet() { if (ShouldProcess(Name, "Create Container Registry")) { var registryNameStatus = RegistryClient.CheckRegistryNameAvailability(Name); if (registryNameStatus?.NameAvailable != null && !registryNameStatus.NameAvailable.Value) { throw new InvalidOperationException(registryNameStatus.Message); } var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); if (Location == null) { Location = ResourceManagerClient.GetResourceGroupLocation(ResourceGroupName); } DeploymentExtended result = ResourceManagerClient.CreateRegistry( ResourceGroupName, Name, Location, Sku, EnableAdminUser, StorageAccountName, tags); if (result.Properties.ProvisioningState == DeploymentState.Succeeded.ToString()) { var registry = RegistryClient.GetRegistry(ResourceGroupName, Name); WriteObject(new PSContainerRegistry(registry)); } } }
public async ValueTask <Response <DeploymentExtended> > GetAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (deploymentName == null) { throw new ArgumentNullException(nameof(deploymentName)); } using var message = CreateGetRequest(resourceGroupName, deploymentName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { DeploymentExtended value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = DeploymentExtended.DeserializeDeploymentExtended(document.RootElement); } return(Response.FromValue(value, message.Response)); }
/// <summary> /// Creates new deployment using the passed template file which can be user customized or /// from gallery templates. /// </summary> /// <param name="parameters">The create deployment parameters</param> /// <returns>The created deployment instance</returns> public virtual PSResourceGroupDeployment ExecuteDeployment(CreatePSResourceGroupDeploymentParameters parameters) { parameters.DeploymentName = GenerateDeploymentName(parameters); Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode); TemplateValidationInfo validationInfo = CheckBasicDeploymentErrors(parameters.ResourceGroupName, parameters.DeploymentName, deployment); if (validationInfo.Errors.Count != 0) { int counter = 1; string errorFormat = "Error {0}: Code={1}; Message={2}\r\n"; StringBuilder errorsString = new StringBuilder(); validationInfo.Errors.ForEach(e => errorsString.AppendFormat(errorFormat, counter++, e.Code, e.Message)); throw new ArgumentException(errorsString.ToString()); } else { WriteVerbose(ProjectResources.TemplateValid); } if (!string.IsNullOrEmpty(parameters.StorageAccountName)) { WriteWarning("The StorageAccountName parameter is no longer used and will be removed in a future release. Please update scripts to remove this parameter."); } ResourceManagementClient.Deployments.CreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); WriteVerbose(string.Format("Create template deployment '{0}'.", parameters.DeploymentName)); DeploymentExtended result = ProvisionDeploymentStatus(parameters.ResourceGroupName, parameters.DeploymentName, deployment); return(result.ToPSResourceGroupDeployment(parameters.ResourceGroupName)); }
public async Task CreateDeploymentExtendeds() { #region Snippet:Managing_DeploymentExtendeds_CreateADeploymentExtended // First we need to get the deployment extended container from the resource group DeploymentExtendedContainer deploymentExtendedContainer = resourceGroup.GetDeploymentExtendeds(); // Use the same location as the resource group string deploymentExtendedName = "myDeployment"; var input = new Deployment(new DeploymentProperties(DeploymentMode.Incremental) { TemplateLink = new TemplateLink() { Uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.storage/storage-account-create/azuredeploy.json" }, Parameters = new JsonObject() { { "storageAccountType", new JsonObject() { { "value", "Standard_GRS" } } } } }); DeploymentCreateOrUpdateAtScopeOperation lro = await deploymentExtendedContainer.CreateOrUpdateAsync(deploymentExtendedName, input); DeploymentExtended deploymentExtended = lro.Value; #endregion Snippet:Managing_DeploymentExtendeds_CreateADeploymentExtended }
/// <summary> /// Creates new deployment using the passed template file which can be user customized or /// from gallery templates. /// </summary> /// <param name="parameters">The create deployment parameters</param> /// <returns>The created deployment instance</returns> public virtual PSResourceGroupDeployment ExecuteDeployment(CreatePSResourceGroupDeploymentParameters parameters) { parameters.DeploymentName = GenerateDeploymentName(parameters); Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode, parameters.DeploymentDebugLogLevel); TemplateValidationInfo validationInfo = CheckBasicDeploymentErrors(parameters.ResourceGroupName, parameters.DeploymentName, deployment); if (validationInfo.Errors.Count != 0) { int counter = 1; string errorFormat = "Error {0}: Code={1}; Message={2}\r\n"; StringBuilder errorsString = new StringBuilder(); validationInfo.Errors.ForEach(e => errorsString.AppendFormat(errorFormat, counter++, e.Code, e.Message)); throw new ArgumentException(errorsString.ToString()); } else { WriteVerbose(ProjectResources.TemplateValid); } ResourceManagementClient.Deployments.CreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); WriteVerbose(string.Format("Create template deployment '{0}'.", parameters.DeploymentName)); DeploymentExtended result = ProvisionDeploymentStatus(parameters.ResourceGroupName, parameters.DeploymentName, deployment); return(result.ToPSResourceGroupDeployment(parameters.ResourceGroupName)); }
/// <summary> /// Creates new deployment /// </summary> /// <param name="parameters">The create deployment parameters</param> public virtual PSResourceGroupDeployment ExecuteDeployment(PSCreateResourceGroupDeploymentParameters parameters) { parameters.DeploymentName = GenerateDeploymentName(parameters); Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode, parameters.DeploymentDebugLogLevel); TemplateValidationInfo validationInfo = CheckBasicDeploymentErrors(parameters.ResourceGroupName, parameters.DeploymentName, deployment); if (validationInfo.Errors.Count != 0) { foreach (var error in validationInfo.Errors) { WriteError(string.Format(ErrorFormat, error.Code, error.Message)); if (error.Details != null && error.Details.Count > 0) { foreach (var innerError in error.Details) { DisplayInnerDetailErrorMessage(innerError); } } } throw new InvalidOperationException(ProjectResources.FailedDeploymentValidation); } else { WriteVerbose(ProjectResources.TemplateValid); } ResourceManagementClient.Deployments.BeginCreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); WriteVerbose(string.Format(ProjectResources.CreatedDeployment, parameters.DeploymentName)); DeploymentExtended result = ProvisionDeploymentStatus(parameters.ResourceGroupName, parameters.DeploymentName, deployment); return(result.ToPSResourceGroupDeployment(parameters.ResourceGroupName)); }
private void WaitForDeployment(Deployment deployment, List <CertificateInformation> certInformations) { var token = new CancellationTokenSource(); var deploymentName = GenerateDeploymentName(); DeploymentExtended deploymentDetail = null; var deploymentTask = Task.Factory.StartNew(() => { try { deploymentDetail = ResourceManagerClient.Deployments.CreateOrUpdate( this.ResourceGroupName, deploymentName, deployment); } finally { token.Cancel(); } }); while (!token.IsCancellationRequested) { if (!RunningTest) { WriteVerboseWithTimestamp(ServiceFabricProperties.Resources.DeploymentVerbose); var c = SafeGetResource(() => this.SFRPClient.Clusters.Get(this.ResourceGroupName, this.Name), true); if (c != null) { WriteVerboseWithTimestamp(string.Format(ServiceFabricProperties.Resources.ClusterStateVerbose, c.ClusterState)); } } Thread.Sleep(TimeSpan.FromSeconds(WriteVerboseIntervalInSec)); } PrintDetailIfThrow(() => deploymentTask.Wait()); var cluster = SFRPClient.Clusters.Get(this.ResourceGroupName, this.Name); WriteObject( new PSDeploymentResult( deploymentDetail == null ? null : new PSDeploymentExtended(deploymentDetail), new PSCluster(cluster), this.adminUserName, certInformations.Select(c => new PSKeyVault() { KeyVaultName = c.KeyVault.Name, KeyVaultId = c.KeyVault.Id, KeyVaultCertificateName = c.CertificateName, KeyVaultCertificateId = c.CertificateUrl, CertificateThumbprint = c.CertificateThumbprint, Certificate = c.Certificate, CertificateSavedLocalPath = c.CertificateOutputPath, SecretIdentifier = c.SecretUrl }).ToList()), true); }
public async Task <CPSCloudResourceSummaryModel> GetSummary(string organization, string project, string service, List <string> environments, string feature, CPSAuthCredentialModel authCredential) { CPSCloudResourceSummaryModel summaryModel = new CPSCloudResourceSummaryModel(); try { var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(authCredential.AccessDirectory, authCredential.AccessAppId, authCredential.AccessAppSecret); ResourceManagementClient resourceManagementClient = new ResourceManagementClient(serviceCreds); resourceManagementClient.SubscriptionId = authCredential.AccessId; foreach (var environmentName in environments) { string resourceGroupName = $"{organization}{project}{service}{environmentName}{feature}".ToLower(); try { var resourceGroupResponse = resourceManagementClient.ResourceGroups.Get(resourceGroupName); if (resourceGroupResponse != null) { var environment = summaryModel.AddEnvironment(environmentName, resourceGroupResponse.Properties.ProvisioningState); var deployments = resourceManagementClient.Deployments.ListByResourceGroup(resourceGroupName, new Microsoft.Rest.Azure.OData.ODataQuery <Microsoft.Azure.Management.ResourceManager.Models.DeploymentExtendedFilter>() { Top = 1, OrderBy = "Name desc" }); DeploymentExtended deployment = null; foreach (var item in deployments) { deployment = item; break; } if (deployment != null && deployment.Properties.Outputs != null) { var outPuts = JObject.Parse(JsonConvert.SerializeObject(deployment.Properties.Outputs)); foreach (var output in outPuts) { string key = output.Key.First().ToString().ToUpper() + output.Key.Substring(1); environment.AddProperty(key, output.Value["value"].ToString()); } } } else { summaryModel.AddEnvironment(environmentName, "NO_DEPLOYED_YET"); } } catch (System.Exception ex) { summaryModel.AddEnvironment(environmentName, "NO_DEPLOYED_YET"); } } } catch (System.Exception) { } return(summaryModel); }
public static PSDeployment ToPSDeployment(this DeploymentExtended result, string managementGroupId = null, string resourceGroupName = null) { PSDeployment deployment = new PSDeployment(); if (result != null) { deployment = CreatePSDeployment(result, managementGroupId, resourceGroupName); } return(deployment); }
/// <summary> /// Creates new deployment using the passed template file which can be user customized or /// from gallery templates. /// </summary> /// <param name="parameters">The create deployment parameters</param> /// <returns>The created deployment instance</returns> public virtual PSResourceGroupDeployment ExecuteDeployment(CreatePSResourceGroupDeploymentParameters parameters) { parameters.DeploymentName = GenerateDeploymentName(parameters); Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode); ResourceManagementClient.Deployments.CreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); WriteVerbose(string.Format("Create template deployment '{0}'.", parameters.DeploymentName)); DeploymentExtended result = ProvisionDeploymentStatus(parameters.ResourceGroupName, parameters.DeploymentName, deployment); return(result.ToPSResourceGroupDeployment(parameters.ResourceGroupName)); }
public static PSDeployment ToPSDeployment(this DeploymentExtended result) { PSDeployment deployment = new PSDeployment(); if (result != null) { deployment = CreatePSDeployment(result.Name, result.Location, result.Properties); } return(deployment); }
public static PSResourceGroupDeployment ToPSResourceGroupDeployment(this DeploymentExtended result, string resourceGroup) { PSResourceGroupDeployment deployment = new PSResourceGroupDeployment(); if (result != null) { deployment = CreatePSResourceGroupDeployment(result.Name, resourceGroup, result.Properties); } return(deployment); }
public static async Task <DeploymentExtended> CreateTemplateDeploymentAsync( ServiceClientCredentials credential, ResourceGroup rgPara, string groupName, string deploymentName, string subscriptionId, string parametersJson) { Console.WriteLine("Creating the template deployment..."); var resourceManagementClient = new ResourceManagementClient(new Uri("https://management.chinacloudapi.cn/"), credential) { SubscriptionId = subscriptionId }; DeploymentExtended aa = null; try { var result = resourceManagementClient.ResourceGroups.CreateOrUpdateAsync(groupName, rgPara).Result; } catch (Exception e) { Console.WriteLine(e.Message); } string filePath = AppDomain.CurrentDomain.BaseDirectory + "WebappTemplate.json"; var deployment = new Deployment(); try { deployment.Properties = new DeploymentProperties { Mode = DeploymentMode.Incremental, Template = System.IO.File.ReadAllText(filePath), Parameters = parametersJson }; } catch (Exception e) { Debug.WriteLine(e.Message); } try { aa = await resourceManagementClient.Deployments.CreateOrUpdateAsync( groupName, deploymentName, deployment); } catch (Exception e) { Console.WriteLine(e.Message); } return(aa); }
public async Task DeleteDeploymentExtendeds() { #region Snippet:Managing_DeploymentExtendeds_DeleteADeploymentExtended // First we need to get the deployment extended container from the resource group DeploymentExtendedContainer deploymentExtendedContainer = resourceGroup.GetDeploymentExtendeds(); // Now we can get the deployment extended with GetAsync() DeploymentExtended deploymentExtended = await deploymentExtendedContainer.GetAsync("myDeployment"); // With DeleteAsync(), we can delete the deployment extended await deploymentExtended.DeleteAsync(); #endregion Snippet:Managing_DeploymentExtendeds_DeleteADeploymentExtended }
public override void ExecuteCmdlet() { if (ShouldProcess(Name, "Create Container Registry")) { var registryNameStatus = RegistryClient.CheckRegistryNameAvailability(Name); if (registryNameStatus?.NameAvailable != null && !registryNameStatus.NameAvailable.Value) { throw new InvalidOperationException(registryNameStatus.Message); } var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); if (Location == null) { Location = ResourceManagerClient.GetResourceGroupLocation(ResourceGroupName); } if (string.Equals(Sku, SkuName.Classic) && StorageAccountName == null) { DeploymentExtended result = ResourceManagerClient.CreateClassicRegistry( ResourceGroupName, Name, Location, EnableAdminUser, tags); if (result.Properties.ProvisioningState == DeploymentState.Succeeded.ToString()) { var registry = RegistryClient.GetRegistry(ResourceGroupName, Name); WriteObject(new PSContainerRegistry(registry)); } } else { var registry = new Registry { Sku = new Microsoft.Azure.Management.ContainerRegistry.Models.Sku(Sku), AdminUserEnabled = EnableAdminUser, Tags = tags, Location = Location }; if (StorageAccountName != null) { var storageAccountId = ResourceManagerClient.GetStorageAccountId(StorageAccountName); registry.StorageAccount = new StorageAccountProperties(storageAccountId); } var createdRegistry = RegistryClient.CreateRegistry(ResourceGroupName, Name, registry); WriteObject(new PSContainerRegistry(createdRegistry)); } } }
public async Task Get() { string rgName = Recording.GenerateAssetName("testRg-3-"); ResourceGroupData rgData = new ResourceGroupData(Location.WestUS2); var lro = await Client.DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync(rgName, rgData); ResourceGroup rg = lro.Value; string deployExName = Recording.GenerateAssetName("deployEx-G-"); Deployment deploymentExtendedData = CreateDeploymentExtendedData(CreateDeploymentProperties()); DeploymentExtended deploymentExtended = (await rg.GetDeploymentExtendeds().CreateOrUpdateAsync(deployExName, deploymentExtendedData)).Value; DeploymentExtended getDeploymentExtended = await rg.GetDeploymentExtendeds().GetAsync(deployExName); AssertValidDeploymentExtended(deploymentExtended, getDeploymentExtended); }
public async Task CreateOrUpdate() { string rgName = Recording.GenerateAssetName("testRg-1-"); ResourceGroupData rgData = new ResourceGroupData(Location.WestUS2); var lro = await Client.DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync(rgName, rgData); ResourceGroup rg = lro.Value; string deployExName = Recording.GenerateAssetName("deployEx-C-"); Deployment deploymentExtendedData = CreateDeploymentExtendedData(CreateDeploymentProperties()); DeploymentExtended deploymentExtended = (await rg.GetDeploymentExtendeds().CreateOrUpdateAsync(deployExName, deploymentExtendedData)).Value; Assert.AreEqual(deployExName, deploymentExtended.Data.Name); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await rg.GetDeploymentExtendeds().CreateOrUpdateAsync(null, deploymentExtendedData)); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await rg.GetDeploymentExtendeds().CreateOrUpdateAsync(deployExName, null)); }
private static PSResourceGroupDeployment CreatePSResourceGroupDeployment( DeploymentExtended deployment, string resourceGroup) { PSResourceGroupDeployment deploymentObject = new PSResourceGroupDeployment { DeploymentName = deployment.Name, ResourceGroupName = resourceGroup, Tags = deployment.Tags == null ? null : new Dictionary <string, string>(deployment.Tags) }; SetDeploymentProperties(deploymentObject, deployment.Properties); return(deploymentObject); }
private ServiceResource WaitForDeployment(Deployment deployment, string deploymentName) { var progress = new ProgressRecord(0, string.Format("Request for {0} in progress", typeof(ServiceResource).Name), "Starting..."); WriteProgress(progress); var token = new CancellationTokenSource(); DeploymentExtended deploymentDetail = null; var deploymentTask = Task.Factory.StartNew(() => { try { deploymentDetail = ResourceManagerClient.Deployments.CreateOrUpdate( this.ResourceGroupName, deploymentName, deployment); } finally { token.Cancel(); } }); while (!token.IsCancellationRequested) { if (!RunningTest) { string progressMessage = string.Format("Provisioning State: {0}", GetServiceProvisioningStatus()); WriteVerboseWithTimestamp(progressMessage); progress.StatusDescription = progressMessage; WriteProgress(progress); } Thread.Sleep(TimeSpan.FromSeconds(WriteVerboseIntervalInSec)); } if (deploymentTask.IsFaulted) { PrintSdkExceptionDetail(deploymentTask.Exception); WriteVerbose("Create Service 0peration failed."); throw deploymentTask.Exception; } return(this.SFRPClient.Services.Get( this.ResourceGroupName, this.ClusterName, this.ApplicationName, this.Name)); }
public async Task Delete() { string rgName = Recording.GenerateAssetName("testRg-4-"); ResourceGroupData rgData = new ResourceGroupData(Location.WestUS2); var lro = await Client.DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync(rgName, rgData); ResourceGroup rg = lro.Value; string deployExName = Recording.GenerateAssetName("deployEx-D-"); Deployment deploymentExtendedData = CreateDeploymentExtendedData(CreateDeploymentProperties()); DeploymentExtended deploymentExtended = (await rg.GetDeploymentExtendeds().CreateOrUpdateAsync(deployExName, deploymentExtendedData)).Value; await deploymentExtended.DeleteAsync(); var ex = Assert.ThrowsAsync <RequestFailedException>(async() => await deploymentExtended.GetAsync()); Assert.AreEqual(404, ex.Status); }
private Deployment ToDeploymentStatus(DeploymentExtended deployment, IEnumerable <DeploymentOperation> failedOps = null) { string errors = null; if (failedOps != null && failedOps.Any()) { errors = string.Join("\n", failedOps.Select(ToErrorString)); } Enum.TryParse <ProvisioningState>(deployment.Properties.ProvisioningState, out var deploymentState); return(new Deployment { ProvisioningState = deploymentState, Error = errors, }); }
/// <summary> /// Creates new deployment using the passed template file which can be user customized or /// from gallery templates. /// </summary> /// <param name="parameters">The create deployment parameters</param> /// <returns>The created deployment instance</returns> public virtual PSResourceGroupDeployment ExecuteDeployment(CreatePSResourceGroupDeploymentParameters parameters) { parameters.DeploymentName = GenerateDeploymentName(parameters); Deployment deployment = CreateBasicDeployment(parameters, parameters.DeploymentMode); if (!string.IsNullOrEmpty(parameters.StorageAccountName)) { WriteWarning("The StorageAccountName parameter is no longer used and will be removed in a future release. Please update scripts to remove this parameter."); } ResourceManagementClient.Deployments.CreateOrUpdate(parameters.ResourceGroupName, parameters.DeploymentName, deployment); WriteVerbose(string.Format("Create template deployment '{0}'.", parameters.DeploymentName)); DeploymentExtended result = ProvisionDeploymentStatus(parameters.ResourceGroupName, parameters.DeploymentName, deployment); return(result.ToPSResourceGroupDeployment(parameters.ResourceGroupName)); }
private async Task UpdateFileServerFromDeploymentAsync( DeploymentExtended deployment, NfsFileServer fileServer) { if (fileServer.Deployment.ProvisioningState == ProvisioningState.Succeeded) { var(privateIp, publicIp) = await GetIpAddressesAsync(fileServer); fileServer.PrivateIp = privateIp; fileServer.PublicIp = publicIp; } if (fileServer.Deployment.ProvisioningState == ProvisioningState.Failed) { fileServer.State = StorageState.Failed; } }
private async Task UpdateAvereFromDeploymentAsync( DeploymentExtended deployment, AvereCluster avereCluster) { await Task.CompletedTask; if (avereCluster.Deployment.ProvisioningState == ProvisioningState.Succeeded) { if (deployment.Properties.Outputs != null) { var outputs = deployment.Properties.Outputs as JObject; avereCluster.SshConnectionDetails = (string)outputs["ssh_string"]?["value"]; avereCluster.ManagementIP = (string)outputs["mgmt_ip"]?["value"]; avereCluster.VServerIPRange = (string)outputs["vserver_ips"]?["value"]; } } }
private static PSDeployment CreatePSDeployment( DeploymentExtended deployment, string managementGroupId, string resourceGroup) { PSDeployment deploymentObject = new PSDeployment(); deploymentObject.Id = deployment.Id; deploymentObject.DeploymentName = deployment.Name; deploymentObject.Location = deployment.Location; deploymentObject.ManagementGroupId = managementGroupId; deploymentObject.ResourceGroupName = resourceGroup; SetDeploymentProperties(deploymentObject, deployment.Properties); return(deploymentObject); }
public async Task List() { string rgName = Recording.GenerateAssetName("testRg-1-"); ResourceGroupData rgData = new ResourceGroupData(Location.WestUS2); var lro = await Client.DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync(rgName, rgData); ResourceGroup rg = lro.Value; string deployExName = Recording.GenerateAssetName("deployEx-"); Deployment deploymentExtendedData = CreateDeploymentExtendedData(CreateDeploymentProperties()); DeploymentExtended deploymentExtended = (await rg.GetDeploymentExtendeds().CreateOrUpdateAsync(deployExName, deploymentExtendedData)).Value; int count = 0; await foreach (var tempDeploymentOperation in deploymentExtended.GetDeploymentOperations().GetAllAsync()) { count++; } Assert.AreEqual(count, 2); //One deployment contains two operations: Create and EvaluteDeploymentOutput }
public async Task Get() { string rgName = Recording.GenerateAssetName("testRg-2-"); ResourceGroupData rgData = new ResourceGroupData(Location.WestUS2); var lro = await Client.DefaultSubscription.GetResourceGroups().CreateOrUpdateAsync(rgName, rgData); ResourceGroup rg = lro.Value; string deployExName = Recording.GenerateAssetName("deployEx-"); Deployment deploymentExtendedData = CreateDeploymentExtendedData(CreateDeploymentProperties()); DeploymentExtended deploymentExtended = (await rg.GetDeploymentExtendeds().CreateOrUpdateAsync(deployExName, deploymentExtendedData)).Value; await foreach (var tempDeploymentOperation in deploymentExtended.GetDeploymentOperations().GetAllAsync()) { DeploymentOperation getDeploymentOperation = await deploymentExtended.GetDeploymentOperations().GetAsync(tempDeploymentOperation.Data.OperationId); AssertValidDeploymentOperation(tempDeploymentOperation, getDeploymentOperation); } }
public void AddResource(string templatePath, string parametersPath, params string[] parameters) { DeploymentExtended result = null; Task <DeploymentExtended> dpResult = CreateTemplateDeploymentAsync(templatePath, parametersPath, parameters); try { result = dpResult.Result; } catch (Exception ex) { Console.WriteLine("Error occured"); Console.WriteLine(dpResult.Exception.InnerException.Message); Console.ReadLine(); return; } Console.WriteLine(result.Properties.ProvisioningState); }
private static PSDeployment CreatePSDeployment( DeploymentExtended deployment, string managementGroupId, string resourceGroup) { PSDeployment deploymentObject = new PSDeployment { Id = deployment.Id, DeploymentName = deployment.Name, Location = deployment.Location, ManagementGroupId = managementGroupId, ResourceGroupName = resourceGroup, Tags = deployment.Tags == null ? new Dictionary <string, string>() : new Dictionary <string, string>(deployment.Tags) }; SetDeploymentProperties(deploymentObject, deployment.Properties); return(deploymentObject); }