Esempio n. 1
0
        /// <summary>
        /// Create the wizard forms
        /// </summary>
        /// <param name="designTimeEnvironment">The design time environment</param>
        /// <param name="runKind">The wizard run kind</param>
        /// <returns>The IWizardFormExtension</returns>
        public override IWizardFormExtension CreateWizardForm(DTE designTimeEnvironment, WizardRunKind runKind)
        {
            //TODO: put this back
            _deploymentProperties = new DeploymentProperties();

            ArtifactWizardForm wiz = new ArtifactWizardForm(designTimeEnvironment, CKSProperties.WebTemplate_WizardTitle);

            if (runKind == WizardRunKind.AsNewProject)
            {
                _webTemplateProperties = new WebTemplateProperties(Guid.NewGuid(), _deploymentProperties);
                DeploymentPresentationModel  model  = new DeploymentPresentationModel(_deploymentProperties, false, IsSharePointConnectionRequired);
                WebTemplatePresentationModel model2 = new WebTemplatePresentationModel(_webTemplateProperties, false, designTimeEnvironment);
                DeploymentPage  page  = new DeploymentPage(wiz, model);
                WebTemplatePage page2 = new WebTemplatePage(wiz, model2);
                wiz.AddPage(page);
                wiz.AddPage(page2);
                return(wiz);
            }

            ISharePointProject spProject = DTEManager.ActiveSharePointProject;

            _deploymentProperties.IsSandboxedSolution = spProject.IsSandboxedSolution;
            _deploymentProperties.Url = spProject.SiteUrl;
            _projectName                 = spProject.Name;
            _webTemplateProperties       = new WebTemplateProperties(Guid.NewGuid(), _deploymentProperties);
            _webTemplateProperties.Title = _rootName;
            WebTemplatePresentationModel model3 = new WebTemplatePresentationModel(_webTemplateProperties, false, designTimeEnvironment);
            WebTemplatePage page5 = new WebTemplatePage(wiz, model3);

            wiz.AddPage(page5);
            return(wiz);
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            switch (Type)
            {
            case CognitiveServicesObjectType.DeploymentProperties:
            {
                var obj = new DeploymentProperties();
                obj.Model         = new DeploymentModel();
                obj.ScaleSettings = new DeploymentScaleSettings();
                WriteObject(obj);
            }
            break;

            case CognitiveServicesObjectType.CommitmentPlanProperties:
            {
                var obj = new CommitmentPlanProperties();
                obj.Current = new CommitmentPeriod();
                obj.Next    = new CommitmentPeriod();
                WriteObject(obj);
            }
            break;
            }
        }
        public string CreateVirtualNetwork(string location)
        {
            var vnetName = TestUtilities.GenerateName("CosmosDBVirtualNetwork");

            var templateParameters = new Dictionary <string, Dictionary <string, object> >
            {
                { "vnetName", new Dictionary <string, object> {
                      { "value", vnetName }
                  } },
                { "location", new Dictionary <string, object> {
                      { "value", location }
                  } }
            };

            var deploymentProperties = new DeploymentProperties
            {
                Template   = JObject.Parse(File.ReadAllText("TestData/ManagedCassandraVnetTemplate.azrm.json")),
                Parameters = templateParameters,
                Mode       = DeploymentMode.Incremental
            };
            var deploymentModel = new Deployment(deploymentProperties);

            var deployment = this.fixture.ResourceManagementClient.Deployments.CreateOrUpdate(
                this.fixture.ResourceGroupName,
                TestUtilities.GenerateName("vnet-deployment"),
                deploymentModel
                );

            var outputs  = (JObject)deployment.Properties.Outputs;
            var subnetId = ((JObject)outputs.GetValue("subnetId")).GetValue("value").ToString();

            return(subnetId);
        }
