public async Task <ActionResult> CreateVMsConfirmed(Models.Subscription sub) { if (sub == null) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "No subscription passed on to the function to create vault")); } string subscriptionId = sub.SubscriptionId; Subscription subscription = db.Subscriptions.Find(subscriptionId); if (subscription == null) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "A valid Azure subscription could not be found")); } // Test auth is working string token = await Helpers.REST.getArmTokenAsync(subscription.CustomerId, UserAuth : true); if (token == null) { return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "ARM token could not be retrieved for customer " + subscription.CustomerId)); } // Create ARM Resource Group and Recovery Services Vault string RgName = ModelTools.GetOfferingRGName("20ApacheVms") + ARM.RandomString(5); await ARM.createResourceGroupAsync(subscription.CustomerId, subscription.SubscriptionId, RgName, "westeurope"); string VMId = await ARM.createVMsAsync(subscription.CustomerId, subscription.SubscriptionId, RgName, "testVM", "westeurope"); int newServiceId = ModelTools.NextServiceId(); Models.Service newService = new Models.Service() { //Id = newServiceId, SubscriptionId = subscription.SubscriptionId, OfferingId = "20ApacheVms", Description = "20 Apache VMs", ResourceId = RgName }; db.Services.Add(newService); db.SaveChanges(); return(RedirectToAction("../Services/Index")); }