Exemple #1
0
        private async Task <ArmDeployment> NewSubscriptionDeployment()
        {
            var azure    = GetAzureClient();
            var template = System.IO.File.ReadAllText(subscribeTemplatePath);



            Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentInner deploymentParam = new Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentInner()
            {
                Location   = "westus",
                Properties = new Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentProperties()
                {
                    Mode       = Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentMode.Incremental,
                    Template   = template,
                    Parameters = "{}"
                }
            };

            Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentExtendedInner deployment = await azure.Deployments.Inner.CreateOrUpdateAtSubscriptionScopeAsync("dpA", deploymentParam);

            var h = new ArmDeployment(
                deployment.Id,
                deployment.Properties.Timestamp,
                deployment.Properties.ProvisioningState,
                null,
                deployment.Name,
                deployment
                );

            return(h);
        }
 public AcmeCertificateGenerator(ILogger <AcmeCertificateGenerator> logger, TokenCredential credential, ILookupClient lookupClient, ArmDeployment armDeployment)
 {
     _logger        = logger;
     _credential    = credential;
     _lookupClient  = lookupClient;
     _armDeployment = armDeployment;
 }
        public void Constructor_SetsAllProperties()
        {
            var actual = new ArmDeployment(client, location);

            Assert.Same(client, actual.Client);
            Assert.Matches(@"^armeval-deployment-\w{5}$", actual.DeploymentName);
            Assert.IsType <Deployment>(actual.Deployment);
            Assert.Same(location, actual.Deployment.Location);
            Assert.Equal(emptyTemplate, actual.Deployment.Properties.Template);
            Assert.Equal(DeploymentMode.Incremental, actual.Deployment.Properties.Mode);
        }
Exemple #4
0
        public async Task <IActionResult> SubscriptionDetails()
        {
            var repo = new ResourceManagementRepo();
            var deploymentExtended = repo.GetAtSubscriptionScope("my123", waitForCompletion: true);
            var armDeployment      = new ArmDeployment(
                deploymentExtended.Id,
                deploymentExtended.Properties.Timestamp,
                deploymentExtended.Properties.ProvisioningState,
                null,
                deploymentExtended.Name,
                deploymentExtended);

            ViewBag.DeploymentSourceObject = deploymentExtended;
            return(View("Details", armDeployment));
        }
Exemple #5
0
        public async Task <IActionResult> ArmResourceGroupDeployment(string ok)
        {
            string template        = System.IO.File.ReadAllText(etagTemplatePath);
            var    azureClientRepo = new AzureDeploymentClient();
            //testnew method

            var rmc = new ResourceManagementRepo();

            var err = rmc.getErrors("testingetag", "testingetag");

            var ret = new ArmDeployment(err.Result[0]);

            return(View("Details", ret));

            var deploymentExtendedInner = await azureClientRepo.NewResourceGroupDeployment(template, "testingetag");

            //var rg = azure.ResourceGroups
            //             .Define("srofoxtestrg07161")
            //             .WithRegion("West US");
            ////var rg = await resourcesManagementClient.ResourceGroups.CreateOrUpdateAsync("srofoxtestrg0716", new ResourceGroup("West US"));

            //var t = await azure.Deployments.Define("someTest1234")
            //        .WithNewResourceGroup(rg)
            //        .WithTemplate(template).WithParameters("{}")
            //        .WithMode(Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentMode.Incremental)
            //        .CreateAsync(CancellationToken.None);

            var deployment = deploymentExtendedInner;

            //returm
            //var h = new ArmDeployment(
            //        deployment.CorrelationId ?? "notProvided",
            //        deployment.Timestamp ?? DateTime.Now,
            //        deployment.ProvisioningState ?? "otherState",
            //        deployment.ResourceGroupName,
            //        deployment.Name,
            //        deployment
            //        );
            //ViewBag.Template =
            //            Newtonsoft.Json.JsonConvert.SerializeObject(deploymentExtendedInner,
            //            Formatting.Indented, loopHandler);
            ViewBag.Deployed = true;
            //TODO: redirect to details endpoint
            return(View("Details", deployment));
        }