Esempio n. 4
0
        public static string CreateVirtualNetwork(ResourceManagementClient client, string resourceGroupName)
        {
            const string testPrefix = "CosmosDBVirtualNetwork";
            var          vnetName   = TestUtilities.GenerateName(testPrefix);

            var templateParameters = new Dictionary <string, Dictionary <string, object> >
            {
                { "vnetName", new Dictionary <string, object> {
                      { "value", vnetName }
                  } }
            };

            var deploymentProperties = new DeploymentProperties
            {
                Template   = JObject.Parse(File.ReadAllText("TestData/ManagedCassandraVnetTemplate.azrm.json")),
                Parameters = templateParameters,
                Mode       = DeploymentMode.Incremental
            };
            var deploymentModel = new Deployment(deploymentProperties);

            var deployment = client.Deployments.CreateOrUpdate(resourceGroupName,
                                                               ManagedCassandraResourcesOperationsTests.VnetDeploymentName, deploymentModel);

            var outputs  = (JObject)deployment.Properties.Outputs;
            var subnetId = ((JObject)outputs.GetValue("subnetId")).GetValue("value").ToString();

            return(subnetId);
        }
Esempio n. 5
0
        public static void CheckSerializationForDeploymentProperties(DeploymentProperties properties)
        {
            if (properties != null)
            {
                if (properties.Template is string templateContent)
                {
                    try
                    {
                        properties.Template = JObject.Parse(templateContent);
                    }
                    catch (JsonException ex)
                    {
                        throw new SerializationException("Unable to serialize template.", ex);
                    }
                }

                if (properties.Parameters is string parametersContent)
                {
                    try
                    {
                        JObject templateParameters = JObject.Parse(parametersContent);
                        properties.Parameters = templateParameters["parameters"] ?? templateParameters;
                    }
                    catch (JsonException ex)
                    {
                        throw new SerializationException("Unable to serialize template parameters.", ex);
                    }
                }
            }
        }
 public DeploymentPresentationModel(DeploymentProperties deploymentProperties, bool isOptional, bool validateUrlWithSharePoint)
     : base(isOptional)
 {
     this._deploymentProperties    = deploymentProperties;
     this._enableUserSolutionInput = true;
     this.Url = this._deploymentProperties.Url.ToString();
     this.IsSandboxedSolution       = this._deploymentProperties.IsSandboxedSolution;
     this.ValidateUrlWithSharePoint = validateUrlWithSharePoint;
 }
        public static void CreateVmss(ResourceManagementClient resourcesClient, string resourceGroupName, string deploymentName)
        {
            var deploymentProperties = new DeploymentProperties
            {
                Template = JObject.Parse(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "TestData", "VmssDeploymentTemplate.json"))),
                Mode     = DeploymentMode.Incremental
            };

            var deployment = resourcesClient.Deployments.CreateOrUpdate(resourceGroupName, deploymentName, new Deployment(deploymentProperties));
        }
Esempio n. 8
0
        public async Task CreateVmss(ResourcesManagementClient resourcesClient, string resourceGroupName, string deploymentName)
        {
            string templateString = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestData", "VmssDeploymentTemplate.json"));

            DeploymentProperties deploymentProperties = new DeploymentProperties(DeploymentMode.Incremental)
            {
                Template = templateString
            };
            Deployment deploymentModel = new Deployment(deploymentProperties);
            Operation <DeploymentExtended> deploymentWait = await resourcesClient.Deployments.StartCreateOrUpdateAsync(resourceGroupName, deploymentName, deploymentModel);

            await WaitForCompletionAsync(deploymentWait);
        }
