From 79f55f52c1dbdab636ff2e0177c92f1151753211 Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Thu, 22 Aug 2024 11:16:03 -0700 Subject: [PATCH] [App Config] Migrate to Bicep (#30857) And update API versions. Live tests run: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4070946&view=results --- .../app-configuration/test/README.md | 2 +- sdk/appconfiguration/test-resources.bicep | 30 +++++++ sdk/appconfiguration/test-resources.json | 85 ------------------- 3 files changed, 31 insertions(+), 86 deletions(-) create mode 100644 sdk/appconfiguration/test-resources.bicep delete mode 100644 sdk/appconfiguration/test-resources.json diff --git a/sdk/appconfiguration/app-configuration/test/README.md b/sdk/appconfiguration/app-configuration/test/README.md index bd64d503a02..ac6032ee3c2 100644 --- a/sdk/appconfiguration/app-configuration/test/README.md +++ b/sdk/appconfiguration/app-configuration/test/README.md @@ -2,7 +2,7 @@ To test this project, make sure to build it by following our [building instructions](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md#building), then follow the [testing instructions](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md#testing). -You can use existing Azure resources for the live tests, or generate new ones by using our [New-TestResources.ps1](https://github.com/Azure/azure-sdk-for-js/blob/main/eng/common/TestResources/New-TestResources.ps1) script, which will use an [ARM template](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/appconfiguration/test-resources.json) that already has all of the the necessary configurations. +You can use existing Azure resources for the live tests, or generate new ones by using our [New-TestResources.ps1](https://github.com/Azure/azure-sdk-for-js/blob/main/eng/common/TestResources/New-TestResources.ps1) script, which will use a [Bicep template](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/appconfiguration/test-resources.bicep) that already has all of the the necessary configurations. The Azure resource that is used by the tests in this project is: diff --git a/sdk/appconfiguration/test-resources.bicep b/sdk/appconfiguration/test-resources.bicep new file mode 100644 index 00000000000..f52541ed67e --- /dev/null +++ b/sdk/appconfiguration/test-resources.bicep @@ -0,0 +1,30 @@ +@minLength(5) +param baseName string = resourceGroup().name +param testApplicationOid string +param location string = resourceGroup().location +param sku string = 'Standard' +param azConfigPrefix string = 'azconfig-resource-js' + +var roleDefinitionId = '5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b' +var uniqueAzConfigName = '${baseName}-${azConfigPrefix}' + +// Create Azure App Configuration Store +resource azConfigStore 'Microsoft.AppConfiguration/configurationStores@2023-09-01-preview' = { + name: uniqueAzConfigName + location: location + sku: { + name: sku + } +} + +// Assign Role to Test Application +resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid(resourceGroup().id) + properties: { + roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionId) + principalId: testApplicationOid + } +} + +// Outputs +output AZ_CONFIG_ENDPOINT string = azConfigStore.properties.endpoint diff --git a/sdk/appconfiguration/test-resources.json b/sdk/appconfiguration/test-resources.json deleted file mode 100644 index fa4dd4e8c5c..00000000000 --- a/sdk/appconfiguration/test-resources.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "baseName": { - "type": "string", - "defaultValue": "[resourceGroup().name]", - "metadata": { - "description": "The base resource name." - } - }, - "tenantId": { - "type": "string", - "metadata": { - "description": "The tenant ID to which the application and resources belong." - } - }, - "testApplicationId": { - "type": "string", - "metadata": { - "description": "The application client ID used to run tests." - } - }, - "testApplicationOid": { - "type": "string", - "metadata": { - "description": "The client OID to grant access to test resources." - } - }, - "location": { - "type": "string", - "defaultValue": "[resourceGroup().location]", - "metadata": { - "description": "The location of the resource. By default, this is the same as the resource group." - } - }, - "sku": { - "defaultValue": "Standard", - "type": "string" - }, - "azConfigPrefix": { - "defaultValue": "azconfig-resource-js", - "type": "string" - }, - "azConfigEndpointSuffix": { - "defaultValue": ".azconfig.io", - "type": "string" - } - }, - "variables": { - "configurationApiVersion": "2019-10-01", - "roleDefinitionId": "[format('/subscriptions/{0}/providers/Microsoft.Authorization/roleDefinitions/5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b', subscription().subscriptionId)]", - "uniqueAzConfigName": "[format('{0}-{1}', parameters('baseName'), parameters('azConfigPrefix'))]", - "endpointValue": "[format('https://{0}-{1}{2}', parameters('baseName'), parameters('azConfigPrefix'), parameters('azConfigEndpointSuffix'))]" - }, - "resources": [ - { - "type": "Microsoft.AppConfiguration/configurationStores", - "apiVersion": "[variables('configurationApiVersion')]", - "name": "[variables('uniqueAzConfigName')]", - "location": "[parameters('location')]", - "sku": { - "name": "[parameters('sku')]" - }, - "properties": { - "endpoint": "[variables('endpointValue')]" - } - }, - { - "type": "Microsoft.Authorization/roleAssignments", - "apiVersion": "2018-09-01-preview", - "name": "[guid(resourceGroup().id)]", - "properties": { - "roleDefinitionId": "[variables('roleDefinitionId')]", - "principalId": "[parameters('testApplicationOid')]" - } - } - ], - "outputs": { - "AZ_CONFIG_ENDPOINT": { - "type": "string", - "value": "[variables('endpointValue')]" - }, - } -}