コード例 #1
0
        public async Task CreateDeployments()
        {
            #region Snippet:Managing_Deployments_CreateADeployment
            // First we need to get the deployment collection from the resource group
            DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
            // Use the same location as the resource group
            string deploymentName = "myDeployment";
            var    input          = new DeploymentInput(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 deploymentCollection.CreateOrUpdateAsync(deploymentName, input);

            Deployment deployment = lro.Value;
            #endregion Snippet:Managing_Deployments_CreateADeployment
        }
        public async Task CreateDeploymentsUsingJsonElement()
        {
            #region Snippet:Managing_Deployments_CreateADeploymentUsingJsonElement
            // First we need to get the deployment collection from the resource group
            DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
            // Use the same location as the resource group
            string deploymentName = "myDeployment";
            // Create a parameter object
            var parametersObject = new { storageAccountType = new { value = "Standard_GRS" } };
            //convert this object to JsonElement
            var parametersString = JsonSerializer.Serialize(parametersObject);
            var parameters       = JsonDocument.Parse(parametersString).RootElement;
            var input            = new DeploymentInput(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 = parameters
            });
            DeploymentCreateOrUpdateOperation lro = await deploymentCollection.CreateOrUpdateAsync(true, deploymentName, input);

            Deployment deployment = lro.Value;
            #endregion Snippet:Managing_Deployments_CreateADeployment
        }
        public async Task CreateDeploymentsUsingString()
        {
            #region Snippet:Managing_Deployments_CreateADeploymentUsingString
            // First we need to get the deployment collection from the resource group
            DeploymentCollection deploymentCollection = resourceGroup.GetDeployments();
            // Use the same location as the resource group
            string deploymentName = "myDeployment";
            // Passing string to template and parameters
            var input = new DeploymentInput(new DeploymentProperties(DeploymentMode.Incremental)
            {
                Template   = File.ReadAllText("storage-template.json"),
                Parameters = File.ReadAllText("storage-parameters.json")
            });
            DeploymentCreateOrUpdateOperation lro = await deploymentCollection.CreateOrUpdateAsync(true, deploymentName, input);

            Deployment deployment = lro.Value;
            #endregion Snippet:Managing_Deployments_CreateADeployment
        }