DeleteDocumentAsync – PartitionKey value must be supplied

I was trying to delete a document in DocumentDB / CosmoDB and I was surprised to be faced with the error message of, ‘PartitionKey value must be supplied’. There doesn’t appear to be a way of passing the partition key to DeleteDocumentAsync. The trick is to use the request options. For example, if your collection is partitioned by ProductID;

await this.documentClient.DeleteDocumentAsync(productDocument._self, new RequestOptions { PartitionKey = new Microsoft.Azure.Documents.PartitionKey(productDocument.ProductID) });
Posted in Azure, Uncategorized | Tagged , | Leave a comment

The target “MSDeployPublish” does not exist in the project

Had a very strange issue this morning, create a new Azure Web project as usual, went to publish it and it refused to saying, ‘The target “MSDeployPublish” does not exist in the project’. So I compared the project with one of the ones that worked and for some weird reason it was missing the following line. Once added it published without issue.

<Import Project="..\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.targets" Condition="Exists('..\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.targets')" />
Posted in Uncategorized | 1 Comment

A method to compare blobs in different Azure blob storage accounts

I was recently asked to run a comparison of the blobs in two Azure Storage Accounts, where they should contain the same blob entries. However, some of the entries had been deleted from one account. Since it requires scanning the whole account it is expensive in cost and time. The fastest mechanism I found (and I’m sure there are better ways, please comment) was;

var blobsInBackupContainer = backupContainer.ListBlobs(useFlatBlobListing: true).OfType<CloudBlockBlob>().Select(b => b.Name);
var blobsInPrimaryContainer = primaryContainer.ListBlobs(useFlatBlobListing: true).OfType<CloudBlockBlob>().Select(b => b.Name);                

var missing = blobsInBackupContainer.Except(blobsInPrimaryContainer);
Console.WriteLine($"Missing count {missing.Count()}");
foreach (var item in missing)
    Console.WriteLine($"Missing item = {item}");
Posted in Uncategorized | Leave a comment

How to encode a date condition in Azure Data Factory

I keep forgetting the correct format; here is an example;

where created_date >= \\'2017-05-11\\'

Posted in Azure, Uncategorized | Leave a comment

How to remove a search term/url from Edge

The other day I wanted to lookup the price of a PlayStation in France. I entered into Edge and found the details – all was good. However, now whenever I start to type ‘am..’ into Edge it keeps trying to ‘help’ me auto-filling in again. Grrr. The way I managed to stop Edge doing this is to hack the values out of the Registry. As with any Registry changes you must be careful and do this at your own risk;

    Close Edge
    Open Registry Editor: Windows->Run. Regedit
    Select the first node
    Type in the core part of the url you want to remove, e.g.
    Look at the path (in the status bar at the bottom). Delete each instance your find that has any path related to Edge
    Repeat by pressing F3 once after each delete
Posted in Uncategorized | Leave a comment

Monitoring the progress of CreateIndex

One of the frustrating aspects of SQL Server is the lack of progress indicators. One such command falling into this pit is CreateIndex. However, this is a great link for a solution;

Step 1 – Before you run the following query make sure you have ‘include actual execution plan’ option set in query analyser. If you don’t have this, or similar, then the DMV won’t produce any results.

Step 2 – Select @@SPID

Step 3 – run your Create Index in the same query window as step 2

Step 4 – Create a new query with the following SQL, replace the SPID in the first line with that from step (2)

;WITH agg AS
SELECT SUM(qp.[row_count]) AS [RowsProcessed],
SUM(qp.[estimate_row_count]) AS [TotalRows],
MAX(qp.last_active_time) – MIN(qp.first_active_time) AS [ElapsedMS],
MAX(IIF(qp.[close_time] = 0 AND qp.[first_row_time] > 0,
N'<Transition>’)) AS [CurrentStep]
FROM sys.dm_exec_query_profiles qp
WHERE qp.[physical_operator_name] IN (N’Table Scan’, N’Clustered Index Scan’, N’Sort’)
AND   qp.[session_id] = @SPID
), comp AS
([TotalRows] – [RowsProcessed]) AS [RowsLeft],
([ElapsedMS] / 1000.0) AS [ElapsedSeconds]
FROM   agg
SELECT [CurrentStep],
(([RowsProcessed] * 1.0) / [TotalRows]) * 100) AS [PercentComplete],
(([ElapsedSeconds] / [RowsProcessed]) * [RowsLeft]) AS [EstimatedSecondsLeft],
(([ElapsedSeconds] / [RowsProcessed]) * [RowsLeft]),
GETDATE()) AS [EstimatedCompletionTime]
FROM   comp;
Posted in SQL Server, Uncategorized | Leave a comment

Problem shrinking tempdb – could not be moved because it is a work table page

SQL holds a lot of cached information in tempdb. Until it’s cleared it won’t allow tempdb to be shrunk. So here’s a quick script you might have some joy with (obviously be aware that you will suffer the cost of losing this cached information) (thanks to MSDN);

USE [tempdb]













Posted in SQL Server, Uncategorized | Leave a comment