From e77e987754369aff171097ff52afd92df2d0368c Mon Sep 17 00:00:00 2001 From: ramziay Date: Wed, 19 May 2021 02:02:49 +0300 Subject: [PATCH] Update getting_started.md --- docs/getting_started.md | 110 ---------------------------------------- 1 file changed, 110 deletions(-) diff --git a/docs/getting_started.md b/docs/getting_started.md index 7a2c25f0..d4510c26 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -295,113 +295,3 @@ The pipeline stages are summarized below: To configure your own custom scoring data, see [Configure Custom Batch Scoring](custom_model.md#Configure-Custom-Batch-Scoring). -## Further Exploration - -You should now have a working set of pipelines that can get you started with MLOpsPython. Below are some additional features offered that might suit your scenario. - -### Deploy the model to Azure Kubernetes Service - -MLOpsPython also can deploy to [Azure Kubernetes Service](https://azure.microsoft.com/en-us/services/kubernetes-service). - -Creating a cluster on Azure Kubernetes Service is out of scope of this tutorial, but you can find set up information on the [Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using the Azure portal](https://docs.microsoft.com/en-us/azure/aks/kubernetes-walkthrough-portal#create-an-aks-cluster) page. - -> **_Note_** -> -> If your target deployment environment is a Kubernetes cluster and you want to implement Canary and/or A/B testing deployment strategies, check out this [tutorial](./canary_ab_deployment.md). - -Keep the Azure Container Instances deployment active because it's a lightweight way to validate changes before deploying to Azure Kubernetes Service. - -In the Variables tab, edit your variable group (`devopsforai-aml-vg`). In the variable group definition, add these variables: - -| Variable Name | Suggested Value | Description | -| ------------------- | --------------- | ----------- | -| AKS_COMPUTE_NAME | aks | The Compute name of the inference cluster, created in the Azure ML Workspace (ml.azure.com). This connection has to be created manually before setting the value! | -| AKS_DEPLOYMENT_NAME | mlops-aks | The name of the deployed aks cluster in your subscripttion. | - -After successfully deploying to Azure Container Instances, the next stage will deploy the model to Kubernetes and run a smoke test. - -Set **AKS_COMPUTE_NAME** to the _Compute name_ of the Inference Cluster that references the Azure Kubernetes Service cluster in your Azure ML Workspace. - -![build](./images/multi-stage-aci-aks.png) - -Consider enabling [manual approvals](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/approvals) before the deployment stages. - -#### Web Service Authentication on Azure Kubernetes Service - -When deploying to Azure Kubernetes Service, key-based authentication is enabled by default. You can also enable token-based authentication. Token-based authentication requires clients to use an Azure Active Directory account to request an authentication token, which is used to make requests to the deployed service. For more details on how to authenticate with ML web service deployed on the AKS service please follow [Smoke Test](../ml_service/util/smoke_test_scoring_service.py) or the Azure documentation on [web service authentication](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-deploy-azure-kubernetes-service#web-service-authentication). - -### Deploy the model to Azure App Service (Azure Web App for containers) - -If you want to deploy your scoring service as an [Azure App Service](https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-app-service) instead of Azure Container Instances and Azure Kubernetes Service, follow these additional steps. - -In the Variables tab, edit your variable group (`devopsforai-aml-vg`) and add a variable: - -| Variable Name | Suggested Value | -| ---------------------- | ---------------------- | -| WEBAPP_DEPLOYMENT_NAME | _name of your web app_ | - -Set **WEBAPP_DEPLOYMENT_NAME** to the name of your Azure Web App. This app must exist before you can deploy the model to it. - -Delete the **ACI_DEPLOYMENT_NAME** variable. - -The pipeline uses the [Azure ML CLI](../.pipelines/diabetes_regression-package-model-template.yml) to create a scoring image. The image will be registered under an Azure Container Registry instance that belongs to the Azure Machine Learning Service. Any dependencies that the scoring file depends on can also be packaged with the container with an image config. Learn more about how to create a container using the Azure ML SDK with the [Image class](https://docs.microsoft.com/en-us/python/api/azureml-core/azureml.core.image.image.image?view=azure-ml-py#create-workspace--name--models--image-config-) API documentation. - -Make sure your webapp has the credentials to pull the image from the Azure Container Registry created by the Infrastructure as Code pipeline. Instructions can be found on the [Configure registry credentials in web app](https://docs.microsoft.com/en-us/azure/devops/pipelines/targets/webapp-on-container-linux?view=azure-devops&tabs=dotnet-core%2Cyaml#configure-registry-credentials-in-web-app) page. You'll need to run the pipeline once (including the Deploy to Webapp stage up to the `Create scoring image` step) so an image is present in the registry. After that, you can connect the Webapp to the Azure Container Registry in the Azure Portal. - -![build](./images/multi-stage-webapp.png) - -### Example pipelines using R - -The build pipeline also supports building and publishing Azure ML pipelines using R to train a model. You can enable it by changing the `build-train-script` pipeline variable to either of the following values: - -- `diabetes_regression_build_train_pipeline_with_r.py` to train a model with R on Azure ML Compute. You'll also need to uncomment (include) the `r-essentials` Conda packages in the environment definition YAML `diabetes_regression/conda_dependencies.yml`. -- `diabetes_regression_build_train_pipeline_with_r_on_dbricks.py` to train a model with R on Databricks. You'll need to manually create a Databricks cluster and attach it to the Azure ML Workspace as a compute resource. Set the DB_CLUSTER_ID and DATABRICKS_COMPUTE_NAME variables in your variable group. - -Example ML pipelines using R have a single step to train a model. They don't demonstrate how to evaluate and register a model. The evaluation and registering techniques are shown only in the Python implementation. - -### Observability and Monitoring - -You can explore aspects of model observability in the solution, such as: - -- **Logging**: Navigate to the Application Insights instance linked to the Azure ML Portal, then go to the Logs (Analytics) pane. The following sample query correlates HTTP requests with custom logs generated in `score.py`. This can be used, for example, to analyze query duration vs. scoring batch size: - - ```sql - let Traceinfo=traces - | extend d=parse_json(tostring(customDimensions.Content)) - | project workspace=customDimensions.["Workspace Name"], - service=customDimensions.["Service Name"], - NumberOfPredictions=tostring(d.NumberOfPredictions), - id=tostring(d.RequestId), - TraceParent=tostring(d.TraceParent); - requests - | project timestamp, id, success, resultCode, duration - | join kind=fullouter Traceinfo on id - | project-away id1 - ``` - -- **Distributed tracing**: The smoke test client code sets an HTTP `traceparent` header (per the [W3C Trace Context proposed specification](https://www.w3.org/TR/trace-context-1)), and the `score.py` code logs the header. The query above shows how to surface this value. You can adapt it to your tracing framework. -- **Monitoring**: You can use [Azure Monitor for containers](https://docs.microsoft.com/en-us/azure/azure-monitor/insights/container-insights-overview) to monitor the Azure ML scoring containers' performance. - -### Clean up the example resources - -To remove the resources created for this project, use the [/environment_setup/iac-remove-environment-pipeline.yml](../environment_setup/iac-remove-environment-pipeline.yml) definition or you can just delete the resource group in the [Azure Portal](https://portal.azure.com). - -## Next Steps: Integrating your project - -- The [custom model](custom_model.md) guide includes information on bringing your own code to this repository template. -- We recommend using a [custom container](custom_model.md#customize-the-build-agent-environment) to manage your pipeline environment and dependencies. The container provided with the getting started guide may not be suitable or up to date with your project needs. -- Consider using [Azure Pipelines self-hosted agents](https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops&tabs=browser#install) to speed up your Azure ML pipeline execution. The Docker container image for the Azure ML pipeline is sizable, and having it cached on the agent between runs can trim several minutes from your runs. - -### Additional Variables and Configuration - -#### More variable options - -There are more variables used in the project. They're defined in two places: one for local execution and one for using Azure DevOps Pipelines. - -For using Azure Pipelines, all other variables are stored in the file `.pipelines/diabetes_regression-variables-template.yml`. Using the default values as a starting point, adjust the variables to suit your requirements. - -In that folder, you'll also find the `parameters.json` file that we recommend using to provide parameters for training, evaluation, and scoring scripts. The sample parameter that `diabetes_regression` uses is the ridge regression [_alpha_ hyperparameter](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html). We don't provide any serializers for this config file. - -#### Local configuration - -For instructions on how to set up a local development environment, refer to the [Development environment setup instructions](development_setup.md).