{"id":12085,"date":"2021-08-16T13:21:04","date_gmt":"2021-08-16T13:21:04","guid":{"rendered":"http:\/\/ismiletechnologies.com\/?p=12085"},"modified":"2022-10-06T17:20:23","modified_gmt":"2022-10-06T11:50:23","slug":"deploying-ml-models-to-azure","status":"publish","type":"post","link":"https:\/\/ismiletechnologies.com\/en_us\/cloud-services\/deploying-ml-models-to-azure\/","title":{"rendered":"Deploying ML models to Azure"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">For deploying ML models to Azure you need to follow the&nbsp;stages&nbsp;as mentioned&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pre-requisites for deployment of ML model to Azure<\/strong>&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Creating the Azure Machine Learning workspace&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>A trained ML&nbsp;Model&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Using the Azure CLI extension for Machine learning services&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li>A docker running machine&nbsp;<\/li><\/ol>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Register&nbsp;and track&nbsp;the&nbsp;ML&nbsp;model<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Model registration helps you in&nbsp;storing version of your ML model in your workspace on Azure cloud. The registration of the model is done by the name and the version of the model. It is a good practice to provide extra metadata tags during registration. These tags enable easy searching of the model on Azure.&nbsp;Azure ML supports any&nbsp;model loaded with Python 3.5.2 or higher versions. For registering your model, you need resources like a&nbsp;pytorch&nbsp;model file which can represent the specific model and codes executing the model.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can register your model from&nbsp;&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>a local file or&nbsp;<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">!wget&nbsp;https:\/\/aka.ms\/bidaf-9-model -o&nbsp;model.onnx&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">!az&nbsp;ml model register -n&nbsp;bidaf_onnx&nbsp;-p .\/model.onnx&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li><strong>an Azure ML training run<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">az&nbsp;ml model register -n&nbsp;bidaf_onnx&nbsp;&#8211;asset-path outputs\/model.onnx&nbsp;&#8211;experiment-name&nbsp;myexperiment&nbsp;&#8211;run-id&nbsp;myrunid&nbsp;&#8211;tag area=qna&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Creating the&nbsp;entry script<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The entry script is required for accepting the requests, scoring the requests with the ML model and returning the result output. Your entry script should enable you to load your model using the (in (it) function and use the input data to run the model with run function&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">import json&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">def&nbsp;init():&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;print(&#8220;This is&nbsp;init&#8221;)&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">def run(data):&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; test =&nbsp;json.loads(data)&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;print(f&#8221;received&nbsp;data {test}&#8221;)&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; return&nbsp;f&#8221;test&nbsp;is {test}&#8221;&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li><strong>Creating the&nbsp;inference configuration<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The inference configuration details the docker containers alongwith files to be used while initialising the web service. The source directory files are pushed to cloud when you start deploying the web service&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li><strong>Deploy the&nbsp;ML model<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">After this, you are fully prepared to deploy the ML model&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">!az&nbsp;ml model deploy -n&nbsp;myservice&nbsp;-m&nbsp;model name&nbsp;&#8211;overwrite &#8211;ic&nbsp;dummyinferenceconfig.json&nbsp;&#8211;dc&nbsp;deploymentconfig.json&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">!az&nbsp;ml service get-logs -n&nbsp;myservice&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li><strong>Conduct liveness Request<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">To ensure that you have deployed the ML model\u00a0successfully ,\u00a0you need to conduct a liveness request and a scoring request\u00a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">!curl&nbsp;-v http:\/\/localhost:32267&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">!curl\u00a0-v -X POST -H &#8220;content-type:application\/json&#8221; -d &#8216;{&#8220;query&#8221;: &#8220;What\u00a0color\u00a0is the fox&#8221;, &#8220;context&#8221;: &#8220;The quick brown fox jumped over the lazy dog.&#8221;}&#8217; http:\/\/localhost:32267\/score\u00a0<\/p>\n\n\n\t\t<div data-elementor-type=\"section\" data-elementor-id=\"33253\" class=\"elementor elementor-33253\" data-elementor-post-type=\"elementor_library\">\n\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-1f27ef0 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"1f27ef0\" data-element_type=\"section\" data-e-type=\"section\" data-settings=\"{&quot;background_background&quot;:&quot;gradient&quot;}\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-c65c317\" data-id=\"c65c317\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-dc3c880 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"dc3c880\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-3248be5\" data-id=\"3248be5\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5886bd6 elementor-widget elementor-widget-heading\" data-id=\"5886bd6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Ready to experience the full power of cloud technology?<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1f56c4e elementor-widget elementor-widget-text-editor\" data-id=\"1f56c4e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p><span class=\"TextRun Highlight SCXW216552313 BCX0\" lang=\"EN-IN\" xml:lang=\"EN-IN\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW216552313 BCX0\">Our cloud experts will speed up cloud deployment, and make your business more efficient.\u00a0<\/span><\/span><span class=\"EOP SCXW216552313 BCX0\" data-ccp-props=\"{&quot;201341983&quot;:0,&quot;335559739&quot;:160,&quot;335559740&quot;:259}\">\u00a0<\/span><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-4b7dd61\" data-id=\"4b7dd61\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-81f081a elementor-align-center elementor-widget elementor-widget-lottie\" data-id=\"81f081a\" data-element_type=\"widget\" data-e-type=\"widget\" data-settings=\"{&quot;source&quot;:&quot;external_url&quot;,&quot;source_external_url&quot;:{&quot;url&quot;:&quot;https:\\\/\\\/assets4.lottiefiles.com\\\/packages\\\/lf20_kkesf8mx.json&quot;,&quot;is_external&quot;:&quot;&quot;,&quot;nofollow&quot;:&quot;&quot;,&quot;custom_attributes&quot;:&quot;&quot;},&quot;loop&quot;:&quot;yes&quot;,&quot;play_speed&quot;:{&quot;unit&quot;:&quot;px&quot;,&quot;size&quot;:0.9,&quot;sizes&quot;:[]},&quot;lazyload&quot;:&quot;yes&quot;,&quot;link_to&quot;:&quot;none&quot;,&quot;trigger&quot;:&quot;arriving_to_viewport&quot;,&quot;viewport&quot;:{&quot;unit&quot;:&quot;%&quot;,&quot;size&quot;:&quot;&quot;,&quot;sizes&quot;:{&quot;start&quot;:0,&quot;end&quot;:100}},&quot;start_point&quot;:{&quot;unit&quot;:&quot;%&quot;,&quot;size&quot;:0,&quot;sizes&quot;:[]},&quot;end_point&quot;:{&quot;unit&quot;:&quot;%&quot;,&quot;size&quot;:100,&quot;sizes&quot;:[]},&quot;renderer&quot;:&quot;svg&quot;}\" data-widget_type=\"lottie.default\">\n\t\t\t\t\t<div class=\"e-lottie__container\"><div class=\"e-lottie__animation\"><\/div><\/div>\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-33 elementor-inner-column elementor-element elementor-element-ac6262c\" data-id=\"ac6262c\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-e19f719 elementor-align-right elementor-mobile-align-left elementor-tablet-align-right elementor-widget elementor-widget-button\" data-id=\"e19f719\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"button.default\">\n\t\t\t\t\t\t\t\t\t\t<a class=\"elementor-button elementor-button-link elementor-size-xs\" href=\"#elementor-action%3Aaction%3Dpopup%3Aopen%26settings%3DeyJpZCI6IjI5OTEiLCJ0b2dnbGUiOnRydWV9\">\n\t\t\t\t\t\t<span class=\"elementor-button-content-wrapper\">\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-button-text\">Start Today !<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t\n\n\n\n<ol class=\"wp-block-list\" start=\"5\"><li><strong>Select a compute target<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Select a compute target based on assessment so that the cost and the availability is optimised for your endpoints that have been deployed&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\"><li><strong>Re-deploy the model to cloud<\/strong>&nbsp;<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Once you have ensured that your ML model is working fit and fine locally and you have selected&nbsp;the right compute target, it is time for redeployment to cloud.&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The deployment configuration would differ based on the compute target you have selected&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">{&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; &#8220;computeType&#8221;: &#8220;aci&#8221;,&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; &#8220;containerResourceRequirements&#8221;:&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; {&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;cpu&#8221;: 0.5,&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8220;memoryInGB&#8221;: 1.0&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; },&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; &#8220;authEnabled&#8221;: true,&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; &#8220;sslEnabled&#8221;: false,&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;&nbsp;&nbsp; &#8220;appInsightsEnabled&#8221;: false&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">}&nbsp;<\/p>\n\n\n<h4>Contact Our DevOps<\/h4>\n<h2><\/h2>\n<p><\/p>\n<p><a href=\"http:\/\/ismiletechnologies.com\/request-a-consultation\/\">Get Free Consultation<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>For deploying ML models to Azure you need to follow the&nbsp;stages&nbsp;as mentioned&nbsp; Pre-requisites for deployment of ML model to Azure&nbsp; Creating the Azure Machine Learning workspace&nbsp; A trained ML&nbsp;Model&nbsp; Using the Azure CLI extension for Machine learning services&nbsp; A docker running machine&nbsp; Register&nbsp;and track&nbsp;the&nbsp;ML&nbsp;model&nbsp; Model registration helps you in&nbsp;storing version of your ML model in [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":12307,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[81],"tags":[],"class_list":["post-12085","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-services"],"_links":{"self":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/12085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/comments?post=12085"}],"version-history":[{"count":2,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/12085\/revisions"}],"predecessor-version":[{"id":33673,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/12085\/revisions\/33673"}],"wp:attachment":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/media?parent=12085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/categories?post=12085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/tags?post=12085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}