Add use of shell commands to verify a token to the walk-through (#117)

* Document prerequisites for sesclient.native.exe (#114)
* Update documentation to include `publish-archives.ps1`
* Update reference to psake when troubleshooting
* Remove platform option from build script
* Add details on using PowerShell to verify the token
* Add examples for curl and wget
This commit is contained in:
Bevan Arps 2018-07-24 10:44:06 +12:00 коммит произвёл peterbom
Родитель 914abe4163
Коммит 6f563a7352
3 изменённых файлов: 62 добавлений и 7 удалений

Просмотреть файл

@ -2,11 +2,9 @@
# Build native components for Windows
#
param (
[ValidateSet('x86', 'x64')]
$platform = "x64",
[ValidateSet('Release', 'Debug')]
$configuration = "Debug"
)
. .\scripts\bootstrap.ps1
invoke-psake -buildFile .\scripts\psake-build.ps1 -taskList Request.$platform, Request.$configuration, Build.Windows
invoke-psake -buildFile .\scripts\psake-build.ps1 -taskList Request.$configuration, Build.Windows

Просмотреть файл

@ -185,8 +185,6 @@ May indicate that you have Visual Studio 2015 Update 2 or earlier; **vcpkg** nee
### Assert: No .NET Framework installation directory found at \Microsoft.NET\Framework64\v4.0.30319\.
This error occurs when attempting to build on Linux using Psake 4.6.0 (the current release as of September 2017).
This error occurs when attempting to build on Linux using Psake version 4.6.0 or earlier. Upgrade your version of Psake to [v4.7.0](https://github.com/psake/psake/releases/tag/v4.7.0) or higher.
Release 4.6.0 of Psake doesn't support Linux - but the current `master` branch does.
[Download](https://github.com/psake/psake/archive/master.zip) the current `master` branch of psake and extract the archive into the root of the repository as `./lib/psake` so that `bootstrap.ps1` will find the psake PowerShell module as `./lib/psake/psake.psm1`.
If you don't want to upgrade your system installation of Psake, extract the new version into the root of the repository as `./lib/psake` so that `bootstrap.ps1` will find the psake PowerShell module as `./lib/psake/psake.psm1`.

Просмотреть файл

@ -182,6 +182,65 @@ With the environment variables previously defined (`AZ_BATCH_SOFTWARE_ENTITLEMEN
PS> .\sesclient --url $env:AZ_BATCH_ACCOUNT_URL --thumbprint $connectionThumbprint --common-name localhost --token $env:AZ_BATCH_SOFTWARE_ENTITLEMENT_TOKEN --application contosoapp
```
If you are having difficulty running `sesclient`, you can do a partial verification using your shell.
Using PowerShell:
``` PowerShell
PS> $result = Invoke-WebRequest -UseBasicParsing "${env:AZ_BATCH_ACCOUNT_URL}softwareEntitlements?api-version=2017-05-01.5.0"
-ContentType 'application/json; odata=minimalmetadata'
-Method POST
-Body "{ 'applicationId':'contosoapp', 'token':'${env:AZ_BATCH_SOFTWARE_ENTITLEMENT_TOKEN}'}"
```
(Note that this commandline has been wrapped onto multiple lines for readability; you'll need to put everything on a single line to use this. Don't forget to replace `contosoapp` with the name of your application.)
The `$result` variable will contain the answer from the server - for a successfully verified token, it would look similar to this:
``` text
PS> $result
StatusCode : 200
StatusDescription : OK
Content : {
"odata.metadata":"https://<batchaccount>.<region>.batch.azure.com/$metadata#softwareentitlementresponses/@Element",
"id":"<entitlementtokenid>"...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
request-id: 68a1efd5-a919-4635-a93a-fe5510c2a983
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
DataServ...
Forms :
Headers : {[Transfer-Encoding, chunked], [request-id, 68a1efd5-a919-4635-a93a-fe5510c2a983],
[Strict-Transport-Security, max-age=31536000; includeSubDomains], [X-Content-Type-Options, nosniff]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 227
```
(Again there's been some light editing for presentation purposes.)
If you're working with a Linux shell, you can achieve the same result with `curl` or `wget`:
``` bash
$ curl --request POST \
--header "Content-Type: application/json; odata=minimalmetadata" \
--data "{'applicationId':'contosoapp', 'token':'$AZ_BATCH_SOFTWARE_ENTITLEMENT_TOKEN'}" \
${AZ_BATCH_ACCOUNT_URL}softwareEntitlements?api-version=2017-05-01.5.0
```
``` bash
$ wget -qO- \
--header "Content-Type: application/json; odata=minimalmetadata" \
--post-data "{'applicationId':'contosoapp', 'token':'$AZ_BATCH_SOFTWARE_ENTITLEMENT_TOKEN'}" \
${AZ_BATCH_ACCOUNT_URL}softwareEntitlements?api-version=2017-05-01.5.0```
```
(Note that these commandlines have also been wrapped onto multiple lines for readability; again, you'll need to put everything on a single line to use this. Don't forget to replace `contosoapp` with the name of your application.)
Both of these will write the JSON response from the server to stdout.
These will verify your token (from the environment variable `AZ_BATCH_SOFTWARE_ENTITLEMENT_TOKEN` against the server, but won't do any of the required local checks that ensure you're talking to a genuine service.
## Troubleshooting
### SSPI Errors