Simon Online

2018-11-15

Durable Functions Logging Best Practices

Durable Functions provide a way to run a series of functions in an orchestrated concert*. The product is relatively new and it is difficult to find a whole lot of guidance on how to do things with it. I found logging to be an area where some guidance was needed. So I’m writing some.

Read More

2018-11-09

Setting the version of Azure functions from ARM

Need to set the version of Azure functions runtime from an ARM template? Weirdly it is actually an app setting and not something on the site. The variable is called FUNCTIONS_EXTENSION_VERSION and can take on the values ~1 or ~2. In an ARM template it looks like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
"type": "Microsoft.Web/sites",
"kind": "functionapp",
"name": "[variables('webSiteName')]",
"tags": {
"displayName": "Site"
},
"apiVersion": "2016-08-01",
"location": "[resourceGroup().location]",
"scale": null,
"resources": [
{
"name": "appsettings",
"type": "config",
"apiVersion": "2015-08-01",
"dependsOn": [ "[concat('Microsoft.Web/sites/', variables('webSiteName'))]" ],
"tags": {
"displayName": "App settings"
},
"properties": {
"FUNCTIONS_EXTENSION_VERSION": "~2",
}
}
],...
}
2018-11-05

Azure Data Factory - a rapid introduction

Azure is huge. There are probably a dozen ways to host a website, a similar number of different data storage technologies, tools for identity, scaling, DDoS protection - you name it Azure has it. With that many services it isn’t unusual for me to find some service I didn’t even know existed. Today that service is Data Factory. Data factory is a batch based Extract, Transform and Load(ETL) service which means that it moves data between locations. I mention that it is batch to distinguish it from services which are online and process events as they come in. Data Factory might be used to move data between a production database and the test system or between two data sources.

Read More

Checking in packages

If there is one thing that we developers are good at it is holy wars. Vi vs. Emacs, tabs vs. spaces, Python vs. R, the list goes on. I’m usually smart enough to not get involved in such low brow exchanges… haha, who am I kidding? (vi, spaces and R, BTW) Recently I’ve been tilting at the windmill that is checking in package files. I don’t mean the files that tell what version of files to check in but the actual library files.

Read More

2018-10-19

DevOps and Microservices - Symbiotes

Two of the major ideas de jour in development circles these past few years have been DevOps and Microservices. That they rose to the forefront at the same time was not a coincidence. They are inexorably linked ideas.

Read More

2018-10-12

Terraform for a statically hosted AWS site

Just the other day somebody was mentioning to me that they were having trouble setting up a statically hosted site on AWS. That was the kick in the nose I needed to get this article written as it’s been on my back-burner for a while. Terraform makes the whole process easy.

Read More

2018-09-12

Downloading a file from S3 using Node/JavaScript

There seems to be very scant examples on how to download a file from S3 using node and JavaScript. Here’s how I ended up doing it using the aws-sdk:

1
2
3
4
5
6
7
8
9
10
11
const params = {
Bucket: 'some bucket',
Key: 'somefilename.txt'
};

const s3Data = await s3.getObject(params).promise();
console.log('Content length is:' s3Data.ContentLength);
console.log('Content type is:' s3Data.ContentType);
console.log('Writing to file');
const file = fs.createWriteStream('c:/afile.txt');
file.write(s3Data.Body);
2018-09-05

Error creating an SQS queue in serverless

I ran into an error today creating an SQS queue in serverless which looked a lot like:

1
2
3
CloudFormation - CREATE_FAILED - AWS::SQS::Queue - SendEmailQueue
...
An error occurred: SendEmailQueue - API: sqs:CreateQueue Access to the resource https://sqs.us-east-1.amazonaws.com/ is denied..

You would think this error is related to something in IAM, and indeed it may well be. However in my case it wasn’t it was actually that I was giving CloudFormation a mal-formed name for the queue. I would like to think that the developers of SQS would use HTTP code 400 (bad request) to report this error but instead they use 403. So keep in mind that even though it looks like a permissions problem it might be a syntax error.

2018-07-03

Dealing with implicit any in node_modules

I like to set noImplicitAny in my TypeScript projects in the hopes it will catch just a few more bugs before they hit production. Problem we had recently was that not every library author agrees with me. In this case the aws-amplify project gave us this error.

1
2
node_modules/aws-amplify/lib/Interactions/Interactions.d.ts
(19,44): Parameter 'err' implicitly has an 'any' type.

Well that sucks, they should use noImplicitAny! From our perspective we can fix this by not applying our implicit any rules to library definition files. This can be done by adding

1
"skipLibCheck": true

To the compilerOptions in our tsconfig.json so that errors in the definition files there were ignored.

2018-07-02

Weird JavaScript - Destructuring

I’ve been at this programming game for a long time and I’ve written two books on JavaScript. Still today I ran into some code that had me scratching my head. It looked like

1
function AppliedRoute ({ component: C, props: cProps, ...rest }) {

I was converting some JavaScript to TypeScript and this line threw an linting error because of implicit any. That means that the type being passed in has no associated type information and has been assumed to be of type any. This is something we’d like to avoid. Problem was I had no idea what this thing was. It looked like an object but it was being built in the parameters?

Read More