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"