Error when retrieving AKV secret in ADF rest API linked service

Carrie 50 Reputation points
2025-02-10T06:09:11.6466667+00:00

Hi,

Is there any solution for this issue?

I got error when retrieving AKV secret using parameter

."message": "ErrorCode=InvalidTemplate, ErrorMessage=The template function 'linkedService' is not defined or not valid."

Here are the steps to reproduce the issue

  1. I created AKV linked service, using parameter like below User's image
  2. I created a rest api linked service, and try to retrieve a secret by using the AKV above , and append it to Auth headers, like belowUser's image
  3. click test connection, I got error "message": "ErrorCode=InvalidTemplate, ErrorMessage=The template function 'linkedService' is not defined or not valid."

And I could see, I have another linked service, it is retrieving AKV secret like below. it works perfect, but got error only for the rest API, where I would need to retrieve it in Auth headers

User's image

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,381 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,272 questions
{count} votes

Accepted answer
  1. Smaran Thoomu 20,305 Reputation points Microsoft Vendor
    2025-02-12T15:59:39.3166667+00:00

    Hi @Carrie
    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others "I'll repost your solution in case you'd like to accept the answer.

    Ask: Is there any solution for this issue?

    I got error when retrieving AKV secret using parameter

    ."message": "ErrorCode=InvalidTemplate, ErrorMessage=The template function 'linkedService' is not defined or not valid."

    Here are the steps to reproduce the issue

    1. I created AKV linked service, using parameter like below User's image
    2. I created a rest api linked service, and try to retrieve a secret by using the AKV above , and append it to Auth headers, like belowUser's image
    3. click test connection, I got error "message": "ErrorCode=InvalidTemplate, ErrorMessage=The template function 'linkedService' is not defined or not valid."

    And I could see, I have another linked service, it is retrieving AKV secret like below. it works perfect, but got error only for the rest API, where I would need to retrieve it in Auth headers

    User's image

    Solution: I found somewhat the issue was because that we could not set AKV URL directly.

    I have to

    1. set AKV URL as parameter in REST API,
    2. Click the AKV like below in Auth Header User's image
    3. And set the AKV URL as @string(linkedService().AKVURL), like below, and it would work perfectly!User's image

    If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.


    Please don’t forget to Accept Answer and Yes for "was this answer helpful" wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Carrie 50 Reputation points
    2025-02-12T13:31:52.6966667+00:00

    Hi @Smaran Thoomu

    I really appreciated your help! Just because the answer you shared me before was not matching my issue, so I pressed "No".

    And I have resolved my issue.

    I found somewhat the issue was because that we could not set AKV URL directly.

    I have to

    1. set AKV URL as parameter in REST API,
    2. Click the AKV like below in Auth Header User's image
    3. And set the AKV URL as @string(linkedService().AKVURL), like below, and it would work perfectly!User's image

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.