Tuesday, 29 August 2017

Reset an iPad vs an Android

My mother had an iPad that needed resetting as it was using an email address for an Apple ID that no longer existed. After hours, yes hours, of trying to perform a factory reset, I thought it rather interesting to make a comparison between the two platforms.

Factory Reset an Android 

Go into settings and select Factory Reset. Follow the prompts, and voila!

Factory Reset an iPad 

Find a proprietary Lightening cable
Download 247Mb of iTunes software (wait! iTunes, isn't that a music program?)
Reset the password I
t still is locked to your old Apple Id
Try and reset the Apple Id multiple times.
It tells you it isn't a valid Apple Id despite the fact the device is telling me this IS the Apple ID on the device.
Go to the Reset credentials website. It is broken.

And I thought Apple was the height of user experience?

CosmosDB change feed is not a record of ALL updates

Given I have two records, PottsA age 24 and PottsB age 30, the change feed processor returns the two records:

{
  "id": "PottsA",
  "FirstName": "Andrew",
  "LastName": "Potts",
  "Age": 24,
  "_rid": "As5lALWJOgABAAAAAAAAAA==",
  "_self": "dbs/As5lAA==/colls/As5lALWJOgA=/docs/As5lALWJOgABAAAAAAAAAA==/",
  "_etag": "\"00008e03-0000-0000-0000-59a53b790000\"",
  "_attachments": "attachments/",
  "_ts": 1504000889,
  "_lsn": 8
}


{
  "id": "PottsB",
  "FirstName": "Andrew",
  "LastName": "Potts",
  "Age": 30,
  "_rid": "As5lALWJOgADAAAAAAAAAA==",
  "_self": "dbs/As5lAA==/colls/As5lALWJOgA=/docs/As5lALWJOgADAAAAAAAAAA==/",
  "_etag": "\"00009203-0000-0000-0000-59a552970000\"",
  "_attachments": "attachments/",
  "_ts": 1504006807,
  "_lsn": 10
}

If I Upsert PottsB to age 50,

await client.UpsertDocumentAsync(
UriFactory.CreateDocumentCollectionUri(databaseName, collectionName),
new Person
{
Id = "PottsB",
FirstName = "Andrew",
LastName = "Potts",
Age = 50
});

Then the change feed detects the change:
ID: PottsB
{
  "id": "PottsB",
  "FirstName": "Andrew",
  "LastName": "Potts",
  "Age": 50,
  "_rid": "As5lALWJOgADAAAAAAAAAA==",
  "_self": "dbs/As5lAA==/colls/As5lALWJOgA=/docs/As5lALWJOgADAAAAAAAAAA==/",
  "_etag": "\"00009303-0000-0000-0000-59a553860000\"",
  "_attachments": "attachments/",
  "_ts": 1504007046,
  "_lsn": 11
}

However, if I reset the checkpoint back to null:
Only two results are returned. Only the latest change to PottsB is returned.

ID: PottsA
{
  "id": "PottsA",
  "FirstName": "Andrew",
  "LastName": "Potts",
  "Age": 24,
  "_rid": "As5lALWJOgABAAAAAAAAAA==",
  "_self": "dbs/As5lAA==/colls/As5lALWJOgA=/docs/As5lALWJOgABAAAAAAAAAA==/",
  "_etag": "\"00008e03-0000-0000-0000-59a53b790000\"",
  "_attachments": "attachments/",
  "_ts": 1504000889,
  "_lsn": 8
}
ID: PottsB
{
  "id": "PottsB",
  "FirstName": "Andrew",
  "LastName": "Potts",
  "Age": 50,
  "_rid": "As5lALWJOgADAAAAAAAAAA==",
  "_self": "dbs/As5lAA==/colls/As5lALWJOgA=/docs/As5lALWJOgADAAAAAAAAAA==/",
  "_etag": "\"00009303-0000-0000-0000-59a553860000\"",
  "_attachments": "attachments/",
  "_ts": 1504007046,
  "_lsn": 11
}

Thus the change feed does not provide a list of all of the changes that took place, just the final changes to the document.
To have an immutable history of changes to a document (e.g. in an event sourcing scenario) each change must have a unique document reference.
Simply appending changes to a document itself will not provide an immutable history.

Sunday, 20 August 2017

Android Studio local emulator incompatible with Hyper-V

Android Studio is incompatible with Hyper-V.
You can turn off Hyper-V with:

bcdedit /set hypervisorlaunchtype off

You also get a bit better performance out of your PC. To turn it back on:

bcdedit /set hypervisorlaunchtype on (or auto start)

Friday, 4 August 2017

Precompiled Azure Functions not appearing when published

I had an Pre-compiled Azure Function that when published, would not appear in the list of functions.
The function.json looked like this:

{
  "disabled": false,
  "scriptFile": "PdfGeneration.dll",
  "entryPoint": "PdfGeneration.EntryPoint.Run",
  "bindings": [
    {
      "authLevel": "anonymous",
      "name": "req",
      "type": "httpTrigger",
      "direction": "in"
    },
    {
      "name": "res",
      "type": "http",
      "direction": "out"
    }
  ]
}

After a while I found the problem. Publishing the precompiled function does not also publish the assembly.
You need to manually copy it to the appropriate folder on the Web App that hosts the Azure Function.

If you put the assembly in the correct place and redeploy, the function appears.


Open Kudu for the app:
https://<FunctionApp>.scm.azurewebsites.net/DebugConsole

Navigate to the folder for the function:
/site/wwwroot/<functionname>

drag and drop the assemblies into the folder.

Note the scriptFile property is relative to the function folder. If you want to put the assemblies in a bin folder off the function folder, you must use:
  "scriptFile": "bin\\PdfGeneration.dll",