Creating ESA Credentials

Policy Agent Function requires ESA credentials to be provided as one of the two options:

ESA Credentials In Azure Key Vault

Policy Agent Function uses Key Vault as secure store for sensitive information like ESA username and password.

Create ESA credentials secrets:

  1. Navigate to Key Vault.

  2. Under Objects, select Secrets > Generate/import.

  3. Select Manual, then type in valid json as shown in the example for Secret value.

    {"username": "<policy_export_user>", "password": "<password>"}
    
  4. Select Create.

  5. Navigate to the secret details in Key Vault by selecting the newly created secret.

  6. Inspect the current secret version properties by selecting the current version.

  7. Copy the Secret Identifier value. For example https://<myvault>.vault.azure.net/secrets/<mysecret>/abcdefgxyz8edef595adaehij0d99123.

  8. Record the Secret Identifier for later use.

ESA Credentials From Custom Azure Function App

Policy Agent Function requests ESA username and password from a custom Azure Function App, further referred to as ESA Credentials function. This method may be used to get the username and password from external vaults.

There are four options for configuring Policy Agent authorization with ESA Credentials function: Option 1, Option 2, Option 3 and Option 4. Only one option is expected to be configured at a time.

Create ESA credentials function:

  1. Create Azure HTTP triggered ESA Credentials function using any supported runtime.

    a. There is no input needed.

    b. The function must accept an HTTP POST request.

    c. The function must return the following response schema

    ```
    response: 
    type: json object
      properties: 
        username: string 
        password: string  
    ```
    
    For example,
    
    ```
    {"username": "admin", "password": "Password1234"} 
    ```
    
  2. Configure Policy Agent to use ESA Credentials function app.

    a. Navigate to HTTP triggered function to open ‘Code + Test’ page.

    b. Under ‘Code + Test’ tab on ‘Code + Test’ page select ‘Resource JSON’.

    c. In ‘Resource JSON’ blade record the value of ‘invoke_url_template’ property.

    **'invoke_url_template'** property is located towards the bottom of resource json.
    
    URL must be in the form of 'https://[function-app-name].azurewebsites.[net|us]/api/[http-trigger-name]'.
    
    **ESA Credentials function URL (EsaCredentialsFnUrl):__________**
    

    d. Navigate to Policy Agent function app.

    e. Expand Settings menu item.

    f. Select Environment Variables menu item.

    g. Click Add button.

    h. For Name use PTY_ESA_CREDENTIALS_FUNCTION.

    i. For Value use ESA Credentials function URL (EsaCredentialsFnUrl) recorded in previous steps.

    j. Hit Apply in Add/Edit application setting blade.

    k. Hit Apply in App Settings tab.

  3. Configure Authorization Option 1: Function Key Option 2: Key Vault Option 3: System-assigned Identity Option 4: User-assigned Identity

Authorization Option 1: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from environment variables.
  1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

    Review Azure documentation on how to accomplish this.

  2. Navigate to ESA Credentials function app.

  3. Expand Functions menu item.

  4. Select App Keys.

  5. Record default key value.

    ESA Credentials function key (EsaCredentialsFnKey):_______________

  6. Navigate to Policy Agent function app.

  7. Expand Settings menu item.

  8. Select Environment Variables menu item.

  9. Click Add button.

  10. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY.

  11. For Value use ESA Credentials function key (EsaCredentialsFnKey) recorded in previous steps.

  12. Hit Apply in Add/Edit application setting blade.

  13. Hit Apply in App Settings tab.

Authorization Option 2: Configure Policy Agent to access ESA Credentials function using ESA Credentials function key from Azure Key Vault.
  1. Configure HTTP trigger of ESA Credentials function with authentication level FUNCTION.

    Review Azure documentation on how to accomplish this.

  2. Navigate to ESA Credentials function app.

  3. Expand Functions menu item.

  4. Select App Keys.

  5. Record default key value.

    ESA Credentials function key (EsaCredentialsFnKey):_______________

  6. Navigate to Key Vault.

  7. Under Objects, select Secrets > Generate/import.

  8. Select Manual, type in secret name and use ESA Credentials function key value recorded in previous steps (EsaCredentialsFnKey) for Secret value.

  9. Select Create.

  10. Record Key Vault secret name.

    ESA Credentials function key secret name (EsaCredentialsFnKeySecretName):_______________

  11. Navigate to Policy Agent function app.

  12. Expand Settings menu item.

  13. Select Environment Variables menu item.

  14. Click Add button.

  15. For Name use PTY_ESA_CREDENTIALS_FUNCTION_KEY_SECRET.

  16. For Value use ESA Credentials function key secret name (EsaCredentialsFnKeySecretName) recorded in previous steps.

  17. Hit Apply in Add/Edit application setting blade.

  18. Hit Apply in App Settings tab.

