Sunday, June 24, 2018

Regex to search VSCode for Azure subscription keys

Before you check in code, make sure the Azure subscription keys are removed or replaced with obvious markers.

In VSCode, select the magnifying glass, the select the last icon on the line, "*." indicating the search is by regular expression. Enter [a-z0-9]{32} in the search text box and select enter.

The search results appear below the search text box. Scan the results for any highlighted keys that are real key values.


Wednesday, May 16, 2018

Changing TLS setting for Azure web apps including Bot Framework

If you need to change the TLS setting for you Azure web apps, including Bot Framework apps, go to the Azure portal. In the left navigation, select All Resources, sort the table by the type column.

Any row with the type of app service may need the TLS setting updated based on on the service announcement here.

On each service, select the SSL section, and change the Minimum TLS Version.


Tuesday, January 16, 2018

Curl command for Microsoft Cognitive Services product QnA Maker

This is the curl command to send QnA Maker a question and receive the answer:

curl -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key:<subscriptionKey>" -X POST -d '{"question":"<question>"}' https://westus.api.cognitive.microsoft.com/qnamaker/v2.0/knowledgebases/<appID>/generateAnswer

<subscriptionKey> found on https://www.qnamaker.ai/UserSettings
<appID> found in url when view app, ?kbid=<appID>
<question> question such as "How do I ...?"

Monday, January 15, 2018

Debug mocha.js with VSCode

This is my cheat sheet for debugging the mocha.js project from VSCode while adding fixes to it. This is not about how to debug ANY project that is using mocha for testing.

The mocha.js repository has a build system that builds into /bin/mocha.

I don't use a package.json script. I just use a launch.json mocha test configuration:

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"program": "${workspaceFolder}/bin/_mocha",
"args": [
"--colors",
"${workspaceFolder}/test/reporters/dina.spec.js"
],
"internalConsoleOptions": "openOnSessionStart"
}
]
}


  • The program value has to be changed from the node_modules directory to the /bin directory. The top level file is supposed to be bin/_mocha but it won't debug. 
  • Remove any timeout args from the args array. 
  • Specify the exact file you want to debug into such as "dina.spec.js"

Sunday, October 15, 2017

Paperspace.com for Windows 10 Desktops in the cloud

I recently needed a clean Windows 10 desktop for testing purposes. I couldn't use Docker, Vagrant, VirtualBox or any of the other local-to-my-computer VM solutions. I tried the Amazon Workspaces solution but it had the typical UX of 30 questions I don't know the answer to. I just wanted a desktop that could download from the Internet.

Paperspace.com to the rescue!

Within 5 minutes I had a Windows 10 desktop in a browser and the hardest questions where how much CPU and ram I wanted. The cost was incredibly inexpensive too.

The test only took 10 minutes and I destroyed the cloud machine after that.

This was the easiest, fastest, and cheapest solution to the problem.

Monday, September 18, 2017

SQL Server AAD Authentication Error

Are you seeing this error from your ADO.NET Code Trying to Connect To Your SQL Server via Active Directory Authentication:

Exception=System.Data.SqlClient.SqlException (0x80131904): Failed to authenticate the user NT Authority\Anonymous Logon in Active Directory (Authentication=ActiveDirectoryIntegrated). Error code 0x800703FA; state 10 Illegal operation attempted on a registry key that has been marked for deletion. 

The issue might be that you are running a windows service or a scheduled task with a user that has logged off. In Windows Server the registry hive for the current user is loaded when the user logs into the machine, and unloaded when they log off. This means that if you service account is running under a user that is logged off then the registry hive will not be available. ADO.NET AAD in .NET 4.6.1 uses the registry hive of the running user -- which could be the user of a service.

To solve this problem you need to tell Windows Server not to unload the registry hive for users when they log off.

{6230289B-5BEE-409e-932A-2F01FA407A92}