protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <JsonDefinedInfrastructure> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var resourcesTemplate = JObject.Parse(elementWithInfrastructure.Infrastructure.Template); Merge(template.Parameters, resourcesTemplate); if (elementWithInfrastructure.Infrastructure.Parameters != null) { Merge(template.ParameterValues, JObject.Parse(elementWithInfrastructure.Infrastructure.Parameters)); } var variables = resourcesTemplate["variables"] as JObject; if (variables != null) { foreach (var v in variables) { template.Variables.Add(v.Key, v.Value.ToString()); } } var resources = resourcesTemplate["resources"] as JArray; if (resources != null) { foreach (var resource in resources) { template.Resources.Add((JObject)resource); } } }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <ApplicationGateway> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var gateway = Template( "Microsoft.Network/applicationGateways", elementWithInfrastructure.Infrastructure.Name, location, "2018-08-01"); gateway["zones"] = new JArray(); gateway["dependsOn"] = new JArray( elementWithInfrastructure.Infrastructure.PublicIpAddress.Infrastructure.ResourceIdReference, elementWithInfrastructure.Infrastructure.VirtualNetwork.Infrastructure.ResourceIdReference); gateway["properties"] = new JObject { ["sku"] = Sku(elementWithInfrastructure, environment), ["gatewayIPConfigurations"] = GatewayIPConfigurations(elementWithInfrastructure, environment), ["frontendIPConfigurations"] = FrontendIPConfigurations(elementWithInfrastructure, environment), ["frontendPorts"] = FrontendPorts(elementWithInfrastructure, environment), ["probes"] = Probes(elementWithInfrastructure, environment), ["backendAddressPools"] = BackendPools(elementWithInfrastructure, environment), ["backendHttpSettingsCollection"] = BackendHttpSettings(elementWithInfrastructure, environment), ["httpListeners"] = HttpListeners(elementWithInfrastructure, environment), ["urlPathMaps"] = UrlPathMaps(elementWithInfrastructure, environment), ["requestRoutingRules"] = RequestRoutingRules(elementWithInfrastructure, environment), ["webApplicationFirewallConfiguration"] = WebApplicationFirewallConfiguration(elementWithInfrastructure, environment) }; template.Resources.Add(PostProcess(gateway)); }
private static void AddNamespace(AzureDeploymentTemplate template, ServiceBus serviceBus, string location) { var sku = "1"; if (serviceBus.Topics.Any()) { sku = "2"; } template.Resources.Add(new JObject { ["type"] = "Microsoft.ServiceBus/namespaces", ["name"] = serviceBus.Name, ["apiVersion"] = "2014-09-01", ["location"] = location, ["properties"] = new JObject { ["MessagingSku"] = sku, ["MessagingSKUPlan"] = new JObject { ["MessagingUnits"] = "1", ["SKU"] = sku } } }); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <FunctionAppService> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var appServicePlan = AppServicePlan(elementWithInfrastructure, location); if (appServicePlan != null) { template.Resources.Add(PostProcess(appServicePlan)); } var functionApp = Template( "Microsoft.Web/sites", elementWithInfrastructure.Infrastructure.Name, location, ApiVersion ); if (appServicePlan != null) { AddHiddenRelatedToAppServicePlan(elementWithInfrastructure, functionApp); } functionApp["properties"] = Properties(elementWithInfrastructure); AddSubResources(elementWithInfrastructure, functionApp); AddDependsOn(elementWithInfrastructure, location, functionApp); AddIdentity(elementWithInfrastructure, functionApp); functionApp["kind"] = "functionapp"; template.Resources.Add(PostProcess(functionApp)); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure<IoTHub> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var hub = elementWithInfrastructure.Infrastructure; template.Resources.Add(PostProcess(new JObject { ["apiVersion"] = hub.ApiVersion, ["type"] = "Microsoft.Devices/iotHubs", ["name"] = hub.Name, ["location"] = location, ["sku"] = new JObject { ["name"] = "F1", ["capacity"] = 1 } })); foreach (var consumerGroup in hub.ConsumerGroups) { template.Resources.Add(PostProcess(new JObject { ["apiVersion"] = hub.ApiVersion, ["type"] = "Microsoft.Devices/iotHubs/eventhubEndpoints/ConsumerGroups", ["name"] = $"{hub.Name}/events/{consumerGroup}", ["dependsOn"] = new JArray { hub.ResourceIdReference } })); } }
protected override void Render( AzureDeploymentTemplate template, IHaveInfrastructure <WebAppService> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var name = elementWithInfrastructure.Infrastructure.Name; template.Resources.Add(PostProcess(AppServicePlan(elementWithInfrastructure, location))); var appService = new JObject { ["type"] = "Microsoft.Web/sites", ["name"] = name, ["apiVersion"] = ApiVersion, ["location"] = location, ["properties"] = Properties(elementWithInfrastructure), }; AddHiddenRelatedToAppServicePlan(elementWithInfrastructure, appService); AddSubResources(elementWithInfrastructure, appService); AddDependsOn(elementWithInfrastructure, location, appService); AddIdentity(elementWithInfrastructure, appService); template.Resources.Add(PostProcess(appService)); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <VirtualNetwork> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var network = Template( "Microsoft.Network/virtualNetworks", elementWithInfrastructure.Infrastructure.Name, location, "2018-08-01"); network["properties"] = new JObject { ["addressSpace"] = new JObject { ["addressPrefixes"] = new JArray(elementWithInfrastructure.Infrastructure.Prefix) }, ["subnets"] = new JArray(elementWithInfrastructure.Infrastructure.Subnets.Select(subnet => new JObject { ["name"] = subnet.Name, ["properties"] = new JObject { ["addressPrefix"] = subnet.Prefix } })) }; template.Resources.Add(PostProcess(network)); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <DeviceProvisioningService> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var dps = elementWithInfrastructure.Infrastructure; template.Resources.Add(PostProcess(new JObject { ["type"] = "Microsoft.Devices/provisioningServices", ["name"] = dps.Name, ["apiVersion"] = dps.ApiVersion, ["location"] = location, ["properties"] = new JObject { ["iotHubs"] = new JArray(dps.IotHubs.Select(iothub => new JObject { ["name"] = iothub.Url, ["connectionString"] = iothub.OwnerConnectionString.Value.ToString(), ["location"] = location })) }, ["dependsOn"] = new JArray(dps.IotHubs.Select(iothub => iothub.ResourceIdReference).ToArray()) })); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <KeyVault> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { template.Resources.Add(new JObject { ["type"] = "Microsoft.KeyVault/vaults", ["name"] = elementWithInfrastructure.Infrastructure.Name, ["apiVersion"] = "2015-06-01", ["location"] = location, ["properties"] = new JObject { ["enabledForDeployment"] = false, ["enabledForTemplateDeployment"] = false, ["enabledForDiskEncryption"] = false, ["accessPolicies"] = new JArray( environment.AdministratorUserIds.Select(s => new JObject { ["tenantId"] = environment.Tenant, ["objectId"] = s, ["permissions"] = new JObject { ["keys"] = new JArray("Get", "List", "Update", "Create", "Import", "Delete", "Backup", "Restore"), ["secrets"] = new JArray("All") } }) .Cast <object>().ToArray() ), ["tenantId"] = environment.Tenant, ["sku"] = new JObject { ["name"] = "Standard", ["family"] = "A" } } }); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <ServiceBus> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var serviceBus = elementWithInfrastructure.Infrastructure; AddNamespace(template, serviceBus, location); foreach (var queue in serviceBus.Queues) { template.Resources.Add(new JObject { ["name"] = $"{serviceBus.Name}/{queue}", ["type"] = "Microsoft.ServiceBus/namespaces/queues", ["apiVersion"] = "2015-08-01", ["location"] = location, ["properties"] = new JObject { ["defaultMessageTimeToLive"] = "14.00:00:00", ["maxSizeInMegabytes"] = "1024", ["deadLetteringOnMessageExpiration"] = false, ["requiresDuplicateDetection"] = false, ["requiresSession"] = false, ["enablePartitioning"] = true, }, ["dependsOn"] = new JArray { serviceBus.ResourceIdReference } }); } foreach (var topic in serviceBus.Topics) { template.Resources.Add(new JObject { ["name"] = $"{serviceBus.Name}/{topic}", ["type"] = "Microsoft.ServiceBus/namespaces/topics", ["apiVersion"] = "2015-08-01", ["location"] = location, ["properties"] = new JObject { ["defaultMessageTimeToLive"] = "14.00:00:00", ["maxSizeInMegabytes"] = "1024", ["requiresDuplicateDetection"] = false, ["enablePartitioning"] = true, }, ["dependsOn"] = new JArray { $"[resourceId('Microsoft.ServiceBus/namespaces', '{serviceBus.Name}')]" } }); } }
public async Task CreateSimpleTemplate() { var template = await AzureDeploymentTemplate .CreateAsync <SimpleTemplate>() .ConfigureAwait(false); Assert.NotNull(template.Template); Assert.NotNull(template.Parameters); Assert.NotNull(template.LinkedTemplates); Assert.Contains(template.Parameters.Keys, parameterName => TemplateParameterTypes.Contains(parameterName)); }
public async Task CreateComplexTemplate() { var template = await AzureDeploymentTemplate .CreateAsync <ComplexTemplate>() .ConfigureAwait(false); Assert.NotNull(template.Template); Assert.NotNull(template.Parameters); Assert.NotNull(template.LinkedTemplates); var linkedTemplates = new string[] { "Linked1.json", "Linked2.json" }; Assert.Contains(template.LinkedTemplates.Keys, templateName => linkedTemplates.Contains(templateName)); }
protected override void Render( AzureDeploymentTemplate template, IHaveInfrastructure <WebAppService> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var name = elementWithInfrastructure.Infrastructure.Name; template.Resources.Add(new JObject { ["type"] = "Microsoft.Web/serverfarms", ["name"] = name, ["apiVersion"] = ApiVersion, ["location"] = ToLocationName(location), ["sku"] = new JObject { ["Tier"] = "Free", ["Name"] = "F1" }, ["properties"] = new JObject { ["name"] = name, ["workerSizeId"] = "0", ["numberOfWorkers"] = "1", ["reserved"] = false, ["hostingEnvironment"] = "" } }); var appService = new JObject { ["type"] = "Microsoft.Web/sites", ["name"] = name, ["apiVersion"] = ApiVersion, ["location"] = location, ["tags"] = new JObject { [ $"[concat(\'hidden-related:\', resourceGroup().id, \'/providers/Microsoft.Web/serverfarms/\', \'{name}\')]" ] = "empty" }, ["properties"] = Properties(elementWithInfrastructure), }; AddSubResources(elementWithInfrastructure, appService); AddDependsOn(elementWithInfrastructure, appService); template.Resources.Add(appService); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <StorageAccount> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var storageAccount = Template( "Microsoft.Storage/storageAccounts", elementWithInfrastructure.Infrastructure.Name, location, "2017-06-01" ); const string accountType = "Standard_LRS"; storageAccount["sku"] = new JObject { ["name"] = accountType }; storageAccount["kind"] = elementWithInfrastructure.Infrastructure.Kind.ToString(); var isBlobStorage = elementWithInfrastructure.Infrastructure.Kind == StorageAccountKind.BlobStorage; var properties = new JObject { ["supportsHttpsTrafficOnly"] = false, ["encryption"] = new JObject { ["keySource"] = "Microsoft.Storage", ["services"] = new JObject { ["blob"] = new JObject { ["enabled"] = true }, ["file"] = new JObject { ["enabled"] = !isBlobStorage } } } }; if (isBlobStorage) { properties["accessTier"] = "Hot"; } storageAccount["properties"] = properties; template.Resources.Add(storageAccount); }
public async Task <IEnumerable <string> > ValidateSubscriptionTemplateAsync(AzureDeploymentTemplate deploymentTemplate, Guid subscriptionId, string location, bool throwOnError = false) { if (deploymentTemplate is null) { throw new ArgumentNullException(nameof(deploymentTemplate)); } var deploymentId = Guid.NewGuid(); var deploymentResourceId = $"/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deployments/{deploymentId}/validate"; var payload = await GetDeploymentPayloadAsync(deploymentId, deploymentTemplate, location, DeploymentMode.Incremental) .ConfigureAwait(false); var token = await azureSessionService .AcquireTokenAsync() .ConfigureAwait(false); try { _ = await azureSessionService.Environment.ResourceManagerEndpoint .AppendPathSegment(deploymentResourceId) .SetQueryParam("api-version", "2019-10-01") .WithOAuthBearerToken(token) .PostJsonAsync(payload) .ConfigureAwait(false); return(null); } catch (FlurlHttpException exc) when(exc.Call.HttpStatus == System.Net.HttpStatusCode.BadRequest) { var validationResultJson = await exc.Call.Response.Content.ReadAsStringAsync().ConfigureAwait(false); var validationResultError = JObject.Parse(validationResultJson).SelectToken("$..error"); var validationResultResourceErrors = AzureDeploymentException.ResolveResourceErrors(validationResultError); if (throwOnError) { throw new AzureDeploymentException($"Invalid deployment template: {string.Join(", ", validationResultResourceErrors)}", deploymentResourceId, validationResultResourceErrors.ToArray()); } return(validationResultResourceErrors); } }
private async Task <object> GetDeploymentPayloadAsync(Guid deploymentId, AzureDeploymentTemplate template, string location, DeploymentMode deploymentMode) { if (string.IsNullOrEmpty(template.Template)) { throw new ArgumentException("Unable to create deployment payload by an empty template.", nameof(template)); } if (template.LinkedTemplates?.Any() ?? false) { var deploymentContainer = await azureDeploymentArtifactsStorage .UploadArtifactsAsync(deploymentId, template) .ConfigureAwait(false); template.Parameters[IAzureDeploymentTemplate.ArtifactsLocationParameterName] = deploymentContainer.Location; template.Parameters[IAzureDeploymentTemplate.ArtifactsLocationSasTokenParameterName] = deploymentContainer.Token; } IDictionary <string, object> deploymentParameters = null; if (template.Parameters?.Any() ?? false) { deploymentParameters = template.Parameters .Where(param => param.Value != null) .Aggregate(new ExpandoObject() as IDictionary <string, object>, (a, kv) => { a.Add(kv.Key, new { value = kv.Value }); return(a); }); } var properties = new DeploymentProperties() { Mode = deploymentMode, Template = JObject.Parse(template.Template), Parameters = deploymentParameters is null ? new JObject() : JObject.FromObject(deploymentParameters) }; if (string.IsNullOrEmpty(location)) { return new { properties } } ; return(new { location, properties }); } } }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <KeyVault> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var keyVault = elementWithInfrastructure.Infrastructure; template.Resources.Add(PostProcess(new JObject { ["type"] = "Microsoft.KeyVault/vaults", ["name"] = keyVault.Name, ["apiVersion"] = "2015-06-01", ["location"] = location, ["properties"] = new JObject { ["enabledForDeployment"] = false, ["enabledForTemplateDeployment"] = false, ["enabledForDiskEncryption"] = false, ["accessPolicies"] = AccessPolicies(environment, keyVault), ["tenantId"] = environment.Tenant, ["sku"] = new JObject { ["name"] = "Standard", ["family"] = "A" } } })); foreach (var keyVaultSecret in keyVault.Secrets) { template.Resources.Add(PostProcess(new JObject { ["type"] = "Microsoft.KeyVault/vaults/secrets", ["name"] = keyVault.Name + "/" + keyVaultSecret.Name, ["apiVersion"] = "2015-06-01", ["properties"] = new JObject { ["contentType"] = "text/plain", ["value"] = keyVaultSecret.Value.Value.ToString(), ["dependsOn"] = GetDependsOn(keyVaultSecret, keyVault) } })); } }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <FunctionAppService> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var functionApp = Template( "Microsoft.Web/sites", elementWithInfrastructure.Infrastructure.Name, location, ApiVersion ); functionApp["properties"] = Properties(elementWithInfrastructure); AddSubResources(elementWithInfrastructure, functionApp); AddDependsOn(elementWithInfrastructure, functionApp); functionApp["kind"] = "functionapp"; template.Resources.Add(functionApp); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <SqlServer> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var sqlServer = elementWithInfrastructure.Infrastructure; template.Resources.Add(PostProcess(new JObject { ["type"] = "Microsoft.Sql/servers", ["name"] = sqlServer.Name, ["apiVersion"] = sqlServer.ApiVersion, ["location"] = location, ["properties"] = new JObject { ["version"] = "12.0", ["administratorLogin"] = sqlServer.AdministratorLogin, ["administratorLoginPassword"] = sqlServer.AdministratorPassword }, ["resources"] = GetResources(sqlServer, location) })); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <EventHubNamespace> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var eventHubNamespace = elementWithInfrastructure.Infrastructure; template.Resources.Add(PostProcess(new JObject { ["apiVersion"] = eventHubNamespace.ApiVersion, ["type"] = "Microsoft.EventHub/namespaces", ["name"] = eventHubNamespace.Name, ["location"] = location, ["sku"] = new JObject { ["name"] = "Basic", ["tier"] = "Basic", ["capacity"] = 1 }, ["properties"] = new JObject(), ["resources"] = Resources(eventHubNamespace, location) })); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <PublicIpAddress> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var ip = Template( "Microsoft.Network/publicIPAddresses", elementWithInfrastructure.Infrastructure.Name, location, "2018-08-01"); ip["sku"] = new JObject { ["name"] = "Basic" }; ip["zones"] = new JArray(); ip["properties"] = new JObject { ["publicIPAllocationMethod"] = "Dynamic", ["idleTimeoutInMinutes"] = 4, }; template.Resources.Add(PostProcess(ip)); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <StreamAnalytics> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var streamAnalytics = elementWithInfrastructure.Infrastructure; template.Resources.Add(PostProcess(new JObject { ["type"] = "Microsoft.StreamAnalytics/streamingjobs", ["name"] = streamAnalytics.Name, ["apiVersion"] = "2017-04-01-preview", ["location"] = location, ["properties"] = new JObject { ["outputErrorPolicy"] = "stop", ["eventsOutOfOrderPolicy"] = "adjust", ["eventsOutOfOrderMaxDelayInSeconds"] = 0, ["eventsLateArrivalMaxDelayInSeconds"] = 5, ["dataLocale"] = "en-US", ["jobType"] = "Cloud", ["sku"] = new JObject { ["name"] = "standard" }, ["inputs"] = Inputs(streamAnalytics), ["outputs"] = Outputs(streamAnalytics), ["transformation"] = new JObject { ["name"] = "Transformation", ["properties"] = new JObject { ["query"] = streamAnalytics.TransformationQuery, ["streamingUnits"] = 1 } } }, ["dependsOn"] = new JArray(streamAnalytics.Inputs.Select(i => i.Source).OfType <IHaveResourceId>().Select(i => i.ResourceIdReference).Cast <object>().ToArray()) })); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <ApplicationInsights> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { var tags = new JObject(); foreach (var usedBy in elementWithInfrastructure.Infrastructure.UsedBy) { tags[usedBy.HiddenLink] = "Resource"; } var insights = Template( "microsoft.insights/components", elementWithInfrastructure.Infrastructure.Name, location); insights["tags"] = tags; insights["properties"] = new JObject { ["ApplicationId"] = elementWithInfrastructure.Infrastructure.Name }; template.Resources.Add(PostProcess(insights)); }
protected override void Render(AzureDeploymentTemplate template, IHaveInfrastructure <CosmosDocumentDatabase> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location) { template.Resources.Add(PostProcess(new JObject { ["type"] = "Microsoft.DocumentDb/databaseAccounts", ["kind"] = "GlobalDocumentDB", ["name"] = elementWithInfrastructure.Infrastructure.Name, ["apiVersion"] = "2015-04-08", ["location"] = location, ["properties"] = new JObject { ["databaseAccountOfferType"] = "Standard", ["locations"] = new JArray { new JObject { ["failoverPriority"] = 0, ["locationName"] = ToLocationName(location) } } } })); }
protected abstract void Render(AzureDeploymentTemplate template, IHaveInfrastructure <TInfrastructure> elementWithInfrastructure, IAzureInfrastructureEnvironment environment, string resourceGroup, string location);
public static async Task Deploy(this IAzure azure, string resourceGroupName, string resourceGroupLocation, AzureDeploymentTemplate template, string deploymentName) { Console.WriteLine($"Starting template deployment '{deploymentName}' in resource group '{resourceGroupName}'"); azure.AppServices.ResourceManager.Deployments .Define(deploymentName) .WithExistingResourceGroup(resourceGroupName) .WithTemplate(template.ToString()) .WithParameters(template.Parameters.ToString()) .WithMode(DeploymentMode.Incremental) .BeginCreate(); var deployment = await azure.AppServices.ResourceManager.Deployments.GetByResourceGroupAsync(resourceGroupName, deploymentName); Console.WriteLine($"Deployment status: {deployment.ProvisioningState}"); var lastProvisioningState = deployment.ProvisioningState; while (!IsCompleted(deployment.ProvisioningState)) { if (lastProvisioningState != deployment.ProvisioningState) { Console.Write($" {deployment.ProvisioningState} "); lastProvisioningState = deployment.ProvisioningState; } Console.Write("."); await Task.Delay(500); deployment = await azure.AppServices.ResourceManager.Deployments.GetByResourceGroupAsync(resourceGroupName, deploymentName); } Console.WriteLine(); Console.WriteLine($"Deployment status: {deployment.ProvisioningState}"); }
public abstract Task <IAzureDeploymentArtifactsContainer> UploadArtifactsAsync(Guid deploymentId, AzureDeploymentTemplate azureDeploymentTemplate);
public override async Task <IAzureDeploymentArtifactsContainer> UploadArtifactsAsync(Guid deploymentId, AzureDeploymentTemplate azureDeploymentTemplate) { if (azureDeploymentTemplate is null) { throw new ArgumentNullException(nameof(azureDeploymentTemplate)); } var container = new Container(); if (azureDeploymentTemplate.LinkedTemplates?.Any() ?? false) { var location = await UploadTemplatesAsync(deploymentId, azureDeploymentTemplate.LinkedTemplates) .ConfigureAwait(false); if (!string.IsNullOrEmpty(azureStorageArtifactsOptions.BaseUrlOverride) && Uri.IsWellFormedUriString(azureStorageArtifactsOptions.BaseUrlOverride, UriKind.Absolute)) { location = azureStorageArtifactsOptions.BaseUrlOverride.AppendPathSegment(deploymentId).ToString(); } else if (azureStorageArtifactsOptions.ConnectionString.IsDevelopmentStorageConnectionString()) { // if the artifact storage connection string points to a development storage (Azure Storage Emulator) // a BaseUrlOverride must be given as the storage is not publicly accessable in this case. // in this case it's required to use a tool like ngrok to make a local endpoint publicly available // that deliveres artifacts requested by the ARM deployment. throw new NotSupportedException($"Using development storage (Azure Storage Emulator) without a {nameof(azureStorageArtifactsOptions.BaseUrlOverride)} is not supported"); } container.Location = $"{location.TrimEnd('/')}/"; container.Token = azureDeploymentTokenProvider is null ? await CreateSasTokenAsync().ConfigureAwait(false) : await azureDeploymentTokenProvider.AcquireToken(deploymentId, this).ConfigureAwait(false); } return(container); }
protected override Task DeployInfrastructure(string resourceGroupName, string location, AzureDeploymentTemplate template) { throw new System.NotImplementedException(); }
public override Task <IAzureDeploymentArtifactsContainer> UploadArtifactsAsync(Guid deploymentId, AzureDeploymentTemplate azureDeploymentTemplate) => (azureDeploymentTemplate?.LinkedTemplates.Any() ?? false) ? Task.FromException <IAzureDeploymentArtifactsContainer>(new NotSupportedException($"{nameof(NullStorageArtifactsProvider)} doesn't support linked templates or artifacts")) : Task.FromResult <IAzureDeploymentArtifactsContainer>(Container.Instance);