Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 8697d2f

Browse files
committed
comments
1 parent b05df4d commit 8697d2f

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/APIM_ARMTemplate/apimtemplate/Creator/ExampleFiles/YAMLConfigs/valid.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
version: 0.0.1 # Required
2-
apimServiceName: LucasUnlinked2 # Required, must match name of an apim service deployed in the specified resource group
2+
apimServiceName: Lucas2 # Required, must match name of an apim service deployed in the specified resource group
33
apiVersionSet: # Optional
4-
displayName: swaggerPetstoreVersionSet
4+
displayName: swaggerPetstoreVersionSetLinked
55
description: a description
66
versioningScheme: Query
77
versionQueryName: versionQuery
88
versionHeaderName: versionHeader
99
api:
10-
name: myAPI2 # Required
10+
name: myUnlinkedAPI # Required
1111
openApiSpec: C:\Users\lucashh\Desktop\Projects\APIM-ARM\azure-api-management-devops-example\src\APIM_ARMTemplate\apimtemplate\Creator\ExampleFiles\OpenApiSpecs\swaggerPetstore.json # Required, can be url or local file
1212
policy: C:\Users\lucashh\Desktop\Projects\APIM-ARM\azure-api-management-devops-example\src\APIM_ARMTemplate\apimtemplate\Creator\ExampleFiles\XMLPolicies\apiPolicyHeaders.xml # Optional, can be url or local file
1313
suffix: conf # Required
@@ -23,5 +23,5 @@ api:
2323
policy: C:\Users\lucashh\Desktop\Projects\APIM-ARM\azure-api-management-devops-example\src\APIM_ARMTemplate\apimtemplate\Creator\ExampleFiles\XMLPolicies\operationRateLimit.xml # Optional, can be url or local file
2424
products: starter, platinum # Optional, adds api to the specified products
2525
outputLocation: C:\Users\lucashh\Desktop\Projects\APIM-ARM\GeneratedTemplates # Required, folder the creator will write the templates to
26-
linked: false # Optional
26+
linked: true # Optional
2727
linkedTemplatesBaseUrl : https://lucasyamlblob.blob.core.windows.net/yaml # Required if 'linked' property is set to true

src/APIM_ARMTemplate/apimtemplate/Creator/TemplateCreators/APITemplateCreator.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task<Template> CreateInitialAPITemplateAsync(CreatorConfig creatorC
3232
};
3333

3434
List<TemplateResource> resources = new List<TemplateResource>();
35-
// create api resource with properties
35+
// create api resource w/ metadata
3636
APITemplateResource initialAPITemplateResource = await this.CreateInitialAPITemplateResource(creatorConfig);
3737
resources.Add(initialAPITemplateResource);
3838

