stephaneey / azure-apim-extension

Full Azure API Management suite and more VSTS extension
MIT License
66 stars 48 forks source link

Swagger definition is too big #73

Closed MichaelKolb02 closed 4 years ago

MichaelKolb02 commented 4 years ago

Dear Stephane,

great work you are doing here!

Just a technical question / issue: I am trying to automate deployment for a rather big API and receive the following error:

2020-02-15T23:53:51.7163250Z ##[warning]Environment variable 'INPUT_SWAGGERCODE' exceeds the maximum supported length. Environment variable length: 84981 , Maximum supported length: 32766 2020-02-15T23:53:53.0138997Z ##[debug]VstsTaskSdk 0.10.0 commit 787a46ec0a2df5b4d12c2e801bd3f319975c054c 2020-02-15T23:54:04.5878655Z ##[debug]Caught exception from task script. 2020-02-15T23:54:04.5922786Z ##[debug]Error record: 2020-02-15T23:54:04.6790899Z ##[debug]ConvertTo-SecureString : Capacity exceeds maximum capacity. 2020-02-15T23:54:04.6879823Z ##[debug]Parameter name: capacity

When trying to download the swagger.json via Url, I receive another error.

I saw that this could be solved by using PowerShell Core, but I assume this is wired in your task definition. Any way to set the Powershell version to use globally or work around this?

BR Michael

stephaneey commented 4 years ago

Hello,

Given the warnings, it's rather a limitation of environment variable length that have a smallint capacity. Not sure using PowerShell core instead of PowerShell would make any difference. You should maybe indeed switch to URL or Azure DevOps artifact for a lengthy OpenAPI definition. If you have an error, feel free to post another issue :). For this one, I'm not even generating those environment variables myself and porting everything to PowerShell Core is not an option at this time.

Best Regards

MichaelKolb02 commented 4 years ago

Dear Stephane,

thanks for analyzing - I heavily agree. I was using the Uri before but received a very generic error:

2020-02-16T19:10:00.5756788Z ##[error]You cannot call a method on a null-valued expression.

After looking into this a bit, I supposed it was around line 161 of this file: https://github.com/stephaneey/azure-apim-extension/blob/master/apimversioned/v3/apimversioned.ps1

So I ran a test with a PS script and got a 403:

2020-02-16T17:47:19.2020710Z Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (403) Forbidden."

Which basically means I secured the Web App very good but it would be great if your script could output that :-)

BR Michael