From a3bd4518560883f610d7be2b99732f465ccb8851 Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Thu, 22 Aug 2024 21:01:58 -0700 Subject: [PATCH] [Maps] Migrate to Bicep (#30867) And update API versions. Live tests run: - https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4075004&view=results - https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4075005&view=results - https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4075006&view=results - https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4075007&view=results --- sdk/maps/maps-geolocation-rest/tests.yml | 1 + sdk/maps/maps-render-rest/tests.yml | 1 + sdk/maps/maps-route-rest/tests.yml | 1 + sdk/maps/maps-search-rest/tests.yml | 1 + sdk/maps/test-resources.bicep | 44 +++++++++++++++ sdk/maps/test-resources.json | 70 ------------------------ 6 files changed, 48 insertions(+), 70 deletions(-) create mode 100644 sdk/maps/test-resources.bicep delete mode 100644 sdk/maps/test-resources.json diff --git a/sdk/maps/maps-geolocation-rest/tests.yml b/sdk/maps/maps-geolocation-rest/tests.yml index e9a025207d8..c771aa615e9 100644 --- a/sdk/maps/maps-geolocation-rest/tests.yml +++ b/sdk/maps/maps-geolocation-rest/tests.yml @@ -5,5 +5,6 @@ extends: parameters: PackageName: "@azure-rest/maps-geolocation" ServiceDirectory: maps + Location: 'eastus' SupportedClouds: 'Public,Canary' UseFederatedAuth: true diff --git a/sdk/maps/maps-render-rest/tests.yml b/sdk/maps/maps-render-rest/tests.yml index d84dae93e03..bbb9ac30b55 100644 --- a/sdk/maps/maps-render-rest/tests.yml +++ b/sdk/maps/maps-render-rest/tests.yml @@ -5,5 +5,6 @@ extends: parameters: PackageName: "@azure-rest/maps-render" ServiceDirectory: maps + Location: 'eastus' SupportedClouds: 'Public,Canary' UseFederatedAuth: true diff --git a/sdk/maps/maps-route-rest/tests.yml b/sdk/maps/maps-route-rest/tests.yml index 5a498924fe1..45129202fc7 100644 --- a/sdk/maps/maps-route-rest/tests.yml +++ b/sdk/maps/maps-route-rest/tests.yml @@ -5,5 +5,6 @@ extends: parameters: PackageName: "@azure-rest/maps-route" ServiceDirectory: maps + Location: 'eastus' SupportedClouds: 'Public,Canary' UseFederatedAuth: true diff --git a/sdk/maps/maps-search-rest/tests.yml b/sdk/maps/maps-search-rest/tests.yml index 9863025e26f..c6c124f582e 100644 --- a/sdk/maps/maps-search-rest/tests.yml +++ b/sdk/maps/maps-search-rest/tests.yml @@ -5,5 +5,6 @@ extends: parameters: PackageName: "@azure-rest/maps-search" ServiceDirectory: maps + Location: 'eastus' SupportedClouds: 'Public,Canary' UseFederatedAuth: true diff --git a/sdk/maps/test-resources.bicep b/sdk/maps/test-resources.bicep new file mode 100644 index 00000000000..b349494563b --- /dev/null +++ b/sdk/maps/test-resources.bicep @@ -0,0 +1,44 @@ +param baseName string = resourceGroup().name +param location string = resourceGroup().location +param testApplicationOid string + +var mapsDataContributerRoleId = '8f5e0ce6-4f7b-4dcf-bddf-e6f48634a204' +var mapsAccountName = guid(resourceGroup().id, deployment().name, baseName) + +// Microsoft.Maps/accounts resource +resource mapsAccount 'Microsoft.Maps/accounts@2024-01-01-preview' = { + name: mapsAccountName + location: location + sku: { + name: 'G2' + } + kind: 'Gen2' + identity: { + type: 'None' + } + properties: { + disableLocalAuth: false + cors: { + corsRules: [ + { + allowedOrigins: [ + '*' + ] + } + ] + } + } +} + +// Microsoft.Authorization/roleAssignments resource +resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid(resourceGroup().id) + properties: { + roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', mapsDataContributerRoleId) + principalId: testApplicationOid + } +} + +// Outputs +output MAPS_SUBSCRIPTION_KEY string = mapsAccount.listKeys().primaryKey +output MAPS_RESOURCE_CLIENT_ID string = mapsAccount.properties.uniqueId diff --git a/sdk/maps/test-resources.json b/sdk/maps/test-resources.json deleted file mode 100644 index c5af48e6b93..00000000000 --- a/sdk/maps/test-resources.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "baseName": { - "type": "string", - "defaultValue": "[resourceGroup().name]", - "metadata": { - "description": "The base resource name." - } - }, - "testApplicationOid": { - "type": "string", - "metadata": { - "description": "The client OID to grant access to test resources." - } - } - }, - "variables": { - "roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/8f5e0ce6-4f7b-4dcf-bddf-e6f48634a204')]", - "mapsAccountName": "[guid(resourceGroup().id, deployment().name, parameters('baseName'))]" - }, - "resources": [ - { - "type": "Microsoft.Maps/accounts", - "apiVersion": "2021-12-01-preview", - "name": "[variables('mapsAccountName')]", - "location": "eastus", - "sku": { - "name": "G2", - "tier": "Standard" - }, - "kind": "Gen2", - "identity": { - "type": "None" - }, - "properties": { - "disableLocalAuth": false, - "cors": { - "corsRules": [ - { - "allowedOrigins": [ - "*" - ] - } - ] - } - } - }, - { - "type": "Microsoft.Authorization/roleAssignments", - "apiVersion": "2018-09-01-preview", - "name": "[guid(resourceGroup().id)]", - "properties": { - "roleDefinitionId": "[variables('roleDefinitionId')]", - "principalId": "[parameters('testApplicationOid')]" - } - } - ], - "outputs": { - "MAPS_SUBSCRIPTION_KEY": { - "type": "string", - "value": "[listKeys(resourceId('Microsoft.Maps/accounts',variables('mapsAccountName')), '2021-12-01-preview').primaryKey]" - }, - "MAPS_RESOURCE_CLIENT_ID": { - "type": "string", - "value": "[reference(resourceId('Microsoft.Maps/accounts',variables('mapsAccountName'))).uniqueId]" - } - } -}