ApiCenterProductionVersionPlugin

Checks if the APIs used in an app are production version of the APIs registered in the specified Azure API Center instance.

Screenshot of a command prompt showing Dev Proxy checking if the recorded API requests match production version APIs registered in Azure API Center.

Configuration example

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "ApiCenterProductionVersionPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "apiCenterProductionVersionPlugin"
    }
  ],
  "apiCenterProductionVersionPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/apicenterproductionversionplugin.schema.json",
    "subscriptionId": "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e",
    "resourceGroupName": "resource-group-name",
    "serviceName": "apic-instance",
    "workspaceName": "default"
  }
}

Configuration properties

Property Description Default
resourceGroupName Name of the resource group where the Azure API Center is located. None
serviceName Name of the Azure API Center instance that Dev Proxy should use to check if the APIs used in the app are registered. None
subscriptionId ID of the Azure subscription where the Azure API Center instance is located. None
workspaceName Name of the Azure API Center workspace to use. default

Command line options

None

Remarks

The ApiCenterProductionVersionPlugin plugin checks if the APIs used in an app are production version of the APIs registered in the specified Azure API Center instance. If the APIs match nonproduction versions, the plugin shows a warning.

To connect to Azure API Center, the plugin uses Azure credentials (in this order):

  • Environment
  • Workload Identity
  • Managed Identity
  • Visual Studio
  • Visual Studio Code
  • Azure CLI
  • Azure PowerShell
  • Azure Developer CLI

If the plugin fails to get an access token to access Azure, it shows an error and Dev Proxy disables it. Sign in to Azure using either of these tools, and restart Dev Proxy to use the ApiCenterProductionVersionPlugin plugin.

If you use Dev Proxy in CI/CD pipelines, you can pass values for the subscriptionId, resourceGroupName, serviceName, and workspaceName properties as environment variables. To reference an environment variable, use the ${VAR_NAME} placeholder, for example:

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "ApiCenterProductionVersionPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "apiCenterProductionVersionPlugin"
    }
  ],
  "apiCenterProductionVersionPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/apicenterproductionversionplugin.schema.json",
    "subscriptionId": "${AZURE_SUBSCRIPTION_ID}",
    "resourceGroupName": "${AZURE_RESOURCE_GROUP_NAME}",
    "serviceName": "${AZURE_APIC_INSTANCE_NAME}",
    "workspaceName": "${AZURE_APIC_WORKSPACE_NAME}"
  }
}

In this example, the ApiCenterProductionVersionPlugin plugin sets subscriptionId, resourceGroupName, serviceName, and workspaceName properties to the values of the AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP_NAME, AZURE_APIC_INSTANCE_NAME, and AZURE_APIC_WORKSPACE_NAME environment variables, respectively.

If an environment variable referenced in the configuration isn't set, Dev Proxy leaves the placeholder as-is and logs a warning, for example Environment variable AZURE_SUBSCRIPTION_ID referenced in /Users/user/devproxyrc.json isn't set. Leaving the placeholder as-is. For more information, see Use environment variables in configuration files.

Note

Earlier versions of Dev Proxy referenced environment variables by prefixing the variable name with @, for example "subscriptionId": "@AZURE_SUBSCRIPTION_ID". This syntax still works but is deprecated and Dev Proxy logs a warning when you use it. If an environment variable referenced using @ isn't set or is empty, the plugin shows an error, for example Environment variable AZURE_SUBSCRIPTION_ID referenced by subscriptionId isn't set., and Dev Proxy disables it. Use ${VAR_NAME} instead.

Next step