Wednesday, February 22, 2017

iPhone Text Message SQLite SQL Query

In my experience, the iPhone text message search functionality is usually pretty awful. Especially if you're trying to find a text from a few years go. Luckily, if you backup your iPhone using iTunes, your text messages are exported/stored in a SQLite database, and it is fairly easy to query.

Here are the steps to SQL Query your Text Messages.

  1. Backup your iPhone using iTunes.

  2. Find the SQLite file that contains your text messages.
    - in ~/Library/Application Support/MobileSync/Backup/* with a filename of 3d0d7e5fb2ce288813306e4d4636395e047a3d28

  3. Ensure you have a SQLite Query tool (SQLiteBrowser is pretty good).

  4. Open your SQLite Text Message DB File using your favorite SQLite query tool.

  5. Execute this query to see all your messages.

Disclaimer, I had to guess at the table structure, therefore I can not confirm that the joins in this query are 100% correct. My quick spot checks seemed to check out, and I was able to query the message.text field to find old messages that the iPhone app was not able to.

Hope this helps,

Monday, January 30, 2017

Azure Kudu Deployment Version Number

I recently blogged about generating a version.txt file on every build via Visual Studio. This solution is fine if you are building from you local machine and using Web Deploy to deploy to Azure, but if you have a github webhook and are using kudu, the VS Post Build Events are not executed.

The easiest way I found to generate a version.txt file for every deployment is to add a post deployment action to your Web App/App Service.

Create a file within the /site/deployments/tools/PostDeploymentActions/ folder of your App Service (you may need to create that folder). You can name the file whatever you'd like, I chose `generategitversionfile.cmd`. The file should contain at least the following line:

git rev-parse HEAD > "..\wwwroot\version.txt"

This command will be executed within the context of the `/site/repository` directory, that's why we need a more fully qualified path for where to write the file.

Now, after every kudu deploy, a new version.txt file will be created that contains the current git comment hash.

Hope this helps,

Thursday, January 26, 2017

Stop Azure WebJob from WebSite

I recently had the need to toggle the status of an Azure WebJob from the WebSite in the same Azure App Service. I found a couple half-complete answers online, but I thought I'd put together this simple guide to have a complete example all in one place.

To accomplish this, we'll be using the kudu REST API for WebJobs.

(note: I also looked into toggling the WEBJOBS_STOPPED environment variable from the WebSite, however I was not able to verify that solution was going to work. I confirmed I was able to set the environment variable from the website, however the value did not update in the "Application Settings" section of the Azure Portal and I was concerned the WebJobs may read a separate environment variable than the WebSite [process scoped vs machine envar for example])

The first thing you'll need to do is download the PublishSettings file (aka "Publish Profile") associated with the App Service (you need the username/password from this file to satisfy the basic auth requirement to the kudu API)

In the "Web Deploy" publish profile section of this file, find the "userName" and "userPWD" values, we'll need these in the code linked below.

The full documentation describing all the various REST endpoints is available here. I have created a simple gist of how to authenticate using basic auth and call a few WebJob methods to start and stop services here:

Hope this helps!