{
  "$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."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "The location of the resource. By default, this is the same as the resource group."
      }
    },
    "isolatedSigningCertificate": {
      "type": "string",
      "defaultValue": ""
    },
    "locationShortName": {
      "type": "string",
      "defaultValue": ""
    },
    "tenantId": {
      "type": "string",
      "defaultValue": "72f988bf-86f1-41af-91ab-2d7cd011db47",
      "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."
      }
    }
  },
  "variables": {
    "isolatedTenantName": "[concat('cp', concat(parameters('baseName'), 'iso'))]",
    "aadTenantName": "[concat('cp', concat(parameters('baseName'), 'aad'))]",
    "isolatedUri": "[format('https://{0}.{1}.attest.azure.net', variables('isolatedTenantName'), parameters('locationShortName'))]",
    "aadUri": "[format('https://{0}.{1}.attest.azure.net', variables('aadTenantName'), parameters('locationShortName'))]",
    "PolicySigningCertificates": {
      "PolicySigningCertificates": {
        "keys": [
          {
            "kty": "RSA",
            "use": "sig",
            "x5c": [ "[parameters('isolatedSigningCertificate')]" ]
          }
        ]
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Attestation/attestationProviders",
      "apiVersion": "2020-10-01",
      "name": "[variables('aadTenantName')]",
      "location": "[parameters('location')]"
    },
    {
      "type": "Microsoft.Attestation/attestationProviders",
      "apiVersion": "2020-10-01",
      "name": "[variables('isolatedTenantName')]",
      "location": "[parameters('location')]",
      "properties": "[variables('PolicySigningCertificates')]"
    }
  ],
  "outputs": {
    "ATTESTATION_ISOLATED_URL": {
      "type": "string",
      "value": "[variables('isolatedUri')]"
    },
    "ATTESTATION_AAD_URL": {
      "type": "string",
      "value": "[variables('aadUri')]"
    },
    "AZURE_TENANT_ID": {
      "type": "string",
      "value": "[parameters('tenantId')]"
    },
    "AZURE_CLIENT_ID": {
      "type": "string",
      "value": "[parameters('testApplicationId')]"
    }
  }
}
