Azure - App Service Docker Compose - is working_directory supported? - azure

I have a node app that I'm running in Azure App Service however in my docker-compose file the option for working_dir doesn't seem to actually do anything. I've tested locally with the same image I have pushed to the registry and it works, just not on Azure.
I just want to check is it actually supported?
https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#docker-compose-options
Thanks,

The link you provide in the question shows you the support and not support options, the option working_dir is not in both. But the Note also tells it:
Any other options not explicitly called out are ignored in Public
Preview.
So in fact, the option working_dir is ignored. Instead, I recommend you use the WORKDIR in the Dockerfile.

Related

How do I create an IoT Edge Module for an existing docker container from Azure Cognitive Services?

I currently have public preview access for the Azure Cognitive Services for Speech-To-Text as a docker container. This allows the container to be run on an IoT Edge device, rather than accessing the cloud to perform this service. This public preview came with installation instructions that show I can download an existing docker image of one of the containers and run it from a CLI using "docker run".
But I don't want to have to run the docker container manually on my IoT Edge devices. I want it to be automatically deployed to my IoT Edge devices and automatically start running. In order to do this, I believe that it needs to exist as an IoT Edge Module. Is my understanding correct?
So my question is more of an instructional question. Do I need to create my own IoT Edge Module that utilizes this ACS docker container, or is there some other way to automatically deploy it to my IoT Edge Device and have it start running automatically?
I was unable to find any documentation or examples online of deploying an existing docker container to an IoT Edge device. Any guidance would be greatly appreciated!
OK, after much digging, I found a solution. Whatever you do, don't search online for "create iot module from docker container" or anything COMPLETELY MEANINGFUL like that. Instead, I had to search for something very specific to the Azure Cognitive Service's EULA acceptance on the docker run (i.e. I had to search for "iot edge module docker \"eula\""). Note the quotation marks around eula to ensure it is in the search result. I came across this article.
Using the article's guidance, I will repeat in detail what I did here in case the link ever goes stale.
In VS Code, create a new IoT Edge Solution
In your solution, add a new IoT Edge Module
a. When prompted for the type of Module to create, select "Choose Existing Module (Enter Full URL)"
If you look inside your deployment.template.json file, you will now see a new element for "registryCredentials" that got added to your edgeAgent details. Fill out the address, username, and password accordingly.
If you haven't done so yet, create your Cognitive Services resource online to obtain an Endpoint URL and an ApiKey. Take note of these values.
In the deployment.template.json file, under your new module's configuration settings, add the following.
"settings": {
"image": "containerpreview.azurecr.io/microsoft/cognitive-services-speech-to-text:latest",
"createOptions":
{
"Cmd": [
"Eula=accept",
"Billing={enter-your-EndpointURL}",
"ApiKey={enter-your-ApiKey}"
],
"HostConfig": {
"PortBindings": {
"5000/tcp": [
{
"HostPort": "5000"
}
]
}
}
}
This will be equivalent to running "docker run" from the command line with parameters like this:
docker run --rm -it -p 5000:5000 --memory 4g --cpus 1 \
containerpreview.azurecr.io/microsoft/cognitive-services-recognize-text \
Eula=accept \
Billing={BILLING_ENDPOINT_URI} \
ApiKey={BILLING_KEY}
Now "Build and Push your IoT Edge Solution", followed by "Create Deployment for Single Device". On your target IoT Edge device, you should now see the module installed and running via CLI "iotedge list".
Update: 2020/05/01
After submitting a request for better documentation from MSFT, they updated their docs site to include information on how to modify the deployment.template.json file to match the docker command line arguments: https://learn.microsoft.com/en-us/azure/iot-edge/how-to-use-create-options
This is the essence from the link above (https://learn.microsoft.com/en-us/azure/iot-edge/how-to-use-create-options):
Once you have the module working the way you want it (ie: in a
docker container), run docker inspect . This command
outputs the module details in JSON format. Find the parameters that
you configured, and copy the JSON.

Azure WebApp for Container WebSocket Not Working - SAFE / ElmishBridge

I have been working on a project built from the SAFE stack template and everything runs successfully when I build it to a docker container and run this locally.
Using Azure WebApp for Container, the container successfully attaches and deploys, and I am able to load the app from the URL as expected. [The Server is responding with the Client App]
The issue is that the WebSockets are not working once deployed, but they work properly from when I run the container locally.
I've looked through a lot in regards to all of this and tried a lot of different things, but am having no success. I could share more, but I was primarily seeing if anyone has encountered this.
I did run this:
az webapp config set --web-sockets-enabled true --name MyAppName --resource-group MyResourceGroup
as per something suggested from here: https://social.msdn.microsoft.com/Forums/azure/en-US/036f9c3d-16dc-4e52-b943-5eb1afed824f/enabling-websockets-on-a-web-app-for-containers-service
I can confirm that the WebSockets being enabled was set to false, by default, and that it required using the CloudShell to set it to true.
It is frustrating, because I am unable to get any information beyon the following:
WebSocket connection to 'wss://xxx.azurewebsites.net/socket/init' failed: Error during WebSocket handshake: Unexpected response code: 503
I don't want to initially overshare detail about code, unless requested as something helpful, because everything works when run in a container locally. It does feel oddly like something related to that Azure setting or perhaps some kind of Port-related Application Setting or the such.
Further, this does feel like it is not an aspect of SAFE-template or Elmish-Bridge, but anyone who has successfully deployed this combo on Azure using a Docker Container may have direct insight on this problem. It seems like something wider than this particular usage, but related to Container/Websocket usage on Azure.
Any help is appreciated. Thanks.
It seems that WebSockets are not fully supported in Azure WebApp for Containers that are running Linux Containers:
https://github.com/aspnet/AspNetCore/issues/10370
Can you check what appservice plan you have?
TLDR: you need to get at least a B1 appservice plan. The FREE one will not work with Streamlit (and apps using WebSockets).
After a couple of hours trying to find the answer to the same answer, I found out what it was. I wanted to deploy a streamlit app, but was stuck at the same place after following the guidance. A Ctrl+Maj+J showed in the "Please wait" page that WebSockets were an issue. It appears WebSockets will not work for FREE Linux appservice plans, and after recreating a B1 appservice plan (as in the guidance), it worked.
Might be a duplicate of this issue.

Deploying Strapi to Azure

I want to deploy Strapi to my Azure. Anyone here who has an experience doing such and making it up and running completely? Somehow I couldn't find any detailed instructions how to do that in Azure.. I'm looking for something that is as easy as deploying it to Heroku - but it's fine though if it'll require more steps as long as I can make it to work completely.
This is the complete instruction I have also created in the README of the repository.
Strapi-Azure 3.1.3
This is a working repository of Strapi 3.1.3 which you can already deploy as an Azure Web App. This requres a paid subscription, minimum of B1 plan (32 USD estimated), so we can enable the 64-bit platform configuration and the Always On feature.
To get started, let us first create and configure our Azure Web App:
Create an instance:
Name: The name of your choice that is still available
Publish: Code
Runtime staci: Node 12 LTS
Operating System: Windows
Region: select near you
Sku and Size: select B1 (minimum)
Configure the Environment variables:
Add the following key-value pairs:
For the HOST make a ping to your .azurewebsites.net instance and get the IP
Configure the Platform Settings
In the General Settings tab (beside the Application Settings), change the Platform from 32 Bit to 64 Bit
To confirm if you are indeed now on 64 Bit mode, go to Console and run node -p "process.arch"
Install yarn:
Go again to Console and run: npm install -g yarn
Deploy from your github account a copy of strapi-azure repo
In the Deployment Center tab, connect your GitHub account and browse your copy of strapi-azure
Select App Service build service as your build provider
Select repository and branch
Deploy!
Build your Admin UI using Kudu service
Go to Advance Tools -> Go -> expand Debug console from the toolbar -> CMD
Inside the wwwroot directory (site/wwwroot/), execute yarn build
See it in action 😊
It should not be any different than installing Strapi on any VM (Azure, AWS, GCP or even local VM).
Quick start guide should help you setup things and run Strapi server --> https://strapi.io/documentation/3.x.x/getting-started/quick-start.html
Primarily: Install nodejs, npm and strapi (via npm). Execute strapi new cms --quickstart and you should be good to go (with default configuration).
Assuming you have it within a GIT repository, I may have some useful insights.
When I set mine up, I created an app service hosted on windows - for some reason I found the Linux ones very unstable. I then used the Deployment Center to then setup the connection between my repository hosted on Azure Devops onto my App Service. When it deploys IISNode will automatically be setup with an appropriate web.config file for getting a NodeJS server up and running.
You may need to ensure you are running in production (assuming this is what you want), you can set this up by going to the App Service - Configuration - Application Settings (tab) - set up new variable called
"NODE_ENV" and set this "PRODUCTION".
I also found it useful to set
"WEBSITE_NODE_DEFAULT_VERSION" and specify the version - in my case it was "10.15.2".
For the database I used a ComosDB with the Mongo API, this was hosted on azure and it worked OK - the main problem I found was that I was getting charged a lot for the usage of it, not quite sure at this stage how to get around it.
One thing that did catch me out was setting the "port" variable within the config/environments/production/server.json - I was hard coding a port which doesn't work within IISNode - this needs to be set to something like
"host": "your.domain.com"
"port": "${process.env.PORT || 1280}"
You will also need to setup your database settings in config/environments/production/database.json file.
Happy to work through any further points, let me know

How to run DotNet Core applications in Azure Batch Jobs

I have followed Azure Batch ffmpeg tutorial and it works as expected. The problem that I have at this point is that my executable that i want to run as a batch is a dotnet core application and images that are available when creating a Pool do not have dot net core installed. In the task command line I need to run something like dotnet myApp.dll myParam but dotnet is not available.
How do I go about having an image that has dotnet core installed. Do I need to create a custom image? Is there a tutorial for doing that. I tried using Docker with dotnetcore runtime image at some point for running the same application locally and that seems to work. Do I need to export this image to Azure somehow? Or can I push the core installation into an image in another way?
Thanks.
If I am understanding your issue correctly, the simplest solution I see would be create your own custom image to provision a batch pool. We have a document on achieving that here:
https://learn.microsoft.com/en-us/azure/batch/batch-custom-images
This way you can preconfigure an image that has all the needed programs and languages installed right away.

OpenLiberty Docker image sample application not workng

I have created my own Docker image using following Dockerfile:-
FROM open-liberty:webProfile8
COPY mysample.war /config/dropins/
COPY server.xml /config/
Docker image got generated with some warning:-
Successfully built cc05c3d94adf Successfully tagged
sampleopenlibty:latest SECURITY WARNING: You are building a Docker
image from Windows against a non-Windows Docker host. All files and
directories added to build context will have '-rwxr-xr-x' permissions.
It is recommended to double check and reset permissions for sensitive files and directories.
I pushed this image to Azure Container Repository and created an App Service out of it but whenever I browse to the Web-App instead of showing my custom/sample web app it shows the out of the box PAGE of Open Liberty.
Can someone please help me what I would have done wrong to fix this issue?
Thank you
I just summarize your comment and post it as an answer.
It was related to the Database connectivity which is in the sample WAR file. We defined some Application settings (Env. vriables) but somehow they are not getting picked up by the app hosted in Docker image. After hard coding it in the code and deployng it everything works.
So now it boils down to fixing the Application settings (Env. varible) to get it all working.
use COPY --chown=1001:0 mysample.war /config/dropins/
to know more open-liberty-docker-docs read Updating file permissions

Resources