Приложение Python/Django, в котором urllib заблокирован на Azure
Я очень новичок в Azure, поэтому, пожалуйста, будьте ко мне помягче.
I recently deployed a Python/Django app onto Azure. In the app, I use the Python library urllib
to retrieve a file on the internet via its URL. I know the code is correct because the app works locally, but when I deploy it on Azure, the request is met by a 403 error which crashes the app: urllib.error.HTTPError: HTTP Error 403: Forbidden
Reading around, such as here, it seems that Azure blocks urllib
requests. So, I created a custom Web App Firewall (WAF) policy where I disabled all firewall rules, and miraculously the app started working! This is obviously not a permanent solution, so I'm asking if someone can help with one of the following, any of which should solve my issue:
- Can someone tell me specifically which WAF rule, from this Pastebin list, is the one blocking urllib requests? I can't find any documentation or description, beyond the short label, that explain what they do?
- Is there a way I can create a WAF exclusion for
urllib
requests? - Is there an alternative to using
urllib
that doesn't run into Azure firewall issues?
Опять же, я очень новичок в том, как работает Azure, и я не слишком хорошо знаком с тем, как работает urllib
, поэтому, если вы ответите (и спасибо, если ответите), пожалуйста, объясните мне все просто :)
Оказывается, использование библиотеки requests
вместо urllib
решает проблему, поскольку Azure, похоже, не блокирует ее. Я не знаю, почему так происходит, но если это работает, я не буду ставить это под сомнение.