mirsaeedi / dotnet-apim

dotnet-apim is a cross-platform dotnet tool which streamlines the CI/CD process of deploying APIs into Azure API Management
MIT License
32 stars 10 forks source link

Allow ProductAPI resources to be generated without specifying products array in yml file #37

Closed levimatheri closed 2 years ago

levimatheri commented 2 years ago

First of all, I love this tool! It would be nice if we didn't have to specify the products array in the yml file for the product-api assignments to be added to the output ARM template. This is useful because we manage products as separate arm templates from the APIs. This is the behavior in the apim-azure-devops-toolkit, as in this section of code, it only adds dependsOn on products/apis resource and not products. Besides, we're already adding dependsOn product in the API resource, i.e. products is added as a dependency in ApiDeploymentDefinition. Therefore, if one decides to add the products array in their yml, it should still work.

Currently, if one doesn't include products in the yml, deployment fails with this error: "The resource 'Microsoft.ApiManagement/service/products/***' is not defined in the template"

@mirsaeedi I'd be happy to submit a PR for this.

Thanks.

mirsaeedi commented 2 years ago

Hello @levimatheri. Thanks for you feedback :) Can you please elaborate more on this issue? the products array is not mandatory in the yml file 🤔

levimatheri commented 2 years ago

Hi @mirsaeedi. Yes, the products array is not required in the yml, but if we don't include it and add product assignments in the API definition, the generated ARM adds a dependsOn the product. Since the product resource isn't included in the generated ARM (i.e. because of omitting the products array in the yml), the deployment fails with the error I indicated above, because dependsOn requires that the referenced resource be in the same ARM template. This is the case with API Tags as well. I've updated the PR.

See example: Here's my yml: image

Here's the generated ARM template: image

This is what I'd expect instead: image