Skip to content

Commit 1a6c447

Browse files
authored
Merge pull request #29 from Azure-Samples/zheyushen/2019update3
Revamp sample code and documentation for .NET Standard 2.0 and Linux support
2 parents 5859a7a + 11f4a7c commit 1a6c447

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+416
-2362
lines changed

README.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,51 @@ languages:
88
- vb
99
products:
1010
- azure
11-
description: "Sample code of Microsoft HPC Pack 2016 RTM / Update 1 / Update 2"
11+
description: "Sample code of Microsoft HPC Pack 2019"
1212
urlFragment: hpcpack-samples
1313
---
1414

15-
# Microsoft HPC Pack 2016 Sample Code
16-
Sample code of Microsoft HPC Pack 2016 RTM / Update 1 / Update 2
15+
# Microsoft HPC Pack 2019 Sample Code
16+
Sample code of Microsoft HPC Pack 2019
1717

18-
Please choose SDK version (_in VisualStudio or by altering packages.config_) according to your need
19-
- Version 5.0.5931: When connecting to __Microsoft HPC Pack 2016 RTM__
20-
- Version 5.1.6088 or later (default): When connecting to __Microsoft HPC Pack 2012__ or __Microsoft HPC Pack 2016 Update 1__ and later versions
18+
Please choose SDK version (_in VisualStudio or by altering .csproj) according to your need:
19+
- Version 6.3.8187-beta: preview SDK with Linux support
20+
- Version 6.2.7756: for __Microsoft HPC Pack 2019 Update 2__
21+
- Version 6.1.7531: for __Microsoft HPC Pack 2019 Update 1__
22+
- Version 6.0.7121 or 6.0.7205: for __Microsoft HPC Pack 2019 RTM__
23+
24+
## .NET Standard 2.0 and Linux support
25+
26+
### Registry
27+
The Linux SDK supports specifying configuration originally taken care of by Windows registry keys by environment variables prefixed with `CCP_CONFIG_`. For example, the `CertificateValidationType` registry key under `HKLM\SOFTWARE\Microsoft\HPC` can be specified on Linux by passing in the environment variable `CCP_CONFIG_CertificateValidationType`.
28+
29+
In addition, configuration can be specified via the `/etc/hpcpack/config.json` configuration file. For example, to configure `CertificateValidationType` to `1` (Skip CN check), use the following JSON config:
30+
```json
31+
{
32+
"CertificateValidationType": 1
33+
}
34+
```
35+
36+
### Certificates
37+
- On Linux, users need to manually add their certificate into the appropriate [X.509 certificate store](https://learn.microsoft.com/en-us/dotnet/standard/security/cross-platform-cryptography#x509store) corresponding to `CurrentUser\My` and `LocalMachine\Root` for Linux. For `CurrentUser\My`, user would need to import their certificate using code similar to the following:
38+
```
39+
using (var store = new X509Store(StoreName.My, StoreLocation.CurrentUser, OpenFlags.ReadWrite))
40+
{
41+
store.Add(new X509Certificate2(
42+
"./thePathToTheCert.pfx", "passwordOfTheCert",
43+
X509KeyStorageFlags.PersistKeySet));
44+
}
45+
```
46+
For `LocalMachine\Root`, user would need to import the certificate into the default OpenSSL CA bundle using the appropriate command for your Linux distribution. See [here](https://ubuntu.com/server/docs/install-a-root-ca-certificate-in-the-trust-store) and [here](https://www.redhat.com/sysadmin/configure-ca-trust-list) for examples of how to do it on Ubuntu and RHEL.
47+
48+
### Logging
49+
Logging can be configured via `appsettings.json`. See [here](https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line#configure-logging-without-code) for more information.
50+
51+
## Known issues with .NET Standard 2.0 SDK and Linux support
52+
- When getting certificates from certificate stores on Windows and Linux, there is no UI pop-up when more than one certificate is available, resulting in no certificate being chosen and failure downstream.
53+
- Connecting to cluster via .NET Remoting is not supported
54+
- Entering credentials interactively is not supported. Pass username and password explicitly or use `CCP_USERNAME` and `CCP_PASSWORD` environment variables instead.
55+
- Excel isn't supported
2156

2257
## Contributing
2358
This project welcomes contributions and suggestions. Most contributions require you to
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
4-
VisualStudioVersion = 17.7.34031.279
4+
VisualStudioVersion = 17.10.35004.147
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicNodeGroups", "DynamicNodeGroups\DynamicNodeGroups.csproj", "{D81F78F7-D5EC-4AAF-87FF-C2A5BCFD4148}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicNodeGroups", "DynamicNodeGroups\DynamicNodeGroups.csproj", "{E35EE4C4-B6A1-444B-B9FA-EDC3C2E53302}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|x64 = Debug|x64
11-
Release|x64 = Release|x64
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
1212
EndGlobalSection
1313
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{D81F78F7-D5EC-4AAF-87FF-C2A5BCFD4148}.Debug|x64.ActiveCfg = Debug|x64
15-
{D81F78F7-D5EC-4AAF-87FF-C2A5BCFD4148}.Debug|x64.Build.0 = Debug|x64
16-
{D81F78F7-D5EC-4AAF-87FF-C2A5BCFD4148}.Release|x64.ActiveCfg = Release|x64
17-
{D81F78F7-D5EC-4AAF-87FF-C2A5BCFD4148}.Release|x64.Build.0 = Release|x64
14+
{E35EE4C4-B6A1-444B-B9FA-EDC3C2E53302}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E35EE4C4-B6A1-444B-B9FA-EDC3C2E53302}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E35EE4C4-B6A1-444B-B9FA-EDC3C2E53302}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E35EE4C4-B6A1-444B-B9FA-EDC3C2E53302}.Release|Any CPU.Build.0 = Release|Any CPU
1818
EndGlobalSection
1919
GlobalSection(SolutionProperties) = preSolution
2020
HideSolutionNode = FALSE
2121
EndGlobalSection
2222
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {54E44C0A-7362-44E6-BF2C-F8D5BE520D50}
23+
SolutionGuid = {058073F2-3899-43BB-8F70-9ACF51375A5A}
2424
EndGlobalSection
2525
EndGlobal
Lines changed: 13 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,20 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{D81F78F7-D5EC-4AAF-87FF-C2A5BCFD4148}</ProjectGuid>
84
<OutputType>Exe</OutputType>
9-
<RootNamespace>DynamicNodeGroups</RootNamespace>
10-
<AssemblyName>DynamicNodeGroups</AssemblyName>
11-
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12-
<FileAlignment>512</FileAlignment>
13-
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14-
<Deterministic>true</Deterministic>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
158
</PropertyGroup>
16-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
17-
<DebugSymbols>true</DebugSymbols>
18-
<OutputPath>bin\x64\Debug\</OutputPath>
19-
<DefineConstants>DEBUG;TRACE</DefineConstants>
20-
<DebugType>full</DebugType>
21-
<PlatformTarget>x64</PlatformTarget>
22-
<LangVersion>7.3</LangVersion>
23-
<ErrorReport>prompt</ErrorReport>
24-
<Prefer32Bit>true</Prefer32Bit>
9+
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT' ">
10+
<TargetFrameworks>net8.0</TargetFrameworks>
2511
</PropertyGroup>
26-
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
27-
<OutputPath>bin\x64\Release\</OutputPath>
28-
<DefineConstants>TRACE</DefineConstants>
29-
<Optimize>true</Optimize>
30-
<DebugType>pdbonly</DebugType>
31-
<PlatformTarget>x64</PlatformTarget>
32-
<LangVersion>7.3</LangVersion>
33-
<ErrorReport>prompt</ErrorReport>
34-
<Prefer32Bit>true</Prefer32Bit>
12+
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
13+
<TargetFrameworks>net472;net8.0</TargetFrameworks>
3514
</PropertyGroup>
15+
3616
<ItemGroup>
37-
<Reference Include="BrokerBase, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
38-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\BrokerBase.dll</HintPath>
39-
</Reference>
40-
<Reference Include="CcpApi, Version=1.0.2.3, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
41-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\CcpApi.dll</HintPath>
42-
</Reference>
43-
<Reference Include="HpcCommon, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
44-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\HpcCommon.dll</HintPath>
45-
</Reference>
46-
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
47-
<HintPath>..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
48-
</Reference>
49-
<Reference Include="Microsoft.Data.Edm, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
50-
<HintPath>..\packages\Microsoft.Data.Edm.5.8.2\lib\net40\Microsoft.Data.Edm.dll</HintPath>
51-
</Reference>
52-
<Reference Include="Microsoft.Data.OData, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
53-
<HintPath>..\packages\Microsoft.Data.OData.5.8.2\lib\net40\Microsoft.Data.OData.dll</HintPath>
54-
</Reference>
55-
<Reference Include="Microsoft.Data.Services.Client, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
56-
<HintPath>..\packages\Microsoft.Data.Services.Client.5.8.2\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
57-
</Reference>
58-
<Reference Include="Microsoft.Hpc.AADAuthUtil, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
59-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.AADAuthUtil.dll</HintPath>
60-
</Reference>
61-
<Reference Include="Microsoft.Hpc.Azure.DataMovement, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
62-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Azure.DataMovement.dll</HintPath>
63-
</Reference>
64-
<Reference Include="Microsoft.Hpc.Azure.FileStaging.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
65-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Azure.FileStaging.Client.dll</HintPath>
66-
</Reference>
67-
<Reference Include="Microsoft.Hpc.Diagnostics.Helpers, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
68-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Diagnostics.Helpers.dll</HintPath>
69-
</Reference>
70-
<Reference Include="Microsoft.Hpc.Excel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
71-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Excel.dll</HintPath>
72-
</Reference>
73-
<Reference Include="Microsoft.Hpc.Excel.Internal, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
74-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Excel.Internal.dll</HintPath>
75-
</Reference>
76-
<Reference Include="Microsoft.Hpc.Scheduler, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
77-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Scheduler.dll</HintPath>
78-
</Reference>
79-
<Reference Include="Microsoft.Hpc.Scheduler.Properties, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
80-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Scheduler.Properties.dll</HintPath>
81-
</Reference>
82-
<Reference Include="Microsoft.Hpc.Scheduler.Session, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
83-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Scheduler.Session.dll</HintPath>
84-
</Reference>
85-
<Reference Include="Microsoft.Hpc.Scheduler.Store, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
86-
<HintPath>..\packages\Microsoft.HPC.SDK.6.2.7756\lib\net472\Microsoft.Hpc.Scheduler.Store.dll</HintPath>
87-
</Reference>
88-
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.16.0.14, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
89-
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.16.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll</HintPath>
90-
</Reference>
91-
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.16.0.14, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
92-
<HintPath>..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.16.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
93-
</Reference>
94-
<Reference Include="Microsoft.IdentityModel.Protocol.Extensions, Version=1.0.40306.1554, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
95-
<HintPath>..\packages\Microsoft.IdentityModel.Protocol.Extensions.1.0.4.403061554\lib\net45\Microsoft.IdentityModel.Protocol.Extensions.dll</HintPath>
96-
</Reference>
97-
<Reference Include="Microsoft.WindowsAzure.Storage, Version=8.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
98-
<HintPath>..\packages\WindowsAzure.Storage.8.4.0\lib\net45\Microsoft.WindowsAzure.Storage.dll</HintPath>
99-
</Reference>
100-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
101-
<HintPath>..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
102-
</Reference>
103-
<Reference Include="System" />
104-
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
105-
<SpecificVersion>False</SpecificVersion>
106-
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0\System.Management.Automation.dll</HintPath>
107-
</Reference>
108-
<Reference Include="System.CodeDom, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
109-
<HintPath>..\packages\System.CodeDom.7.0.0\lib\net462\System.CodeDom.dll</HintPath>
110-
</Reference>
111-
<Reference Include="System.Core" />
112-
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=4.0.40306.1554, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
113-
<HintPath>..\packages\System.IdentityModel.Tokens.Jwt.4.0.4.403061554\lib\net45\System.IdentityModel.Tokens.Jwt.dll</HintPath>
114-
</Reference>
115-
<Reference Include="System.Management" />
116-
<Reference Include="System.Net.Http.Formatting, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
117-
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.9\lib\net45\System.Net.Http.Formatting.dll</HintPath>
118-
</Reference>
119-
<Reference Include="System.Spatial, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
120-
<HintPath>..\packages\System.Spatial.5.8.2\lib\net40\System.Spatial.dll</HintPath>
121-
</Reference>
122-
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
123-
<HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
124-
<Private>True</Private>
125-
<Private>True</Private>
126-
</Reference>
127-
<Reference Include="System.Xml.Linq" />
128-
<Reference Include="System.Data.DataSetExtensions" />
129-
<Reference Include="Microsoft.CSharp" />
130-
<Reference Include="System.Data" />
131-
<Reference Include="System.Net.Http" />
132-
<Reference Include="System.Xml" />
17+
<PackageReference Include="Microsoft.HPC.SDK" Version="6.3.8187-beta" />
13318
</ItemGroup>
134-
<ItemGroup>
135-
<Compile Include="Program.cs" />
136-
<Compile Include="Properties\AssemblyInfo.cs" />
137-
</ItemGroup>
138-
<ItemGroup>
139-
<None Include="App.config" />
140-
<None Include="packages.config" />
141-
</ItemGroup>
142-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
143-
</Project>
19+
20+
</Project>

