How to check the existence of context.Subscription.Name ?

Spai 71 Reputation points
2021-02-03T04:37:21.447+00:00

Hi, we want to log subscriber for API use so context.Subscription.Name is used in log-to-eventhub policy. Everything works well when API subscription is enabled.
But sometimes for quick testing purpose, the subscription of API would be disabled, then the policy would fail due to Object reference not set to an instance of an object for missing context.Subscription.Name.

Is there a way to bypass this ? we hope the outcome like this IIf(context.Subscription.Name,context.Subscription.Name,"") , not sure if there's any equivalent syntax for policy like this ?

Thank you

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,175 questions
{count} votes

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.