Authorization Option 3: Configure ESA Credentials authentication provider to authorize Policy Agent system-assigned identity.
  1. Navigate to Policy Agent function app

  2. Expand Settings menu item

  3. Select Identity

  4. Select System assigned tab

  5. Status should already be On

    Other Status indicates Policy Agent was installed without system-assigned identity. Before proceeding any further you need to either install Policy Agent with system-assigned identity or follow Option 4 which describes configuration steps for Policy Agent installed with user-assigned managed identity.

  6. Copy Object (principal) ID

  7. Navigate to ESA Credentials function app

  8. Expand Settings menu item

  9. Select Authentication

  10. Select Add identity provider

    Review related Microsoft documentation

  11. Select Microsoft in identity provider dropdown

  12. For App registration type provide details of your choice

  13. For Issuer URL accept the default value

  14. For Client application requirement select Allow requests from any application

    Access will be limited to only the Policy Agent identity in the next step

  15. For Identity requirement select Allow requests from specific identities

  16. For Allowed identities add Object (principal) ID copied in previous step

  17. For Restrict access select Require authentication

  18. For Unauthenticated requests select HTTP 401 Unauthorized: recommended for APIs

  19. Check Token store

  20. Select Add

  21. Click OK to apply constraint

  22. Click Save

  23. Navigate to Application of Microsoft identity provider

    A link to identity providers application is available under Authentication menu item of ESA Credentials function

  24. Expand Manage menu item

  25. Select Expose an API

  26. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

  27. Record Application ID URI of identity provider

    ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

  28. Navigate to Policy Agent function app.

  29. Expand Settings menu item.

  30. Select Environment Variables menu item.

  31. Click Add button.

  32. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

  33. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

    Review Microsoft identity platform default scope

  34. Hit Apply in Add/Edit application setting blade.

  35. Hit Apply in App Settings tab.

Authorization Option 4: Configure ESA Credentials authentication provider to authorize Policy Agent user-assigned identity.
  1. Navigate to Policy Agent function app

  2. Expand Settings menu item

  3. Select Identity

  4. Select User assigned tab

    User-assigned identity should already be provided. Missing user-assigned identity indicates Policy Agent was installed without user-assigned identity. Before proceeding any further you need to either install Policy Agent with user-assigned identity or follow Option 3 which describes configuration steps for Policy Agent installed with system-assigned managed identity.

  5. Copy Client ID

  6. Copy Object (principal) ID

  7. Navigate to ESA Credentials function app

  8. Expand Settings menu item

  9. Select Authentication

  10. Select Add identity provider

    Review related Microsoft documentation

  11. Select Microsoft in identity provider dropdown

  12. For App registration type provide details of your choice

  13. For Issuer URL accept the default value

  14. For Client application requirement select Allow requests from specific client applications

  15. For Allowed client applications add Client ID copied in previous step

  16. Click OK to apply constraint

  17. For Identity requirement select Allow requests from specific identities

  18. For Allowed identities add Object (principal) ID copied in previous step

  19. Click OK to apply constraint

  20. Click Save

  21. Navigate to Application of Microsoft identity provider

    A link to identity providers application is available under Authentication menu item of ESA Credentials function

  22. Expand Manage menu item

  23. Select Expose an API

  24. Copy Application ID URI or select Add if it does not exist and Save to accept the default value

  25. Record Application ID URI of identity provider

    ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri):_______________

  26. Navigate to Policy Agent function app.

  27. Expand Settings menu item.

  28. Select Environment Variables menu item.

  29. Click Add button.

  30. For Name use PTY_ESA_CREDENTIALS_FUNCTION_SCOPE.

  31. For Value use ESA Credentials function Application ID URI (EsaCredentialsFnAppIdUri) recorded in previous steps appended with /.default

    Review Microsoft identity platform default scope

  32. Hit Apply in Add/Edit application setting blade.

  33. Hit Apply in App Settings tab.


Last modified : January 14, 2026