@@ -55,7 +55,7 @@ public async Task<Template> CreateSubsequentAPITemplateAsync(CreatorConfig creat
5555
string[] dependsOnSubsequentAPI = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis', parameters('ApimServiceName'), '{apiName}')]" };
5656

5757
List<TemplateResource> resources = new List<TemplateResource>();
58-
// create api resource with properties
58+
// create api resource w/ swagger content and policies
5959
APITemplateResource subsequentAPITemplateResource = await this.CreateSubsequentAPITemplateResourceAsync(creatorConfig);
6060
PolicyTemplateResource apiPolicyResource = await this.policyTemplateCreator.CreateAPIPolicyTemplateResourceAsync(creatorConfig, dependsOnSubsequentAPI);
6161
List<PolicyTemplateResource> operationPolicyResources = await this.policyTemplateCreator.CreateOperationPolicyTemplateResourcesAsync(creatorConfig, dependsOnSubsequentAPI);
@@ -96,7 +96,7 @@ public async Task<APITemplateResource> CreateInitialAPITemplateResource(CreatorC
9696
// if the template is not linked the depends on for the apiVersionSet needs to be inlined here
9797
dependsOn = new string[] { }
9898
};
99-
// if there is a linked template and a version set was created, the initial api depends on it
99+
// if the template is linked and a version set was created, the initial api depends on it
100100
if (creatorConfig.linked == false && creatorConfig.apiVersionSet != null)
101101
{
102102
apiTemplateResource.dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/api-version-sets', parameters('ApimServiceName'), 'versionset')]" };
@@ -139,6 +139,7 @@ public async Task<APITemplateResource> CreateSubsequentAPITemplateResourceAsync(
139139

140140
public string[] CreateProtocols(OpenApiDocument doc)
141141
{
142+
// pull protocols from swagger OpenApiDocument
142143
List<string> protocols = new List<string>();
143144
foreach (OpenApiServer server in doc.Servers)
144145
{

src/APIM_ARMTemplate/apimtemplate/Creator/TemplateCreators/MasterTemplateCreator.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ public Template CreateLinkedMasterTemplate(Template apiVersionSetTemplate,
2929
if (apiVersionSetTemplate != null)
3030
{
3131
string apiVersionSetUri = $"[concat(parameters('LinkedTemplatesBaseUrl'), '{creatorFileNames.apiVersionSet}')]";
32-
resources.Add(this.CreateMasterTemplateResource("versionSetTemplate", apiVersionSetUri, new string[] { }));
32+
resources.Add(this.CreateLinkedMasterTemplateResource("versionSetTemplate", apiVersionSetUri, new string[] { }));
3333
}
3434

3535
//api
3636
string initialAPIUri = $"[concat(parameters('LinkedTemplatesBaseUrl'), '{creatorFileNames.initialAPI}')]";
3737
string[] initialAPIDependsOn = apiVersionSetTemplate != null ? new string[] { "[resourceId('Microsoft.Resources/deployments', 'versionSetTemplate')]" } : new string[] { };
38-
resources.Add(this.CreateMasterTemplateResource("initialAPITemplate", initialAPIUri, initialAPIDependsOn));
38+
resources.Add(this.CreateLinkedMasterTemplateResource("initialAPITemplate", initialAPIUri, initialAPIDependsOn));
3939

4040
string subsequentAPIUri = $"[concat(parameters('LinkedTemplatesBaseUrl'), '{creatorFileNames.subsequentAPI}')]";
4141
string[] subsequentAPIDependsOn = apiVersionSetTemplate != null ? new string[] { "[resourceId('Microsoft.Resources/deployments', 'initialAPITemplate')]" } : new string[] { };
42-
resources.Add(this.CreateMasterTemplateResource("subsequentAPITemplate", subsequentAPIUri, subsequentAPIDependsOn));
42+
resources.Add(this.CreateLinkedMasterTemplateResource("subsequentAPITemplate", subsequentAPIUri, subsequentAPIDependsOn));
4343

4444
masterTemplate.resources = resources.ToArray();
4545
return masterTemplate;
@@ -88,7 +88,7 @@ public Template CreateSubsequentUnlinkedMasterTemplate(Template subequentAPITemp
8888
return masterTemplate;
8989
}
9090

91-
public MasterTemplateResource CreateMasterTemplateResource(string name, string uriLink, string[] dependsOn)
91+
public MasterTemplateResource CreateLinkedMasterTemplateResource(string name, string uriLink, string[] dependsOn)
9292
{
9393
MasterTemplateResource masterTemplateResource = new MasterTemplateResource()
9494
{
@@ -116,6 +116,7 @@ public MasterTemplateResource CreateMasterTemplateResource(string name, string u
116116
public Dictionary<string, TemplateParameterProperties> CreateMasterTemplateParameters(bool linked)
117117
{
118118
// used to create the parameter metatadata, etc (not value) for use in file with resources
119+
// add parameters with metatdata properties
119120
Dictionary<string, TemplateParameterProperties> parameters = new Dictionary<string, TemplateParameterProperties>();
120121
TemplateParameterProperties apimServiceNameProperties = new TemplateParameterProperties()
121122
{
@@ -147,7 +148,7 @@ public Template CreateMasterTemplateParameterValues(CreatorConfig creatorConfig)
147148
// create empty template
148149
Template masterTemplate = this.templateCreator.CreateEmptyTemplate();
149150

150-
// add parameters
151+
// add parameters with value property
151152
Dictionary<string, TemplateParameterProperties> parameters = new Dictionary<string, TemplateParameterProperties>();
152153
TemplateParameterProperties apimServiceNameProperties = new TemplateParameterProperties()
153154
{

0 commit comments

Comments
 (0)