microsoft / vscode-azurefunctions

Azure Functions extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions
MIT License
290 stars 133 forks source link

Azure Function Deployment Fails with Throttling Error on Large Subscriptions (146+ Function-Apps) #4237

Closed JoshuaAndrae closed 2 months ago

JoshuaAndrae commented 2 months ago

Problem Description: When attempting to deploy an Azure Function using the extension in Visual Studio Code, the deployment consistently fails with a throttling error related to the subscription. This issue occurs despite successful deployments via PowerShell and Azure DevOps Pipelines.

Steps to Reproduce: Open Visual Studio Code and load the Azure Functions extension. Attempt to deploy an Azure Function to a subscription with 146+ Azure Function apps. Observe the throttling error in the output window. Expected Result: The Azure Function should deploy successfully without throttling errors, as it does via PowerShell and Azure DevOps Pipelines.

Actual Result: Deployment fails with the following error: GET Operation on subscriptions/{subscriptionId}/providers/Microsoft.Web/sites Endpoint is currently throttled for xxxxxxxx Subscription. Please retry after some time.

Environment Details:

Troubleshooting Steps Taken:

This issue hinders our ability to deploy Azure Function apps quickly and efficiently using Visual Studio Code. While alternative methods like PowerShell and Azure DevOps Pipelines are available, we prefer to use your extension for its ease of use and integration into our workflow.

Could you please investigate this issue? Any guidance or workaround would be greatly appreciated.

RBT-MikeClaffey commented 2 months ago

Also impacted here on a subscription that has 109 Function Apps but not on a subscription with 28 Function Apps.

Digging into the traffic a bit it looks like there are a ton of call to the /subscriptions/<SubscriptionID>/providers/Microsoft.Web/sites in addition to the call to /subscriptions/<SubscriptionID>resourceGroups/<RGName>/providers/Microsoft.Web/sites/<FAName>

Looking at the firewall logs it seems like maybe once the extension gets a 429 Endpoint is currently throttled error, it immediately retries causing many more request to be made as the number of calls is much more than the number of Function Apps: image

Here we can see a test workstation called out to the /subscriptions/<SubscriptionID>/providers/Microsoft.Web/sites API 132 times and then tried to call the next page, $skipToken=100&$top=100 another 400 times: image This subscription only has 109 Function Apps.

It seems odd that it is calling the Microsoft.Web/sites API so many times when it is getting the same information back. Based on the x-ms-ratelimit-remaining-subscription-reads header response we only get ~250 API calls for this API until it is throttled: image

@JoshuaAndrae one workaround we found, at least for the UI, is to Group by Resource Group rather than Resource Type: image Our Function Apps are in a number of different Resource Groups so that helps to limit the number of API calls.

nturinski commented 2 months ago

Hi @JoshuaAndrae & @RBT-MikeClaffey

Thanks for reporting this issue to us, and a big shout out to Mike for that deep dive of requests. We were able to pinpoint why all of those LIST calls were happening and were able to (hopefully) fix it.

If you could help us test that our fix actually worked, please follow these steps:

  1. Download the zip file artifact from here: https://github.com/microsoft/vscode-azurefunctions/actions/runs/10496126089/artifacts/1839129228
  2. Extract the .vsix file from the zip file
  3. In VS Code, hit F1 > Extensions: Install from VSIX
  4. Navigate to vscode-azurefunctions-1.15.2-alpha.1.vsix
  5. Install and reload VS Code

If you could let us know if this resolves the problem, it would be greatly appreciated 😄

pascalemmanuelli-sesimagotagcom commented 2 months ago

I tested it and it works for me (I can now access Azure FA from vscode, and deploy my code to them); thanks.

JoshuaAndrae commented 2 months ago

For me it works also. I can Fetch and Deploy

balfa666 commented 2 months ago

Also had the same problem. Installing that alpha version fixed it for me

nturinski commented 2 months ago

Thanks for everybody that tested this and gave us confidence in the fix! It is now released.