Skip to content

Commit

Permalink
fix: APIM SKUs not deploying due to incorrect param logic (#2565)
Browse files Browse the repository at this point in the history
## Description

<!--
>Thank you for your contribution !
> Please include a summary of the change and which issue is fixed.
> Please also include the context.
> List any dependencies that are required for this change.

Fixes #123
Fixes #456
Closes #123
Closes #456
-->
Closes #2561 

- Added tests for different SKUs to ensure no more issues in the future
- Disable some APIM PSRule tests that are $$ and not necessary for
non-prod deployments
- fix logic to ensure various SKUs can be deployed and use availability
zones and scale units

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.api-management.service](https://github.com/tony-box/bicep-registry-modules/actions/workflows/avm.res.api-management.service.yml/badge.svg?branch=fix%2F2561)](https://github.com/tony-box/bicep-registry-modules/actions/workflows/avm.res.api-management.service.yml)
|

## Type of Change

<!-- Use the checkboxes [x] on the options that are relevant. -->

- [ ] Update to CI Environment or utilities (Non-module affecting
changes)
- [x] Azure Verified Module updates:
- [x] Bugfix containing backwards-compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [x] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [x] Update to documentation

## Checklist

- [x] I'm sure there are no other open Pull Requests for the same
update/change
- [x] I have run `Set-AVMModule` locally to generate the supporting
module files.
- [x] My corresponding pipelines / checks run clean and green without
any errors or warnings

<!-- Please keep up to date with the contribution guide at
https://aka.ms/avm/contribute/bicep -->

---------

Co-authored-by: Tony Box <tobox@microsoft.com>
  • Loading branch information
tony-box and Tony Box authored Jul 24, 2024
1 parent aac0eb7 commit d25ccbc
Show file tree
Hide file tree
Showing 25 changed files with 368 additions and 152 deletions.
184 changes: 151 additions & 33 deletions avm/res/api-management/service/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# API Management Services `[Microsoft.ApiManagement/service]`

This module deploys an API Management Service.
This module deploys an API Management Service. The default deployment is set to use a Premium SKU to align with Microsoft WAF-aligned best practices. In most cases, non-prod deployments should use a lower-tier SKU.

## Navigation

Expand All @@ -16,7 +16,7 @@ This module deploys an API Management Service.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.ApiManagement/service` | [2023-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ApiManagement/2023-05-01-preview/service) |
| `Microsoft.ApiManagement/service` | [2023-05-01-preview](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ApiManagement/service) |
| `Microsoft.ApiManagement/service/apis` | [2022-08-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ApiManagement/2022-08-01/service/apis) |
| `Microsoft.ApiManagement/service/apis/diagnostics` | [2022-08-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ApiManagement/2022-08-01/service/apis/diagnostics) |
| `Microsoft.ApiManagement/service/apis/policies` | [2022-08-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.ApiManagement/2022-08-01/service/apis/policies) |
Expand Down Expand Up @@ -45,12 +45,74 @@ The following section provides usage examples for the module, which were used to
>**Note**: To reference the module, please use the following syntax `br/public:avm/res/api-management/service:<version>`.
- [Using only defaults](#example-1-using-only-defaults)
- [Using large parameter set](#example-2-using-large-parameter-set)
- [Test deploying apim v2 sku](#example-3-test-deploying-apim-v2-sku)
- [WAF-aligned](#example-4-waf-aligned)
- [Deploying a Consumption SKU](#example-1-deploying-a-consumption-sku)
- [Using only defaults](#example-2-using-only-defaults)
- [Deploying a Developer SKU](#example-3-deploying-a-developer-sku)
- [Using large parameter set](#example-4-using-large-parameter-set)
- [Deploying an APIM v2 sku](#example-5-deploying-an-apim-v2-sku)
- [WAF-aligned](#example-6-waf-aligned)

### Example 1: _Using only defaults_
### Example 1: _Deploying a Consumption SKU_

This instance deploys the module using a Consumption SKU.


<details>

<summary>via Bicep module</summary>

```bicep
module service 'br/public:avm/res/api-management/service:<version>' = {
name: 'serviceDeployment'
params: {
// Required parameters
name: 'apiscon001'
publisherEmail: 'apimgmt-noreply@mail.windowsazure.com'
publisherName: 'az-amorg-x-001'
// Non-required parameters
location: '<location>'
sku: 'Consumption'
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"name": {
"value": "apiscon001"
},
"publisherEmail": {
"value": "apimgmt-noreply@mail.windowsazure.com"
},
"publisherName": {
"value": "az-amorg-x-001"
},
// Non-required parameters
"location": {
"value": "<location>"
},
"sku": {
"value": "Consumption"
}
}
}
```

</details>
<p>

### Example 2: _Using only defaults_

This instance deploys the module with the minimum set of required parameters.

Expand Down Expand Up @@ -106,7 +168,67 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
</details>
<p>

### Example 2: _Using large parameter set_
### Example 3: _Deploying a Developer SKU_

This instance deploys the module using a Developer SKU.


<details>

<summary>via Bicep module</summary>

```bicep
module service 'br/public:avm/res/api-management/service:<version>' = {
name: 'serviceDeployment'
params: {
// Required parameters
name: 'apisdev001'
publisherEmail: 'apimgmt-noreply@mail.windowsazure.com'
publisherName: 'az-amorg-x-001'
// Non-required parameters
location: '<location>'
sku: 'Developer'
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
// Required parameters
"name": {
"value": "apisdev001"
},
"publisherEmail": {
"value": "apimgmt-noreply@mail.windowsazure.com"
},
"publisherName": {
"value": "az-amorg-x-001"
},
// Non-required parameters
"location": {
"value": "<location>"
},
"sku": {
"value": "Developer"
}
}
}
```

</details>
<p>

### Example 4: _Using large parameter set_

This instance deploys the module with most of its features enabled.

Expand Down Expand Up @@ -598,9 +720,9 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
</details>
<p>

### Example 3: _Test deploying apim v2 sku_
### Example 5: _Deploying an APIM v2 sku_

This instance deploys the module using a v2 SKU with the minimum set of required parameters.
This instance deploys the module using a v2 SKU.


<details>
Expand Down Expand Up @@ -658,7 +780,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
</details>
<p>

### Example 4: _WAF-aligned_
### Example 6: _WAF-aligned_

This instance deploys the module in alignment with the best-practices of the Azure Well-Architected Framework.

Expand Down Expand Up @@ -1113,6 +1235,12 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
| [`publisherEmail`](#parameter-publisheremail) | string | The email address of the owner of the service. |
| [`publisherName`](#parameter-publishername) | string | The name of the owner of the service. |

**Conditional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`skuCapacity`](#parameter-skucapacity) | int | The scale units for this API Management service. Required if using Basic, Standard, or Premium skus. For range of capacities for each sku, reference https://azure.microsoft.com/en-us/pricing/details/api-management/. |

**Optional parameters**

| Parameter | Type | Description |
Expand All @@ -1125,7 +1253,7 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
| [`backends`](#parameter-backends) | array | Backends. |
| [`caches`](#parameter-caches) | array | Caches. |
| [`certificates`](#parameter-certificates) | array | List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. |
| [`customProperties`](#parameter-customproperties) | object | Custom properties of the API Management service. |
| [`customProperties`](#parameter-customproperties) | object | Custom properties of the API Management service. Not supported if SKU is Consumption. |
| [`diagnosticSettings`](#parameter-diagnosticsettings) | array | The diagnostic settings of the service. |
| [`disableGateway`](#parameter-disablegateway) | bool | Property only valid for an API Management service deployed in multiple locations. This can be used to disable the gateway in master region. |
| [`enableClientCertificate`](#parameter-enableclientcertificate) | bool | Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also enables the ability to authenticate the certificate in the policy on the gateway. |
Expand All @@ -1147,12 +1275,11 @@ module service 'br/public:avm/res/api-management/service:<version>' = {
| [`restore`](#parameter-restore) | bool | Undelete API Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. |
| [`roleAssignments`](#parameter-roleassignments) | array | Array of role assignments to create. |
| [`sku`](#parameter-sku) | string | The pricing tier of this API Management service. |
| [`skuCount`](#parameter-skucount) | int | The instance size of this API Management service. Not supported with V2 SKUs. If using Consumption, sku should = 0. |
| [`subnetResourceId`](#parameter-subnetresourceid) | string | The full resource ID of a subnet in a virtual network to deploy the API Management service in. |
| [`subscriptions`](#parameter-subscriptions) | array | Subscriptions. |
| [`tags`](#parameter-tags) | object | Tags of the resource. |
| [`virtualNetworkType`](#parameter-virtualnetworktype) | string | The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual Network, External means the API Management deployment is set up inside a Virtual Network having an internet Facing Endpoint, and Internal means that API Management deployment is setup inside a Virtual Network having an Intranet Facing Endpoint only. |
| [`zones`](#parameter-zones) | array | A list of availability zones denoting where the resource needs to come from. Not supported with V2 SKUs. |
| [`zones`](#parameter-zones) | array | A list of availability zones denoting where the resource needs to come from. Only supported by Premium sku. |

### Parameter: `name`

Expand All @@ -1175,6 +1302,14 @@ The name of the owner of the service.
- Required: Yes
- Type: string

### Parameter: `skuCapacity`

The scale units for this API Management service. Required if using Basic, Standard, or Premium skus. For range of capacities for each sku, reference https://azure.microsoft.com/en-us/pricing/details/api-management/.

- Required: No
- Type: int
- Default: `2`

### Parameter: `additionalLocations`

Additional datacenter locations of the API Management service. Not supported with V2 SKUs.
Expand Down Expand Up @@ -1241,7 +1376,7 @@ List of Certificates that need to be installed in the API Management service. Ma

### Parameter: `customProperties`

Custom properties of the API Management service.
Custom properties of the API Management service. Not supported if SKU is Consumption.

- Required: No
- Type: object
Expand Down Expand Up @@ -1704,23 +1839,6 @@ The pricing tier of this API Management service.
]
```

### Parameter: `skuCount`

The instance size of this API Management service. Not supported with V2 SKUs. If using Consumption, sku should = 0.

- Required: No
- Type: int
- Default: `2`
- Allowed:
```Bicep
[
0
1
2
3
]
```

### Parameter: `subnetResourceId`

The full resource ID of a subnet in a virtual network to deploy the API Management service in.
Expand Down Expand Up @@ -1761,7 +1879,7 @@ The type of VPN in which API Management service needs to be configured in. None

### Parameter: `zones`

A list of availability zones denoting where the resource needs to come from. Not supported with V2 SKUs.
A list of availability zones denoting where the resource needs to come from. Only supported by Premium sku.

- Required: No
- Type: array
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/api-version-set/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "2869637630248924190"
"version": "0.29.47.4906",
"templateHash": "17159723717884761443"
},
"name": "API Management Service API Version Sets",
"description": "This module deploys an API Management Service API Version Set.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/api/diagnostics/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "15990218139655805007"
"version": "0.29.47.4906",
"templateHash": "15630166564208731013"
},
"name": "API Management Service APIs Diagnostics.",
"description": "This module deploys an API Management Service API Diagnostics.",
Expand Down
12 changes: 6 additions & 6 deletions avm/res/api-management/service/api/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "4127687153063244658"
"version": "0.29.47.4906",
"templateHash": "13121653397859804060"
},
"name": "API Management Service APIs",
"description": "This module deploys an API Management Service API.",
Expand Down Expand Up @@ -281,8 +281,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "5034167782203178970"
"version": "0.29.47.4906",
"templateHash": "2474188503939052987"
},
"name": "API Management Service APIs Policies",
"description": "This module deploys an API Management Service API Policy.",
Expand Down Expand Up @@ -428,8 +428,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "15990218139655805007"
"version": "0.29.47.4906",
"templateHash": "15630166564208731013"
},
"name": "API Management Service APIs Diagnostics.",
"description": "This module deploys an API Management Service API Diagnostics.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/api/policy/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "5034167782203178970"
"version": "0.29.47.4906",
"templateHash": "2474188503939052987"
},
"name": "API Management Service APIs Policies",
"description": "This module deploys an API Management Service API Policy.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/authorization-server/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "17095671534556603009"
"version": "0.29.47.4906",
"templateHash": "4256977187793378377"
},
"name": "API Management Service Authorization Servers",
"description": "This module deploys an API Management Service Authorization Server.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/backend/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "1411324864869146839"
"version": "0.29.47.4906",
"templateHash": "2365531440872951056"
},
"name": "API Management Service Backends",
"description": "This module deploys an API Management Service Backend.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/cache/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "8223409608484938303"
"version": "0.29.47.4906",
"templateHash": "3234729148013684780"
},
"name": "API Management Service Caches",
"description": "This module deploys an API Management Service Cache.",
Expand Down
4 changes: 2 additions & 2 deletions avm/res/api-management/service/identity-provider/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.28.1.47646",
"templateHash": "834622836195899034"
"version": "0.29.47.4906",
"templateHash": "13129392765749462635"
},
"name": "API Management Service Identity Providers",
"description": "This module deploys an API Management Service Identity Provider.",
Expand Down
Loading

0 comments on commit d25ccbc

Please sign in to comment.