Exemple #6
0
        public async Task <IActionResult> FluentAzureSubscription(string ok = "123")
        {
            var azureClientRepo = new AzureDeploymentClient();
            //testnew method
            var deploymentExtendedInner = await azureClientRepo.NewSubscriptionDeployment();

            var armDeployment = new ArmDeployment(
                deploymentExtendedInner.Id,
                deploymentExtendedInner.Properties.Timestamp,
                deploymentExtendedInner.Properties.ProvisioningState,
                null,
                deploymentExtendedInner.Name,
                deploymentExtendedInner);

            ViewBag.DeploymentSourceObject     = deploymentExtendedInner;
            ViewBag.DeploymentSourceObjectType = deploymentExtendedInner.GetType().Name;
            ViewBag.DeploymentType             = "Azure Flient Subscription Deployment";
            return(View("Details", armDeployment));
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var container = ContainerConfig.Configure();

            using (var scope = container.BeginLifetimeScope())
            {
                var app = scope.Resolve <IApplication>();
                app.Init();

                var expression = new ArmTemplateExpression(@"[parameters('obj').Property1]");

                var deployment     = new ArmDeployment(app.Client, app.AzureRegion);
                var inputVariables = new List <ArmTemplateVariable>()
                {
                    new ArmTemplateVariable("num2", 7)
                };
                var inputParams = new List <ArmTemplateParameter>()
                {
                    new ArmTemplateParameter("obj", new { Property1 = "customString", Property2 = true }, "object")
                };

                try
                {
                    var result = expression.Invoke(deployment, ArmValueTypes.@string, inputParams, inputVariables);
                    if (result is List <MissingInput> )
                    {
                        var missingInputs = result as List <MissingInput>;
                        missingInputs.ForEach(m => WriteLine($"Please enter a value for {m.InputType} \"{m.Name}\"."));
                    }
                    else
                    {
                        Console.WriteLine(result);
                    }
                }
                catch (Exception ex)
                {
                    WriteLine(ex.Message);
                }
            }
            Console.ReadKey();
        }
Exemple #8
0
        public async Task <IActionResult> Details(string name, DeploymentExtended?deploymentExtended)
        {
            if (deploymentExtended.Name != null)
            {
                var armDeployment = new ArmDeployment(
                    deploymentExtended.Id,
                    deploymentExtended.Properties.Timestamp,
                    deploymentExtended.Properties.ProvisioningState,
                    null,
                    deploymentExtended.Name,
                    deploymentExtended);
                ViewBag.DeploymentSourceObject = deploymentExtended;
                return(View(armDeployment));
            }

            var azure      = GetAzureClient();
            var deployment = azure.Deployments.GetByName(name);
            var output     = new ArmDeployment(deployment.Inner.Id, deployment.Timestamp, deployment.ProvisioningState, deployment.ResourceGroupName, deployment.Name, deployment);

            ViewBag.DeploymentSourceObject = deployment;
            return(View(output));
        }
Exemple #9
0
        public async Task <IActionResult> ResourceManagementAzureSubscription(string ok = "123")
        {
            string subscriptionTemplate = System.IO.File.ReadAllText(subscribeTemplatePath);

            var repo = new ResourceManagementRepo();



            var deploymentExtended = await repo.CreateSubscriptionDeployment();

            var armDeployment = new ArmDeployment(
                deploymentExtended.Id,
                deploymentExtended.Properties.Timestamp,
                deploymentExtended.Properties.ProvisioningState,
                null,
                deploymentExtended.Name,
                deploymentExtended);

            ViewBag.DeploymentType             = "Resource Management Client Deployment";
            ViewBag.DeploymentSourceObject     = deploymentExtended;
            ViewBag.DeploymentSourceObjectType = deploymentExtended.GetType().Name;
            return(View("Details", armDeployment));
        }