Posts

Azure DevOps - Cloning and updating all Git repositories

If you have a lot of repositories in your Azure DevOps team, you need an easy way to clone and/or update your local Git repositories. You first need to install the Az-cli available at: https://docs.microsoft.com/cli/azure/install-azure-cli Once installed, please run the following in a console: az extension add --name azure-devops You also need to login, just once. Run the following in a console: az login Create the following files: Replace C:\YourWorkFolder with the root folder of all your repos. Replace XXXXXXXXXX with the name of your organisation and project. For example: az devops configure --defaults project= TestProject az devops configure --defaults organization=https://dev.azure.com/ TestCompany / Run the sync.cmd file, and that is it. It will clone new repos if you don't already have them, and will update your repos if you already have some.

Amazon Alexa skill account linking using IdentityServer4

Image
It took a lot of reading and quite some time to wade though exactly what was required to get Amazon Alexa account linking working with our Identity Server 4 oauth server. Most of the stuff out there was to perform account linking with Amazon's own OAUTH server, and not IdentityServer4. Well, I finally got to the bottom of it all, and to save you devs valuable time and frustrations, I've laid it all out below: Create your Asp.Net Core API Configure Identity Server 4 for account linking Create your Alexa Skill Account link your Alexa skill to Identity Server 4. Amazon will take care to call your Identity Server 4 to obtain a token and manage refresh tokens for you. Call your API from Alexa. Alexa voice command → Amazon Lambda function → [Hidden Identity Server 4 call] → Asp.Net Core API → Return Speech back to Alexa to say aloud. Asp.Net Core API The controller for your Alexa API should look something like this: The IDataService is used solely for accessing the data...

Azure Sql Server Profiling

As you may have already guessed, you cannot use SQL Server Profiler on an Azure database. However, you can use the following code to find out what SQL was executed: In order to get the real parameter values, you need to enable sensitive data logging by using DbContextOptionsBuilder.EnableSensitiveDataLogging method: Enables application data to be included in exception messages, logging, etc. This can include the values assigned to properties of your entity instances, parameter values for commands being sent to the database, and other such data. You should only enable this flag if you have the appropriate security measures in place based on the sensitivity of this data.

SQL Server Paging - The Holy Grail

More info on the above see SqlServerCentral Another version:

Interpreting the query plan and speeding it up

Image
Bookmark Lookup - An index was used but as the index does not 'cover' the query the query processor must use the ROWID from the index to 'lookup' the actual data row. Unless the index can be alter to ‘cover’ the columns of the query this cannot be optimised further. Clustered Index Scan - Similar to a table scan (its just that the table has a clustered index) and similarly undesirable, particularly for large tables. If you see these then the columns in the query are either not indexed or the distribution statistics have led the query optimiser to decide the scan is more/ as efficient. Restructuring the query can sometimes eliminate these operations; or add an index. Clustered Index Seek - The clustered index is used to find matching rows. This is optimal behaviour. Compute Scalar - As it says – a scalar is being computed. Unless this is not really needed it can't be optimised. It its not needed, remove it! Constant Scan - The query requires a constan...

MSMQ Best Practices

Performance recommendations Avoid unnecessary database lookups before deciding if a message can be dropped. Prioritization should be given in code for dropping the message as quickly and efficiently as possible. If database lookups are required in deciding if a message can be dropped, can these be cached (with a refresh timeout)? If you are dropping messages, is there a better way to only receive the correct messages? If you are subscribed to an event processor publisher, does that publisher provide any kind of subscription filtering? Filtering can be achieved via database event subscription tables, (a list of subscribers with their input queues, and a list of events each input queue is interested in). Separate event types Publishers should translate event types into separate System.Types, with hierarchies to support grouping. For example, with some kind of  delivery event data, these could be group interfaces such as ProofOfDeliveryGroup, ProofOfCollectionGroup, e...

Stock prediction using Azure Machine Learning

Image
I like dabbling in the stock market, and wondered if artificial intelligence could help predict when I should buy/sell stock. Using one of the FANG stocks (Facebook, Amazon, Netflix, Google) I'll choose Netflix for the purposes of this blog post. Here is what Netflix has done in the last 3 months: The top graph is Fast Stochastics (12,26) As you can see, predicting the future is not easy. So my first step was to not use AI at all, but to write a program to help me decide which values of %K and %D I should use for the Fast Stochastics graph, using the last 5 years of stock history for Netflix. Historical data This can be obtained from Yahoo finance . Change the Time period to 5Y and press Apply. Then click the download data link to obtain your CSV file. Best %K %D Fast Stochastics values for Netflix The program I wrote takes into account that buying stock and selling stock incur a fee, and that the buy and sell values are not the same (bid/ask difference). The...