Esempio n. 9
0
        protected static DeploymentProperties CreateDeploymentPropertiesUsingJsonElement()
        {
            DeploymentProperties tmpDeploymentProperties = new DeploymentProperties(DeploymentMode.Incremental);

            tmpDeploymentProperties.TemplateLink     = new TemplateLink();
            tmpDeploymentProperties.TemplateLink.Uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.storage/storage-account-create/azuredeploy.json";
            var parametersObject = new { storageAccountType = new { value = "Standard_GRS" } };
            //convert this object to JsonElement
            var parametersString = JsonSerializer.Serialize(parametersObject);
            var parameters       = JsonDocument.Parse(parametersString).RootElement;

            tmpDeploymentProperties.Parameters = parameters;
            return(tmpDeploymentProperties);
        }
        protected static DeploymentProperties CreateDeploymentProperties()
        {
            DeploymentProperties tmpDeploymentProperties = new DeploymentProperties(DeploymentMode.Incremental);

            tmpDeploymentProperties.TemplateLink     = new TemplateLink();
            tmpDeploymentProperties.TemplateLink.Uri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.storage/storage-account-create/azuredeploy.json";
            tmpDeploymentProperties.Parameters       = new JsonObject()
            {
                { "storageAccountType", new JsonObject()
                  {
                      { "value", "Standard_GRS" }
                  } }
            };
            return(tmpDeploymentProperties);
        }
Esempio n. 11
0
        private static Tuple <DeploymentExtended, GenericResource> CreateCommitmentPlanResource(string resourceGroupName, string commitmentPlanName, string deploymentName, ResourceManagementClient resourcesClient, string cpApiVersion)
        {
            string deploymentParams     = @"{'planName': {'value': '" + commitmentPlanName + "'}, 'planSkuName': {'value': 'PLAN_SKU_NAME'}, 'planSkuTier': {'value': 'PLAN_SKU_TIER'}, 'apiVersion': {'value': '" + cpApiVersion + "'}}";
            var    deploymentProperties = new DeploymentProperties
            {
                Template   = JObject.Parse(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "TestData", "DeployCommitmentPlanTemplate.json"))),
                Parameters = JObject.Parse(deploymentParams),
                Mode       = DeploymentMode.Incremental
            };

            var deployment = resourcesClient.Deployments.CreateOrUpdate(resourceGroupName, deploymentName, new Deployment(deploymentProperties));
            var cpResource = resourcesClient.Resources.Get(resourceGroupName, WebServiceTests.MLResourceProviderNamespace, string.Empty, WebServiceTests.CPResourceType, commitmentPlanName, cpApiVersion);

            return(Tuple.Create(deployment, cpResource));
        }
Esempio n. 12
0
        protected static DeploymentProperties CreateDeploymentPropertiesUsingString()
        {
            DeploymentProperties tmpDeploymentProperties = new DeploymentProperties(DeploymentMode.Incremental);

            tmpDeploymentProperties.Template = File.ReadAllText(Path.Combine(
                                                                    Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                                                    "Scenario",
                                                                    "DeploymentTemplates",
                                                                    $"storage-template.json"));
            tmpDeploymentProperties.Parameters = File.ReadAllText(Path.Combine(
                                                                      Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                                                      "Scenario",
                                                                      "DeploymentTemplates",
                                                                      $"storage-parameters.json"));
            return(tmpDeploymentProperties);
        }
