Azure docker: linuxFxVersion vs DOCKER_CUSTOM_IMAGE_NAME - azure

I have these three release steps in Azure De Ops:
AzureRmWebAppDeployment#4 - which deploys a docker image to my staging site
AzureResourceGroupDeployment#2 which deploys all the appsettings and properties with an ARM template
AzureAppServiceManage#0 - it swaps staging into production
Step 1 is applied so I am sure that the docker image is pulled to the staging slot (without it and only applying the ARM the swap begins before the pull is over, and I dont like that). Step 2 is to be sure that all environment variables and properties. Step 1 adds the DOCKER_CUSTOM_IMAGE_NAME environment variable and by that triggers a docker pull, but in step 3 I manually set the linuxFxVersion property. Both points to the same image tag. I don't set the DOCKER_CUSTOM_IMAGE_NAME in my ARM template, so when I deploy my ARM, only linuxFxVersion is set. But in essence it pulls nothing, because step 2 has already pulled the image.
Is there anything wrong in removing the DOCKER_CUSTOM_IMAGE_NAME? Or? What is the difference between linuFxVersion and DOCKER_CUSTOM_IMAGE_NAME? Do I need both, or is one of them good enough?

LinuxFxVersion and DOCKER_CUSTOM_IMAGE_NAME are both ways to specify the image to be used in a Linux function app or a Linux web app.
LinuxFxVersion is given higher precedence. If that value is invalid or empty,it would use DOCKER_CUSTOM_IMAGE_NAME. LinuxFxVersion is recommended since it can be used to set both custom container images as well as blessed images.

Related

Azure resource manager template deployments - Using _artifactsLocation and _artifactsLocationSasToken

Where and how to use artifactsLocation and _artifactsLocationSasToken in Arm template deployments. Are these used only for nested deployments.
Can we use these for custom VM extension of the Virtual machine as part of post provisioning activity, after VM is built or should the extension be added as part of the VM build deployment template only.
VM Custom script extension - (Initialize and format data drives, Mount file shares for instance)
Azure quick start templates, have the parameter values for these as default for artifactsLocation and type securestring for _artifactsLocationSasToken. How these values are populated in the ARM deployment runtime.
It would be great if someone can provide documentation around the same / step by step process or share an existing working custom script extension template.
There's nothing inherent in the platform that makes _artifactsLocation and _artifactsLocationSasToken special... it's just a pattern (well used) that has developed for staging artifacts needed for a deployment. The pattern is to stage all artifacts together and then use the uri of the main template as a relative location. The defaultValue generally used for _artifactsLocation is:
"defaultValue": "[deployment().properties.templateLink.uri]"
The deployment() function is inherent and contains the uri passed in for the main template.
That said, you can use those values anyway you see fit and the primary use case is for retrieving any artifact needed by any resource. For example:
Custom Script Extension
https://github.com/Azure/azure-quickstart-templates/blob/master/demos/vm-winrm-windows/azuredeploy.json#L256-L259
MSDeploy Packages for WebApps
https://github.com/Azure/azure-quickstart-templates/blob/master/demos/private-endpoint-sql-from-appservice/azuredeploy.json#L277
DSC Configuration Modules
https://github.com/Azure/azure-quickstart-templates/blob/master/demos/iis-2vm-sql-1vm/azuredeploy.json#L585
etc, etc...
That help?

Azure AppService continuous deployment from container registry tag selection

