コード例 #1
0
        /// <summary>
        /// Add resource group metadata to a deployment result
        /// </summary>
        /// <param name="result">The result to augment</param>
        /// <param name="resourceGroup">Metadata on the resource group for the deployment</param>
        /// <returns>A ResourceGroupDeployment object combining the metadata about the deployment and the resource group it is deployed to</returns>
        public static ResourceGroupDeployment ToPSResourceGroupDeployment(this DeploymentExtended result, string resourceGroup)
        {
            ResourceGroupDeployment deployment = new ResourceGroupDeployment();

            if (result != null)
            {
                deployment = CreatePSResourceGroupDeployment(result.Name, resourceGroup, result.Properties);
            }

            return(deployment);
        }
コード例 #2
0
        private static ResourceGroupDeployment CreatePSResourceGroupDeployment(
            string name,
            string gesourceGroup,
            DeploymentPropertiesExtended properties)
        {
            ResourceGroupDeployment deploymentObject = new ResourceGroupDeployment();

            deploymentObject.DeploymentName    = name;
            deploymentObject.ResourceGroupName = gesourceGroup;

            if (properties != null)
            {
                deploymentObject.Mode = properties.Mode;
                deploymentObject.ProvisioningState = properties.ProvisioningState;
                deploymentObject.TemplateLink      = properties.TemplateLink;
                deploymentObject.Timestamp         = properties.Timestamp;
                deploymentObject.CorrelationId     = properties.CorrelationId;

                if (properties.DebugSetting != null && !string.IsNullOrEmpty(properties.DebugSetting.DetailLevel))
                {
                    deploymentObject.DeploymentDebugLogLevel = properties.DebugSetting.DetailLevel;
                }

                if (properties.Outputs != null && !string.IsNullOrEmpty(properties.Outputs.ToString()))
                {
                    Dictionary <string, DeploymentVariable> outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs.ToString());
                    deploymentObject.Outputs = outputs;
                }

                if (properties.Parameters != null && !string.IsNullOrEmpty(properties.Parameters.ToString()))
                {
                    Dictionary <string, DeploymentVariable> parameters = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Parameters.ToString());
                    deploymentObject.Parameters = parameters;
                }

                if (properties.TemplateLink != null)
                {
                    deploymentObject.TemplateLinkString = ConstructTemplateLinkView(properties.TemplateLink);
                }
            }

            return(deploymentObject);
        }