In our deployment pipelines, we create an app servcie by deploying its ARM template in one of the steps(powershell) in ocopus pipeilne. In a subsequent step(powershell), we are creating a dynamic deployment target which is the app service just mentioned before like,
New-OctopusAzureWebAppTarget -name “Azure $appServiceName AppService”
-azureWebApp $appServiceName
-azureResourceGroupName $resourceGroupName-octopusAccountIdOrName $subscription
-octopusRoles “…” `
-updateIfExisting
and then in another subsequent step(DEPLOY AN AZURE WEB APP), when we push the nuget package into the target, it fails saying that target not found or health check failed.
it fails only the first time when the app servcie is created from scratch. but from next time, it works when the app service is already deployed.
the logs are like
11:39:31 Error | Error running AzureWebAppCreateTargetServiceMessageHandler for create-azurewebapptarget:
| Health check failed: Azure app-capacity-mgmt-api-dev AppService(Machines-582) is unable to be contacted.
| System.Exception: Health check failed: Azure app-capacity-mgmt-api-dev AppService(Machines-582) is unable to be contacted.
| at Octopus.Server.Orchestration.Targets.Scripting.ServiceMessageHandlerTargetBase.RunHealthCheck(DeploymentTarget machine, VariableCollection variables, String environmentIdOrNames, String tenentIdOrNames, ITaskContext taskContext, ActionCommand command) in C:\buildAgent\work\6099152b9b48bea6\source\Octopus.Server\Orchestration\Targets\Scripting\ServiceMessageHandlerTargetBase.cs:line 148
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.AzureWebAppCreateTargetServiceMessageHandler.HandleServiceMessage(ScriptOutputAction action, VariableCollection variables, ITaskContext taskContext, ActionCommand command) in C:\buildAgent\work\6099152b9b48bea6\source\Octopus.Server\Orchestration\ServerTasks\Deploy\ActionDispatch\ServiceMessageHandlers\AzureWebAppCreateTargetServiceMessageHandler.cs:line 67
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.ServiceMessageProcessor.ExecuteHandlersForAction(ILog log, VariableCollection variables, ScriptOutputAction action, ActionCommand command) in C:\buildAgent\work\6099152b9b48bea6\source\Octopus.Server\Orchestration\ServerTasks\Deploy\ActionDispatch\ServiceMessageHandlers\ServiceMessageProcessor.cs:line 54
| Octopus.Server version 2020.2.16 (2020.2.16+Branch.tags-2020.2.16.Sha.768f1ab39d3a63d1a7356cd18487d8cb14d27fdc)
11:39:31 Verbose | Health check failed: Azure app-capacity-mgmt-api-dev AppService(Machines-582) is unable to be contacted.
| System.Exception
| at Octopus.Server.Orchestration.Targets.Scripting.ServiceMessageHandlerTargetBase.RunHealthCheck(DeploymentTarget machine, VariableCollection variables, String environmentIdOrNames, String tenentIdOrNames, ITaskContext taskContext, ActionCommand command) in ServiceMessageHandlerTargetBase.cs:line 148
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.AzureWebAppCreateTargetServiceMessageHandler.HandleServiceMessage(ScriptOutputAction action, VariableCollection variables, ITaskContext taskContext, ActionCommand command) in AzureWebAppCreateTargetServiceMessageHandler.cs:line 67
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.ServiceMessageProcessor.ExecuteHandlersForAction(ILog log, VariableCollection variables, ScriptOutputAction action, ActionCommand command) in ServiceMessageProcessor.cs:line 54
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.ServiceMessageHandlers.ServiceMessageProcessor.Process(ILog log, IActionHandlerResult result, VariableCollection variables, ActionCommand command) in ServiceMessageProcessor.cs:line 36
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.NewActionDispatcher.<>c__DisplayClass13_0.b__3() in NewActionDispatcher.cs:line 174
| at Octopus.Server.Orchestration.ServerTasks.Deploy.Guidance.ExecuteWithoutGuidance(Action callback, String actionName, Boolean actionIsRequiredToRun) in Guidance.cs:line 132
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.NewActionDispatcher.ExecuteOnDeploymentTarget(ActionCommand command, DeploymentTarget deploymentTarget, Maybe1 guidanceExcludeCallback) in NewActionDispatcher.cs:line 104 | at Octopus.Server.Orchestration.ServerTasks.Deploy.ExecutionTaskController
1.<>c__DisplayClass45_1.b__1() in ExecutionTaskController.cs:line 532
| at Octopus.Server.Orchestration.ServerTasks.Deploy.Guidance.ExecuteWithoutGuidance(Action callback, String actionName, Boolean actionIsRequiredToRun) in Guidance.cs:line 132
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ExecutionTaskController1.<>c__DisplayClass45_0.<ExecuteActionAndInitLoggingContext>b__0() in ExecutionTaskController.cs:line 537 | at Octopus.Server.Orchestration.ServerTasks.Deploy.ExecutionTaskController
1.ExecuteWithTransientErrorDetection(Action action, DeploymentTarget deploymentTarget) in ExecutionTaskController.cs:line 678
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ExecutionTaskController`1.ExecuteActionAndInitLoggingContext(PlannedStep step, DeploymentTarget targetContext, PlannedAction action) in ExecutionTaskController.cs:line 553
11:39:31 Fatal | The action Create Octopus Dynamic Deployment Azure App Service Target on ASP Build Testing IIS Web Server (Development) failed
|
| == Failed: Check deployment target: Azure app-capacity-mgmt-api-dev AppService ==
11:39:27 Verbose | Checking connectivity to machine
11:39:27 Verbose | Using account ID ‘azureserviceprincipal-shared-services-dev-spaces-1’
11:39:27 Verbose | Account variables are being contributed by the target
11:39:27 Verbose | Using Calamari.Cloud.netfx 12.1.1
11:39:27 Verbose | Using Calamari.linux-x64 12.1.1
11:39:27 Verbose | Running this script in the Octopus Server security context (SCDOM\imsbatch)
11:39:27 Verbose | Starting C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in working directory ‘D:\Octopus\Work\20210312103927-149088-683’ using ‘Western European (DOS)’ encoding running as ‘SCDOM\imsbatch’ with the same environment variables as the launching process
11:39:28 Verbose | Calamari Version: 12.1.1
11:39:28 Verbose | Environment Information:
11:39:28 Verbose | OperatingSystem: Microsoft Windows NT 6.3.9600.0
11:39:28 Verbose | OsBitVersion: x64
11:39:28 Verbose | Is64BitProcess: True
11:39:28 Verbose | CurrentUser: SCDOM\imsbatch
11:39:28 Verbose | MachineName: DK01SV1176
11:39:28 Verbose | ProcessorCount: 2
11:39:28 Verbose | CurrentDirectory: D:\Octopus\Work\20210312103927-149088-683
11:39:28 Verbose | TempDirectory: C:\Users\imsbatch\AppData\Local\Temp
11:39:28 Verbose | HostProcess: Calamari (6464)
11:39:28 Verbose | Authentication Context: https://login.windows.net/12dcf0d8-fc71-4abe-a06c-2d2bc1c6d3f0
11:39:30 Error | Could not find site app-capacity-mgmt-api-dev in resource group cockpit-capacity-mgmt, using Service Principal with subscription 03c17943-b278-41db-a125-c72c5383be24
11:39:30 Error | System.Exception
11:39:30 Error | at Calamari.Azure.WebApps.HealthChecks.WebAppHealthChecker.ConfirmWebAppExists(AzureServicePrincipalAccount servicePrincipalAccount, String resourceGroupName, String siteAndSlotName)
11:39:30 Error | at Calamari.Azure.WebApps.HealthChecks.WebAppHealthChecker.ExecuteHealthCheck()
11:39:30 Error | at Calamari.CalamariFlavourProgram.Run(String args)
11:39:30 Verbose | Process C:\windows\system32\WindowsPowershell\v1.0\PowerShell.exe in D:\Octopus\Work\20210312103927-149088-683 exited with code 100
11:39:30 Verbose | Exit code: 100
11:39:30 Fatal | The remote script failed with exit code 100
11:39:30 Verbose | The remote script failed with exit code 100
| Octopus.Server.Orchestration.Targets.Tasks.ActionHandlerFailedException: The remote script failed with exit code 100
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.SuccessArbitrator.ThrowIfNotSuccessfull(IActionHandlerResult result) in C:\buildAgent\work\6099152b9b48bea6\source\Octopus.Server\Orchestration\ServerTasks\Deploy\ActionDispatch\SuccessArbitrator.cs:line 23
| at Octopus.Server.Orchestration.ServerTasks.Deploy.ActionDispatch.AdHocActionDispatcher.Dispatch(Machine machine, ActionHandlerInvocation actionHandler, VariableCollection variables) in C:\buildAgent\work\6099152b9b48bea6\source\Octopus.Server\Orchestration\ServerTasks\Deploy\ActionDispatch\AdHocActionDispatcher.cs:line 63
| at Octopus.Server.Orchestration.ServerTasks.HealthCheck.Controllers.VirtualTargetHealthController.CheckHealth(Machine machine) in C:\buildAgent\work\6099152b9b48bea6\source\Octopus.Server\Orchestration\ServerTasks\HealthCheck\Controllers\VirtualTargetHealthController.cs:line 69
| at Octopus.Server.Orchestration.ServerTasks.HealthCheck.HealthCheckService.PerformConnectivityCheck(Machine machine, ExceptionHandling exceptionHandling) in C:\buildAgent\work\6099152b9b48bea6\source\Octopus.Server\Orchestration\ServerTasks\HealthCheck\HealthCheckService.cs:line 66
| Octopus.Server version 2020.2.16 (2020.2.16+Branch.tags-2020.2.16.Sha.768f1ab39d3a63d1a7356cd18487d8cb14d27fdc)
11:39:30 Verbose | Recording health check results
please guide