question

suvrajyoti-2505 avatar image
0 Votes"
suvrajyoti-2505 asked MayankBargali-MSFT commented

Setting sunset header in the API response

There would be different teams that would be publishing their APIs in our API Management instance. We need to set sunset header in response. I understand we can do so in the Outbound policies of each Product/API/Operation(as per requirement the scope will be different) using the return response policy: https://docs.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#ReturnResponse.

We would need to do the above manually. Is there some way we make it configurable such that different teams wanting to publish can select the scope i.e. the Product/API/Operation and set the sunset header as per the requirements so that manually going and putting in the policy in the azure api management is not required.

Do we need to create a custom task in which different teams publishing apis can se the scope(Product/API/Operation) and apply the policy that set the sunset header in the return response policy : https://docs.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#ReturnResponse. If we go by the custom task , do we need to create separate tasks for Product, API and Operation level? What about existing APIs that already have a policy applied, in that case how do we handle.?


Any inputs in this direction is much appreciated.

Thanks,
SuvraJyoti

azure-api-management
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MayankBargali-MSFT avatar image
0 Votes"
MayankBargali-MSFT answered MayankBargali-MSFT commented

@suvrajyoti-2505 If your different team can return the response/header with the sunset details for their respective APIs then the APIM can pass the same to your end user if you are not transforming the backend response with any of your custom policy. But in case if your backend APIs doesn't response with the sunset details then inidividual team need to create their own custom policy to change/add the sunset response according to their sunset time.

The best option would be your backend API's returning the sunset details so the APIM can pass the same backend response to the end users.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Mayank,

We are transforming the backend response with our custom policy and our backend APIs doesn't response with the sunset details .

Below are the screenshots of task that we have that different teams can use to create or update an API in the APIM.

You have suggested "individual team need to create their own custom policy to change/add the sunset response according to their sunset time"
As can be seen in the screenshot we have created a custom task that has the option to specify the policy.


  • List item

Do we need to create separate Custom Tasks in the pipeline for the different scopes i.e Product, API, Operation.

  • List item
    Or we can have a single custom task where we can specify the Scope by selecting from a dropdown that has the options : Product, API, Operation. Lets say we select the scope as "Product", a separate dropdown gets filled with all the Products from which the publisher can select the Product and can specify the policy.

  • List item

Is there a way where we can append the return response policy for an already existing Product/API/Operation or we need to get hold of the old policy and then chip in the change for the return response policy

All i am trying to figure out is how to make setting up the Sunset details configurable across the teams.


127420-task-1.png127563-task2.png


0 Votes 0 ·
task-1.png (46.2 KiB)
task2.png (125.1 KiB)

@suvrajyoti-2505 Please find my inline comment

Do we need to create separate Custom Tasks in the pipeline for the different scopes i.e Product, API, Operation.
Yes you need to created seperate custom task.

Or we can have a single custom task where we can specify the Scope by selecting from a dropdown that has the options : Product, API, Operation. Lets say we select the scope as "Product", a separate dropdown gets filled with all the Products from which the publisher can select the Product and can specify the policy.
I think this might be be possible with a Custom Task. This is more towards the devops part and if you need any help with the implementation then I will suggest you to open devops tthread here :
https://stackoverflow.com/questions/tagged/devops
https://developercommunity.visualstudio.com/spaces/21/index.html

Is there a way where we can append the return response policy for an already existing Product/API/Operation or we need to get hold of the old policy and then chip in the change for the return response policy
There is no way to to append it and youl have to update the whole policy file.

Ideally, I think you should follow the git-based devops process for APIM instead of just leveraging ADO Tasks as that will give you more control.

0 Votes 0 ·