An Azure service that provides a hybrid, multi-cloud management platform for APIs.
@Nagashree Balasundaram Thank you for reaching out to Microsoft Q&A. Based on your statement, you are setting up a backend URL using a policy like "<set-backend-service backend-id="test-Backend" />" and would like to assign it to a variable using a set-variable policy.
set-variable policy can assign a value either a string literal or using a policy expression (https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#set-variable). The policy expression has access only to context variable (docs: https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ContextVariables share the full info about the fields) and hence we cannot directly read backend URL specified using backend id.
I tested with the sample policy below and I was able to retrieve the backend URL in the outbound processing using Context.Request.Url. Note, set-backend-service policy is evaluated during backend processing and hence you cannot perform the same in inbound processing to get new backend URL as it is not evaluated yet.
I hope this helps in answering your question. Feel free to reach out if any questions.
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.