Esempio n. 13
0
        public async Task CreateVm(
            ResourcesManagementClient resourcesClient,
            string resourceGroupName,
            string location,
            string virtualMachineName,
            string storageAccountName,
            string networkInterfaceName,
            string networkSecurityGroupName,
            string diagnosticsStorageAccountName,
            string deploymentName,
            string adminPassword)
        {
            string deploymentParams = "{" +
                                      "\"resourceGroupName\": {\"value\": \"" + resourceGroupName + "\"}," +
                                      "\"location\": {\"value\": \"" + location + "\"}," +
                                      "\"virtualMachineName\": { \"value\": \"" + virtualMachineName + "\"}," +
                                      "\"virtualMachineSize\": { \"value\": \"Standard_DS1_v2\"}," +
                                      "\"adminUsername\": { \"value\": \"netanalytics32\"}," +
                                      "\"storageAccountName\": { \"value\": \"" + storageAccountName + "\"}," +
                                      "\"routeTableName\": { \"value\": \"" + resourceGroupName + "RT\"}," +
                                      "\"virtualNetworkName\": { \"value\": \"" + resourceGroupName + "-vnet\"}," +
                                      "\"networkInterfaceName\": { \"value\": \"" + networkInterfaceName + "\"}," +
                                      "\"networkSecurityGroupName\": { \"value\": \"" + networkSecurityGroupName + "\"}," +
                                      "\"adminPassword\": { \"value\": \"" + adminPassword + "\"}," +
                                      "\"storageAccountType\": { \"value\": \"Premium_LRS\"}," +
                                      "\"diagnosticsStorageAccountName\": { \"value\": \"" + diagnosticsStorageAccountName + "\"}," +
                                      "\"diagnosticsStorageAccountId\": { \"value\": \"Microsoft.Storage/storageAccounts/" + diagnosticsStorageAccountName + "\"}," +
                                      "\"diagnosticsStorageAccountType\": { \"value\": \"Standard_LRS\"}," +
                                      "\"addressPrefix\": { \"value\": \"10.17.3.0/24\"}," +
                                      "\"subnetName\": { \"value\": \"default\"}, \"subnetPrefix\": { \"value\": \"10.17.3.0/24\"}," +
                                      "\"publicIpAddressName\": { \"value\": \"" + virtualMachineName + "-ip\"}," +
                                      "\"publicIpAddressType\": { \"value\": \"Dynamic\"}" +
                                      "}";
            string templateString = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TestData", "DeploymentTemplate.json"));

            DeploymentProperties deploymentProperties = new DeploymentProperties(DeploymentMode.Incremental)
            {
                Template   = templateString,
                Parameters = deploymentParams
            };
            Deployment deploymentModel = new Deployment(deploymentProperties);

            Operation <DeploymentExtended> deploymentWait = await resourcesClient.Deployments.StartCreateOrUpdateAsync(resourceGroupName, deploymentName, deploymentModel);

            await WaitForCompletionAsync(deploymentWait);
        }
Esempio n. 14
0
        public ArmDeployment(IResourceManagementClient resourceManagementClient, string location)
        {
            Client   = resourceManagementClient;
            Location = location;
            var template = new TemplateBuilder().Template;

            var suffix = UniqueString.Create();

            DeploymentName = $"armeval-deployment-{suffix}";

            var deploymentProperties = new DeploymentProperties
            {
                Mode       = DeploymentMode.Incremental,
                Template   = template,
                Parameters = template["parameters"]
            };

            Deployment = new Deployment(deploymentProperties, Location);
        }
