internal static string DeploymentTemplateNewStorage( string registryName, string registryLocation, string registrySku, string storageAccountName, bool?adminUserEnabled, IDictionary <string, string> tags = null) { var template = new DeploymentTemplate { Schema = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", ContentVersion = "1.0.0.0", Resources = new AzureResource[] { new StorageResource { Name = storageAccountName, Location = registryLocation, ApiVersion = StorageApiVersion, Tags = new Dictionary <string, string> { { "containerregistry", registryName } }, Sku = new Sku { Name = StorageAccountSku } }, new RegistryResource { Name = registryName, Location = registryLocation, ApiVersion = RegistryApiVersion, Tags = tags, Sku = new Sku { Name = registrySku }, DependsOn = new string[] { $"[resourceId('Microsoft.Storage/storageAccounts', '{storageAccountName}')]" }, Properties = new RegistryProperties { AdminUserEnabled = adminUserEnabled != null ? adminUserEnabled.Value : false, StorageAccount = new StorageAccount { Name = storageAccountName, AccessKey = $"[listKeys(resourceId('Microsoft.Storage/storageAccounts', '{storageAccountName}'), '{StorageApiVersion}').keys[0].value]" } } } } }; return(template.ToJsonString()); }
internal static string ToJsonString(this DeploymentTemplate template) { var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() }; return(JsonConvert.SerializeObject(template, settings)); }
internal static JObject ToJson(this DeploymentTemplate template) { var settings = new JsonSerializer { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() }; return(JObject.FromObject(template, settings)); }