public async Task <ActionResult> CreateVaultConfirmed(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("RSVault"); await ARM.createResourceGroupAsync(subscription.CustomerId, subscription.SubscriptionId, RgName, "westeurope"); string VaultId = await ARM.createSRVaultAsync(subscription.CustomerId, subscription.SubscriptionId, RgName, "testVault", "westeurope"); Models.Service newService = new Models.Service() { SubscriptionId = subscription.SubscriptionId, OfferingId = "RSVault", Description = "Backup as a Service", ResourceId = VaultId }; db.Services.Add(newService); db.SaveChanges(); return(RedirectToAction("../Services/Index")); }