Esempio n. 15
0
        public static void CreateVm(
            ResourceManagementClient resourcesClient,
            string resourceGroupName,
            string location,
            string virtualMachineName,
            string storageAccountName,
            string networkInterfaceName,
            string networkSecurityGroupName,
            string diagnosticsStorageAccountName,
            string deploymentName)
        {
            string deploymentParams = @"{" +
                                      @"'resourceGroupName': {'value': '" + resourceGroupName + "'}," +
                                      @"'location': {'value': '" + location + "'}," +
                                      @"'virtualMachineName': { 'value': '" + virtualMachineName + "'}," +
                                      @"'virtualMachineSize': { 'value': 'Standard_DS1_v2'}," +
                                      @"'adminUsername': { 'value': 'netanalytics32'}," +
                                      @"'storageAccountName': { 'value': '" + storageAccountName + "'}," +
                                      @"'routeTableName': { 'value': '" + resourceGroupName + "RT'}," +
                                      @"'virtualNetworkName': { 'value': '" + resourceGroupName + "-vnet'}," +
                                      @"'networkInterfaceName': { 'value': '" + networkInterfaceName + "'}," +
                                      @"'networkSecurityGroupName': { 'value': '" + networkSecurityGroupName + "'}," +
                                      @"'adminPassword': { 'value': '" + NetworkManagementTestUtilities.GetRandomPassword() + "'}," +
                                      @"'storageAccountType': { 'value': 'Premium_LRS'}," +
                                      @"'diagnosticsStorageAccountName': { 'value': '" + diagnosticsStorageAccountName + "'}," +
                                      @"'diagnosticsStorageAccountId': { 'value': 'Microsoft.Storage/storageAccounts/" + diagnosticsStorageAccountName + "'}," +
                                      @"'diagnosticsStorageAccountType': { 'value': 'Standard_LRS'}," +
                                      @"'addressPrefix': { 'value': '10.17.3.0/24'}," +
                                      @"'subnetName': { 'value': 'default'}, 'subnetPrefix': { 'value': '10.17.3.0/24'}," +
                                      @"'publicIpAddressName': { 'value': '" + virtualMachineName + "-ip'}," +
                                      @"'publicIpAddressType': { 'value': 'Dynamic'}" +
                                      @"}";

            var deploymentProperties = new DeploymentProperties
            {
                Template   = JObject.Parse(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "TestData", "DeploymentTemplate.json"))),
                Parameters = JObject.Parse(deploymentParams),
                Mode       = DeploymentMode.Incremental
            };

            var deployment = resourcesClient.Deployments.CreateOrUpdate(resourceGroupName, deploymentName, new Deployment(deploymentProperties));
        }
        private static PSResourceGroupDeployment CreatePSResourceGroupDeployment(
            string name,
            string gesourceGroup,
            DeploymentProperties properties)
        {
            Dictionary <string, DeploymentVariable> outputs    = new Dictionary <string, DeploymentVariable>();
            Dictionary <string, DeploymentVariable> parameters = new Dictionary <string, DeploymentVariable>();
            PSResourceGroupDeployment deploymentObject         = new PSResourceGroupDeployment();

            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 (!string.IsNullOrEmpty(properties.Outputs))
                {
                    outputs = JsonConvert.DeserializeObject <Dictionary <string, DeploymentVariable> >(properties.Outputs);
                    deploymentObject.Outputs       = outputs;
                    deploymentObject.OutputsString = ToString(outputs);
                }

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

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

            return(deploymentObject);
        }
        private void EnableAdsWithVa(string resourceGroupName, string serverName, string serverLocation, string templateName, string deploymentName)
        {
            // Generate deployment name if it was not provided
            if (string.IsNullOrEmpty(deploymentName))
            {
                deploymentName = "EnableADS_" + serverName + "_" + Guid.NewGuid().ToString("N");
            }

            // Trim deployment name as it has a maximum of 64 chars
            if (deploymentName.Length > 64)
            {
                deploymentName = deploymentName.Substring(0, 64);
            }

            Dictionary <string, object> parametersDictionary = new Dictionary <string, object>
            {
                { "serverName", new Dictionary <string, object> {
                      { "value", serverName }
                  } },
                { "location", new Dictionary <string, object> {
                      { "value", serverLocation }
                  } },
            };
            string parameters = JsonConvert.SerializeObject(parametersDictionary, new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.None,
                Formatting       = Formatting.Indented
            });

            var properties = new DeploymentProperties
            {
                Mode       = DeploymentMode.Incremental,
                Parameters = JObject.Parse(parameters),
                Template   = JObject.Parse(GetArmTemplateContent(templateName)),
            };

            Deployment deployment = new Deployment(properties);

            AzureCommunicator.DeployArmTemplate(resourceGroupName, deploymentName, deployment);
        }
Esempio n. 18
0
        public VibesCm DeepCopy()
        {
            VibesCm newCm = new VibesCm
            {
                Id             = Id,
                CmResourceName = CmResourceName ?? "",
                CmPath         = CmPath ?? "",
                CmCorePath     = CmCorePath ?? "",
                CmPort         = CmPort ?? "",
                CmStatus       = CmStatus,
                CmType         = CmType,
                VibesHost      = VibesHost,
                VibesHostId    = VibesHostId
            };

            if (DeploymentProperties != null && DeploymentProperties.Any())
            {
                foreach (DeploymentProperty prop in DeploymentProperties)
                {
                    newCm.DeploymentProperties.Add(prop);
                }
            }
            return(newCm);
        }
