Thanks for working with us offline @Vadim Berman.
For the benefit of the community, the root cause is of this issue was identified to be related to the wrong library being used. We did discuss using Add custom functionality to developer portal - Azure API Management | Microsoft Learn as a workaround; however, this did not work for your specific situation. You were, however, able to determine a more involved solution to get past this issue.The product group has been made aware of this specific issue so we can get a fixed rolled out sooner than later.