Scheduler/DynamicNodeGroups/DynamicNodeGroups/Program.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
//
55
//Copyright (C) Microsoft Corporation. All rights reserved.
66

7-
using System;
8-
using System.Threading;
97
using Microsoft.Hpc.Scheduler;
108
using Microsoft.Hpc.Scheduler.Properties;
119
using System.Diagnostics;
12-
using System.Threading.Tasks;
1310

1411
namespace DynamicNodeGroups
1512
{
@@ -20,12 +17,12 @@ class Program
2017
//for best results, run this sample code in queued scheduling mode
2118
static async Task Main(string[] args)
2219
{
23-
string clusterName = Environment.GetEnvironmentVariable("CCP_SCHEDULER");
20+
string? clusterName = Environment.GetEnvironmentVariable("CCP_SCHEDULER");
2421
using (IScheduler scheduler = new Scheduler())
2522
{
2623
Console.WriteLine("Connecting to {0}", clusterName);
2724
scheduler.Connect(clusterName);
28-
25+
Console.WriteLine("Connected");
2926
//assume you have two nodegroups, NodeGroup1 and NodeGroup2
3027
IStringCollection nodeGroup1 = scheduler.GetNodesInNodeGroup("NodeGroup1");
3128
IStringCollection nodeGroup2 = scheduler.GetNodesInNodeGroup("NodeGroup2");
@@ -125,7 +122,7 @@ static async Task Main(string[] args)
125122
}
126123
}
127124

128-
static void Job_OnTaskState(object sender, TaskStateEventArg e)
125+
static void Job_OnTaskState(object? sender, TaskStateEventArg e)
129126
{
130127
if (e.NewState == TaskState.Running)
131128
{

Scheduler/DynamicNodeGroups/DynamicNodeGroups/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Scheduler/DynamicNodeGroups/DynamicNodeGroups/app.config

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)