Azure Docker Deployment with multiple environment variables - azure

I´m trying to get some docker images running on Azure. To be concrete, I have a Redis service, a MongoDB server (not CosmosDB) from bitnami and the coralproject talk. In order to start the docker container locally, I have to set some environment variables like
docker run -e key1=value1 -e key2=value2 -p 80:3000 ...
Now, I am trying to get the app running in Azure. Searching for how to start docker container in Azure, I found several options:
Container Instances
App Services
Virtual Machine
Managed Kubernetes (Preview state)
Container Services (somehow deprecated, will be replaced by Managed Kubernetes in the future)
Running a VM for one docker instance doesn´t sound economical. A Managed Kubernetes or Container Service is maybe a bit too much for now, whereby I can not select any version even with "Managed Kubernetes". I guess this is related to the current Preview state. I also tried App Services, but without success, e.g. no proper settings for environment variables. I saw that in App Services you can set a Start File, but without explanations from Microsoft. What should this be, a Start File? So I tried number one, Container Instances.
Unfortunately I can not find a way how to pass multiple environment variables at the time of starting the container. At the setup wizard you can set one environment variable and another two if you like to:
First, it is limited to three environment parameters. I need more. Second, the value needs to be alphanumeric, setting a domain is not possible.
Does anyone here has some experience in running docker instances on Azure? What is the best setup for you?
Thanks in advance.

Related

Testing a Deployed container in Kubernetes via python

I have pushed a container to Container registry and am able to deploy it to kubernetes. Whats the best way to run this container to test if the deployment is working fine?
I have gone through the documentation and have seen that I can setup a endpoint but I am unable to figure out how to call the container once I have setup a post request to the endpoint. Note the container hosts a python script that basically runs a ml model and spits out a prediction. So I would like a way to do api calls to the cluster to run the container and a call to print the results of the container.
Or instead of setting a endpoint are there better ways to accomplish this?
• Setting an endpoint to the Kubernetes pod for accessing the container and executing the python script in the container is a good approach.
• As suggested in the Microsoft documentation, there are three options through which we can deploy API management in front of AKS. You can see the same in the picture provided in the document.
https://learn.microsoft.com/en-us/azure/api-management/api-management-kubernetes#kubernetes-services-and-apis
• Once you configure the API with Kubernetes cluster, you can deploy a model to Azure Kubernetes Service cluster, for that, you need to create a deployment configuration that describes the compute resources needed. For example, the number of cores and memory. You also need an inference configuration, which describes the environment needed to host the model and web service. For more information on creating the inference configuration, see how and where to deploy models.
For more information on how you can deploy and reference a python ML model, you can refer to this document below: -
https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-and-where?tabs=azcli

Unable to set the environment variables on a NodeJS Container on Azure App Service