I have an AppService which uses Azure Container Registry.
The docker images are built by the pipeline and pushed with a 'Docker push' task in Azure Release.
I am using semantic versioning, I put the version into the BuildNumber and to the image name.
I can see my images being available in the DeploymentCenter, along with all the tags that have been pushed so far.
However, whenever I create a Release in AZ DevOps, it does not automatically get deployed to the AppService.
I have to go to the DeploymentCenter, pick the newest tag and then redeploy again (restarting the app didn't seem to work, but am no 100% sure).
In any case, I would like the AppService to be updated and run the latest image automatically when the release succeeds in DevOps.
Is that possible with the Docker push task to ACR?
Also, I wonder - I have the 'Include latest tag' tickbox checked, but the 'latest' tag is not available in the tag dropdown in Deployment Center. Why is that?
Is that possible with the Docker push task to ACR?
Of course, yes. But the thing you need to know is the continuous deployment of the App Service only triggers for the one tag can it can't change. Generally, we use the certain tag latest. So you need to create the image with the tag latest all the time, don't use the default tag $(Build.BuildId) in DevOps.
I have the 'Include latest tag' tickbox checked, but the 'latest' tag
is not available in the tag dropdown in Deployment Center. Why is
that?
I'm not familiar with DevOps, but I think the include latest tag means the latest Build.BuildId, not one certain tag, so it will change each time when you create the image and push it. And it won't work for App Service Continuous Deployment.

In azure devops: how can I inject my pipeline variables as appsettings when deploying a docker container to azure?

I'm having trouble setting my appsettings in a deployed docker container on azure.
My setup:
I have a .NET core app
My build pipeline builds a docker image and pushes it to my container registry on azure.
My release pipeline pulls the image based on a tag and deploys it to an azure web app.
I need to deploy the image to multiple environments. Every environment has different appsettings. I defined the variables in my pipeline "variables tab":
And I need to send these to my azure so they can be used.
When I manually add them it works, but i want to extract them from my variables, so I only have to add them once. (see screenshot 1)
Edit: The screenshot above works. But this is not what I'm looking for. As I'd have to edit the appsettings pipeline each time I add or remove a new appsetting. Also I believe that removing an appsetting here will just leave it on the deployed environment.
I'm deploying an existing docker image, so i'm unable to edit the appsetting.json file. I also won't make different docker files for each environment.
Is there a way to achieve this? How can I extract / list the variables defined in my pipeline as docker variables or appsettings?
You can define pipeline variables in your pipeline and have them attached to a specific scope (read stage) or the release scope (applied to all stages).
E.g. I have a variable defined as EnvironmentConnectionString which is defined in two scopes:
Scope Test: "EnvironmentConnectionString = server=test-db; ...."
Scope QA: "EnvironmentConnectionString = server=qa-db;..."
Score Release: "logging_flag=enabled"
Then you can set this up in your "Application and Configuration Settings" like
- ConnectionString $(EnvironmentConnectionString)
- Logging $(logging_flag)
Note the $(variable name) syntax for using these variables
When the different stages of the pipeline run, they automatically pick up the values specific to the stage and apply to azure app settings.
You can have different variable groups for different stages. These Variable Groups should have same variables defined with different values.
For example: The Dev Variable Group and Release group both have variables Port, RequestTimeout... The Port in Dev is 4999 while the Port in Release could be 5000. We can link these groups to specific Stage scope, Dev variable group for Dev stage and Release group for Release stage.
[![enter image description here][1]][1]
Make sure all your stages have same settings like this, and then the variables with be replaced with correspondings values for different scopes.
Update:
Each stage in the pipeline is independent, they represent different environments. So we have to define the settings of stage or settings of the tasks within the stages one by one. We have to define the appsettings input one by one.
[1]: https://i.stack.imgur.com/ukbjs.png

Azure deployment The value of deployment parameter 'dockerRegistryUrl' is null

Trying to deploy a web app using docker-compose and azure container registry and some public images but when I get to the review it gives me this error.
The value of deployment parameter 'dockerRegistryUrl' is null. Please specify the value or use the parameter reference. See https://aka.ms/resource-manager-parameter-files for details.
here is how I'm linking the azure container registry
image: csym023.azurecr.io/csym023_api:latest
...
image: csym023.azurecr.io/csym023_app:latest
think I may have set up the docker-compose file incorrectly for the azure container registry but I am not sure. the documentation link isn't very clear to me it doesn't say anything about the 'dockerRegistryUrl' or where to upload the resource manager parameter file.
here is the Docker compose file
For your issue, actually, the "dockerRegistryUrl" is not a property in the docker-compose file, it's an environment variable of the Azure Web App for Container if you use the template.
So if you use the ACR for you images, you need to set the environment variables DOCKER-REGISTRY-SERVER-UTL, DOCKER-REGISTRY-SERVER-PASSWORD and DOCKER-REGISTRY-SERVER-USERNAME in the app settings. Also, WEBSITES_ENABLE_APP_SERVICE_STORAGE is necessary.
In addition, you need to meet the Docker compose options which supported in Azure. And you can the details here.

Docker task : How to set the Azure container registry name or id from build/release variable?

I have a problem on my build/release pipeline with Azure Container Reigstry.
I use a Azure Resource Group Deployment task to deploy Azure Container Registry (and other stuff) and it works perfectly.
I have the loginServer, username and password in output variables to reuse it.
Then I want to build and push image to ACR but I can't set the name of the registry (that I get from output variable) with a variable. I have to choose the registry when I setup the definition, but it is not created at this moment.
Is there a way to do this ?
As a workaround, I use the Azure Resource Group Deployment the create the registry and then I send output variables to a powershell script which build, tag and push my images to the registry.
If nobody has a better way, I think I will post a uservoice to change that.
When you say you use an Azure Resource Group Deployment task, are you referring to VSTS?
If you could provide more specific repro steps, I might be more helpful.
I'd also suggest you might take a look at https://aka.ms/acr/build as easy way to natively docker build images with your registry. ACR Build is now available in all regions and simplifies may of the experiences you may be hitting.
Daniel just made this post that helps with the VSTS integration: https://www.danielstechblog.io/building-arm-based-container-images-with-vsts-and-azure-container-registry-build/
Steve
Sorry for the delay, I was off the office.
I just retry to fix my problem and it seems that I can now enter a free text (and so, a release variable) to the VSTS docker task to specify the ACR I just created before with a Azure Resource Group Deployment task.
So no problem anymore.
Thank you for your response, I will take a look to ACR build :)
Bastien

Resources