Esempio n. 19
0
        /// <summary>
        /// Creates a deployment at provided target scope and returns deployment succeeded/failed message.
        /// </summary>
        /// <param name="deploymentCollectionProvider">deployment collection provider</param>
        /// <param name="armClient">arm client</param>
        /// <param name="template">template used in deployment</param>
        /// <param name="parameterFilePath">path to parameter file used in deployment</param>
        /// <param name="id">id string to create the ResourceIdentifier from</param>
        /// <param name="scope">target scope</param>
        /// <param name="location">location to store the deployment data</param>
        /// <returns>deployment succeeded/failed message</returns>
        public static async Task <string> CreateDeployment(
            IDeploymentCollectionProvider deploymentCollectionProvider,
            ArmClient armClient,
            string template,
            string parameterFilePath,
            string id,
            string scope,
            string location)
        {
            if ((scope == LanguageConstants.TargetScopeTypeSubscription ||
                 scope == LanguageConstants.TargetScopeTypeManagementGroup) &&
                string.IsNullOrWhiteSpace(location))
            {
                return(LangServerResources.MissingLocationDeploymentFailedMessage);
            }

            DeploymentCollection?deploymentCollection;
            var resourceIdentifier = new ResourceIdentifier(id);

            try
            {
                deploymentCollection = deploymentCollectionProvider.GetDeploymentCollection(armClient, resourceIdentifier, scope);
            }
            catch (Exception e)
            {
                return(string.Format(LangServerResources.DeploymentFailedWithExceptionMessage, e.Message));
            }

            if (deploymentCollection is not null)
            {
                JsonElement parameters;

                try
                {
                    parameters = GetParameters(parameterFilePath);
                }
                catch (Exception e)
                {
                    return(e.Message);
                }

                var deploymentProperties = new DeploymentProperties(DeploymentMode.Incremental)
                {
                    Template   = JsonDocument.Parse(template).RootElement,
                    Parameters = parameters
                };
                var input = new DeploymentInput(deploymentProperties)
                {
                    Location = location,
                };

                string deployment = "bicep_deployment_" + DateTime.UtcNow.ToString("yyyyMMddHHmmss");

                try
                {
                    var deploymentCreateOrUpdateOperation = await deploymentCollection.CreateOrUpdateAsync(waitForCompletion : true, deployment, input);

                    return(GetDeploymentResultMessage(deploymentCreateOrUpdateOperation));
                }
                catch (Exception e)
                {
                    return(string.Format(LangServerResources.DeploymentFailedWithExceptionMessage, e.Message));
                }
            }

            return(LangServerResources.DeploymentFailedMessage);
        }
Esempio n. 20
0
 protected static Deployment CreateDeploymentExtendedData(DeploymentProperties deploymentProperties) => new Deployment(deploymentProperties);
Esempio n. 21
0
        public async Task <DeploymentValidateResult> ValidateArmTemplate(string resourceGroupName, string deploymentName, DeploymentProperties deploymentProperties)
        {
            var result = await Client.Deployments.ValidateAsync(resourceGroupName, deploymentName, new Deployment(deploymentProperties));

            return(result);
        }
 protected static DeploymentInput CreateDeploymentData(DeploymentProperties deploymentProperties) => new DeploymentInput(deploymentProperties);
Esempio n. 23
0
        public async Task <DeploymentExtended> DeployArmTemplate(string resourceGroupName, string deploymentName, DeploymentProperties deploymentProperties)
        {
            var result = await Client.Deployments.CreateOrUpdateAsync(resourceGroupName, deploymentName, new Deployment(deploymentProperties));

            return(result);
        }