Before starting the deployment, we need to have a trained model handy for the deployment. As the trained model is available and the process needs to be deployed as a web service.
Check out the procedure of creating a container resource for the web app.

Click on “create a resource”

Click on “Container” in the left panel

Click on Web App for Containers and click on create

Give the details required and keep the container details handy for further usage.
docker_image = Model.package(ws,models_latest, inf_conf,image_name="imgname")
docker_image.wait_for_creation(show_output=True)
docker_image.pull()
After the **image.pull()**
method was used, we will get the process notification regarding the docker image which we created.
Status: Downloaded newer image for myworkspacef78fd10.azurecr.io/package:packagenumber
After downloading the docker image, user the command “docker images
” to get the list of local images
REPOSITORY name.azurecr.io/package
TAG Your docker tag
IMAGE ID Your Image ID
CREATED Time created
SIZE Size of the container
The data contains the <image id>
which we need to replace in the below syntax
docker run -p 6789:5001 --name containername <imageid>
**6789**
is the local port number and 5001
is the web service listening number.
Create a Dockerfile and dependencies
package = Model.package(ws, [model], inference_config, generate_dockerfile=True)
package.wait_for_creation(show_output=True)
# Download the package.
package.save("./imagefiles")
# Get the Azure container registry that the model/Dockerfile uses.
acr=package.get_container_registry()
print("Address:", acr.address)
print("Username:", acr.username)
print("Password:", acr.password)
the above code block helps us to download the files required to build the image in **imagefiles**
directory.
We need to use the shell to authenticate the docker image
docker login <address> -u <username> -p <password>
Now, build the docker image
docker build --tag myimage <imagefiles>
To run the container use the command below, which is listening based on the port and web service number.
docker run -p 6789:5001 --name mycontainer image_name:latest