Cross-Origin Resource Sharing and Azure Machine Learning web services
Cross-Origin Resource Sharing (CORS) is a mechanism that allows web objects (e.g., JavaScript) from one domain to request objects (web service requests) from another domain. Cross-origin requests initiated from scripts have been subject to restrictions primarily for security reasons. CORS provides a way for web servers to support cross-site access controls, which enable secure cross-site data transfers.
At the time of this writing, it should be noted that Azure Machine Learning web services do not currently support CORS requests. See the following link for more information:
https://social.msdn.microsoft.com/Forums/en-US/b6ddeb77-30e1-45b2-b7c1-eb4492142c0a/azure-ml-published-web-services-cross-origin-requests?forum=MachineLearning.
This CORS restriction really means that if you wish to fully exploit Azure Machine Learning web services for deployment, testing, and production for a wide variety of (web) clients, you will need to host your own server-side applications. You basically have two choices.
- Host a web application, such as an ASP.NET webpage, and invoke the Azure Machine Learning web service server-side to conform to the current Azure Machine Learning CORS restrictions.
- Host your own web service that does provide CORS support and can in turn invoke the Azure Machine Learning web service on behalf of a wide variety of web and mobile clients via modern protocols and data formats like REST and JSON.
- On each web node, open the configuration file, <web-node-install-path>/appsettings.json. (Find the install, path for your version.)
- Enable CORS in the "CORS": { section of the appsettings.json file:
- Set CORS "Enabled": true
- Enter a comma-separated list of allowed "Origins" for your policy. In this example, the policy allows cross-origin requests from "http://www.contoso.com", "http://www.microsoft.com", and no other origins.
3. Launch the administrator's utility and restart the web node.
Commentaires
Enregistrer un commentaire