public static async Task InitApiApps(this ResourceGroup resourceGroup) { if (!resourceGroup.Tags.ContainsKey(Constants.CommonApiAppsDeployed) || !resourceGroup.Tags[Constants.CommonApiAppsDeployed].Equals(Constants.CommonApiAppsDeployedVersion)) { var csmTemplateString = string.Empty; using (var reader = new StreamReader(SimpleSettings.CommonApiAppsCsmTemplatePath)) { csmTemplateString = await reader.ReadToEndAsync(); } var gatewayName = resourceGroup.Gateways.Count() != 0 ? resourceGroup.Gateways.Select(s => s.GatewayName).First() : Guid.NewGuid().ToString().Replace("-", ""); csmTemplateString = csmTemplateString.Replace("{{gatewayName}}", gatewayName); var deployment = new CsmDeployment { DeploymentName = resourceGroup.ResourceUniqueId, SubscriptionId = resourceGroup.SubscriptionId, ResourceGroupName = resourceGroup.ResourceGroupName, CsmTemplate = JsonConvert.DeserializeObject <JToken>(csmTemplateString), }; await RetryHelper.Retry(() => deployment.Deploy(block: true), 3); resourceGroup.Tags[Constants.CommonApiAppsDeployed] = Constants.CommonApiAppsDeployedVersion; await resourceGroup.Update(); await resourceGroup.Load(); } }
public Task <JToken> CreateDeployment(object template, bool block, SubscriptionType subscriptionType) { Deployment = new CsmDeployment { DeploymentName = ResourceGroup.ResourceUniqueId, SubscriptionId = ResourceGroup.SubscriptionId, ResourceGroupName = ResourceGroup.ResourceGroupName, CsmTemplate = template, }; return(Deployment.Deploy(block: block, subscriptionType: subscriptionType)); }
public Task <JToken> CreateDeployment(object template, bool block) { Deployment = new CsmDeployment { DeploymentName = ResourceGroup.ResourceUniqueId, SubscriptionId = ResourceGroup.SubscriptionId, ResourceGroupName = ResourceGroup.ResourceGroupName, CsmTemplate = template }; return(RetryHelper.Retry(() => Deployment.Deploy(block: block), 3)); }