I have a Dotnet 6 Web Application running on a Windows-based Azure App Service. As traffic grew, I took the recommendation to "scale-out" the app service to two instances. My deployments are done via a simple GitHub action and publish profile.
I've noticed that, by hitting the root API endpoint in which I return the build and server of the running API, that each of the two servers is running a different version of the code. When it builds and deploys next time, only one server reflects the newer version.
- name: Azure WebApp
uses: azure/webapps-deploy#v2.2.3
with:
publish-profile: ${{ secrets.AZUREWEBAPPPUBLISHPROFILE }}
app-name: esferas-app
slot-name: staging
package: ./artifacts/web
Is there something I'm missing? I couldn't find anything scouring the Azure or the GitHub Actions documentation for anything special required for scaling out on deploys.
Related
DevOps Pipeline is using VSBuild#1 and PublishBuildArtifacts#1 to create zip artifact.
DevOps Releases is using Azure App Service deploy 4.* and Azure App Service Settings 1.* to deploy app on Azure Service App.
Both processes finish with green status but when I check service it says "Your app is running and wait for content".
Reason is that application is deployed to path: /wwwroot/Content/D_C/a/1/s/src/Project/obj/Release/net6.0/PubTmp/Out/ which is also visible in zip artifact: Content\D_C\a\1\s\src\Project\obj\Release\net6.0\PubTmp\Out.
When I setup start command to use this path it works, but:
I don't like fact I must to set it
If application is not web API but MVC app with own 'wwwroot' I have to move this manually or setup post-deployment script
I spent some time on debugging this issue and I can't believe that default settings don't work for basic scenario and deployment from VS/Rider is working ok!
On which step I have error? Path in ZIP is already wrong? Deployment is not smart enough? App Service is wrongly configured?
I'm trying Azure App Services. I've set up a build pipeline in Azure DevOps which builds and pushes my image to Docker Hub and then publishes docker-compose.yml as an artifact.
My release pipeline takes the docker-compose.yml and feeds it to the "Azure Web App for Container" task which succeeds. But the bot goes down and doesn't get back up after the deployment unless I access http://<myappname>.azurewebsites.net, then it starts and is of the latest pushed version. So everything seems to work, except the "restart" or docker-compose up.
I've been reading that I want to add a WebJob to my app service, but since I am using a Linux host I cannot seem to configure this. I've tried adding a curl task after deployment, but this probably executes too early.
Any ideas on how I would get to solve this last piece of the puzzle to have a simple CI/CD environment?
Currently there is zero out of the box support for hosting WebJobs in a Linux hosted app service. I've heard there's a hacky way of doing it (I'll have to find the post) but since it's not supported out of the gate, there's no guarantee it'll work.
I'm using the ASP.NET Core & Angular startup template from ASP.NET Boilerplate with Multi-Tenancy disabled: 1 database with a single tenant(Default).
I'm also using TeamCity to build/test/publish the projects available in the startup template so I end up with 3 NuGet packages that are getting pushed to Octopus Deploy:
API (Host project, ASP.NET Core Web Application)
Migrator (Console application, capable of migrating the database(s))
UI (Angular App)
I want to deploy this setup to Azure with Octopus Deploy(self hosted, v2018.9.0) in the following way using 2 App Services(Host & UI) and 1 Azure SQL database(Host):
Take the UI and API applications offline, displaying a friendly maintenance message while updating the projects.
Migrate the database using the Migrator package
Deploy the API application package
Deploy the UI application package
Put the API application online, maybe some more tests to check that it's working correctly
Put the UI application online.
If all this was on-prem, I would have no questions. It's the Azure part that I can't figure out because I don't know how to do these things on Azure via Octopus Deploy:
Put an Azure App Service offline/online (using an app_offline.htm file)
Deploy the Migrator package to the API Azure App Service in a special folder(so that I don't overwrite the API deployment) and run the migrator: dotnet [migrator.dll] -q
I tried using the Octopus Deploy "Deploy an Azure Web App" but this step won't let me also deploy the migrator package and run it before the API package is deployed. Or does it? I don't know how.
I tried using the "Run an Azure PowerShell script" but this executes on the Octopus Deploy server and not on the Azure App Service environment right?
Maybe there are other, even better, approaches deploying this setup to Azure?
You can use App service slots to swap in/out version of your logical applications. When you swap there's a warming up that occurs and no loss of traffic.
So basically deploy to backup slot, then swap production with backup slot.
For the db I don't think your strategy is valid. There are some assumptions you are making that will not make your life easy. I would look at handling the db deployment separately with no breaking changes but that's my opinion.
I'm not familiar with Octopus or TeamCity so I won't go into details about those.
I've searched a bit about this, but is there documentation at all on how to schedule jobs that run with Azure CLI commands?
I want to run in the cloud, but azure automation doesn't support CLI (yet), so i am leaning towards perhaps using Azure Scheduler... but don't know the pros and cons...
Alternatively, is it possible to create a scheduled job, somehow, in the Azure Cloud Shell... i assume this is backed by some VM and therefore perhaps if it is Linux based we could whizz up a cron job... i don't really know how to do that though.
Ta!
I tried finding some information on how to use Azure CLI in the cloud but there doesn't seem to be much available.
There are two versions of Azure CLI:
v1.0
Built as a node.js module
Can be installed by running npm install -g azure-cli
v2.0
Standalone package
Install MSI on Windows or using some package manager, e.g. apt/yum/zyper/etc, on Linux.
Azure App Service
Azure Web Apps support running applications built ontop of node.js. Technically you could then install the v1.0 module in a Web App and run your script on a schedule there.
However, recommended is to use v2.0. But this would offere one possibility of automation.
Azure Automation
Current Azure CLI is not support but it's under review at the time of writing. See this link for the uservoice suggestion and vote on it if this a desired feature.
Azure Functions
As far as I can tell, there's no way to run Azure CLI on an Azure Function.
Azure Scheduler
Azure Scheduler is a service for only invoking code hosted elsewhere. This would still mean you need to host your code somewhere else, i.e. cloud or on-premises, then have the scheduler run it for you.
Triggering mechanisms that are supported are:
HTTP, HTTPS
Azure Storage queue
Azure Service bus queue
Azure Service bus topic
Azure Cloud Shell
It's a shell that contains tools needed for running commands and scripts without the needed to locally install anything. Scheduling anything, using cron does not seem to be possible.
Suggestion
At the moment, if you want to script something, and run it in the cloud, I recommend you have a look at PowerShell. Running PowerShell scripts, with a time trigger is possible on Azure Functions and support adding your own custom modules as well.
If you need to use Azure CLI and serverless, then you could run it inside of a Docker container and host the container in the cloud, e.g. in an Azure Container Instances. See this link on how to create it.
You can use an AzureDevOps pipeline for this:
pr: none
trigger: none
schedules:
- cron: "0 7 * * 1-5"
displayName: "Working-hours (7 am UTC, Monday to Friday)"
always: true
branches:
include:
- master
steps:
- task: AzureCLI#2
inputs:
azureSubscription: 'PipelineServiceConnection'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'az --version'
What you have to do is create a new pipeline via the AzureDevops Pipelines tab:
Choose the location for the pipeline script
Choose the branch
Choose the pipline template: "Starter pipeline"
Paste the above yaml code in the editor
Save and run the pipeline
The yaml script uses a service connection called 'PipelineServiceConnection', to create such service connection see: https://learn.microsoft.com/en-us/azure/devops/pipelines/library/connect-to-azure?view=azure-devops
More info about AzureCLI task:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-cli?view=azure-devops
Configure scheduled pipelines:
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml
Is it possible to setup Continuous Integration on VSTS without using external VM as build agent (https://azure.microsoft.com/en-us/documentation/articles/service-fabric-set-up-continuous-integration/)?
What I would like to achieve is to have one Service Fabric Solution with 2 statefull/stateless services (serviceA and serviceB). I want to build and deploy them separately as different build jobs on VSTS, but to deployed them to the same Service Fabric Cluster on Azure (fabric:/App/ServiceA, fabric:/App/ServiceB).
As of the Service Fabric SDK 2.1.150 and Runtime 5.1.150 release, it is possible to deploy Service Fabric application using VSTS's hosted build agent as the dependencies can be added via a NuGet package - refer to the following video for details. http://www.dotjson.uk/azure-service-fabric-continous-integration-and-deployment-in-15-minutes/
In your specific case; just create 2 build definitions (1 for each service) and 2 release definitions (1 for each service) and hook them up to the same hosted Service Fabric cluster.
Unfortunately deploying applications relies on the Service Fabric SDK being installed so you'll need to set up an agent as the instructions suggest. If you don't want to pay for the Azure VM, you might want to consider running the agent service locally e.g. On your devbox.
Note that with Service Fabric you deploy applications, not services. You can however update services independently.
It sounds like you need to have service fabric SDK installed on the build machine, and I'm guessing the hosted agent doesn't have that. If that's the case, then yes you need to create your own build server VM