Tag Archives: deployment

Azure App Service release hangs and then fails

We got a hazardous deployment on Azure: in every 4-5th release the pipeline timed out after 60 minutes of waiting for Azure. First we suspected Azure services, as the script was hanging on their API call, but there was no outage report. Tried to investigate other deployments when this one failed, but every other worked just fine. Searching Microsoft’s wiki gave the answer:

A release hangs for a long time and then fails, a “503 service unavailable” error occurs, or the deployment history in the deployment logs fails to update

It turned out that the App Service Plan was hosting multiple, small services which took most of the resources, making the deployment hazardous.

Increasing the App Service Plan’s tier solved our issue.

One good reason to use custom deployment buckets

When deploying serverless Lambda it will create a bucket with the code and CloudFormation template. It is totally fine, but the newly created bucket will be associated with the stack and will prevent us from purging the whole stack.

When do we want to delete a stack?

During development there could be many reasons to completely remove one, few ideas:

  • our Lambda’s type changed, thus it cannot be just updated
  • we had to experiment with roles and want to test them after clean serverless installation
  • none of the resources are required anymore

According to the default AWS policy an S3 bucket cannot be deleted if it is not empty, which exactly is preventing us from purging the stack.

What can one do?

It is really straightforward: create a bucket for serverless deployment. If we manually add a new S3 bucket and point our serverless installer to that, it won’t be interfering with our stack.

When the bucket is there we can add these two lines under provider to our serverless to make it use that for deployment:

  deploymentBucket:
    name: serverless-dep-bucket-dev

Updating the utc-time-teller’s serverless it looks like this:

service: BlogDavidPythonLambdaDeploy

provider:
  name: aws
  region: eu-west-1
  deploymentBucket:
    name: serverless-dep-bucket-dev

functions:
  utc-time-teller:
    name: utc-time-teller
    handler: src/lambda_handler.handler
    memorySize: 128
    timeout: 30
    runtime: python3.8
    events:
      - http:
          path: /{proxy+}
          method: any
      - http:
          path: /
          method: any