I have a containerized application with a docker file that requires 4 environment variables that have to be set during runtime otherwise the application fails. I typically set it on the host and have the host set the environment variable on the container. This works great on a K8 and local docker runs. However, I am trying to use Azure App Service to bring up the container. I deployed the container on the Azure Container registry and wired up the App Service to point to the container in the registry. I then set the Application Settings (which according to the documentation is used for environment variables on the run command i.e. https://learn.microsoft.com/en-us/azure/app-service/configure-common#configure-app-settings) under Configuration of the Azure App Service and restart the application. I can see in the context of the host, the docker run command that is invoked and it does not set the environment variables. I have even added verbose logging in the containerized app and I can see in the context of the application, the env variables do not get set.
Am I missing a step in the configuration and setup? I can provide additional details if required
This ended up being a problem with the logging that Azure provides. It was not printing the logs in the correct order so I ended up showing errors. Also the logs do not show the environment variables passed in the docker run hence, the command look suspicious. After figuring out how to navigate the logs and reviewing the correct output, I was able to determine the. The Diagnosis and solve problems / Availability and Performance / Application Logs feature in Azure help a bunch in resolving this issue.

How do I run a dockerized 'Hello World' web job deployed into Virtual Kubelet within Azure Kubernetes Service (AKS)

I did create a simple 'Hello World' Web Job and placed that Web Job inside a Docker Windows Container/Nanoserver
I did push that Docker Windows Container into an Azure Container Registry
I did follow this article and successfully created Virtual AKS pods/nodes
When I run 'get pods' I do see the pods created and running
I do see IP's generated reflected in the 'get pods' command
My question is how do I run the container inside these pods/nodes?
I did try to reference the IP's but those IP's don't load anything
How can I run those containers that I successfully placed into Virtual Kubelet pods/nodes
If the containers in the get fired up by themselves, do they fire up/get invoked only once or every n number of minutes?
Is there a way to check on how the last run went, like log files?
Thank you very much for your help
First of all, I see you create your web job inside a Windows-based Docker. If so, you cannot run the container in the AKS while it does not support Windows nodes, at least current. For window container, I suggest you could use the Azure Container Instance or Web App for Container.
For Linux containers, the pod in AKS is a group of one or more containers (such as Docker containers), with shared storage/network, and a specification for how to run the containers. If you already have the Docker image, you can create the container inside the pod follow the steps in Running the application in AKS.
In addition, you can set the restart policy for your container. See Restart Policy for the container in Kubernetes. For the logs, I suggest you could use the persist volumes. If not, the files will be lost if the container crash.\
Update
If you really want to run windows container in AKS cluster, there is also a way for you. You can use the virtual Kubelet and Azure Container Instance in AKS. Follow the steps Run Windows container in AKS.

Run docker container on azure

I have a simple docker container which runs just fine on my local machine. I was hoping to find an easy checklist how I could publish and run my docker container on Azure, but couldn't find one. I only found https://docs.docker.com/docker-for-azure/, but this document kind of leaves me alone when it comes to actually copy my local docker container to Azure. Isn't that supposed to be very easy? Can anybody point me in the right direction how to do this?
But it is really easy.. once you know where to find the docs :-). I would take the azure docs as a starting point as there are multiple options when it comes to hosting containers in Azure:
If you're looking for this...
Simplify the deployment, management, and operations of Kubernetes -> Azure Container Service (AKS)
Easily run containers on Azure with a single command -> Container Instances
Store and manage container images across all types of Azure deployments
-> Container Registry
Develop microservices and orchestrate containers on Windows or Linux
-> Service Fabric
Deploy web applications on Linux using containers
-> App Service
Based on your info I would suggest storing the image using the Azure Container Registry and host the container using Azure Container Instances. No need for a VM to manage this way.
There is an excellent tutorial you could follow (I skipped the first 1 step since it involves creating a docker image, you already have one)
Another complete guide of pushing your image to azure and create a running container can be found here.
The good thing about Azure Container Instances is that you only pay for what you actually use. The Azure Container Registry is a private image repository hosted in Azure, if course you could also use Docker Hub but using ACR makes it all really simple.
In order to run an image, you simply need to configure a new VM with the Docker Daemon. I personally found Azure's documentation to be pretty complex. Assuming you are not trying to scale your service across instances, I would recommend using docker-machine rather than the Azure guide.
docker-machine is a CLI tool published by the Docker team which automatically installs the Docker Daemon (and all the dependencies) on a host. So all you would need to do is input your Azure subscription and it will automatically create a VM configured appropriately.
In terms of publishing the image, Azure is probably not the right solution. I would recommend one of two things:
Use Docker Hub, which serves as a free hosted Docker image repository. You can simply push images to Docker Hub (or even have them built directly from your Git repository).
Configure a CD tool, such as TravisCI or CircleCI, and use these to build your image and push directly to your deployment.
To run your docker image inside ACI, You can use of Azure Container Registry.
Step0: Create Azure Container Registry
Step1: Include a Dockerfile in your application code
Step2: Build the code along with the Dockerfile with a tag and create a
Docker image ( docker build -t imagename:tag .)
Step3: Push the Docker image to Azure container Registry with a image name and tag.
Step4: Now create a ACI, while creating, choose the image type as private, provide the image name, tag, image registry login server, image registry username, image registry password ( these details can be found under access keys tab inside Azure Container Registry)
Step5: choose running os as linux, in network step you can give an dns name for your ACI, then click on review & create
Step6: once ACI gets created you can go to overview and you can see fqdn, using fqdn you can access your application running inside Azure Container Instance.

Docker for Azure - no swarm mode?

I just tried Docker 4 Azure Beta, but I'm confused right at the beginning.
When I SSH into docker manager VM and do docker info or docker service ls I see that there is no swarm enabled?
Why? What's going on here? Do I have to enable it by myself? But as I understand, I have no option to SSH into my worker nodes, so how would I do this?
Or is there some "azure-clustering" configured instead of Docker Swarm? But why would they do so - and how can I manage my cluster/swarm in that case (scaling container count up and down)?
After you login to one of the manager VMs, you should be able to execute docker node ls and see all the VMs brought up through the ARM template as part of the swarm. The swarm should have been configured for you as part of the VM bring-up. Did you correctly generate an Azure Service Principal and pass in the credential details to the ARM template?
Old school Docker clustering (swarm) is supported out of the box.
Swarm Mode is available in the UK region at the moment.
I was wondering why running a custom template gives me the option to select Swarm Mode and also asks if I am in the UK, then I found this!
I'll give it a try to check what happens if I select swarm mode but I am quite certain the deployment will fail since my account is in Greece.

Resources