Azure-docs: How to disable CORS policy?

Created on 12 Dec 2018  Â·  9Comments  Â·  Source: MicrosoftDocs/azure-docs

I have a problem that I can't consume the web service by JavaScript Web Application because of the block of CORS policy. Is there any configuration from Azure ML SDK that can solve this problem? If not. Does it has solution to solve this problem?

Here is the mentioned bug:
Access to XMLHttpRequest at 'my web service uri' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 assigned-to-author machine-learninsvc product-question triaged

Most helpful comment

@thananstr Looks like ACI webservices are not designed for browser access as there is no configuration for CORS. I would recommend consuming the web service using Java/C#/Go/Python in the backend of your web app by following the tutorial in the doc.

@aashishb Is there a way to configure CORS in an ACI web service ?

All 9 comments

@thananstr
Thanks for the feedback! We are currently investigating and will update you shortly.

@jpe316

@thananstr Where are you deploying your web sevice ? CORS needs to be enabled on the web service end and it has nothing to do with the client.

@ChiragMishra-MSFT I deployed it from Azure Machine Learning Services (I followed this guideline link. But the guideline doesn't provide me a way to add header like "Allow-Control-Allow-Origin": "*" to the web service.

@thananstr Looks like ACI webservices are not designed for browser access as there is no configuration for CORS. I would recommend consuming the web service using Java/C#/Go/Python in the backend of your web app by following the tutorial in the doc.

@aashishb Is there a way to configure CORS in an ACI web service ?

You can get access to raw HTTP from your run method, here is the doc: https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-consume-web-service#binary-data
After building AMLResponse you can set any additional headers like CORS, see http://flask.pocoo.org/docs/1.0/api/#flask.Response.headers

@thananstr
We will now proceed to close this thread. If there are further questions regarding this matter, please respond here and @YutongTie-MSFT and we will gladly continue the discussion.

This seems to throw a spanner in the works of the whole Automed code free ML idea. You can train and deploy this endpoint really easily, but then it is actually impossible to call that endpoint. without writing a bunch of python. It would be great if you could just call the endpoint from javascript directly

Having the same above issue when try to call the ACI Webservice using c#. Please advice on how to resolve it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jebeld17 picture jebeld17  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments

behnam89 picture behnam89  Â·  3Comments

DeepPuddles picture DeepPuddles  Â·  3Comments

JeffLoo-ong picture JeffLoo-ong  Â·  3Comments