0

I am very new to Azure, so please go easy on me here.

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:

  1. 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?
  2. Is there a way I can create a WAF exclusion for urllib requests?
  3. Is there an alternative to using urllib that doesn't run into Azure firewall issues?

Once again, I am very new to how Azure works, and I'm not too familiar with how urllib works either, so if you do reply (and thank you if you do), please explain stuff to me simply :)

  • Does this answer your question? [Python urllib.request Throws 403 in Azure Notebooks](https://stackoverflow.com/questions/45514959/python-urllib-request-throws-403-in-azure-notebooks) – basic mojo Aug 29 '21 at 10:26
  • https://learn.microsoft.com/en-us/answers/questions/47223/azure-application-gateway-rule-id-913101-python-re.html – basic mojo Aug 29 '21 at 10:28

1 Answers1

0

Turns out using the library requests, instead of urllib, resolves the issue as Azure doesn't seem to block it. I don't know why this is the case, but if it works, I won't question it.

  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Aug 29 '21 at 19:36