├── .gitattributes ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── CSharp ├── .gitignore ├── AccountManagement │ ├── AccountManagement.csproj │ ├── AccountManagement.sln │ ├── Program.cs │ └── README.md ├── ArticleProjects │ ├── ApplicationInsights │ │ ├── ApplicationInsights.sln │ │ ├── Microsoft.Azure.Batch.Samples.TelemetryInitializer │ │ │ ├── ApplicationInsights.config │ │ │ ├── AzureBatchNodeTelemetryInitializer.cs │ │ │ └── Microsoft.Azure.Batch.Samples.TelemetryInitializer.csproj │ │ ├── Microsoft.Azure.Batch.Samples.TelemetryStartTask │ │ │ ├── ApplicationInsights.config │ │ │ ├── Microsoft.Azure.Batch.Samples.TelemetryStartTask.csproj │ │ │ └── Program.cs │ │ ├── README.md │ │ ├── TopNWords │ │ │ ├── ApplicationInsights.config │ │ │ ├── Job.cs │ │ │ ├── Program.cs │ │ │ ├── Settings.cs │ │ │ ├── TopNWords.csproj │ │ │ ├── TopNWordsTask.cs │ │ │ ├── documents │ │ │ │ ├── 180555main_ETM.Teachers.Guide.txt │ │ │ │ ├── 180556main_ETM.Moon.ABCs.Fact.Sheet.txt │ │ │ │ ├── 180560main_ETM.Unit.1.Introduction.txt │ │ │ │ ├── 180561main_ETM.Distance.Moon.txt │ │ │ │ ├── 180562main_ETM.Diameter.Moon.txt │ │ │ │ ├── 180565main_ETM.Unit.2.Introduction.txt │ │ │ │ ├── 180572main_ETM.Impact.Craters.txt │ │ │ │ ├── 180576main_ETM.Roving.Vehicle.txt │ │ │ │ ├── 180577main_ETM.Moon.Anomalies.txt │ │ │ │ └── ExploringtheMoonGuide.txt │ │ │ └── settings.json │ │ └── media │ │ │ └── batch-monitoring-with-application-insights │ │ │ ├── ApplicationInsightsLiveStream.png │ │ │ ├── BlobDownloadTime.png │ │ │ ├── Exception.png │ │ │ └── TraceLogsForTask.png │ ├── EfficientListQueries │ │ ├── EfficientListQueries.csproj │ │ ├── EfficientListQueries.sln │ │ ├── Program.cs │ │ └── README.md │ ├── JobPrepRelease │ │ ├── JobPrepRelease.csproj │ │ ├── JobPrepRelease.sln │ │ ├── Program.cs │ │ └── README.md │ ├── MultiInstanceTasks │ │ ├── MPIHelloWorld │ │ │ ├── MPIHelloWorld.cpp │ │ │ ├── MPIHelloWorld.vcxproj │ │ │ ├── README.md │ │ │ ├── packages.config │ │ │ ├── stdafx.cpp │ │ │ ├── stdafx.h │ │ │ └── targetver.h │ │ ├── MultiInstanceTasks.csproj │ │ ├── MultiInstanceTasks.sln │ │ ├── Program.cs │ │ └── README.md │ ├── ParallelTasks │ │ ├── ParallelTasks.csproj │ │ ├── ParallelTasks.sln │ │ ├── Program.cs │ │ └── README.md │ ├── PersistOutputs │ │ ├── BatchExtensions.cs │ │ ├── FileConventionsExample.cs │ │ ├── OutputFilesExample.cs │ │ ├── PersistOutputs.csproj │ │ ├── PersistOutputs.sln │ │ ├── PersistOutputsTask │ │ │ ├── PersistOutputsTask.csproj │ │ │ └── Program.cs │ │ ├── Program.cs │ │ └── README.md │ ├── README.md │ └── TaskDependencies │ │ ├── Program.cs │ │ ├── README.md │ │ ├── TaskDependencies.csproj │ │ └── TaskDependencies.sln ├── BatchMetrics │ ├── BatchMetrics.sln │ ├── BatchMetrics │ │ ├── BatchMetrics.csproj │ │ ├── DetailLevels.cs │ │ ├── EnumHelpers.cs │ │ ├── JobMetrics.cs │ │ ├── Latency.cs │ │ ├── MetricEvent.cs │ │ ├── MetricMonitor.cs │ │ ├── TaskHelpers.cs │ │ ├── TaskStateCache.cs │ │ └── TaskStateCounts.cs │ ├── BatchMetricsUsageSample │ │ ├── BatchMetricsUsageSample.csproj │ │ ├── ErrorExtensions.cs │ │ ├── JobSubmitter.cs │ │ └── Program.cs │ └── README.md ├── Common │ ├── AccountSettings.cs │ ├── ArticleHelpers.cs │ ├── CreatePoolResult.cs │ ├── GettingStartedCommon.cs │ ├── Microsoft.Azure.Batch.Samples.Common.csproj │ ├── SampleHelpers.cs │ └── accountsettings.json ├── GettingStarted │ ├── 01_HelloWorld │ │ ├── HelloWorld.csproj │ │ ├── HelloWorld.sln │ │ ├── Program.cs │ │ ├── Settings.cs │ │ └── settings.json │ ├── 02_PoolsAndResourceFiles │ │ ├── JobSubmitter │ │ │ ├── JobSubmitter.cs │ │ │ ├── JobSubmitter.csproj │ │ │ ├── Program.cs │ │ │ ├── Settings.cs │ │ │ └── settings.json │ │ └── PoolsAndResourceFiles.sln │ ├── 03_JobManager │ │ ├── JobManager.sln │ │ ├── JobSubmitter │ │ │ ├── JobSubmitter.cs │ │ │ ├── JobSubmitter.csproj │ │ │ ├── Program.cs │ │ │ ├── Settings.cs │ │ │ └── settings.json │ │ └── SampleJobManager │ │ │ ├── JobManagerSettings.cs │ │ │ ├── Program.cs │ │ │ ├── SampleJobManagerTask.cs │ │ │ └── SampleJobManagerTask.csproj │ ├── README.md │ └── Shared │ │ └── SimpleTask │ │ ├── Program.cs │ │ └── SimpleTask.csproj ├── LICENSE.txt ├── README.md ├── TextSearch │ ├── Common │ │ ├── Common.csproj │ │ ├── Constants.cs │ │ ├── Helpers.cs │ │ ├── Settings.cs │ │ └── settings.json │ ├── JobSubmitter │ │ ├── FileSplitter.cs │ │ ├── JobSubmitter.cs │ │ ├── JobSubmitter.csproj │ │ ├── Program.cs │ │ └── Text.txt │ ├── MapperTask │ │ ├── MapperTask.cs │ │ ├── MapperTask.csproj │ │ └── Program.cs │ ├── ReducerTask │ │ ├── Program.cs │ │ ├── ReducerTask.cs │ │ └── ReducerTask.csproj │ ├── TextSearch.sln │ └── readme.md └── TopNWords │ ├── Job.cs │ ├── Program.cs │ ├── Settings.cs │ ├── TopNWords.csproj │ ├── TopNWords.sln │ ├── TopNWordsTask.cs │ ├── book.txt │ └── settings.json ├── Java ├── .gitignore ├── LICENSE.txt ├── PoolAndResourceFile │ ├── README.md │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── PoolAndResourceFile.java │ └── test.txt ├── README.md └── pom.xml ├── JavaScript ├── Node.js │ ├── package-lock.json │ ├── package.json │ ├── processcsv.py │ ├── sample.js │ └── startup_prereq.sh └── README.md ├── LICENSE.txt ├── Python ├── .coveragerc ├── .gitignore ├── Batch │ ├── README.md │ ├── article_samples │ │ └── mpi │ │ │ ├── README.md │ │ │ ├── __init__.py │ │ │ ├── data │ │ │ ├── application-cmd │ │ │ ├── coordination-cmd │ │ │ └── linux │ │ │ │ └── openfoam │ │ │ │ └── application-cmd │ │ │ ├── linux_mpi_task_demo.py │ │ │ ├── multi_task_helpers.py │ │ │ └── requirements.txt │ ├── common │ │ ├── __init__.py │ │ └── helpers.py │ ├── configuration.cfg │ ├── requirements.txt │ ├── resources │ │ ├── docker_starttask.sh │ │ ├── secret.txt │ │ └── simple_task.py │ ├── sample1_helloworld.cfg │ ├── sample1_helloworld.py │ ├── sample1_jobprep_and_release.cfg │ ├── sample1_jobprep_and_release.py │ ├── sample2_pools_and_resourcefiles.cfg │ ├── sample2_pools_and_resourcefiles.py │ ├── sample3_encrypted_resourcefiles.cfg │ ├── sample3_encrypted_resourcefiles.py │ ├── sample4_job_scheduler.cfg │ └── sample4_job_scheduler.py ├── LICENSE.txt └── README.md ├── README.md ├── appveyor.yml ├── azure-pipelines.yml └── build.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | # Set the default behavior of Linux shell scripts to lf 3 | *.sh text eol=lf 4 | Python/Batch/article_samples/mpi/data/* text eol=lf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | cache: pip 3 | python: 4 | - 2.7 5 | - 3.4 6 | - 3.5 7 | # disable pypy until travis upgrades to at least pypy2.6 due to cryptography 8 | #- pypy 9 | # disable pypy3 until 3.3 compliance 10 | #- pypy3 11 | addons: 12 | apt: 13 | config: 14 | retries: true 15 | update: true 16 | packages: 17 | - oracle-java8-installer 18 | env: 19 | - BATCH_SAMPLES_DIR=Python/Batch 20 | install: 21 | - python -m pip install --upgrade pip 22 | - pip install --upgrade setuptools 23 | - pip install -r $BATCH_SAMPLES_DIR/requirements.txt 24 | - pip install coveralls flake8 pytest pytest-cov requests_mock 25 | # install Java stuff 26 | - export PATH="/usr/lib/jvm/java-8-oracle:$PATH" 27 | - export JAVA_HOME="/usr/lib/jvm/java-8-oracle" 28 | - mkdir mvn 29 | - wget "http://www-us.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz" 30 | - tar -zxvf apache-maven-3.5.4-bin.tar.gz -C ./mvn 31 | - export PATH=`pwd`/mvn/bin:$PATH 32 | - mvn -v 33 | script: 34 | - cd Java 35 | - mvn install 36 | - cd ../$BATCH_SAMPLES_DIR 37 | - flake8 . --statistics 38 | 39 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Azure Batch samples 2 | 3 | Thank you for your interest in contributing to Azure batch samples! 4 | 5 | ## Ways to contribute 6 | 7 | You can contribute to [Azure batch samples](https://github.com/Azure/azure-batch-samples/) in a few different ways: 8 | 9 | - Submit issues through [issue tracker](https://github.com/Azure/azure-batch-samples/issues) on GitHub. We are actively monitoring the issues and improving our samples. 10 | - If you wish to make code changes to samples, or contribute something new, please follow the [GitHub Forks / Pull requests model](https://help.github.com/articles/fork-a-repo/): Fork the sample repo, make the change and propose it back by submitting a pull request. 11 | 12 | 13 | ## CSharp samples 14 | 15 | #### Building the CSharp samples 16 | To build all the CSharp samples without opening Visual Studio, you can use this simple script: 17 | ``` 18 | for /R %f in (*.sln) do (dotnet build "%f") 19 | ``` 20 | 21 | If you want to write the output of the build to a file you can tack on ` >> mybuild.tmp` to the end of the command. 22 | 23 | #### Update the Azure.Batch NuGet project reference 24 | The Azure Batch samples should be kept up to date with the latest Azure.Batch NuGet package. 25 | 26 | ##### Using a text replace 27 | The following commands can be used to perform the textual replace: `rep.exe -find:"" -replace:"" -r *.csproj` 28 | -------------------------------------------------------------------------------- /CSharp/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # VS IDE file 14 | *.sln.ide/ 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | build/ 24 | bld/ 25 | [Bb]in/ 26 | [Oo]bj/ 27 | 28 | # Visual Studo 2015 cache/options directory 29 | .vs/ 30 | 31 | # MSTest test Results 32 | [Tt]est[Rr]esult*/ 33 | [Bb]uild[Ll]og.* 34 | 35 | # NUNIT 36 | *.VisualState.xml 37 | TestResult.xml 38 | 39 | # Build Results of an ATL Project 40 | [Dd]ebugPS/ 41 | [Rr]eleasePS/ 42 | dlldata.c 43 | 44 | *_i.c 45 | *_p.c 46 | *_i.h 47 | *.ilk 48 | *.meta 49 | *.obj 50 | *.pch 51 | *.pdb 52 | *.pgc 53 | *.pgd 54 | *.rsp 55 | *.sbr 56 | *.tlb 57 | *.tli 58 | *.tlh 59 | *.tmp 60 | *.tmp_proj 61 | *.log 62 | *.vspscc 63 | *.vssscc 64 | .builds 65 | *.pidb 66 | *.svclog 67 | *.scc 68 | *.chk 69 | 70 | # Chutzpah Test files 71 | _Chutzpah* 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opendb 78 | *.opensdf 79 | *.sdf 80 | *.cachefile 81 | 82 | # Visual Studio profiler 83 | *.psess 84 | *.vsp 85 | *.vspx 86 | 87 | # TFS 2012 Local Workspace 88 | $tf/ 89 | 90 | # Guidance Automation Toolkit 91 | *.gpState 92 | 93 | # ReSharper is a .NET coding add-in 94 | _ReSharper*/ 95 | *.[Rr]e[Ss]harper 96 | *.DotSettings.user 97 | 98 | # JustCode is a .NET coding addin-in 99 | .JustCode 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | _NCrunch_* 109 | .*crunch*.local.xml 110 | 111 | # MightyMoose 112 | *.mm.* 113 | AutoTest.Net/ 114 | 115 | # Web workbench (sass) 116 | .sass-cache/ 117 | 118 | # Installshield output folder 119 | [Ee]xpress/ 120 | 121 | # DocProject is a documentation generator add-in 122 | DocProject/buildhelp/ 123 | DocProject/Help/*.HxT 124 | DocProject/Help/*.HxC 125 | DocProject/Help/*.hhc 126 | DocProject/Help/*.hhk 127 | DocProject/Help/*.hhp 128 | DocProject/Help/Html2 129 | DocProject/Help/html 130 | 131 | # Click-Once directory 132 | publish/ 133 | 134 | # Publish Web Output 135 | *.[Pp]ublish.xml 136 | *.azurePubxml 137 | # TODO: Comment the next line if you want to checkin your web deploy settings 138 | # but database connection strings (with potential passwords) will be unencrypted 139 | *.pubxml 140 | *.publishproj 141 | 142 | # NuGet Packages 143 | *.nupkg 144 | # The packages folder can be ignored because of Package Restore 145 | **/packages/* 146 | # except build/, which is used as an MSBuild target. 147 | !**/packages/build/ 148 | # Uncomment if necessary however generally it will be regenerated when needed 149 | #!**/packages/repositories.config 150 | 151 | # Windows Azure Build Output 152 | csx/ 153 | *.build.csdef 154 | 155 | # Windows Store app package directory 156 | AppPackages/ 157 | 158 | # Others 159 | *.[Cc]ache 160 | ClientBin/ 161 | [Ss]tyle[Cc]op.* 162 | ~$* 163 | *~ 164 | *.dbmdl 165 | *.dbproj.schemaview 166 | *.pfx 167 | *.publishsettings 168 | node_modules/ 169 | bower_components/ 170 | 171 | # RIA/Silverlight projects 172 | Generated_Code/ 173 | 174 | # Backup & report files from converting an old project file 175 | # to a newer Visual Studio version. Backup files are not needed, 176 | # because we have git ;-) 177 | _UpgradeReport_Files/ 178 | Backup*/ 179 | UpgradeLog*.XML 180 | UpgradeLog*.htm 181 | 182 | # SQL Server files 183 | *.mdf 184 | *.ldf 185 | 186 | # Business Intelligence projects 187 | *.rdl.data 188 | *.bim.layout 189 | *.bim_*.settings 190 | 191 | # Microsoft Fakes 192 | FakesAssemblies/ 193 | 194 | # Node.js Tools for Visual Studio 195 | .ntvs_analysis.dat 196 | 197 | # Visual Studio 6 build log 198 | *.plg 199 | 200 | # Visual Studio 6 workspace options file 201 | *.opt 202 | 203 | # Roslyn 204 | **/*.sln.ide/** 205 | -------------------------------------------------------------------------------- /CSharp/AccountManagement/AccountManagement.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.AccountManagement 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /CSharp/AccountManagement/AccountManagement.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccountManagement", "AccountManagement.csproj", "{4C0FEB5F-3A19-44F1-A2E9-11DAC2AB11BE}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {4C0FEB5F-3A19-44F1-A2E9-11DAC2AB11BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {4C0FEB5F-3A19-44F1-A2E9-11DAC2AB11BE}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {4C0FEB5F-3A19-44F1-A2E9-11DAC2AB11BE}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {4C0FEB5F-3A19-44F1-A2E9-11DAC2AB11BE}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CSharp/AccountManagement/README.md: -------------------------------------------------------------------------------- 1 | ### AccountManagement 2 | 3 | The AccountManagement sample project demonstrates usage of the [Batch Management .NET][net_mgmt_api] library. 4 | 5 | NOTE: To run the sample application successfully, you must first register it with Azure Active Directory using the Azure Management Portal. See [Integrating Applications with Azure Active Directory][aad_integrate] for more information. 6 | 7 | This sample application demonstrates the following operations: 8 | 9 | 1. Acquire security token from Azure Active Directory (AAD) using [ADAL][aad_adal] 10 | 2. Use acquired security token to create a [SubscriptionClient][net_subclient], query Azure for a list of subscriptions associated with the account, prompt user for subscription 11 | 3. Create a new credentials object associated with the selected subscription 12 | 4. Create a [ResourceManagementClient][net_resclient] using the new credentials 13 | 5. Use the [ResourceManagementClient][net_resclient] to create a new resource group 14 | 6. Use the [BatchManagementClient][net_batchclient] to perform a number of Batch account operations 15 | 7. Delete the resource group 16 | 17 | For more information on using the [Batch Management .NET][net_mgmt_api] library, please see the following article: 18 | 19 | [Manage Azure Batch accounts and quotas with Batch Management .NET][acom_article] 20 | 21 | [aad_adal]: https://azure.microsoft.com/documentation/articles/active-directory-authentication-libraries/ 22 | [aad_integrate]: https://azure.microsoft.com/documentation/articles/active-directory-integrating-applications/ 23 | [acom_article]: https://azure.microsoft.com/documentation/articles/batch-management-dotnet/ 24 | [net_batchclient]: https://msdn.microsoft.com/library/azure/microsoft.azure.management.batch.batchmanagementclient.aspx 25 | [net_mgmt_api]: https://msdn.microsoft.com/library/azure/mt463120.aspx 26 | [net_mgmt_nuget]: https://www.nuget.org/packages/Microsoft.Azure.Management.Batch/ 27 | [net_resclient]: https://msdn.microsoft.com/library/azure/microsoft.azure.management.resources.resourcemanagementclient.aspx 28 | [net_subclient]: https://msdn.microsoft.com/library/azure/microsoft.azure.subscriptions.subscriptionclient.aspx 29 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/ApplicationInsights.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.TelemetryInitializer", "Microsoft.Azure.Batch.Samples.TelemetryInitializer\Microsoft.Azure.Batch.Samples.TelemetryInitializer.csproj", "{B7E52328-B511-489A-95B6-D070889AB630}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TopNWords", "TopNWords\TopNWords.csproj", "{D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {256022B6-5241-4FF7-8B4F-183E2200D11B} = {256022B6-5241-4FF7-8B4F-183E2200D11B} 11 | EndProjectSection 12 | EndProject 13 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 14 | EndProject 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.TelemetryStartTask", "Microsoft.Azure.Batch.Samples.TelemetryStartTask\Microsoft.Azure.Batch.Samples.TelemetryStartTask.csproj", "{256022B6-5241-4FF7-8B4F-183E2200D11B}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {B7E52328-B511-489A-95B6-D070889AB630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {B7E52328-B511-489A-95B6-D070889AB630}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {B7E52328-B511-489A-95B6-D070889AB630}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {B7E52328-B511-489A-95B6-D070889AB630}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 35 | {256022B6-5241-4FF7-8B4F-183E2200D11B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {256022B6-5241-4FF7-8B4F-183E2200D11B}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {256022B6-5241-4FF7-8B4F-183E2200D11B}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {256022B6-5241-4FF7-8B4F-183E2200D11B}.Release|Any CPU.Build.0 = Release|Any CPU 39 | EndGlobalSection 40 | GlobalSection(SolutionProperties) = preSolution 41 | HideSolutionNode = FALSE 42 | EndGlobalSection 43 | EndGlobal 44 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/Microsoft.Azure.Batch.Samples.TelemetryInitializer/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 15 | core.windows.net 16 | core.chinacloudapi.cn 17 | core.cloudapi.de 18 | core.usgovcloudapi.net 19 | 20 | 21 | 22 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 5 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/Microsoft.Azure.Batch.Samples.TelemetryInitializer/AzureBatchNodeTelemetryInitializer.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TelemetryInitializer 4 | { 5 | using ApplicationInsights.Channel; 6 | using ApplicationInsights.Extensibility; 7 | using System; 8 | using System.Threading; 9 | 10 | public class AzureBatchNodeTelemetryInitializer : ITelemetryInitializer 11 | { 12 | private const string PoolIdEnvironmentVariable = "AZ_BATCH_POOL_ID"; 13 | private const string NodeIdEnvironmentVariable = "AZ_BATCH_NODE_ID"; 14 | 15 | private string roleInstanceName; 16 | private string roleName; 17 | 18 | public void Initialize(ITelemetry telemetry) 19 | { 20 | if (string.IsNullOrEmpty(telemetry.Context.Cloud.RoleName)) 21 | { 22 | string name = LazyInitializer.EnsureInitialized(ref this.roleName, this.GetPoolName); 23 | telemetry.Context.Cloud.RoleName = name; 24 | } 25 | 26 | if (string.IsNullOrEmpty(telemetry.Context.Cloud.RoleInstance)) 27 | { 28 | string name = LazyInitializer.EnsureInitialized(ref this.roleInstanceName, this.GetNodeName); 29 | telemetry.Context.Cloud.RoleInstance = name; 30 | } 31 | } 32 | 33 | private string GetPoolName() 34 | { 35 | return Environment.GetEnvironmentVariable(PoolIdEnvironmentVariable) ?? string.Empty; 36 | } 37 | 38 | private string GetNodeName() 39 | { 40 | return Environment.GetEnvironmentVariable(NodeIdEnvironmentVariable) ?? string.Empty; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/Microsoft.Azure.Batch.Samples.TelemetryInitializer/Microsoft.Azure.Batch.Samples.TelemetryInitializer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net462 5 | Microsoft.Azure.Batch.Samples.TelemetryInitializer 6 | 7 | 8 | 9 | 10 | 11 | 12 | PreserveNewest 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/Microsoft.Azure.Batch.Samples.TelemetryStartTask/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | YOUR-IKEY-GOES-HERE 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | core.windows.net 21 | core.chinacloudapi.cn 22 | core.cloudapi.de 23 | core.usgovcloudapi.net 24 | 25 | 26 | 27 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 5 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/Microsoft.Azure.Batch.Samples.TelemetryStartTask/Microsoft.Azure.Batch.Samples.TelemetryStartTask.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.TelemetryStartTask 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/Microsoft.Azure.Batch.Samples.TelemetryStartTask/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TelemetryStartTask 4 | { 5 | using ApplicationInsights.Extensibility; 6 | using System; 7 | using TelemetryInitializer; 8 | 9 | public static class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | TelemetryConfiguration.Active.TelemetryInitializers.Add(new AzureBatchNodeTelemetryInitializer()); 14 | while (true) 15 | { 16 | Console.WriteLine(string.Format("{0} Batch Application Insights process running.", DateTime.Now)); 17 | Console.Out.Flush(); 18 | System.Threading.Thread.Sleep(10000); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | YOUR-IKEY-GOES-HERE 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | core.windows.net 21 | core.chinacloudapi.cn 22 | core.cloudapi.de 23 | core.usgovcloudapi.net 24 | 25 | 26 | 27 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 5 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TopNWordsSample 4 | { 5 | using System.Threading.Tasks; 6 | 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | //We share the same EXE for both the main program and the task 12 | //Decide which one to start based on the command line parameters 13 | if (args != null && args.Length > 0 && args[0] == "--Task") 14 | { 15 | TopNWordsTask.TaskMain(args); 16 | } 17 | else 18 | { 19 | Task.Run(() => Job.JobMain(args)).GetAwaiter().GetResult(); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Azure.Batch.Samples.TopNWordsSample 8 | { 9 | public class Settings 10 | { 11 | public int PoolNodeCount { get; set; } 12 | public int TopWordCount { get; set; } 13 | public string DocumentsRootPath { get; set; } 14 | public string PoolId { get; set; } 15 | public string JobId { get; set; } 16 | public bool ShouldDeleteJob { get; set; } 17 | public bool ShouldDeletePool { get; set; } 18 | public bool ShouldDeleteContainer { get; set; } 19 | public string PoolNodeVirtualMachineSize { get; set; } 20 | public string ImagePublisher { get; set; } 21 | public string ImageOffer { get; set; } 22 | public string ImageSku { get; set; } 23 | public string ImageVersion { get; set; } 24 | public string NodeAgentSkuId { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/TopNWords.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.TopNWordsSample 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | PreserveNewest 28 | 29 | 30 | PreserveNewest 31 | 32 | 33 | PreserveNewest 34 | 35 | 36 | PreserveNewest 37 | 38 | 39 | PreserveNewest 40 | 41 | 42 | PreserveNewest 43 | 44 | 45 | PreserveNewest 46 | 47 | 48 | PreserveNewest 49 | 50 | 51 | PreserveNewest 52 | 53 | 54 | PreserveNewest 55 | 56 | 57 | PreserveNewest 58 | 59 | 60 | PreserveNewest 61 | 62 | 63 | PreserveNewest 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/documents/180556main_ETM.Moon.ABCs.Fact.Sheet.txt: -------------------------------------------------------------------------------- 1 | Moon ABCs Fact Sheet 2 | Property 3 | 4 | Earth 5 | 6 | Moon 7 | 8 | Brain Busters 9 | 10 | Equatorial 11 | diameter 12 | 13 | 12,756 km 14 | 15 | 3,476 km 16 | 17 | How long would it take to drive 18 | around the Moon's equator at 19 | 80 km per hour? 20 | 21 | Surface area 22 | 23 | 510 million 24 | square km 25 | 26 | 37.8 million 27 | square km 28 | 29 | The Moon's surface area is 30 | similar to that of one of Earth's 31 | continents. Which one? 32 | 33 | Mass 34 | 35 | 5.98 x 1024 kg 36 | 37 | 7.35 x 1022 kg 38 | 39 | What percentage of Earth's mass 40 | is the Moon's mass? 41 | 42 | Volume 43 | 44 | --- 45 | 46 | --- 47 | 48 | Can you calculate the volumes of 49 | Earth and the Moon? 50 | 51 | Density 52 | 53 | 5.52 grams per 54 | cubic cm 55 | 56 | 3.34 grams per 57 | cubic cm 58 | 59 | Check this by calculating the 60 | density from the mass and 61 | volume. 62 | 63 | Surface 64 | gravity 65 | 66 | 9.8 m/sec/sec 67 | 68 | 1.63 m/sec/sec 69 | 70 | What fraction of Earth's gravity is 71 | the Moon's gravity? 72 | 73 | Crust 74 | 75 | Silicate rocks. 76 | Continents 77 | dominated by 78 | granites. Ocean 79 | crust dominated 80 | by basalt. 81 | 82 | Silicate rocks. 83 | Highlands 84 | dominated by 85 | feldspar-rich 86 | rocks and maria 87 | by basalt. 88 | 89 | What portion of each body is 90 | crust? 91 | 92 | Mantle 93 | 94 | Silicate rocks 95 | dominated by 96 | minerals 97 | containing iron 98 | and magnesium. 99 | 100 | Similar to Earth. 101 | 102 | Collect some silicate rocks and 103 | determine the density. Is the 104 | density greater or lesser than the 105 | Earth/Moon's density? Why? 106 | 107 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 108 | 109 | 17 110 | 111 | Moon ABCs Fact Sheet 112 | Property 113 | 114 | Earth 115 | 116 | Moon 117 | 118 | Brain Busters 119 | 120 | Core 121 | 122 | Iron, nickel metal Same, but core is 123 | What portion of each body is 124 | much smaller 125 | core? 126 | Sediment or 127 | Silicon and 128 | Silicon and oxygen 129 | Do you think life ever existed 130 | Regolith 131 | oxygen bound in bound in minerals, 132 | on the Moon? 133 | minerals that 134 | glass produced by 135 | Why or why not? 136 | contain water, 137 | meteorite impacts, 138 | plus organic 139 | small amounts of 140 | materials. 141 | gases (e.g., hydrogen) 142 | implanted by the solar 143 | wind. No water or 144 | organic materials. 145 | Atmosphere 146 | 78 % nitrogen, 147 | Basically none. Some Could you breathe the lunar 148 | (main 149 | 21 % oxygen 150 | carbon gases (CO2 , atmosphere? 151 | constituents) 152 | CO, and methane), 153 | but very little of them. 154 | Pressure is about onetrillionth of Earth's 155 | atmospheric pressure. 156 | Length of day 23.93 hours 157 | How long does daylight last 158 | 27.3 Earth days 159 | (sidereal 160 | on the Moon? 161 | rotation 162 | period) 163 | Air temperature 164 | Surface 165 | Surface temperature Why are the temperatures of 166 | ranges from 167 | temperature 168 | ranges from -193oC Earth and the Moon so 169 | -88oC (winter in 170 | different? 171 | (night in polar 172 | o 173 | polar regions) to 174 | regions) to 111 C 175 | o 176 | 58 C (summer in (day in equatorial 177 | tropical regions). regions). 178 | Surface 179 | features 180 | 181 | 18 182 | 183 | 25 % land 184 | (seven continents) 185 | with varied terrain 186 | of mountains, 187 | plains, river valleys. Ocean floor 188 | characterized by 189 | mountains, plains. 190 | 191 | 84 % heavily-cratered Compare maps of Earth and 192 | highlands. 193 | the Moon. Is there any 194 | 16 % basalt-covered evidence that plate tectonics 195 | maria. 196 | operated on the Moon? 197 | Impact craters-some with bright rays, 198 | crater chains, and 199 | rilles. 200 | 201 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 202 | 203 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/documents/180560main_ETM.Unit.1.Introduction.txt: -------------------------------------------------------------------------------- 1 | Unit 1 2 | Pre-Apollo Activities 3 | Distance to the Moon 4 | Diameter of the Moon 5 | Reaping Rocks 6 | Before Apollo 11 astronauts Neil A. Armstrong and Edwin E. “Buzz” Aldrin Jr. 7 | stepped on the Moon on July 20, 1969, people had studied the Moon by eye, 8 | telescope, and images from spacecraft. The theme of Unit 1 is a basic introduction 9 | to the Moon -- how it looks from Earth, how far away it is, and how big it is. The 10 | activities allow students to make comparisons between the Moon and Earth as well 11 | as to make predictions about the Moon rocks. 12 | Encourage students to sketch and describe nightly observations of the Moon and 13 | keep a written record of date and time. Nightly charting of the Moon helps students 14 | recognize Moon phases as well as the bright and dark terrains. 15 | Scale models and proportional relationships are featured in the first two activities. 16 | The “Distance to the Moon” and “Diameter of the Moon” activities introduce 17 | students to techniques of measuring distances in space indirectly. 18 | This unit also includes an activity to collect and study rocks called “Reaping 19 | Rocks.” This activity should follow a more comprehensive lesson on basic rock 20 | and mineral identification. The activity also extends learning to the Moon and asks 21 | students to predict how their rock collections will compare with lunar samples. 22 | A Resource Section for Unit 1 is on Page 24. 23 | 24 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 25 | 26 | 23 27 | 28 | Unit 1 29 | Resource Section 30 | This list presents possible independent and commercial sources of items to complement the activities in Unit 31 | 1. The sources are offered without recommendation or endorsement by NASA. Inquiries should be made 32 | directly to the appropriate source to determine availability, cost, and ordering information before sending 33 | money. Contact your NASA Educator Resource Center (see Page 146) for more lists of resources available 34 | directly from the National Aeronautics and Space Administration. 35 | Maps 36 | The Earth's Moon by National Geographic Society. 37 | Wall map showing nearside and farside. Also includes graphics with captions explaining eclipses, 38 | lunar phases, tides, and other phenomena. U.S. and 39 | Soviet landing/impact sites are shown. The reverse 40 | side has an index of lunar named features and 41 | selected photographs from the Apollo missions. 42 | National Geographic Society 43 | Educational Services, Department 91 44 | Washington, D.C. 20036 45 | 1-800-368-2728 or FAX 1-301-921-1575 46 | Giant Moon Map by Rand McNally. Wall map 47 | showing the nearside. Contact Rand McNally directly, or order it through: 48 | Astronomical Society of the Pacific 49 | 390 Ashton Ave. 50 | San Francisco, CA 94112 51 | 1-415-337-2624 52 | Maps of Earth, Moon, Mars, etc. 53 | U.S. Geological Survey Map Sales 54 | Box 25286 55 | Denver Federal Center 56 | Denver, CO 80225 57 | 303-236-7477 58 | (Ask for Customer Service) 59 | Globes 60 | Edmund Scientific Co. 61 | 101 E. Gloucester Pike 62 | Barrington, NJ 08007-1380 63 | 1-609-573-6270 or FAX 1-609-573-6295 64 | 65 | 24 66 | 67 | Lunar Phase Calendars 68 | Celestial Products 69 | P.O. Box 801 70 | Middleburg, VA 22117 71 | 1-800-235-3783 or FAX 1-703-338-4042 72 | Earth Rock Sample Sets 73 | Ward's Natural Science Establishment, Inc. 74 | P.O. Box 92912 75 | Rochester, NY 14692-9012 76 | 1-800-962-2660 77 | Slides 78 | Glorious Eclipses slide set 79 | Astronomical Society of the Pacific 80 | 390 Ashton Ave. 81 | San Francisco, CA 94112 82 | 1-415-337-2624 83 | Other Teacher's Guides 84 | Exploring Meteorite Mysteries: Teacher's Guide 85 | with Activities, NASA EG-1997-08-104-HQ. 86 | M. Lindstrom et. al., 1997 87 | Companion volume available from NASA Educator 88 | Resource Centers or CORE (refer to Page 146 of 89 | this book.) 90 | Return to the Moon: Moon Activities Teacher's 91 | Guide, 1990 92 | Challenger Center for Space Science Education 93 | 1101 King Street, Suite 190 94 | Alexandria, VA 22314 95 | 1-703-683-9740 96 | 97 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 98 | 99 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/documents/180562main_ETM.Diameter.Moon.txt: -------------------------------------------------------------------------------- 1 | Teacher Page 2 | 3 | Diameter of the Moon 4 | Purpose 5 | To calculate the diameter of the Moon using 6 | proportions. 7 | 8 | Background 9 | The diameter of the Moon is proportional to the diameter of a cardboard disk, given that 10 | you know the distance to the Moon and the distance to the cardboard disk. 11 | The relationship is: 12 | d 13 | l 14 | 15 | D 16 | L 17 | 18 | so that: 19 | D = L(d/l) 20 | where 21 | 22 | D 23 | d 24 | L 25 | l 26 | 27 | = diameter of Moon 28 | = diameter of cardboard disk 29 | = distance to Moon 30 | = distance to cardboard disk 31 | 32 | In this activity, students will measure d and l. They will be given L. 33 | They will calculate D. 34 | The diameter of the Moon (D) is 3,476 km. 35 | 36 | Preparation 37 | Review and prepare materials listed on the student sheet. 38 | Choose a day and location for this activity which is best for viewing a full Moon. 39 | A cardboard disk of 2 cm diameter works well. Better accuracy may be achieved by 40 | using a larger disk, thus a greater distance l. However, if obtaining or cutting cardboard 41 | is difficult, then this activity can also be done with dimes. A dime held out at arm's 42 | length will cover the Moon. 43 | The distance from Earth to the Moon for a given date can be obtained by asking a local 44 | planetarium staff, Or for this activity, students may use an average value of 45 | 382,500 km. 46 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 47 | 48 | 29 49 | 50 | Teacher Page 51 | 52 | Diameter of the Moon 53 | In Class 54 | If students work in pairs, then one student can use the string to measure distance from 55 | their partner's eye to the disk. 56 | The same units do not have to be used on both sides of the equation, but d and l have to 57 | be the same units. The D will be the same unit as L. 58 | 59 | Wrap-Up 60 | To compute the density of the Moon use the diameter to compute volume and use the 61 | mass value of 7.35 x 1022 kg. 62 | Density of the Moon is 3.34 grams/cubic cm. 63 | 64 | 30 65 | 66 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 67 | 68 | Diameter of the Moon 69 | Purpose 70 | To calculate the diameter of the Moon using 71 | proportions. 72 | 73 | Key Words 74 | 75 | Procedure 76 | 77 | proportional 78 | 79 | 1. On a day when you can see the Moon: place a 80 | cardboard disk on top of a stake or on a 81 | window sill so that it exactly covers the Moon 82 | from your point of view behind the cardboard 83 | disk. 84 | 85 | Materials 86 | 2-cm wide cardboard disk 87 | wooden stake (optional) 88 | meter stick 89 | calculator 90 | string 91 | 92 | 2. Have a friend measure the distance from 93 | your eye to the cardboard disk. 94 | Call this distance l and write the value here: 95 | l= 96 | 3. The distance from Earth to the Moon varies 97 | between 360,000 km and 405,000 km. Find the 98 | distance for today’s date or use an average value 99 | for your calculations of 382,500 km. 100 | Write the value that you are going to use here: 101 | L= 102 | 4. What is the diameter of the cardboard disk? 103 | d= 104 | 105 | 5. The diameter of the Moon is proportional to the 106 | diameter of your cardboard disk by this equation: 107 | d D 108 | l L 109 | 110 | where: D 111 | d 112 | L 113 | l 114 | 115 | so that, D = L(d/l) 116 | 117 | = diameter of Moon 118 | = diameter of cardboard disk 119 | = distance to Moon 120 | = distance to cardboard disk 121 | 122 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 123 | 124 | 31 125 | 126 | Diameter of the Moon 127 | Results 128 | 1. By your calculations, the diameter of the Moon is: 129 | D= 130 | 2. Compare your result with the accepted diameter of the Moon. 131 | How close did you get? 132 | 133 | 3. How many times smaller is the diameter of the Moon than the 134 | diameter of Earth? 135 | 136 | 4. When you calculated the diameter of the Moon, did you have to 137 | use the same units on both sides of the equation? 138 | 139 | 5. How and where could you find the value for the distance to the 140 | Moon for today's date? 141 | 142 | 6. What else would you need to know to compute the density of the 143 | Moon? Try it. 144 | 145 | 32 146 | 147 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 148 | 149 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/documents/180565main_ETM.Unit.2.Introduction.txt: -------------------------------------------------------------------------------- 1 | Unit 2 2 | Learning from Apollo 3 | The Lunar Disk 4 | Apollo Landing Sites 5 | Regolith Formation 6 | Lunar Surface 7 | Differentiation 8 | Impact Craters 9 | Clay Lava Flows 10 | Lava Layering 11 | Lunar Landing Sites 12 | Lunar Roving Vehicle 13 | Moon Anomalies 14 | The U.S. Space Program called Apollo achieved monumental goals including the 15 | collection and return of rock and sediment samples from the Moon. Analyses of the 16 | samples by scientists worldwide continue to give us new insight to the forces that 17 | shaped the early solar system, the Moon, and maybe most importantly, Earth. This 18 | excitement of discovery, a legacy of the Apollo program, is the theme of Unit 2. 19 | The highlight of this unit is the Lunar Sample Disk. Classroom activities focus on the 20 | Moon's rocks, surface features, and the geologic processes that formed them. Students 21 | are then given the opportunity to plan their own lunar missions in the “Lunar Landing 22 | Sites” and “Lunar Roving Vehicle” activities. The last activity of the unit presents four 23 | anomalies of the Moon for investigation and interpretation. 24 | A Resource Section for Unit 2 is on Page 38. 25 | 26 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 27 | 28 | 37 29 | 30 | Unit 2 31 | Resource Section 32 | This list presents possible independent and commercial sources of items to complement the activities in Unit 33 | 2. The sources are offered without recommendation or endorsement by NASA. Materials from the U.S. 34 | Government Printing Office also are included. Inquiries should be made directly to the appropriate source 35 | to determine availability, cost, and ordering information before sending money. Contact your NASA 36 | Educator Resource Center (see Page 146) for more resources available directly from NASA. 37 | Books 38 | Apollo Over the Moon: A View From Orbit, 39 | NASA SP-362, 1978, 255 p. Annotated picture 40 | book of lunar geologic features. U.S. Government 41 | Printing Office, Superintendent of Documents 42 | P.O. Box 371954 43 | Pittsburgh, PA 15250-7054 44 | phone 1-202-783-3238 45 | 46 | Apollo and the Moon Landing, by Gregory Vogt, 47 | 1991, Millbrook Press, 112 p. An illustrated text 48 | in the Missions in Space Series for grades 4-6. 49 | Slides 50 | The Apollo Landing Sites, set of 40 slides 51 | Lunar and Planetary Institute 52 | 3600 Bay Area Boulevard 53 | Houston, TX 77058-1113 54 | phone 1-281-486-2172 or fax 1-281-486-2186 55 | 56 | Apollo Expeditions to the Moon, NASA SP-250, 57 | 1975, 313 p. Illustrated chronicle of the Apollo 58 | missions with a focus on the engineering and team- Videos 59 | work that made the missions possible. 60 | Out of This World: The Apollo Moon Landings, 61 | U.S. Government Printing Office, same as above. 62 | Finley-Holiday Film Corp./Steve Skootsky, 1993, 63 | 60 minutes. Historically accurate video using newly 64 | The Moon, by Patrick Moore, 1981, Rand McNally restored NASA footage. Finley-Holiday Film Corp. 65 | and Co., 96 p. Illustrated with maps, drawings, and P.O. Box 619 66 | Apollo mission photographs. Also gives descriptions Whittier, CA 90608 67 | of unmanned missions including Russian Luna probes. phone 1-800-345-6707 68 | To Rise From Earth: An Easy to Understand 69 | Guide to Space Flight, by Wayne Lee, 1993, Texas 70 | Space Grant Consortium (ISBN 0-9637400-3-2), 71 | 279 p. Detailed, non-mathematical discussions of 72 | orbital mechanics, Apollo missions, and the Shuttle. 73 | To A Rocky Moon: A Geologist's History of 74 | Lunar Exploration, by Don E. Wilhelms, 1993, 75 | Univ. of Arizona Press, 477 p. 76 | 77 | Rockets and Models 78 | Estes Industries 79 | P.O. Box 227 80 | Penrose, CO 81240 81 | Other Teacher's Guides 82 | Exploring Meteorite Mysteries: Teacher's Guide 83 | with Activities, NASA EG-1997-08-104-HQ. 84 | Marilyn Lindstrom et. al., 1997. 85 | 86 | Carrying the Fire: An Astronaut's Journeys, by Rockets: Physical Science Teacher's Guide with 87 | Michael Collins, 1974, Ballantine Books, 488p. p. Activities, NASA EP-291. 88 | Gregory L. Vogt, 1993. 89 | 90 | 38 91 | 92 | Exploring the Moon -- A Teacher's Guide with Activities, NASA EG-1997-10-116-HQ 93 | 94 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/TopNWords/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolNodeCount": 3, 3 | "topWordCount": 50, 4 | "DocumentsRootPath": "documents", 5 | "shouldDeleteJob": true, 6 | "shouldDeletePool": false, 7 | "shouldDeleteContainer": true, 8 | "poolId": "TopNWordsPool", 9 | "jobId": "TopNWordsJob", 10 | "poolNodeVirtualMachineSize": "standard_d2_v3", 11 | "imagePublisher": "MicrosoftWindowsServer", 12 | "imageOffer": "WindowsServer", 13 | "imageSku": "2016-Datacenter-smalldisk", 14 | "imageVersion": "latest", 15 | "nodeAgentSkuId": "batch.node.windows amd64" 16 | } 17 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/ApplicationInsightsLiveStream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/azure-batch-samples/17fa81b07b13aaf9091d4fd6cd3664066d92ffc2/CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/ApplicationInsightsLiveStream.png -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/BlobDownloadTime.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/azure-batch-samples/17fa81b07b13aaf9091d4fd6cd3664066d92ffc2/CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/BlobDownloadTime.png -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/Exception.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/azure-batch-samples/17fa81b07b13aaf9091d4fd6cd3664066d92ffc2/CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/Exception.png -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/TraceLogsForTask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/azure-batch-samples/17fa81b07b13aaf9091d4fd6cd3664066d92ffc2/CSharp/ArticleProjects/ApplicationInsights/media/batch-monitoring-with-application-insights/TraceLogsForTask.png -------------------------------------------------------------------------------- /CSharp/ArticleProjects/EfficientListQueries/EfficientListQueries.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.Articles.EfficientListQueries 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/EfficientListQueries/EfficientListQueries.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EfficientListQueries", "EfficientListQueries.csproj", "{1F7E4DB3-2140-46A2-B0FE-003782C79279}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {1F7E4DB3-2140-46A2-B0FE-003782C79279}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {1F7E4DB3-2140-46A2-B0FE-003782C79279}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {1F7E4DB3-2140-46A2-B0FE-003782C79279}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {1F7E4DB3-2140-46A2-B0FE-003782C79279}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/EfficientListQueries/README.md: -------------------------------------------------------------------------------- 1 | ## EfficientListQueries 2 | 3 | This console application sample project backs the code snippets found in [Efficient Batch list queries](http://azure.microsoft.com/documentation/articles/batch-efficient-list-queries/), and demonstrates the value of limiting the type (and therefore the amount) of information returned by the Batch service when querying it for task, job, or other information. This example restricts the properties returned for each of a large number of tasks, showing how query performance is increased by printing elapsed time information for different queries. 4 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/JobPrepRelease/JobPrepRelease.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.Articles.JobPrepRelease 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/JobPrepRelease/JobPrepRelease.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JobPrepRelease", "JobPrepRelease.csproj", "{C5BF4B0C-07BE-4BBD-9461-E2FA37D71DC2}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C5BF4B0C-07BE-4BBD-9461-E2FA37D71DC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {C5BF4B0C-07BE-4BBD-9461-E2FA37D71DC2}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {C5BF4B0C-07BE-4BBD-9461-E2FA37D71DC2}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {C5BF4B0C-07BE-4BBD-9461-E2FA37D71DC2}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/JobPrepRelease/README.md: -------------------------------------------------------------------------------- 1 | ### JobPrepRelease 2 | 3 | The JobPrepRelease sample project backs the code snippets found in [Run job preparation and completion tasks on Azure Batch compute nodes](http://azure.microsoft.com/documentation/articles/batch-job-prep-release/). The application demonstrates the creation of a CloudJob configured with job preparation and release tasks, then prints information to the console detailing the execution of these and the other CloudTasks. 4 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MPIHelloWorld/MPIHelloWorld.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // 3 | // MPI sample program for use with the companion project to the following article: 4 | // https://azure.microsoft.com/documentation/articles/batch-mpi/ 5 | // Based on the sample in the following blog post: 6 | // https://blogs.technet.microsoft.com/windowshpc/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program/ 7 | 8 | #include "stdafx.h" 9 | #include "mpi.h" 10 | #include "stdio.h" 11 | #include "stdlib.h" 12 | 13 | int main(int argc, char* argv[]) 14 | { 15 | MPI_Init(&argc, &argv); 16 | 17 | int rank, size; 18 | 19 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 20 | MPI_Comm_size(MPI_COMM_WORLD, &size); 21 | if (rank == 0) 22 | { 23 | char helloStr[] = "Hello world"; 24 | for (int i = 1; i < size; ++i) 25 | { 26 | MPI_Send(helloStr, _countof(helloStr), MPI_CHAR, i, 0, MPI_COMM_WORLD); 27 | } 28 | } 29 | else 30 | { 31 | char helloStr[12]; 32 | MPI_Recv(helloStr, _countof(helloStr), MPI_CHAR, 0, 0, MPI_COMM_WORLD, MPI_STATUSES_IGNORE); 33 | printf("Rank %d received string \"%s\" from Rank 0\n", rank, helloStr); 34 | } 35 | 36 | MPI_Finalize(); 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MPIHelloWorld/MPIHelloWorld.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Release 6 | x64 7 | 8 | 9 | 10 | {72607067-3187-45A5-9286-A8E6A60533FD} 11 | Win32Proj 12 | MPIHelloWorld 13 | 8.1 14 | 15 | 16 | 17 | Application 18 | false 19 | v140 20 | true 21 | Unicode 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | false 34 | 35 | 36 | 37 | Level3 38 | Use 39 | MaxSpeed 40 | true 41 | true 42 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 43 | true 44 | $(SolutionDir)\packages\MSMPISDK.7.1.12437.25\Include;$(SolutionDir)\packages\MSMPISDK.7.1.12437.25\Include\x64 45 | 46 | 47 | Console 48 | true 49 | true 50 | true 51 | $(SolutionDir)\packages\MSMPISDK.7.1.12437.25\Lib\x64 52 | msmpi.lib;%(AdditionalDependencies) 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Create 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MPIHelloWorld/README.md: -------------------------------------------------------------------------------- 1 | ## MPIHelloWorld 2 | 3 | This Visual Studio 2015 project is provided as a sample MPI application for use 4 | with the [MultiInstanceTasks](../README.md) code sample. For more information 5 | on building this project, see the [How to compile and run a simple MS-MPI 6 | program][msmpi_howto] blog post. 7 | 8 | [msmpi_howto]: http://blogs.technet.com/b/windowshpc/archive/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program.aspx -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MPIHelloWorld/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MPIHelloWorld/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // MPIHelloWorld.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MPIHelloWorld/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MPIHelloWorld/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MultiInstanceTasks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.MultiInstanceTasks 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/MultiInstanceTasks.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiInstanceTasks", "MultiInstanceTasks.csproj", "{55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MPIHelloWorld", "MPIHelloWorld\MPIHelloWorld.vcxproj", "{72607067-3187-45A5-9286-A8E6A60533FD}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|x64 = Debug|x64 16 | Release|Any CPU = Release|Any CPU 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Debug|x64.Build.0 = Debug|Any CPU 24 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Release|x64.ActiveCfg = Release|Any CPU 27 | {55B3E0CC-7D1E-42F3-B1C2-CB21DF37DE1B}.Release|x64.Build.0 = Release|Any CPU 28 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|x64.ActiveCfg = Debug|Any CPU 31 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|x64.Build.0 = Debug|Any CPU 32 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|x64.ActiveCfg = Release|Any CPU 35 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|x64.Build.0 = Release|Any CPU 36 | {72607067-3187-45A5-9286-A8E6A60533FD}.Debug|Any CPU.ActiveCfg = Release|x64 37 | {72607067-3187-45A5-9286-A8E6A60533FD}.Debug|Any CPU.Build.0 = Release|x64 38 | {72607067-3187-45A5-9286-A8E6A60533FD}.Debug|x64.ActiveCfg = Release|x64 39 | {72607067-3187-45A5-9286-A8E6A60533FD}.Debug|x64.Build.0 = Release|x64 40 | {72607067-3187-45A5-9286-A8E6A60533FD}.Release|Any CPU.ActiveCfg = Release|x64 41 | {72607067-3187-45A5-9286-A8E6A60533FD}.Release|Any CPU.Build.0 = Release|x64 42 | {72607067-3187-45A5-9286-A8E6A60533FD}.Release|x64.ActiveCfg = Release|x64 43 | {72607067-3187-45A5-9286-A8E6A60533FD}.Release|x64.Build.0 = Release|x64 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/MultiInstanceTasks/README.md: -------------------------------------------------------------------------------- 1 | ## MultiInstanceTasks 2 | 3 | This C# console application project backs the code snippets found in [Use 4 | multi-instance tasks to run Message Passing Interface (MPI) applications in 5 | Azure Batch][batch_mpi]. It demonstrates how to use a multi-instance task to 6 | run an MS-MPI application on Batch compute nodes. 7 | 8 | To successfully run this sample, you must first create an 9 | [application package][batch_app_pkg] containing [MSMpiSetup.exe][msmpi_msdn] 10 | (installed on a pool's compute nodes with a start task) and an 11 | [MS-MPI][msmpi_howto] program for the multi-instance task to execute. For the 12 | latter, we provide the [MPIHelloWorld](./MPIHelloWorld) sample project for you 13 | to compile and use as your MS-MPI program. 14 | 15 | For full instructions on running the sample, see the 16 | [Code sample][batch_mpi_sample] section of the Batch MPI article. 17 | 18 | [batch_app_pkg]: https://azure.microsoft.com/documentation/articles/batch-application-packages/ 19 | [batch_mpi]: https://azure.microsoft.com/documentation/articles/batch-mpi/ 20 | [batch_mpi_sample]: https://azure.microsoft.com/documentation/articles/batch-mpi/#code-sample 21 | [msmpi_howto]: http://blogs.technet.com/b/windowshpc/archive/2015/02/02/how-to-compile-and-run-a-simple-ms-mpi-program.aspx 22 | [msmpi_msdn]: https://msdn.microsoft.com/library/bb524831.aspx 23 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ParallelTasks/ParallelTasks.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.Articles.ParallelTasks 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ParallelTasks/ParallelTasks.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParallelTasks", "ParallelTasks.csproj", "{A5F8A431-DDF5-4EE3-A841-47129D3A4AAF}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {A5F8A431-DDF5-4EE3-A841-47129D3A4AAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {A5F8A431-DDF5-4EE3-A841-47129D3A4AAF}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {A5F8A431-DDF5-4EE3-A841-47129D3A4AAF}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {A5F8A431-DDF5-4EE3-A841-47129D3A4AAF}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/ParallelTasks/README.md: -------------------------------------------------------------------------------- 1 | ### ParallelTasks 2 | 3 | This console application sample project backs the code snippets found in [Maximize Azure Batch compute resource usage with concurrent node tasks](http://azure.microsoft.com/documentation/articles/batch-parallel-node-tasks/). The application demonstrates the creation of a Batch pool whose compute nodes are configured for executing multiple concurrent tasks, submit tasks with variable slots, and prints node/job/task information to the console during execution to show how tasks are distributed among compute nodes and node cores. 4 | 5 | 1. Open the project in **Visual Studio 2017**. 6 | 2. Add your Batch and Storage **account credentials** to **accountsettings.json** in the Microsoft.Azure.Batch.Samples.Common project. 7 | 3. **Build** and then **run** the solution. Restore any NuGet packages if prompted. 8 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/PersistOutputs/BatchExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Azure.Batch.Samples.Articles.PersistOutputs 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using Batch.Common; 7 | using Conventions.Files; 8 | using Microsoft.WindowsAzure.Storage; 9 | 10 | public static class BatchExtensions 11 | { 12 | /// 13 | /// Monitors the specified job's tasks and returns each as they complete. When all 14 | /// of the tasks in the job have completed, the method returns. 15 | /// 16 | /// The containing the tasks to monitor. 17 | /// One or more completed . 18 | public static IEnumerable CompletedTasks(this CloudJob job) 19 | { 20 | HashSet yieldedTasks = new HashSet(); 21 | 22 | ODATADetailLevel detailLevel = new ODATADetailLevel(); 23 | detailLevel.SelectClause = "id,state,url,executionInfo"; 24 | 25 | while (true) 26 | { 27 | List tasks = job.ListTasks(detailLevel).ToList(); 28 | 29 | IEnumerable newlyCompleted = tasks.Where(t => t.State == TaskState.Completed) 30 | .Where(t => !yieldedTasks.Contains(t.Id)); 31 | 32 | foreach (CloudTask task in newlyCompleted) 33 | { 34 | yield return task; 35 | yieldedTasks.Add(task.Id); 36 | } 37 | 38 | if (yieldedTasks.Count == tasks.Count) 39 | { 40 | yield break; 41 | } 42 | } 43 | } 44 | 45 | public static CloudTask WithOutputFile( 46 | this CloudTask task, 47 | CloudJob job, 48 | string pattern, 49 | string containerUrl, 50 | JobOutputKind outputKind, 51 | OutputFileUploadCondition uploadCondition) 52 | { 53 | var outputBase = job.GetOutputStoragePath(outputKind); 54 | bool patternContainsWildcard = pattern.Contains("*"); 55 | var path = patternContainsWildcard ? outputBase : $"{outputBase}/{pattern}"; 56 | 57 | return task.WithOutputFile( 58 | pattern, 59 | containerUrl, 60 | path, 61 | uploadCondition); 62 | } 63 | 64 | public static CloudTask WithOutputFile( 65 | this CloudTask task, 66 | string pattern, 67 | string containerUrl, 68 | TaskOutputKind outputKind, 69 | OutputFileUploadCondition uploadCondition) 70 | { 71 | var outputBase = task.GetOutputStoragePath(outputKind); 72 | bool patternContainsWildcard = pattern.Contains("*"); 73 | var path = patternContainsWildcard ? outputBase : $"{outputBase}/{pattern}"; 74 | 75 | return task.WithOutputFile( 76 | pattern, 77 | containerUrl, 78 | path, 79 | uploadCondition); 80 | } 81 | 82 | private static CloudTask WithOutputFile( 83 | this CloudTask task, 84 | string pattern, 85 | string containerUrl, 86 | string path, 87 | OutputFileUploadCondition uploadCondition) 88 | { 89 | if (task.OutputFiles == null) 90 | { 91 | task.OutputFiles = new List(); 92 | } 93 | 94 | task.OutputFiles.Add( 95 | new OutputFile( 96 | filePattern: pattern, 97 | destination: new OutputFileDestination(new OutputFileBlobContainerDestination( 98 | containerUrl: containerUrl, 99 | path: path)), 100 | uploadOptions: new OutputFileUploadOptions( 101 | uploadCondition: uploadCondition))); 102 | 103 | return task; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/PersistOutputs/PersistOutputs.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.Articles.PersistOutputs 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/PersistOutputs/PersistOutputs.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersistOutputs", "PersistOutputs.csproj", "{EF627E82-DF0F-420F-81B8-C5F21FCCC9AC}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PersistOutputsTask", "PersistOutputsTask\PersistOutputsTask.csproj", "{92662AB2-FAEA-4C70-82A1-31F4AF5A2E1D}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {EF627E82-DF0F-420F-81B8-C5F21FCCC9AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {EF627E82-DF0F-420F-81B8-C5F21FCCC9AC}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {EF627E82-DF0F-420F-81B8-C5F21FCCC9AC}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {EF627E82-DF0F-420F-81B8-C5F21FCCC9AC}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {92662AB2-FAEA-4C70-82A1-31F4AF5A2E1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {92662AB2-FAEA-4C70-82A1-31F4AF5A2E1D}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {92662AB2-FAEA-4C70-82A1-31F4AF5A2E1D}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {92662AB2-FAEA-4C70-82A1-31F4AF5A2E1D}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/PersistOutputs/PersistOutputsTask/PersistOutputsTask.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.Articles.PersistOutputs.PersistOutputsTask 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/PersistOutputs/README.md: -------------------------------------------------------------------------------- 1 | ## PersistOutputs 2 | 3 | This console application sample project backs the code snippets found in [Persist Azure Batch job and task output](http://azure.microsoft.com/documentation/articles/batch-task-output/). This Visual Studio 2017 solution demonstrates how to use the [Azure Batch File Conventions](https://www.nuget.org/packages/Microsoft.Azure.Batch.Conventions.Files/) library to persist task output to durable storage. 4 | 5 | To run the sample, follow these steps: 6 | 7 | 1. Open the project in **Visual Studio 2017**. 8 | 2. Add your Batch and Storage **account credentials** to **accountsettings.json** in the Microsoft.Azure.Batch.Samples.Common project. 9 | 3. **Build** (but do not run) the solution. Restore any NuGet packages if prompted. 10 | 4. If running in "File Conventions" mode, use the Azure portal to upload an [application package](http://azure.microsoft.com/documentation/articles/batch-application-packages/) for **PersistOutputsTask**. Include the `PersistOutputsTask.exe` and its dependent assemblies in the .zip package, set the application ID to "PersistOutputsTask", and the application package version to "1.0". 11 | 5. **Start** (run) the **PersistOutputs** project. -------------------------------------------------------------------------------- /CSharp/ArticleProjects/README.md: -------------------------------------------------------------------------------- 1 | ## Article Projects 2 | 3 | These projects contain the sample code backing various articles in [Batch documentation](http://azure.microsoft.com/documentation/services/batch/). 4 | 5 | ### [ApplicationInsights](./ApplicationInsights) 6 | This article shows how to add and configure the Application Insights library into your solution and instrument your application code. Futhermore it provides examples on how to monitor your application via the Azure portal and build custom dashboards. 7 | 8 | ### [EfficientListQueries](./EfficientListQueries) 9 | This console application project backs the code snippets found in [Efficient Batch list queries](http://azure.microsoft.com/documentation/articles/batch-efficient-list-queries/), and demonstrates the value of limiting the type (and therefore the amount) of information returned by the Batch service when querying it for task, job, or other information. This example restricts the properties returned for each of a large number of tasks, showing how query performance is increased by printing elapsed time information for different queries. 10 | 11 | ### [JobPrepRelease](./JobPrepRelease) 12 | The JobPrepRelease sample project backs the code snippets found in [Run job preparation and completion tasks on Azure Batch compute nodes](http://azure.microsoft.com/documentation/articles/batch-job-prep-release/). The application demonstrates the creation of a CloudJob configured with job preparation and release tasks, then prints information to the console detailing the execution of these and the other CloudTasks. 13 | 14 | ### [MultiInstanceTasks](./MultiInstanceTasks) 15 | The MultiInstanceTasks sample project backs the code snippets found in [Use multi-instance tasks to run Message Passing Interface (MPI) applications in Azure Batch](http://azure.microsoft.com/documentation/articles/batch-mpi/). It demonstrates how to use a multi-instance task to run an MS-MPI application on Batch compute nodes. 16 | 17 | ### [ParallelTasks](./ParallelTasks) 18 | The ParallelTasks sample project backs the code snippets found in [Maximize Azure Batch compute resource usage with concurrent node tasks](http://azure.microsoft.com/documentation/articles/batch-parallel-node-tasks/). The application demonstrates the creation of a Batch pool whose compute nodes are configured for executing multiple concurrent tasks, and prints node and task information to the console during execution to show how tasks are distributed among compute nodes and node cores. 19 | 20 | ### [PersistOutputs](./PersistOutputs) 21 | 22 | This PersistOutputs sample project backs the code snippets found in [Persist Azure Batch job and task output](http://azure.microsoft.com/documentation/articles/batch-task-output/). This Visual Studio 2017 solution demonstrates how to use the [Azure Batch File Conventions](https://www.nuget.org/packages/Microsoft.Azure.Batch.Conventions.Files/) library to persist task output to durable storage. 23 | 24 | ### [TaskDependencies](./TaskDependencies) 25 | The TaskDependencies sample project demonstrates the use of the task dependency feature of Azure Batch. With task dependencies, you can create tasks that depend on the completion of other tasks before they are executed. 26 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/TaskDependencies/README.md: -------------------------------------------------------------------------------- 1 | ## TaskDependencies 2 | 3 | This C# console application demonstrates the use of task dependencies in Azure Batch. With task dependencies, you can configure scenarios such as the following: 4 | 5 | * *taskB* depends on *taskA* (*taskB* will not begin execution until *taskA* has completed) 6 | * *taskC* depends on both *taskA* and *taskB* 7 | * *taskD* depends on a range of tasks, such as tasks *1* through *10*, before it executes 8 | 9 | ### Requirements 10 | 11 | * Task dependencies require a job with [CloudJob][net_cloudjob].[UsesTaskDependencies][net_cloudjob_usestdp] set to `true` (the default is `false`). You **must** set this property value to `true` to use task dependencies. 12 | 13 | ``` 14 | CloudJob myJob = batchClient.JobOperations.CreateJob( 15 | "MyJob", 16 | new PoolInformation { PoolId = "MyPool" }); 17 | 18 | myJob.UsesTaskDependencies = true; 19 | ``` 20 | 21 | * When using **task ranges** for your dependencies, your task IDs must be string reprepresentations of integer values. 22 | 23 | ``` 24 | List tasks = new List 25 | { 26 | new CloudTask("1", "cmd.exe /c MyTaskExecutable.exe -process data1") 27 | new CloudTask("2", "cmd.exe /c MyTaskExecutable.exe -process data2") 28 | }; 29 | ``` 30 | 31 | 32 | [net_cloudjob]: https://msdn.microsoft.com/library/azure/microsoft.azure.batch.cloudjob.aspx 33 | [net_cloudjob_usestdp]: https://msdn.microsoft.com/library/azure/microsoft.azure.batch.cloudjob.usestaskdependencies.aspx -------------------------------------------------------------------------------- /CSharp/ArticleProjects/TaskDependencies/TaskDependencies.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.Articles.EfficientListQueries 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /CSharp/ArticleProjects/TaskDependencies/TaskDependencies.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TaskDependencies", "TaskDependencies.csproj", "{405407EC-785E-4E30-AFEE-641133DB5DBB}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {405407EC-785E-4E30-AFEE-641133DB5DBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {405407EC-785E-4E30-AFEE-641133DB5DBB}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {405407EC-785E-4E30-AFEE-641133DB5DBB}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {405407EC-785E-4E30-AFEE-641133DB5DBB}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BatchMetrics", "BatchMetrics\BatchMetrics.csproj", "{1A83F547-21BB-42D3-B546-DD19F58074D4}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BatchMetricsUsageSample", "BatchMetricsUsageSample\BatchMetricsUsageSample.csproj", "{6080556C-76DC-45E9-A1BF-7D2289407F92}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {1A83F547-21BB-42D3-B546-DD19F58074D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {1A83F547-21BB-42D3-B546-DD19F58074D4}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {1A83F547-21BB-42D3-B546-DD19F58074D4}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {1A83F547-21BB-42D3-B546-DD19F58074D4}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {6080556C-76DC-45E9-A1BF-7D2289407F92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {6080556C-76DC-45E9-A1BF-7D2289407F92}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {6080556C-76DC-45E9-A1BF-7D2289407F92}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {6080556C-76DC-45E9-A1BF-7D2289407F92}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/BatchMetrics.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net462 5 | Microsoft.Azure.Batch.Samples.BatchMetrics 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/DetailLevels.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetrics 4 | { 5 | using Microsoft.Azure.Batch; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | // Provides ODATADetailLevel objects for task state queries, both initial (all 13 | // entities) and delta (entities changed since a given time). 14 | internal static class DetailLevels 15 | { 16 | internal static class IdAndState 17 | { 18 | internal static readonly ODATADetailLevel AllEntities = new ODATADetailLevel(selectClause: "id,state"); 19 | 20 | internal static ODATADetailLevel OnlyChangedAfter(DateTime time) 21 | { 22 | return new ODATADetailLevel( 23 | selectClause: "id, state", 24 | filterClause: string.Format("stateTransitionTime gt DateTime'{0:o}'", time) 25 | ); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/EnumHelpers.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetrics 4 | { 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | internal static class EnumHelpers 12 | { 13 | // We use the underlying values of enums (specifically the TaskState enum) 14 | // to index into arrays; to do this requires an array whose size is big enough 15 | // to accommodate the maximum value of the enum type. This method gets that 16 | // maximum value. 17 | internal static int GetMaxValue(Type enumType) 18 | { 19 | return Enum.GetValues(enumType).Cast().Max(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/JobMetrics.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetrics 4 | { 5 | using Microsoft.Azure.Batch.Common; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | /// 13 | /// Contains aggregate information about a job at a point in time. 14 | /// 15 | public sealed class JobMetrics 16 | { 17 | private readonly TimeSpan listTasksLatency; 18 | private readonly TaskStateCounts taskStateCounts; 19 | 20 | internal JobMetrics(TimeSpan listTasksLatency, TaskStateCounts taskStateCounts) 21 | { 22 | this.listTasksLatency = listTasksLatency; 23 | this.taskStateCounts = taskStateCounts; 24 | } 25 | 26 | /// 27 | /// Gets the number of tasks in each in the job. 28 | /// 29 | public TaskStateCounts TaskStateCounts 30 | { 31 | get { return this.taskStateCounts; } 32 | } 33 | 34 | internal TimeSpan ListTasksLatency 35 | { 36 | get { return this.listTasksLatency; } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/Latency.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetrics 4 | { 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Collections.ObjectModel; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | /// 13 | /// Contains information about how long it took a to gather data 14 | /// for a . 15 | /// 16 | public struct Latency 17 | { 18 | private readonly TimeSpan totalTime; 19 | private readonly TimeSpan listJobsTime; 20 | private readonly IReadOnlyDictionary listTasksTimes; 21 | 22 | internal Latency(TimeSpan totalTime, TimeSpan listJobsTime, IDictionary listTasksTimes) 23 | { 24 | this.totalTime = totalTime; 25 | this.listJobsTime = listJobsTime; 26 | this.listTasksTimes = new ReadOnlyDictionary(listTasksTimes); 27 | } 28 | 29 | /// 30 | /// Gets the total time taken to gather data for the . 31 | /// 32 | public TimeSpan Total 33 | { 34 | get { return this.totalTime; } 35 | } 36 | 37 | /// 38 | /// Gets the time taken to list the jobs in the Batch account. 39 | /// 40 | public TimeSpan ListJobs 41 | { 42 | get { return this.listJobsTime; } 43 | } 44 | 45 | /// 46 | /// Gets the time taken to list the task status changes for the given job. 47 | /// 48 | /// The id of the job. 49 | /// The time taken to list the task status changes for the given job. 50 | public TimeSpan ListTasks(string jobId) 51 | { 52 | return this.listTasksTimes[jobId]; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/TaskHelpers.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetrics 4 | { 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | 12 | internal static class TaskHelpers 13 | { 14 | public static async Task CancellableDelay(TimeSpan delay, CancellationToken ct) 15 | { 16 | try 17 | { 18 | await Task.Delay(delay, ct); 19 | } 20 | catch (TaskCanceledException) 21 | { 22 | } 23 | } 24 | 25 | public static void WaitForCompletionOrCancellation(this Task task) 26 | { 27 | try 28 | { 29 | task.Wait(); 30 | } 31 | catch (TaskCanceledException) 32 | { 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/TaskStateCache.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetrics 4 | { 5 | using Microsoft.Azure.Batch.Common; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | internal sealed class TaskStateCache 13 | { 14 | // The key is the task id 15 | private readonly Dictionary taskStateMap = new Dictionary(); 16 | 17 | public void UpdateTaskState(string taskId, TaskState taskState) 18 | { 19 | this.taskStateMap[taskId] = taskState; 20 | } 21 | 22 | public TaskStateCounts GetTaskStateCounts() 23 | { 24 | TaskStateCounts taskStateCounts = new TaskStateCounts(); 25 | 26 | foreach (var kvp in this.taskStateMap) 27 | { 28 | taskStateCounts.IncrementCount(kvp.Value); 29 | } 30 | 31 | return taskStateCounts; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetrics/TaskStateCounts.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetrics 4 | { 5 | using Microsoft.Azure.Batch.Common; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | /// 13 | /// Contains information about how many tasks in a job are in each 14 | /// . 15 | /// 16 | public sealed class TaskStateCounts 17 | { 18 | private readonly int[] counts; 19 | 20 | internal TaskStateCounts() 21 | { 22 | // The counts array is indexed by TaskState. The constructor examines the TaskState 23 | // type to determine how to size the array. 24 | var maxStateIndex = EnumHelpers.GetMaxValue(typeof(TaskState)); 25 | this.counts = new int[maxStateIndex + 1]; 26 | } 27 | 28 | internal void IncrementCount(TaskState taskState) 29 | { 30 | this.counts[(int)taskState]++; 31 | } 32 | 33 | /// 34 | /// Gets the number of tasks in the specified state. 35 | /// 36 | /// The for which to get the number of tasks in that state. 37 | /// The number of tasks in the specified state. 38 | public int this[TaskState state] 39 | { 40 | get { return this.counts[(int)state]; } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetricsUsageSample/BatchMetricsUsageSample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.BatchMetricsUsageSample 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/BatchMetricsUsageSample/ErrorExtensions.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.BatchMetricsUsageSample 4 | { 5 | using Microsoft.Azure.Batch.Common; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | internal static class ErrorExtensions 13 | { 14 | internal static bool IsBatchErrorCode(this BatchException ex, string errorCode) 15 | { 16 | return ex.RequestInformation != null 17 | && ex.RequestInformation.BatchError != null 18 | && ex.RequestInformation.BatchError.Code == errorCode; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CSharp/BatchMetrics/README.md: -------------------------------------------------------------------------------- 1 | ### BatchMetrics 2 | 3 | The BatchMetrics sample project demonstrates how to efficiently monitor Azure Batch 4 | job progress using the Batch API. 5 | 6 | This sample application demonstrates the following operations: 7 | 8 | 1. Selecting specific attributes in order to download only the fields you need 9 | 2. Filtering on state transition times in order to download only changes 10 | 11 | The sample includes a library project which you can incorporate into your own projects 12 | and a simple command line program to exercise and demonstrate the use of the library. 13 | -------------------------------------------------------------------------------- /CSharp/Common/AccountSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Microsoft.Azure.Batch.Samples.Common 6 | { 7 | public class AccountSettings 8 | { 9 | public string BatchServiceUrl { get; set; } 10 | public string BatchAccountName { get; set; } 11 | public string BatchAccountKey { get; set; } 12 | 13 | public string StorageServiceUrl { get; set; } 14 | public string StorageAccountName { get; set; } 15 | public string StorageAccountKey { get; set; } 16 | 17 | public override string ToString() 18 | { 19 | StringBuilder stringBuilder = new StringBuilder(); 20 | 21 | AddSetting(stringBuilder, "BatchAccountName", this.BatchAccountName); 22 | AddSetting(stringBuilder, "BatchAccountKey", this.BatchAccountKey); 23 | AddSetting(stringBuilder, "BatchServiceUrl", this.BatchServiceUrl); 24 | 25 | AddSetting(stringBuilder, "StorageAccountName", this.StorageAccountName); 26 | AddSetting(stringBuilder, "StorageAccountKey", this.StorageAccountKey); 27 | AddSetting(stringBuilder, "StorageServiceUrl", this.StorageServiceUrl); 28 | 29 | return stringBuilder.ToString(); 30 | } 31 | 32 | private static void AddSetting(StringBuilder stringBuilder, string settingName, object settingValue) 33 | { 34 | stringBuilder.AppendFormat("{0} = {1}", settingName, settingValue).AppendLine(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /CSharp/Common/CreatePoolResult.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.Common 4 | { 5 | public enum CreatePoolResult 6 | { 7 | PoolExisted, 8 | CreatedNew, 9 | ResizedExisting, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CSharp/Common/Microsoft.Azure.Batch.Samples.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net462 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | PreserveNewest 16 | 17 | 18 | -------------------------------------------------------------------------------- /CSharp/Common/accountsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "batchAccountName": "", 3 | "batchAccountKey": "", 4 | "batchServiceUrl": "", 5 | "storageAccountName": "", 6 | "storageAccountKey": "", 7 | "storageServiceUrl": "core.windows.net" 8 | } 9 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/01_HelloWorld/HelloWorld.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.HelloWorld 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | PreserveNewest 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/01_HelloWorld/HelloWorld.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorld", "HelloWorld.csproj", "{FE62D509-B9A9-4592-81BB-779306C22F95}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {FE62D509-B9A9-4592-81BB-779306C22F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {FE62D509-B9A9-4592-81BB-779306C22F95}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {FE62D509-B9A9-4592-81BB-779306C22F95}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {FE62D509-B9A9-4592-81BB-779306C22F95}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/01_HelloWorld/Settings.cs: -------------------------------------------------------------------------------- 1 | namespace Microsoft.Azure.Batch.Samples.HelloWorld 2 | { 3 | using System.Text; 4 | using Common; 5 | 6 | public partial class Settings 7 | { 8 | public string PoolId { get; set; } 9 | public int PoolTargetNodeCount { get; set; } 10 | public string PoolOSFamily { get; set; } 11 | public string PoolNodeVirtualMachineSize { get; set; } 12 | public bool ShouldDeleteJob { get; set; } 13 | public string ImagePublisher { get; set; } 14 | public string ImageOffer { get; set; } 15 | public string ImageSku { get; set; } 16 | public string ImageVersion { get; set; } 17 | public string NodeAgentSkuId { get; set; } 18 | 19 | public override string ToString() 20 | { 21 | StringBuilder stringBuilder = new StringBuilder(); 22 | 23 | SampleHelpers.AddSetting(stringBuilder, "PoolId", this.PoolId); 24 | SampleHelpers.AddSetting(stringBuilder, "PoolTargetNodeCount", this.PoolTargetNodeCount); 25 | SampleHelpers.AddSetting(stringBuilder, "PoolOSFamily", this.PoolOSFamily); 26 | SampleHelpers.AddSetting(stringBuilder, "PoolNodeVirtualMachineSize", this.PoolNodeVirtualMachineSize); 27 | SampleHelpers.AddSetting(stringBuilder, "ShouldDeleteJob", this.ShouldDeleteJob); 28 | SampleHelpers.AddSetting(stringBuilder, "ImagePublisher", this.ImagePublisher); 29 | SampleHelpers.AddSetting(stringBuilder, "ImageOffer", this.ImageOffer); 30 | SampleHelpers.AddSetting(stringBuilder, "ImageSku", this.ImageSku); 31 | SampleHelpers.AddSetting(stringBuilder, "ImageVersion", this.ImageVersion); 32 | SampleHelpers.AddSetting(stringBuilder, "NodeAgentSkuId", this.NodeAgentSkuId); 33 | 34 | 35 | return stringBuilder.ToString(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/01_HelloWorld/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolTargetNodeCount": 2, 3 | "poolNodeVirtualMachineSize": "standard_d2_v3", 4 | "poolOSFamily": "5", 5 | "poolId": "HelloWorld-Pool", 6 | "shouldDeleteJob": true, 7 | "imagePublisher": "MicrosoftWindowsServer", 8 | "imageOffer": "WindowsServer", 9 | "imageSku": "2016-Datacenter-smalldisk", 10 | "imageVersion": "latest", 11 | "nodeAgentSkuId": "batch.node.windows amd64" 12 | } 13 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/02_PoolsAndResourceFiles/JobSubmitter/JobSubmitter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.PoolsAndResourceFiles 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | PreserveNewest 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/02_PoolsAndResourceFiles/JobSubmitter/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.PoolsAndResourceFiles 4 | { 5 | using System; 6 | using Common; 7 | 8 | /// 9 | /// The main program of the PoolsAndResourceFiles sample 10 | /// 11 | public static class Program 12 | { 13 | public static void Main(string[] args) 14 | { 15 | // This will boost parallel submission speed for REST APIs. If your use requires many simultaneous service calls set this number to something large, such as 100. 16 | // See: https://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit.aspx for more info. 17 | System.Net.ServicePointManager.DefaultConnectionLimit = 20; 18 | 19 | try 20 | { 21 | JobSubmitter jobSubmitter = new JobSubmitter(); 22 | jobSubmitter.RunAsync().Wait(); 23 | } 24 | catch (AggregateException aggregateException) 25 | { 26 | // Go through all exceptions and dump useful information 27 | SampleHelpers.PrintAggregateException(aggregateException); 28 | 29 | throw; 30 | } 31 | 32 | Console.WriteLine("Press return to exit..."); 33 | Console.ReadLine(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/02_PoolsAndResourceFiles/JobSubmitter/Settings.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.PoolsAndResourceFiles 4 | { 5 | using System.Text; 6 | using Common; 7 | 8 | public class Settings 9 | { 10 | public string PoolId { get; set; } 11 | public int PoolTargetNodeCount { get; set; } 12 | public string PoolOsFamily { get; set; } 13 | public string PoolNodeVirtualMachineSize { get; set; } 14 | public bool ShouldDeletePool { get; set; } 15 | public bool ShouldDeleteJob { get; set; } 16 | public string BlobContainer { get; set; } 17 | public string ImagePublisher { get; set; } 18 | public string ImageOffer { get; set; } 19 | public string ImageSku { get; set; } 20 | public string ImageVersion { get; set; } 21 | public string NodeAgentSkuId { get; set; } 22 | 23 | public override string ToString() 24 | { 25 | StringBuilder stringBuilder = new StringBuilder(); 26 | 27 | SampleHelpers.AddSetting(stringBuilder, "PoolId", this.PoolId); 28 | SampleHelpers.AddSetting(stringBuilder, "PoolTargetNodeCount", this.PoolTargetNodeCount); 29 | SampleHelpers.AddSetting(stringBuilder, "PoolOSFamily", this.PoolOsFamily); 30 | SampleHelpers.AddSetting(stringBuilder, "PoolNodeVirtualMachineSize", this.PoolNodeVirtualMachineSize); 31 | SampleHelpers.AddSetting(stringBuilder, "ShouldDeletePool", this.ShouldDeletePool); 32 | SampleHelpers.AddSetting(stringBuilder, "ShouldDeleteJob", this.ShouldDeleteJob); 33 | SampleHelpers.AddSetting(stringBuilder, "BlobContainer", this.BlobContainer); 34 | SampleHelpers.AddSetting(stringBuilder, "ImagePublisher", this.ImagePublisher); 35 | SampleHelpers.AddSetting(stringBuilder, "ImageOffer", this.ImageOffer); 36 | SampleHelpers.AddSetting(stringBuilder, "ImageSku", this.ImageSku); 37 | SampleHelpers.AddSetting(stringBuilder, "ImageVersion", this.ImageVersion); 38 | SampleHelpers.AddSetting(stringBuilder, "NodeAgentSkuId", this.NodeAgentSkuId); 39 | 40 | return stringBuilder.ToString(); 41 | } 42 | 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/02_PoolsAndResourceFiles/JobSubmitter/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolTargetNodeCount": 2, 3 | "poolNodeVirtualMachineSize": "standard_d2_v3", 4 | "poolOSFamily": "5", 5 | "poolId": "PoolsAndResourceFilesPool", 6 | "shouldDeleteJob": true, 7 | "shouldDeletePool": false, 8 | "blobContainer": "PoolAndResourceFilesContainer", 9 | "imagePublisher": "MicrosoftWindowsServer", 10 | "imageOffer": "WindowsServer", 11 | "imageSku": "2016-Datacenter-smalldisk", 12 | "imageVersion": "latest", 13 | "nodeAgentSkuId": "batch.node.windows amd64" 14 | } 15 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/02_PoolsAndResourceFiles/PoolsAndResourceFiles.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JobSubmitter", "JobSubmitter\JobSubmitter.csproj", "{96FA96C5-2982-4A67-9939-58D03D5E7414}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleTask", "..\Shared\SimpleTask\SimpleTask.csproj", "{0950B124-DEED-4F4C-B067-70E0AE06B41C}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/JobManager.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JobSubmitter", "JobSubmitter\JobSubmitter.csproj", "{96FA96C5-2982-4A67-9939-58D03D5E7414}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleTask", "..\Shared\SimpleTask\SimpleTask.csproj", "{0950B124-DEED-4F4C-B067-70E0AE06B41C}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleJobManagerTask", "SampleJobManager\SampleJobManagerTask.csproj", "{AEE5AF9A-4581-469F-9A75-B4C7121C493D}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {96FA96C5-2982-4A67-9939-58D03D5E7414}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {0950B124-DEED-4F4C-B067-70E0AE06B41C}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {AEE5AF9A-4581-469F-9A75-B4C7121C493D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {AEE5AF9A-4581-469F-9A75-B4C7121C493D}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {AEE5AF9A-4581-469F-9A75-B4C7121C493D}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {AEE5AF9A-4581-469F-9A75-B4C7121C493D}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | EndGlobal 41 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/JobSubmitter/JobSubmitter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.JobManager 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | PreserveNewest 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/JobSubmitter/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.JobManager 4 | { 5 | using System; 6 | using Common; 7 | 8 | /// 9 | /// The main program of the JobManager sample 10 | /// 11 | public static class Program 12 | { 13 | public static void Main(string[] args) 14 | { 15 | // This will boost parallel submission speed for REST APIs. If your use requires many simultaneous service calls set this number to something large, such as 100. 16 | // See: https://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit.aspx for more info. 17 | System.Net.ServicePointManager.DefaultConnectionLimit = 20; 18 | 19 | try 20 | { 21 | JobSubmitter jobSubmitter = new JobSubmitter(); 22 | jobSubmitter.RunAsync().Wait(); 23 | } 24 | catch (AggregateException aggregateException) 25 | { 26 | // Go through all exceptions and dump useful information 27 | SampleHelpers.PrintAggregateException(aggregateException); 28 | 29 | throw; 30 | } 31 | 32 | Console.WriteLine("Press return to exit..."); 33 | Console.ReadLine(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/JobSubmitter/Settings.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.JobManager 4 | { 5 | using System.Text; 6 | using Microsoft.Azure.Batch.Samples.Common; 7 | 8 | public class Settings 9 | { 10 | public string PoolId { get; set; } 11 | public int PoolTargetNodeCount { get; set; } 12 | public string PoolOsFamily { get; set; } 13 | public string PoolNodeVirtualMachineSize { get; set; } 14 | public bool ShouldDeletePool { get; set; } 15 | public bool ShouldDeleteJob { get; set; } 16 | public string BlobContainer { get; set; } 17 | public string ImagePublisher { get; set; } 18 | public string ImageOffer { get; set; } 19 | public string ImageSku { get; set; } 20 | public string ImageVersion { get; set; } 21 | public string NodeAgentSkuId { get; set; } 22 | 23 | public override string ToString() 24 | { 25 | StringBuilder stringBuilder = new StringBuilder(); 26 | 27 | SampleHelpers.AddSetting(stringBuilder, "PoolId", this.PoolId); 28 | SampleHelpers.AddSetting(stringBuilder, "PoolTargetNodeCount", this.PoolTargetNodeCount); 29 | SampleHelpers.AddSetting(stringBuilder, "PoolOSFamily", this.PoolOsFamily); 30 | SampleHelpers.AddSetting(stringBuilder, "PoolNodeVirtualMachineSize", this.PoolNodeVirtualMachineSize); 31 | SampleHelpers.AddSetting(stringBuilder, "ShouldDeletePool", this.ShouldDeletePool); 32 | SampleHelpers.AddSetting(stringBuilder, "ShouldDeleteJob", this.ShouldDeleteJob); 33 | SampleHelpers.AddSetting(stringBuilder, "BlobContainer", this.BlobContainer); 34 | SampleHelpers.AddSetting(stringBuilder, "ImagePublisher", this.ImagePublisher); 35 | SampleHelpers.AddSetting(stringBuilder, "ImageOffer", this.ImageOffer); 36 | SampleHelpers.AddSetting(stringBuilder, "ImageSku", this.ImageSku); 37 | SampleHelpers.AddSetting(stringBuilder, "ImageVersion", this.ImageVersion); 38 | SampleHelpers.AddSetting(stringBuilder, "NodeAgentSkuId", this.NodeAgentSkuId); 39 | 40 | return stringBuilder.ToString(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/JobSubmitter/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "poolTargetNodeCount": 2, 3 | "poolNodeVirtualMachineSize": "standard_d2_v3", 4 | "poolOSFamily": "5", 5 | "poolId": "JobManagerSamplePool", 6 | "shouldDeleteJob": true, 7 | "shouldDeletePool": false, 8 | "blobContainer": "JobManagerSampleContainer", 9 | "imagePublisher": "MicrosoftWindowsServer", 10 | "imageOffer": "WindowsServer", 11 | "imageSku": "2016-Datacenter-smalldisk", 12 | "imageVersion": "latest", 13 | "nodeAgentSkuId": "batch.node.windows amd64" 14 | } 15 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/SampleJobManager/JobManagerSettings.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.JobManager 4 | { 5 | using System.Text; 6 | 7 | public class JobManagerSettings 8 | { 9 | public string BatchAccountName { get; private set; } 10 | 11 | public string BatchAccountKey { get; private set; } 12 | 13 | public string BatchAccountUrl { get; private set; } 14 | 15 | public string StorageAccountName { get; private set; } 16 | 17 | public string StorageAccountKey { get; private set; } 18 | 19 | public string StorageAccountUrl { get; private set; } 20 | 21 | public JobManagerSettings( 22 | string batchAccountName, 23 | string batchAccountKey, 24 | string batchAccountUrl, 25 | string storageAccountName, 26 | string storageAccountKey, 27 | string storageAccountUrl) 28 | { 29 | this.BatchAccountName = batchAccountName; 30 | this.BatchAccountKey = batchAccountKey; 31 | this.BatchAccountUrl = batchAccountUrl; 32 | 33 | this.StorageAccountName = storageAccountName; 34 | this.StorageAccountKey = storageAccountKey; 35 | this.StorageAccountUrl = storageAccountUrl; 36 | } 37 | 38 | public override string ToString() 39 | { 40 | StringBuilder stringBuilder = new StringBuilder(); 41 | 42 | stringBuilder.AppendFormat("{0} = {1}", "BatchAccountName", this.BatchAccountName).AppendLine(); 43 | stringBuilder.AppendFormat("{0} = {1}", "BatchAccountKey", this.BatchAccountKey).AppendLine(); 44 | stringBuilder.AppendFormat("{0} = {1}", "BatchAccountUrl", this.BatchAccountUrl).AppendLine(); 45 | 46 | stringBuilder.AppendFormat("{0} = {1}", "StorageAccountName", this.StorageAccountName).AppendLine(); 47 | stringBuilder.AppendFormat("{0} = {1}", "StorageAccountKey", this.StorageAccountKey).AppendLine(); 48 | stringBuilder.AppendFormat("{0} = {1}", "storageAccountUrl", this.StorageAccountUrl).AppendLine(); 49 | 50 | return stringBuilder.ToString(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/SampleJobManager/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.JobManager 4 | { 5 | using System; 6 | using Common; 7 | 8 | public class Program 9 | { 10 | public static void Main(string[] args) 11 | { 12 | try 13 | { 14 | SampleJobManagerTask jobManagerTask = new SampleJobManagerTask(); 15 | 16 | jobManagerTask.RunAsync().Wait(); 17 | } 18 | catch (AggregateException e) 19 | { 20 | SampleHelpers.PrintAggregateException(e); 21 | 22 | throw; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/03_JobManager/SampleJobManager/SampleJobManagerTask.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.JobManager 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/README.md: -------------------------------------------------------------------------------- 1 | ## Getting Started 2 | 3 | ### [01_HelloWorld](./01_HelloWorld) 4 | The HelloWorld sample is an introduction to the framework required to communicate with the Batch service. It submits a job using an auto-pool and then submits a task which performs a simple echo command. The task has no required files. The focus of this sample is on the API calls required to add a job to the Batch service and monitor the status of that job from a client. 5 | 6 | ### [02_PoolsAndResourceFiles](./02_PoolsAndResourceFiles) 7 | This sample expands on the HelloWorld sample. It creates a fixed pool and then uses the FileStaging feature to submit a task with a set of required files. The FileStaging class is used to move the files into Azure Storage and then onto the Batch compute node. This sample also showcases the use of a StartTask as a method to get files onto every node in the pool. 8 | 9 | ### [03_JobManager](./03_JobManager) 10 | This sample extends on the previous sample. It uses a fixed pool and submits a job with a JobManager task. The JobManager task adds other tasks to the job and also ends the job when all tasks have completed. 11 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/Shared/SimpleTask/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.SimpleTask 4 | { 5 | using System; 6 | using System.IO; 7 | 8 | // Simple command line program which prints the names of all the files in the current directory 9 | public class Program 10 | { 11 | public static void Main(string[] args) 12 | { 13 | foreach (string file in Directory.EnumerateFiles(".")) 14 | { 15 | Console.WriteLine("Found a file: {0}", file); 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /CSharp/GettingStarted/Shared/SimpleTask/SimpleTask.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.SimpleTask 7 | 8 | 9 | -------------------------------------------------------------------------------- /CSharp/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2015 Microsoft Corporation 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /CSharp/README.md: -------------------------------------------------------------------------------- 1 | ## General Info 2 | 3 | ### Visual Studio Requirements 4 | You will need Visual Studio 2017 or later to compile the projects. If you don't have it, you can download the community edition [here](https://www.visualstudio.com/products/visual-studio-community-vs.aspx) for free. 5 | 6 | ### A note on .NET Core 7 | The samples currently all target .NET Framework. Most samples can easily be changed to target .NET Core by changing the .csproj to produce a netcoreapp binary instead of a net462 binary. In the case of samples with 8 | worker task exectuables or JobManager executables a standalone .NET Core binary distribution must be produced, zipped, uploaded to Azure Storage, and unzipped on the node prior to execution of the task process. 9 | In order to keep the samples simple, this is left as an exercize to the reader. 10 | 11 | ### Building the Samples 12 | Download the samples and open the solution file for each one using Visual Studio. Right click on the solution and select "Rebuild". Visual Studio will analyze the dependencies and download the dependent binaries from [nuget.org](http://www.nuget.org/packages/Azure.Batch/). 13 | 14 | ### Preallocating Pools and Compute Nodes 15 | Samples outside of [ArticleProjects](./ArticleProjects) require a pre-created pool with deployed compute nodes. If your tasks are not being scheduled, it is likely that there are no nodes to host the tasks; some of the samples detect this and will add 3 small nodes to the specified pool. You can use the [Azure Batch Explorer](https://azure.github.io/BatchExplorer/) to monitor this situation, as well as create the pool and resize it to have some number of nodes. You can then specify this pool's id in some of the samples so you don't have to wait for the nodes to become available. 16 | 17 | ### Configuring Credentials 18 | In order the run the samples, they must be configured with Azure Batch and Azure Storage credentials. The credentials for each sample are gathered from the AccountSettings configuration located [here](./Common/AccountSettings.settings). The settings can be set via the Visual Studio settings manager. Once you have configured your account credentials, you can run any of the samples and they will make use of the credentials provided in the AccountSettings configuration. 19 | 20 | ## Sample Descriptions 21 | 22 | ### [AccountManagement](./AccountManagement) 23 | This sample demonstrates the use of the [Microsoft.Azure.Management.Batch](https://msdn.microsoft.com/library/azure/mt463120.aspx) library to perform basic operations related to Batch accounts. View the [companion article](https://azure.microsoft.com/documentation/articles/batch-management-dotnet/) for more information. 24 | 25 | ### [ArticleProjects](./ArticleProjects) 26 | These projects contain the sample code backing various articles in [Batch documentation](http://azure.microsoft.com/documentation/services/batch/). Most of the samples in [ArticleProjects](./ArticleProjects) are intended not as end-to-end API usage samples, but rather to demonstrate a specific feature of the Batch service. 27 | 28 | ### [BatchMetrics](./BatchMetrics) 29 | This sample demonstrates efficient list queries and provides a utility library for job progress monitoring. 30 | 31 | ### [GettingStarted](./GettingStarted) 32 | This set of samples is intended to be the starting point for learning the concepts behind Azure Batch and its API. It covers basic features of the service, including jobs, pools, tasks, and more. 33 | 34 | ### [TextSearch](./TextSearch) 35 | This map-reduce style sample uses Azure Batch to perform parallel text processing on an input file by splitting it up into multiple sub-files and performing regular expression matching on each sub-file. 36 | This sample makes use of a variety of Azure Batch features, such as auto-pool functionality, task `ResourceFiles` for moving data into VMs, task `OutputFiles` for moving data out of VMs, and task dependencies for specifying tasks relationships to one another. See the readme in the source directory for more information. 37 | 38 | ### [TopNWords](./TopNWords) 39 | This sample demonstrates how to process a set of input blobs in parallel on multiple compute nodes. In this case, there is only one blob but the code can be expanded to load more blobs and bind them to individual tasks. The task writes a list of length N to stdout that contains the words in the blob with the highest occurrence count. A run-once job is created followed by the creation of multiple tasks with each task processing its blob. The job code then waits for each of the tasks to complete and prints out the list generated for each input blob. 40 | -------------------------------------------------------------------------------- /CSharp/TextSearch/Common/Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net462 5 | Microsoft.Azure.Batch.Samples.TextSearch 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | PreserveNewest 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /CSharp/TextSearch/Common/Constants.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace Microsoft.Azure.Batch.Samples.TextSearch 6 | { 7 | /// 8 | /// A set of useful constants. 9 | /// 10 | public static class Constants 11 | { 12 | public const string MapperTaskExecutable = "MapperTask.exe"; 13 | public const string ReducerTaskExecutable = "ReducerTask.exe"; 14 | public const string ReducerTaskResultBlobName = "ReducerTaskOutput"; 15 | 16 | public const string MapperTaskPrefix = "MapperTask"; 17 | public const string ReducerTaskId = "ReducerTask"; 18 | public const string TextFilePath = "Text.txt"; 19 | 20 | /// 21 | /// The list of required files to run the sample executables. Since the JobManager.exe is run as a job manager in Batch 22 | /// it needs all the DLLs of the Batch client library. 23 | /// 24 | public readonly static IReadOnlyList RequiredExecutableFiles = new List 25 | { 26 | "JobSubmitter.pdb", 27 | MapperTaskExecutable, 28 | MapperTaskExecutable + ".config", 29 | "MapperTask.pdb", 30 | ReducerTaskExecutable, 31 | ReducerTaskExecutable + ".config", 32 | "ReducerTask.pdb", 33 | "settings.json", 34 | "accountsettings.json", 35 | "Microsoft.Azure.Batch.Samples.Common.dll", 36 | "Common.dll", 37 | "Microsoft.WindowsAzure.Storage.dll", 38 | "Microsoft.Azure.Batch.dll", 39 | "Microsoft.Rest.ClientRuntime.dll", 40 | "Microsoft.Rest.ClientRuntime.Azure.dll", 41 | "Newtonsoft.Json.dll", 42 | "Microsoft.Extensions.Configuration.dll", 43 | "Microsoft.Extensions.Configuration.Abstractions.dll", 44 | "Microsoft.Extensions.Configuration.Json.dll", 45 | "Microsoft.Extensions.Configuration.Binder.dll", 46 | "Microsoft.Extensions.Configuration.FileExtensions.dll", 47 | "Microsoft.Extensions.FileProviders.Physical.dll", 48 | "Microsoft.Extensions.FileProviders.Abstractions.dll", 49 | "netstandard.dll", 50 | "Microsoft.Extensions.Primitives.dll", 51 | "System.Net.Http.dll", 52 | }; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /CSharp/TextSearch/Common/Helpers.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System; 6 | using System.Threading.Tasks; 7 | using Microsoft.Azure.Batch.Common; 8 | 9 | /// 10 | /// Class containing helpers for the TextSearch sample. 11 | /// 12 | public static class Helpers 13 | { 14 | /// 15 | /// Gets the mapper task id corresponding to the specified task number. 16 | /// 17 | /// The mapper task number. 18 | /// The mapper task id corresponding to the specified task number. 19 | public static string GetMapperTaskId(int taskNumber) 20 | { 21 | return $"{Constants.MapperTaskPrefix}_{taskNumber}"; 22 | } 23 | 24 | /// 25 | /// Gets the file name corresponding to the specified file number. 26 | /// 27 | /// The file number. 28 | /// The file name corresponding to the specified file number. 29 | public static string GetSplitFileName(int fileNumber) 30 | { 31 | return $"TextFile_{fileNumber}.txt"; 32 | } 33 | 34 | /// 35 | /// Checks for a task's success or failure, and optionally dumps the output of the task. In the case that the task hit a scheduler or execution error, 36 | /// dumps that information as well. 37 | /// 38 | /// The task. 39 | /// True to log the standard output file of the task even if it succeeded. False to not log anything if the task succeeded. 40 | public static async Task CheckForTaskSuccessAsync(CloudTask boundTask, bool dumpStandardOutOnTaskSuccess) 41 | { 42 | if (boundTask.State == TaskState.Completed) 43 | { 44 | //Dump the task failure info if there was one. 45 | if (boundTask.ExecutionInformation.FailureInformation != null) 46 | { 47 | TaskFailureInformation failureInformation = boundTask.ExecutionInformation.FailureInformation; 48 | Console.WriteLine($"Task {boundTask.Id} had a failure."); 49 | Console.WriteLine($"Failure Code: {failureInformation.Code}"); 50 | Console.WriteLine($"Failure Message: {failureInformation.Message}"); 51 | Console.WriteLine($"Failure Category: {failureInformation.Category}"); 52 | Console.WriteLine("Failure Details:"); 53 | 54 | foreach (NameValuePair detail in failureInformation.Details) 55 | { 56 | Console.WriteLine("{0} : {1}", detail.Name, detail.Value); 57 | } 58 | 59 | if (boundTask.ExecutionInformation.ExitCode.HasValue) 60 | { 61 | Console.WriteLine($"Task {boundTask.Id} exit code: {boundTask.ExecutionInformation.ExitCode}"); 62 | 63 | if (boundTask.ExecutionInformation.ExitCode.Value != 0) 64 | { 65 | await GetFileAsync(boundTask, Batch.Constants.StandardOutFileName); 66 | await GetFileAsync(boundTask, Batch.Constants.StandardErrorFileName); 67 | } 68 | } 69 | 70 | throw new TextSearchException($"Task {boundTask.Id} failed"); 71 | } 72 | else 73 | { 74 | await GetFileAsync(boundTask, Batch.Constants.StandardOutFileName, dumpStandardOutOnTaskSuccess); 75 | } 76 | } 77 | else 78 | { 79 | throw new TextSearchException($"Task {boundTask.Id} is not completed yet. Current state: {boundTask.State}"); 80 | } 81 | } 82 | 83 | private static async Task GetFileAsync(CloudTask boundTask, string fileName, bool dumpFile = true) 84 | { 85 | //Dump the standard out file of the task. 86 | NodeFile file = await boundTask.GetNodeFileAsync(Batch.Constants.StandardOutFileName); 87 | 88 | string fileContent = await file.ReadAsStringAsync(); 89 | if (dumpFile) 90 | { 91 | Console.WriteLine($"Task {boundTask.Id} {fileName}:"); 92 | Console.WriteLine("----------------------------------------"); 93 | Console.WriteLine(fileContent); 94 | } 95 | return fileContent; 96 | } 97 | } 98 | 99 | /// 100 | /// Custom exception type for the Text Search sample. 101 | /// 102 | public class TextSearchException : Exception 103 | { 104 | public TextSearchException(string message) : base(message) 105 | { 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /CSharp/TextSearch/Common/Settings.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System.Text; 6 | 7 | public class Settings 8 | { 9 | public bool ShouldUploadResources { get; set; } 10 | public bool ShouldDeleteJob { get; set; } 11 | public string RegularExpression { get; set; } 12 | public string InputBlobContainer { get; set; } 13 | public string OutputBlobContainer { get; set; } 14 | public int NumberOfMapperTasks { get; set; } 15 | public bool ShouldDeleteContainers { get; set; } 16 | public string PoolNodeVirtualMachineSize { get; set; } 17 | public string ImagePublisher { get; set; } 18 | public string ImageOffer { get; set; } 19 | public string ImageSku { get; set; } 20 | public string ImageVersion { get; set; } 21 | public string NodeAgentSkuId { get; set; } 22 | 23 | public override string ToString() 24 | { 25 | StringBuilder stringBuilder = new StringBuilder(); 26 | 27 | stringBuilder.AppendFormat("{0} = {1}", "NumberOfMapperTasks", this.NumberOfMapperTasks).AppendLine(); 28 | stringBuilder.AppendFormat("{0} = {1}", "ShouldUploadResources", this.ShouldUploadResources).AppendLine(); 29 | stringBuilder.AppendFormat("{0} = {1}", "ShouldDeleteJob", this.ShouldDeleteJob).AppendLine(); 30 | stringBuilder.AppendFormat("{0} = {1}", "RegularExpression", this.RegularExpression).AppendLine(); 31 | stringBuilder.AppendFormat("{0} = {1}", "InputBlobContainer", this.InputBlobContainer).AppendLine(); 32 | stringBuilder.AppendFormat("{0} = {1}", "OutputBlobContainer", this.OutputBlobContainer).AppendLine(); 33 | stringBuilder.AppendFormat("{0} = {1}", "ShouldDeleteContainers", this.ShouldDeleteContainers).AppendLine(); 34 | stringBuilder.AppendFormat("{0} = {1}", "PoolNodeVirtualMachineSize", this.PoolNodeVirtualMachineSize).AppendLine(); 35 | stringBuilder.AppendFormat("{0} = {1}", "ImagePublisher", this.ImagePublisher).AppendLine(); 36 | stringBuilder.AppendFormat("{0} = {1}", "ImageOffer", this.ImageOffer).AppendLine(); 37 | stringBuilder.AppendFormat("{0} = {1}", "ImageSku", this.ImageSku).AppendLine(); 38 | stringBuilder.AppendFormat("{0} = {1}", "NodeAgentSkuId", this.NodeAgentSkuId).AppendLine(); 39 | 40 | return stringBuilder.ToString(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CSharp/TextSearch/Common/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "shouldUploadResources": true, 3 | "shouldDeleteJob": true, 4 | "regularExpression": "I observe", 5 | "poolId": "PoolsAndResourceFilesPool", 6 | "numberOfMapperTasks": 2, 7 | "inputBlobContainer": "textsearchinputcontainer", 8 | "outputBlobContainer": "textsearchoutputcontainer", 9 | "shouldDeleteContainers": true, 10 | "poolNodeVirtualMachineSize": "standard_d2_v3", 11 | "imagePublisher": "MicrosoftWindowsServer", 12 | "imageOffer": "WindowsServer", 13 | "imageSku": "2016-Datacenter-smalldisk", 14 | "imageVersion": "latest", 15 | "nodeAgentSkuId": "batch.node.windows amd64" 16 | } 17 | -------------------------------------------------------------------------------- /CSharp/TextSearch/JobSubmitter/FileSplitter.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Threading.Tasks; 8 | 9 | /// 10 | /// Supports splitting a file into smaller subfiles based on line count. 11 | /// 12 | public class FileSplitter 13 | { 14 | /// 15 | /// Default FileSplitter constructor. 16 | /// 17 | public FileSplitter() 18 | { 19 | } 20 | 21 | /// 22 | /// Splits the file into the specified number of files. 23 | /// 24 | /// The file to split. 25 | /// The number of files to split the original file into. 26 | /// The list of file names generated by splitting the original file. 27 | public async Task> SplitAsync(string filePath, int fileCount) 28 | { 29 | List filePaths = new List(); 30 | 31 | //Load the existing file. 32 | using (FileStream fileStream = new FileStream(filePath, FileMode.Open)) 33 | { 34 | using (StreamReader streamReader = new StreamReader(fileStream)) 35 | { 36 | //Count the total number of lines in the original file. 37 | int lineCount = 0; 38 | while (!streamReader.EndOfStream) 39 | { 40 | ++lineCount; 41 | await streamReader.ReadLineAsync(); 42 | } 43 | 44 | //Compute the number of lines per file. 45 | int linesPerFile = lineCount / fileCount; 46 | 47 | streamReader.BaseStream.Seek(0, SeekOrigin.Begin); 48 | 49 | //Generate each output file. 50 | for(int i = 0; i < fileCount; i++) 51 | { 52 | string fileName = Helpers.GetSplitFileName(i); 53 | 54 | filePaths.Add(fileName); 55 | 56 | using (FileStream newFileStream = new FileStream(fileName, FileMode.Create)) 57 | { 58 | using (StreamWriter streamWriter = new StreamWriter(newFileStream)) 59 | { 60 | for (int linesInCurrentFile = 0; 61 | linesInCurrentFile < linesPerFile || 62 | (i == fileCount - 1 && !streamReader.EndOfStream); //Write any remaining lines (due to rounding) to the last file. 63 | linesInCurrentFile++) 64 | { 65 | string line = await streamReader.ReadLineAsync(); 66 | 67 | await streamWriter.WriteLineAsync(line); 68 | } 69 | } 70 | } 71 | } 72 | 73 | } 74 | } 75 | 76 | return filePaths; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /CSharp/TextSearch/JobSubmitter/JobSubmitter.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.TextSearch 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | PreserveNewest 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /CSharp/TextSearch/JobSubmitter/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System; 6 | using Common; 7 | 8 | /// 9 | /// The main program for the JobSubmitter 10 | /// 11 | public class Program 12 | { 13 | public static void Main(string[] args) 14 | { 15 | try 16 | { 17 | JobSubmitter jobSubmitter = new JobSubmitter(); 18 | 19 | jobSubmitter.RunAsync().Wait(); 20 | } 21 | catch (AggregateException e) 22 | { 23 | SampleHelpers.PrintAggregateException(e); 24 | 25 | throw; 26 | } 27 | 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /CSharp/TextSearch/MapperTask/MapperTask.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System; 6 | using System.IO; 7 | using System.Text.RegularExpressions; 8 | using System.Threading.Tasks; 9 | using Microsoft.Extensions.Configuration; 10 | 11 | /// 12 | /// The mapper task - it processes a file by performing a regular expression match on each line. 13 | /// 14 | public class MapperTask 15 | { 16 | private readonly Settings configurationSettings; 17 | private readonly string fileName; 18 | 19 | /// 20 | /// Constructs a mapper task object with the specified file name. 21 | /// 22 | /// The file name to process. 23 | public MapperTask(string fileName) 24 | { 25 | this.fileName = fileName; 26 | this.configurationSettings = new ConfigurationBuilder() 27 | .SetBasePath(Directory.GetCurrentDirectory()) 28 | .AddJsonFile("settings.json") 29 | .Build() 30 | .Get(); 31 | } 32 | 33 | /// 34 | /// Runs the mapper task. 35 | /// 36 | public async Task RunAsync() 37 | { 38 | using (FileStream fileStream = File.Open(this.fileName, FileMode.Open)) 39 | using (StreamReader streamReader = new StreamReader(fileStream)) 40 | { 41 | Regex regex = new Regex(this.configurationSettings.RegularExpression); 42 | 43 | int lineCount = 0; 44 | 45 | //Read the file content. 46 | while (!streamReader.EndOfStream) 47 | { 48 | ++lineCount; 49 | string textLine = await streamReader.ReadLineAsync(); 50 | 51 | //If the line matches the search parameters, then print it out. 52 | if (textLine.Length > 0) 53 | { 54 | if (regex.Match(textLine).Success) 55 | { 56 | Console.WriteLine("Match: \"{0}\" -- line: {1}", textLine, lineCount); 57 | } 58 | } 59 | } 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /CSharp/TextSearch/MapperTask/MapperTask.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.TextSearch 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /CSharp/TextSearch/MapperTask/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System; 6 | using Common; 7 | 8 | public class Program 9 | { 10 | public static void Main(string[] args) 11 | { 12 | if (args != null && args.Length > 0) 13 | { 14 | if (args.Length != 1) 15 | { 16 | DisplayUsage(); 17 | throw new ArgumentException("Incorrect number of arguments"); 18 | } 19 | 20 | string blobSas = args[0]; 21 | 22 | try 23 | { 24 | MapperTask mapperTask = new MapperTask(blobSas); 25 | mapperTask.RunAsync().Wait(); 26 | } 27 | catch (AggregateException e) 28 | { 29 | SampleHelpers.PrintAggregateException(e); 30 | 31 | throw; 32 | } 33 | } 34 | else 35 | { 36 | DisplayUsage(); 37 | } 38 | } 39 | 40 | /// 41 | /// Displays the usage of this executable. 42 | /// 43 | private static void DisplayUsage() 44 | { 45 | Console.WriteLine("{0} Usage:", Constants.MapperTaskExecutable); 46 | Console.WriteLine("{0} - Runs the mapper task, which downloads a file and performs a search on it", Constants.MapperTaskExecutable); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CSharp/TextSearch/ReducerTask/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System; 6 | using Common; 7 | 8 | public class Program 9 | { 10 | public static void Main(string[] args) 11 | { 12 | try 13 | { 14 | ReducerTask reducerTask = new ReducerTask(); 15 | reducerTask.Run(); 16 | } 17 | catch (AggregateException e) 18 | { 19 | SampleHelpers.PrintAggregateException(e); 20 | 21 | throw; 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /CSharp/TextSearch/ReducerTask/ReducerTask.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TextSearch 4 | { 5 | using System; 6 | using System.IO; 7 | using System.Threading.Tasks; 8 | using Common; 9 | using Microsoft.Azure.Batch.Auth; 10 | using Microsoft.Extensions.Configuration; 11 | 12 | /// 13 | /// The reducer task. This task aggregates the results from mapper tasks and prints the results. 14 | /// 15 | public class ReducerTask 16 | { 17 | private readonly Settings textSearchSettings; 18 | private readonly AccountSettings accountSettings; 19 | 20 | private readonly string accountName; 21 | private readonly string jobId; 22 | 23 | /// 24 | /// Constructs a reducer task object. 25 | /// 26 | public ReducerTask() 27 | { 28 | this.textSearchSettings = new ConfigurationBuilder() 29 | .SetBasePath(Directory.GetCurrentDirectory()) 30 | .AddJsonFile("settings.json") 31 | .Build() 32 | .Get(); 33 | this.accountSettings = SampleHelpers.LoadAccountSettings(); 34 | 35 | //Read some important data from preconfigured environment variables on the Batch compute node. 36 | this.accountName = Environment.GetEnvironmentVariable("AZ_BATCH_ACCOUNT_NAME"); 37 | this.jobId = Environment.GetEnvironmentVariable("AZ_BATCH_JOB_ID"); 38 | } 39 | 40 | /// 41 | /// Runs the reducer task. 42 | /// 43 | public void Run() 44 | { 45 | //Set up the Batch Service credentials used to authenticate with the Batch Service. 46 | BatchSharedKeyCredentials credentials = new BatchSharedKeyCredentials( 47 | this.accountSettings.BatchServiceUrl, 48 | this.accountSettings.BatchAccountName, 49 | this.accountSettings.BatchAccountKey); 50 | 51 | using (BatchClient batchClient = BatchClient.Open(credentials)) 52 | { 53 | //Gather each Mapper tasks output and write it to standard out. 54 | for (int i = 0; i < this.textSearchSettings.NumberOfMapperTasks; i++) 55 | { 56 | string mapperTaskId = Helpers.GetMapperTaskId(i); 57 | string mapperFileContent = File.ReadAllText(mapperTaskId); 58 | Console.WriteLine(mapperFileContent); 59 | Console.WriteLine(); 60 | } 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /CSharp/TextSearch/ReducerTask/ReducerTask.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.TextSearch 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /CSharp/TextSearch/TextSearch.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JobSubmitter", "JobSubmitter\JobSubmitter.csproj", "{63AABF29-A1A2-4B12-89CB-BFB5E7D90D6D}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "Common\Common.csproj", "{C3C6C51E-0BB3-4C86-95DA-913CCE289390}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MapperTask", "MapperTask\MapperTask.csproj", "{F1AF014B-B6E9-4B13-9F9B-13C3C190453B}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReducerTask", "ReducerTask\ReducerTask.csproj", "{AB57D31E-3493-48BB-8367-87F51668DC9D}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {63AABF29-A1A2-4B12-89CB-BFB5E7D90D6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {63AABF29-A1A2-4B12-89CB-BFB5E7D90D6D}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {63AABF29-A1A2-4B12-89CB-BFB5E7D90D6D}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {63AABF29-A1A2-4B12-89CB-BFB5E7D90D6D}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {C3C6C51E-0BB3-4C86-95DA-913CCE289390}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {C3C6C51E-0BB3-4C86-95DA-913CCE289390}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {C3C6C51E-0BB3-4C86-95DA-913CCE289390}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {C3C6C51E-0BB3-4C86-95DA-913CCE289390}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {F1AF014B-B6E9-4B13-9F9B-13C3C190453B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {F1AF014B-B6E9-4B13-9F9B-13C3C190453B}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {F1AF014B-B6E9-4B13-9F9B-13C3C190453B}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {F1AF014B-B6E9-4B13-9F9B-13C3C190453B}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {AB57D31E-3493-48BB-8367-87F51668DC9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {AB57D31E-3493-48BB-8367-87F51668DC9D}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {AB57D31E-3493-48BB-8367-87F51668DC9D}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {AB57D31E-3493-48BB-8367-87F51668DC9D}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /CSharp/TextSearch/readme.md: -------------------------------------------------------------------------------- 1 | ## TextSearch 2 | 3 | ### About this sample 4 | This map-reduce style sample uses Azure Batch to perform parallel text processing on an input file by splitting it up into multiple sub-files and performing regular expression matching on each sub-file. This sample makes use of a variety of Azure Batch features, such as auto-pool functionality, task `ResourceFiles` for moving data into VMs, task `OutputFiles` for moving data out of VMs, and task dependencies for specifying tasks relationships to one another. 5 | The results are then rolled-up into a final report by a reduction phase where it is uploaded to Azure Storage. 6 | 7 | #### JobSubmitter 8 | Uploads the files required for the text processing to Azure Storage and submits a job to the Azure Batch service that utilizes the auto-pool functionality. 9 | A series of mapper tasks are submitted, and a single reducer task is submitted which depends on the mapper tasks. 10 | 11 | #### MapperTask 12 | This executable performs a regular expression search on a specified file and writes the results to standard out. 13 | 14 | #### ReducerTask 15 | This executable aggregates the output of the mapper tasks. 16 | 17 | ### Configuring this sample 18 | Note: Arguments to this sample are controlled via the Common\Settings.settings, which are specific to this sample, and the AccountSettings.settings files where your Azure Batch and Storage credentials are specified. 19 | 20 | ### Running this sample 21 | The TextSearch is comprised of 3 separate projects. In order to open the sample, open the TextSearch.sln file. In order to run the sample, first configure the sample as described in the previous section and then run the [JobSubmitter](./JobSubmitter) executable. 22 | -------------------------------------------------------------------------------- /CSharp/TopNWords/Program.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | namespace Microsoft.Azure.Batch.Samples.TopNWordsSample 4 | { 5 | public class Program 6 | { 7 | public static void Main(string[] args) 8 | { 9 | //We share the same EXE for both the main program and the task 10 | //Decide which one to start based on the command line parameters 11 | if (args != null && args.Length > 0 && args[0] == "--Task") 12 | { 13 | TopNWordsTask.TaskMain(args); 14 | } 15 | else 16 | { 17 | Job.JobMain(args); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /CSharp/TopNWords/Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Azure.Batch.Samples.TopNWordsSample 8 | { 9 | public class Settings 10 | { 11 | public int NumberOfTasks { get; set; } 12 | public int PoolNodeCount { get; set; } 13 | public int TopWordCount { get; set; } 14 | public string FileName { get; set; } 15 | public string PoolId { get; set; } 16 | public string JobId { get; set; } 17 | public bool ShouldDeleteJob { get; set; } 18 | public bool ShouldDeletePool { get; set; } 19 | public bool ShouldDeleteContainer { get; set; } 20 | public string PoolNodeVirtualMachineSize { get; set; } 21 | public string ImagePublisher { get; set; } 22 | public string ImageOffer { get; set; } 23 | public string ImageSku { get; set; } 24 | public string ImageVersion { get; set; } 25 | public string NodeAgentSkuId { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /CSharp/TopNWords/TopNWords.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net462 6 | Microsoft.Azure.Batch.Samples.TopNWordsSample 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | PreserveNewest 24 | 25 | 26 | PreserveNewest 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /CSharp/TopNWords/TopNWords.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26430.12 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TopNWords", "TopNWords.csproj", "{D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Batch.Samples.Common", "..\Common\Microsoft.Azure.Batch.Samples.Common.csproj", "{612B170A-1697-4C40-BD57-26A6C8AC6534}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {D1152AF1-6D43-4C37-BF07-E2BB4F09FD90}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {612B170A-1697-4C40-BD57-26A6C8AC6534}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /CSharp/TopNWords/TopNWordsTask.cs: -------------------------------------------------------------------------------- 1 | //Copyright (c) Microsoft Corporation 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using Microsoft.WindowsAzure.Storage.Auth; 8 | using Microsoft.WindowsAzure.Storage.Blob; 9 | 10 | namespace Microsoft.Azure.Batch.Samples.TopNWordsSample 11 | { 12 | /// 13 | /// This class has the code for each task. The task reads the 14 | /// blob assigned to it and determine TopNWords and writes 15 | /// them to standard out 16 | /// 17 | public class TopNWordsTask 18 | { 19 | public static void TaskMain(string[] args) 20 | { 21 | if (args == null || args.Length != 5) 22 | { 23 | throw new Exception("Usage: TopNWordsSample.exe --Task "); 24 | } 25 | 26 | string blobName = args[1]; 27 | int numTopN = int.Parse(args[2]); 28 | string storageAccountName = args[3]; 29 | string storageAccountKey = args[4]; 30 | 31 | // open the cloud blob that contains the book 32 | var storageCred = new StorageCredentials(storageAccountName, storageAccountKey); 33 | CloudBlockBlob blob = new CloudBlockBlob(new Uri(blobName), storageCred); 34 | using (Stream memoryStream = new MemoryStream()) 35 | { 36 | blob.DownloadToStream(memoryStream); 37 | memoryStream.Position = 0; //Reset the stream 38 | var sr = new StreamReader(memoryStream); 39 | var myStr = sr.ReadToEnd(); 40 | string[] words = myStr.Split(' '); 41 | var topNWords = 42 | words. 43 | Where(word => word.Length > 0). 44 | GroupBy(word => word, (key, group) => new KeyValuePair(key, group.LongCount())). 45 | OrderByDescending(x => x.Value). 46 | Take(numTopN). 47 | ToList(); 48 | foreach (var pair in topNWords) 49 | { 50 | Console.WriteLine("{0} {1}", pair.Key, pair.Value); 51 | } 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /CSharp/TopNWords/book.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/azure-batch-samples/17fa81b07b13aaf9091d4fd6cd3664066d92ffc2/CSharp/TopNWords/book.txt -------------------------------------------------------------------------------- /CSharp/TopNWords/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "numberOfTasks": 70, 3 | "poolNodeCount": 3, 4 | "topWordCount": 10, 5 | "fileName": "book.txt", 6 | "shouldDeleteJob": true, 7 | "shouldDeletePool": false, 8 | "shouldDeleteContainer": true, 9 | "poolId": "TopNWordsPool", 10 | "jobId": "TopNWordsJob", 11 | "poolNodeVirtualMachineSize": "standard_d2_v3", 12 | "imagePublisher": "MicrosoftWindowsServer", 13 | "imageOffer": "WindowsServer", 14 | "imageSku": "2016-Datacenter-smalldisk", 15 | "imageVersion": "latest", 16 | "nodeAgentSkuId": "batch.node.windows amd64" 17 | } 18 | -------------------------------------------------------------------------------- /Java/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Auth filed 4 | *.auth 5 | *.azureauth 6 | 7 | # Mobile Tools for Java (J2ME) 8 | .mtj.tmp/ 9 | 10 | # Package Files # 11 | *.jar 12 | *.war 13 | *.ear 14 | 15 | # Azure Tooling # 16 | node_modules 17 | packages 18 | 19 | # Eclipse # 20 | *.pydevproject 21 | .project 22 | .metadata 23 | bin/** 24 | tmp/** 25 | tmp/**/* 26 | *.tmp 27 | *.bak 28 | *.swp 29 | *~.nib 30 | local.properties 31 | .classpath 32 | .settings/ 33 | .loadpath 34 | 35 | # Other Tooling # 36 | .classpath 37 | .project 38 | target 39 | .idea 40 | *.iml 41 | .java-version 42 | 43 | # Mac OS # 44 | .DS_Store 45 | .DS_Store? 46 | 47 | # Windows # 48 | Thumbs.db 49 | 50 | # reduced pom files should not be included 51 | dependency-reduced-pom.xml 52 | 53 | -------------------------------------------------------------------------------- /Java/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Java/PoolAndResourceFile/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | services: Batch 3 | platforms: java 4 | --- 5 | 6 | ## Description 7 | When run, this sample will: 8 | 9 | - Create an Azure Batch pool with a single dedicated node 10 | - Wait for the nodes to be ready 11 | - Create a storage container and upload a resource file to it 12 | - Submit a job with 5 tasks associated with the resource file 13 | - Wait for all tasks to finish 14 | - Delete the job, the pool and the storage container 15 | 16 | ## Running this Sample 17 | To run this sample: 18 | 19 | Set the following environment variables: 20 | - `AZURE_BATCH_ACCOUNT` -- The Batch account name. 21 | - `AZURE_BATCH_ACCESS_KEY` -- The Batch account key. 22 | - `AZURE_BATCH_ENDPOINT` -- The Batch account endpoint. 23 | - `STORAGE_ACCOUNT_NAME` -- The storage account to hold resource files. 24 | - `STORAGE_ACCOUNT_KEY` -- The storage account key. 25 | 26 | Clone repo and compile the code: 27 | 28 | git clone https://github.com/Azure/azure-batch-samples.git 29 | 30 | cd azure-batch-samples/Java/PoolAndResourceFile 31 | 32 | mvn clean compile exec:java -------------------------------------------------------------------------------- /Java/PoolAndResourceFile/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 4.0.0 11 | 12 | com.microsoft.azure 13 | PoolAndResourceFile 14 | 1.0.0 15 | 16 | 17 | 18 | com.microsoft.azure 19 | azure-batch 20 | 9.0.0 21 | 22 | 23 | com.microsoft.rest 24 | client-runtime 25 | 1.7.12 26 | 27 | 28 | com.microsoft.azure 29 | azure-client-runtime 30 | 1.7.12 31 | 32 | 33 | commons-codec 34 | commons-codec 35 | 1.15 36 | 37 | 38 | com.microsoft.azure 39 | azure-storage 40 | 8.6.6 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | org.apache.maven.plugins 49 | maven-jar-plugin 50 | 3.2.0 51 | 52 | 53 | 54 | true 55 | lib/ 56 | PoolAndResourceFile 57 | 58 | 59 | 60 | 61 | 62 | 63 | maven-dependency-plugin 64 | 65 | 66 | install 67 | 68 | copy-dependencies 69 | 70 | 71 | ${targetdirectory} 72 | 73 | 74 | 75 | 76 | 77 | 78 | org.codehaus.mojo 79 | exec-maven-plugin 80 | 3.0.0 81 | 82 | 83 | 84 | java 85 | 86 | 87 | 88 | 89 | PoolAndResourceFile 90 | 91 | 92 | 93 | org.apache.maven.plugins 94 | maven-compiler-plugin 95 | 96 | 8 97 | 8 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /Java/PoolAndResourceFile/test.txt: -------------------------------------------------------------------------------- 1 | This is test text. 2 | It will be printed after batch task is completed. 3 | -------------------------------------------------------------------------------- /Java/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | services: Batch 3 | platforms: java 4 | --- 5 | 6 | # General Info 7 | This directory contains sample projects showing interaction with the Azure Batch service using the Java SDK. 8 | 9 | ## Requirements 10 | To run this example, you will need to install the following: 11 | 12 | - JDK 8 or higher 13 | - [Maven](https://maven.apache.org) 14 | 15 | ## Sample Descriptions 16 | 17 | ### [PoolAndResourceFile](./PoolAndResourceFile) 18 | This sample creates a fixed pool then submits several tasks which download a resource file from a storage container then execute a simple bash script. 19 | 20 | ## More information 21 | 22 | [http://azure.com/java](http://azure.com/java) 23 | 24 | If you don't have a Microsoft Azure subscription you can get a FREE trial account [here](http://go.microsoft.com/fwlink/?LinkId=330212) 25 | -------------------------------------------------------------------------------- /Java/pom.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 4.0.0 8 | com.microsoft.azure 9 | 1.0.0 10 | azure-batch-example 11 | pom 12 | 13 | Microsoft Azure Batch SDK Sample 14 | This package contains the parent module of Microsoft Azure Batch SDK. 15 | 16 | 17 | 18 | The MIT License (MIT) 19 | http://opensource.org/licenses/MIT 20 | repo 21 | 22 | 23 | 24 | 25 | UTF-8 26 | 27 | playback 28 | 29 | 30 | 31 | 32 | microsoft 33 | Microsoft 34 | 35 | 36 | 37 | 38 | ./PoolAndResourceFile 39 | 40 | 41 | -------------------------------------------------------------------------------- /JavaScript/Node.js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejsgettingstarted", 3 | "type": "module", 4 | "version": "1.0.0", 5 | "description": "Getting started sample in Node.js for deploying Azure batch jobs", 6 | "dependencies": { 7 | "@azure/batch": "^8.0.0", 8 | "@azure/ms-rest-nodeauth": "^3.0.6" 9 | }, 10 | "main": "sample.js", 11 | "scripts": { 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "keywords": [], 15 | "author": "Shweta Gupta", 16 | "license": "ISC", 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/Azure/azure-batch-samples.git" 20 | }, 21 | "bugs": { 22 | "url": "https://github.com/Azure/azure-batch-samples/issues" 23 | }, 24 | "homepage": "https://github.com/Azure/azure-batch-samples#readme" 25 | } 26 | -------------------------------------------------------------------------------- /JavaScript/Node.js/processcsv.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import json 3 | from azure.storage.blob import BlobServiceClient 4 | import datetime 5 | import os 6 | import argparse 7 | 8 | #### Recommendation: Store these as environment variables or download it from Key Vault 9 | 10 | storage_acc_url = 'https://.blob.core.windows.net' 11 | storage_acc_key = '' 12 | block_blob_service = BlobServiceClient(account_url=storage_acc_url,credential=storage_acc_key) 13 | #### 14 | 15 | def getfilename(name): 16 | names = str(name).split('/') 17 | return names[len(names)-1] 18 | 19 | def processcsvfile(fname,seperator,outdir,outfname): 20 | header = [] 21 | isHeaderLoaded = False 22 | with open(fname) as inpfile: 23 | allrows = csv.reader(inpfile,delimiter=seperator) 24 | print("loaded file " + fname) 25 | all_vals = [] 26 | for rows in allrows: 27 | line = "" 28 | if isHeaderLoaded is False: 29 | # Getting the first line as header 30 | header = rows 31 | isHeaderLoaded = True 32 | else: 33 | if len(header) > 0: 34 | i = 0 35 | # Creating a JSON object for every row 36 | line = "{" 37 | for r in rows: 38 | if i == 0: 39 | line = line + '"' + header[i] + '":"' + r.decode('utf-8','ignore') + '"' 40 | else: 41 | line = line + "," + '"' + header[i] + '":"' + r.decode('utf-8','ignore') + '"' 42 | i = i + 1 43 | line = line + "}" 44 | all_vals.append(json.loads(json.dumps(line))) 45 | if not os.path.exists(outdir): 46 | os.makedirs(outdir) 47 | json_fpath = outdir + "/" + outfname + '.json' 48 | o = open(json_fpath,mode='w') 49 | json.dump(all_vals,o) 50 | o.close() 51 | return json_fpath 52 | 53 | if __name__ == "__main__": 54 | 55 | parser = argparse.ArgumentParser(description="Processes and stores data into hbase") 56 | parser.add_argument("--container",dest="container") 57 | parser.add_argument("--pattern",dest="pattern") 58 | 59 | args = parser.parse_args() 60 | container = args.container 61 | pattern = args.pattern 62 | 63 | container_client = block_blob_service.get_container_client(container) 64 | 65 | print("Processing files from container : " + str(container)) 66 | if pattern is not None: 67 | blob_list = container_client.list_blobs(name_starts_with=pattern) 68 | else: 69 | blob_list = container_client.list_blobs() 70 | 71 | for blob in blob_list: 72 | print("Processing blob : " + blob.name) 73 | blob_name = getfilename(blob.name) 74 | blob_name_without_extension = blob_name.split('.')[0] 75 | downloadedblob = "downloaded_" + blob_name 76 | 77 | #Download the blob locally 78 | blob_client = container_client.get_blob_client(blob.name) 79 | with open(downloadedblob, "wb") as my_blob: 80 | downloaded_blob_stream = blob_client.download_blob() 81 | my_blob.write(downloaded_blob_stream.readall()) 82 | 83 | output_dir = "" 84 | uploaded_blob_name = "" 85 | 86 | if pattern is not None: 87 | output_dir = "jsonfiles/" + container + "/" + pattern 88 | uploaded_blob_name = str(pattern + 'json/' + blob_name_without_extension + ".json") 89 | 90 | else: 91 | output_dir = "jsonfiles/" + container + "/" 92 | uploaded_blob_name = str('json/' + blob_name_without_extension + ".json") 93 | 94 | json_outpath = processcsvfile(fname=downloadedblob,seperator="|",outfname=blob_name_without_extension,outdir=output_dir) 95 | print("uploading blob " + json_outpath) 96 | with open(json_outpath, "rb") as data: 97 | container_client.upload_blob(name=uploaded_blob_name, data=data) -------------------------------------------------------------------------------- /JavaScript/Node.js/sample.js: -------------------------------------------------------------------------------- 1 | import { BatchServiceClient, BatchSharedKeyCredentials } from "@azure/batch"; 2 | 3 | // Replace values below with Batch Account details 4 | const batchAccountName = ''; 5 | const batchAccountKey = ''; 6 | const batchEndpoint = ''; 7 | 8 | // Replace values with SAS URIs of the shell script file 9 | const sh_url = ""; 10 | 11 | // Replace values with SAS URIs of the Python script file 12 | const scriptURI = ""; 13 | 14 | 15 | const credentials = new BatchSharedKeyCredentials(batchAccountName, batchAccountKey); 16 | const batchClient = new BatchServiceClient(credentials, batchEndpoint); 17 | 18 | // Pool ID 19 | const now = new Date(); 20 | const poolId = `processcsv_${now.getFullYear()}${now.getMonth()}${now.getDay()}${now.getHours()}${now.getSeconds()}`; 21 | 22 | // Job ID 23 | const jobId = "processcsvjob"; 24 | 25 | // Pool VM Image Reference 26 | const imgRef = { 27 | publisher: "Canonical", 28 | offer: "UbuntuServer", 29 | sku: "18.04-LTS", 30 | version: "latest" 31 | } 32 | // Pool VM configuraion object 33 | const vmConfig = { 34 | imageReference: imgRef, 35 | nodeAgentSKUId: "batch.node.ubuntu 18.04" 36 | }; 37 | // Number of VMs to create in a pool 38 | const numVms = 4; 39 | const vmSize = "STANDARD_D1_V2"; 40 | // Pool configuration object 41 | const poolConfig = { 42 | id: poolId, 43 | displayName: "Processing csv files", 44 | vmSize: vmSize, 45 | virtualMachineConfiguration: vmConfig, 46 | targetDedicatedNodes: numVms, 47 | enableAutoScale: false 48 | }; 49 | 50 | // Creating Batch Pool 51 | console.log("Creating pool with ID : " + poolId); 52 | const pool = batchClient.pool.add(poolConfig, function (error, result, request, response) { 53 | if (error !== null) { 54 | console.log("An error occured while creating the pool..."); 55 | console.log(error.response); 56 | } 57 | else { 58 | // If there is no error then create the Batch Job 59 | createJob(); 60 | } 61 | }); 62 | 63 | function createJob() { 64 | console.log("Creating job with ID : " + jobId); 65 | // Preparation Task configuraion object 66 | const jobPrepTaskConfig = { 67 | id: "installprereq", 68 | commandLine: "sudo sh startup_prereq.sh > startup.log", 69 | resourceFiles: [{ 'httpUrl': sh_url, 'filePath': 'startup_prereq.sh' }], 70 | waitForSuccess: true, runElevated: true, 71 | userIdentity: { 72 | autoUser: { 73 | elevationLevel: "admin", 74 | scope: "pool" 75 | } 76 | } 77 | }; 78 | 79 | // Setting Batch Pool ID 80 | const poolInfo = { poolId: poolId }; 81 | // Batch job configuration object 82 | const jobConfig = { 83 | id: jobId, 84 | displayName: "process csv files", 85 | jobPreparationTask: jobPrepTaskConfig, 86 | poolInfo: poolInfo 87 | }; 88 | 89 | // Submitting Batch Job 90 | const job = batchClient.job.add(jobConfig, function (error, result) { 91 | if (error !== null) { 92 | console.log("An error occurred while creating the job..."); 93 | console.log(error); 94 | } 95 | else { 96 | // Create tasks if the job submitted successfully 97 | createTasks(); 98 | } 99 | }); 100 | } 101 | 102 | function createTasks() { 103 | console.log("Creating tasks...."); 104 | const containerList = ["con1", "con2", "con3", "con4"]; //Replace with list of blob containers within storage account 105 | containerList.forEach(function (val, index) { 106 | console.log("Submitting task for container : " + val); 107 | const containerName = val; 108 | const taskID = containerName + "_process"; 109 | // Task configuration object 110 | const taskConfig = { 111 | id: taskID, 112 | displayName: 'process csv in ' + containerName, 113 | commandLine: 'python processcsv.py --container ' + containerName, 114 | resourceFiles: [{ 'httpUrl': scriptURI, 'filePath': 'processcsv.py' }] 115 | }; 116 | 117 | const task = batchClient.task.add(jobId, taskConfig, function (error, result) { 118 | if (error !== null) { 119 | console.log("Error occured while creating task for container " + containerName + ". Details : " + error.response); 120 | } 121 | else { 122 | console.log("Task for container : " + containerName + " submitted successfully"); 123 | } 124 | }); 125 | }); 126 | } -------------------------------------------------------------------------------- /JavaScript/Node.js/startup_prereq.sh: -------------------------------------------------------------------------------- 1 | cd $(dirname $0) 2 | sudo apt-get update | sudo apt-get upgrade 3 | sudo apt-get -y install python-pip 4 | sudo apt-get -y install git 5 | sudo apt-get -y install python-dev 6 | sudo apt-get -y install build-essential 7 | sudo apt-get -y install libssl-dev 8 | sudo apt-get -y install libffi-dev 9 | sudo pip install -U pyOpenSSL 10 | sudo pip install cryptography && echo 'y' 11 | sudo pip install azure-storage-blob --upgrade && echo 'y' -------------------------------------------------------------------------------- /JavaScript/README.md: -------------------------------------------------------------------------------- 1 | # Azure Batch JavaScript sample 2 | The set of scripts provided in the [GettingStarted](https://github.com/Azure/azure-batch-samples/tree/master/JavaScript/GettingStarted) folder is a sample of creating Azure Batch jobs using the JavaScript SDK. 3 | 4 | Please refer to a step by step explanation of these scripts at the [Azure documentation link](https://docs.microsoft.com/en-us/azure/batch/batch-nodejs-get-started). 5 | 6 | You will need to fill in Azure Batch Account details and the resource file SAS URIs 7 | 8 | ```// Setting up variables specific to Batch & storage account 9 | var accountName = ''; 10 | var accountKey = ''; 11 | var accountUrl = ''; 12 | var sh_url = ''; 13 | var scriptURI = '; 14 | ``` 15 | 16 | Also modify the [processcsv.py](https://github.com/Azure/azure-batch-samples/blob/master/Node.js/GettingStarted/processcsv.py) with your storage account credentials that contain the csv files for conversion. 17 | 18 | After the above steps are complete, you can run the sample as follows (requires [Node.js](https://nodejs.org/en/) v14 or later): 19 | 20 | > node sample -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | See the individual directory's LICENSE.txt file for the license associated 2 | with each sample. If the sample itself does not have a LICENSE.txt file, then 3 | either the parent directory will have a LICENSE.txt file covering all samples 4 | for the children or the self-contained sample file will have the license terms 5 | at the top of the file. 6 | -------------------------------------------------------------------------------- /Python/.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = 3 | **/test/* 4 | 5 | [report] 6 | exclude_lines = 7 | # Have to re-enable the standard pragma 8 | pragma: no cover 9 | 10 | # Don't complain about missing debug-only code: 11 | def __repr__ 12 | if self\.debug 13 | 14 | # Don't complain if tests don't hit defensive assertion code: 15 | raise AssertionError 16 | raise NotImplementedError 17 | 18 | # Don't complain if non-runnable code isn't run: 19 | if 0: 20 | if False: 21 | if __name__ == .__main__.: 22 | 23 | -------------------------------------------------------------------------------- /Python/.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | *.[oa] 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | env35/ 13 | env27/ 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .coverage 43 | .coverage.* 44 | .cache 45 | nosetests.xml 46 | coverage.xml 47 | *,cover 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | 56 | # Sphinx documentation 57 | docs/_build/ 58 | 59 | # PyBuilder 60 | target/ 61 | 62 | # Visual Studo 2015 cache/options directory 63 | .vs/ 64 | 65 | #PyCharm 66 | .idea/ -------------------------------------------------------------------------------- /Python/Batch/article_samples/mpi/README.md: -------------------------------------------------------------------------------- 1 | ## Azure Batch Python Article Samples 2 | 3 | ### Configuring the samples 4 | In order to run the Python samples, they must be updated with Azure Batch 5 | and Azure Storage credentials. 6 | 7 | ### Setting up the Python environment 8 | In order to run the samples, you will need a Python interpreter compatible 9 | with version 2.7 or 3.3+. You will also need to install the 10 | [Azure Batch](https://pypi.python.org/pypi/azure-batch) and 11 | [Azure Storage](https://pypi.python.org/pypi/azure-storage) python packages. 12 | Installation can be performed using the [requirements.txt](./requirements.txt) 13 | file via the command `pip install -r requirements.txt` 14 | 15 | ### MPI sample 16 | The MPI sample is an introduction to running an MPI command in Azure Batch in a 17 | Linux environment. It creates a pool with RDMA enabled virtual machines (You can 18 | use STANDARD_A8 to replace the virtual machine size if you don't have enough 19 | core quota). It submits a job to the pool, and then submits a task which 20 | performs a simple MPI pingpong command. The files required by the task are 21 | automatically uploaded to Azure Storage and then downloaded onto the nodes via 22 | Batch resource files. When the task is done, the console output of the MPI 23 | pingpong command is uploaded back to Azure Storage. 24 | 25 | For more details on MPI/RDMA, visit [here](https://docs.microsoft.com/en-us/azure/virtual-machines/linux/classic/rdma-cluster). 26 | -------------------------------------------------------------------------------- /Python/Batch/article_samples/mpi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/azure-batch-samples/17fa81b07b13aaf9091d4fd6cd3664066d92ffc2/Python/Batch/article_samples/mpi/__init__.py -------------------------------------------------------------------------------- /Python/Batch/article_samples/mpi/data/application-cmd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Command script to run pingpong performance testing on multiple machines as MPI task on Azure Batch. 3 | #Usage: application-cmd [nodes] 4 | 5 | #For more details of MPI/RDMA, visit: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/classic/rdma-cluster 6 | 7 | #Use the intel mpi exists in CentOS-HPC 7.4 image 8 | source /opt/intel/impi/5.1.3.223/bin64/mpivars.sh 9 | #prepare environment variables for intel mpi to use RDMA 10 | export I_MPI_FABRICS=shm:dapl 11 | export I_MPI_DAPL_PROVIDER=ofa-v2-ib0 12 | export I_MPI_DYNAMIC_CONNECTION=0 13 | 14 | # Run mpi application with appropriate parameters 15 | mpirun -n $1 -ppn 1 -hosts $AZ_BATCH_HOST_LIST IMB-MPI1 pingpong 16 | -------------------------------------------------------------------------------- /Python/Batch/article_samples/mpi/data/coordination-cmd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | #Command script to run pingpong performance testing on multiple machines as MPI task on Azure Batch. 3 | #Usage: coordination-cmd 4 | 5 | #For more details of MPI/RDMA, visit: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/classic/rdma-cluster 6 | 7 | #Prepare environment 8 | -------------------------------------------------------------------------------- /Python/Batch/article_samples/mpi/data/linux/openfoam/application-cmd: -------------------------------------------------------------------------------- 1 | source /opt/intel/impi/5.1.3.223/bin64/mpivars.sh 2 | export I_MPI_FABRICS=shm:dapl 3 | export I_MPI_DAPL_PROVIDER=ofa-v2-ib0 4 | export I_MPI_DYNAMIC_CONNECTION=0 5 | 6 | # Run mpi application with appropriate parameters 7 | mpirun -n $1 -ppn `nproc` --host $AZ_BATCH_HOST_LIST IMB-MPI1 pingpong 8 | -------------------------------------------------------------------------------- /Python/Batch/article_samples/mpi/requirements.txt: -------------------------------------------------------------------------------- 1 | azure-batch==6.0.0 2 | azure-storage-blob==1.3.1 3 | -------------------------------------------------------------------------------- /Python/Batch/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure-Samples/azure-batch-samples/17fa81b07b13aaf9091d4fd6cd3664066d92ffc2/Python/Batch/common/__init__.py -------------------------------------------------------------------------------- /Python/Batch/configuration.cfg: -------------------------------------------------------------------------------- 1 | [Batch] 2 | batchaccountname= 3 | batchaccountkey= 4 | batchserviceurl= 5 | 6 | [Storage] 7 | storageaccounturl= 8 | storageaccountkey= 9 | -------------------------------------------------------------------------------- /Python/Batch/requirements.txt: -------------------------------------------------------------------------------- 1 | azure-batch==12.0.0 2 | azure-storage-blob==12.8.1 3 | -------------------------------------------------------------------------------- /Python/Batch/resources/docker_starttask.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | set -o pipefail 5 | 6 | apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D 7 | echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list 8 | apt-get update 9 | apt-get purge -y lxc-docker 10 | apt-get install -y docker-engine 11 | service docker stop 12 | echo DOCKER_OPTS=\"-H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock\" >> /etc/default/docker 13 | rm -f /var/lib/docker/network/files/local-kv.db 14 | service docker start 15 | -------------------------------------------------------------------------------- /Python/Batch/resources/secret.txt: -------------------------------------------------------------------------------- 1 | Attack at dawn! 2 | -------------------------------------------------------------------------------- /Python/Batch/resources/simple_task.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # simple_task.py Code Sample 4 | # 5 | # Copyright (c) Microsoft Corporation 6 | # 7 | # All rights reserved. 8 | # 9 | # MIT License 10 | # 11 | # Permission is hereby granted, free of charge, to any person obtaining a 12 | # copy of this software and associated documentation files (the "Software"), 13 | # to deal in the Software without restriction, including without limitation 14 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | # and/or sell copies of the Software, and to permit persons to whom the 16 | # Software is furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included in 19 | # all copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 | 28 | import os 29 | 30 | 31 | if __name__ == '__main__': 32 | print("simpletask.py listing files:") 33 | for item in os.listdir('.'): 34 | print(item) 35 | -------------------------------------------------------------------------------- /Python/Batch/sample1_helloworld.cfg: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | shoulddeletejob=true 3 | poolvmsize=STANDARD_DS1_V2 4 | poolvmcount=1 -------------------------------------------------------------------------------- /Python/Batch/sample1_jobprep_and_release.cfg: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | shoulddeletejob=true 3 | poolvmsize=STANDARD_DS1_V2 4 | poolvmcount=1 -------------------------------------------------------------------------------- /Python/Batch/sample2_pools_and_resourcefiles.cfg: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | shoulddeletecontainer=true 3 | shoulddeletejob=true 4 | shoulddeletepool=true 5 | poolvmsize=STANDARD_DS1_V2 6 | poolvmcount=1 7 | -------------------------------------------------------------------------------- /Python/Batch/sample3_encrypted_resourcefiles.cfg: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | shoulddeletecontainer=true 3 | shoulddeletejob=true 4 | shoulddeletepool=true 5 | shoulddeletecert=true 6 | poolvmsize=STANDARD_DS1_V2 7 | poolvmcount=1 8 | -------------------------------------------------------------------------------- /Python/Batch/sample4_job_scheduler.cfg: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | shoulddeletejobschedule=true 3 | poolvmsize=STANDARD_DS1_V2 4 | poolvmcount=1 5 | shoulddeletecontainer=true 6 | -------------------------------------------------------------------------------- /Python/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Python/README.md: -------------------------------------------------------------------------------- 1 | ## Python Samples 2 | 3 | ### Azure Batch samples 4 | 5 | #### [Batch Samples](./Batch) 6 | Code samples showing interaction with the Azure Batch Service using the 7 | Azure Batch Python SDK. 8 | 9 | ### Azure Storage samples 10 | 11 | #### [blobxfer.py](https://github.com/Azure/blobxfer) 12 | Code sample to perform AzCopy-like blob data transfer to/from Azure Blob 13 | Storage. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | page_type: sample 3 | languages: 4 | - csharp 5 | - python 6 | - java 7 | - javascript 8 | - nodejs 9 | products: 10 | - azure 11 | - azure-batch 12 | - dotnet 13 | description: "A set of HPC and Batch related samples that demonstrate the usage of Azure Batch services along with some general utilities." 14 | --- 15 | 16 | [![Build status](https://ci.appveyor.com/api/projects/status/j3gnm8slcaysr6va/branch/master?svg=true)](https://ci.appveyor.com/project/matthchr/azure-batch-samples/branch/master) 17 | 18 | # Azure Batch Samples 19 | 20 | This GitHub repository contains a set of HPC and Batch related samples that demonstrate the usage of Microsoft Azure Batch services along with some general purpose utilities. See [http://azure.microsoft.com/services/batch/](http://azure.microsoft.com/services/batch/) for more information on the Azure Batch service. 21 | 22 | ### Batch Account 23 | Before you can interact with the Batch service, you will need a Batch service account. For detailed information on creating a Batch account, see [Create and manage an Azure Batch account in the Azure portal](https://azure.microsoft.com/documentation/articles/batch-account-create-portal/). 24 | 25 | ### Azure Storage viewer 26 | You will find it useful to have an Azure Storage viewer available to assist with managing containers and blobs, as well as observing interaction of the samples with Storage. There are a number of free viewers available including the [Microsoft Azure Storage Explorer](http://storageexplorer.com/) which is cross-platform, free, and from Microsoft. 27 | 28 | ### Batch Explorer 29 | If you would like to visualize the samples as they run try [Batch Explorer](https://azure.github.io/BatchExplorer/). Batch Explorer is a client side tool which can assist with creating, debugging and monitoring Azure Batch Applications. 30 | 31 | ### Docker Support 32 | Want to use Docker containers with Azure Batch? No problem! Visit [Batch Shipyard](https://github.com/Azure/batch-shipyard/) for more information. 33 | 34 | * * * 35 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 36 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Choose VS2017 build image 2 | image: Visual Studio 2017 3 | 4 | # Set up build options 5 | platform: Any CPU 6 | configuration: Release 7 | 8 | # Do not build on tags (GitHub only) 9 | skip_tags: true 10 | 11 | # Use a custom script to do dotnet build (build CSharp tree recursively) 12 | build_script: 13 | - ps: ./build.ps1 "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" 14 | 15 | # No tests for the samples at this time 16 | test: off 17 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Starter pipeline 2 | # Start with a minimal pipeline that you can customize to build and deploy your code. 3 | # Add steps that build, run tests, deploy, and more: 4 | # https://aka.ms/yaml 5 | 6 | trigger: 7 | - master 8 | 9 | jobs: 10 | - job: 'PythonTest' 11 | pool: 12 | vmImage: 'windows-2019' 13 | strategy: 14 | matrix: 15 | PythonMinVersion: 16 | python.version: '3.7' 17 | PythonMaxVersion: 18 | python.version: '3.10' 19 | steps: 20 | - task: UsePythonVersion@0 21 | inputs: 22 | versionSpec: '$(python.version)' 23 | - script: | 24 | python -m pip install --upgrade setuptools 25 | python -m pip install -r $(System.DefaultWorkingDirectory)/Python/Batch/requirements.txt 26 | python -m pip install coveralls flake8 pytest pytest-cov requests_mock 27 | python -m flake8 $(System.DefaultWorkingDirectory)/Python/Batch 28 | displayName: 'Run lint tests' 29 | 30 | - job: 'JavaTest' 31 | pool: 32 | vmImage: 'windows-2019' 33 | steps: 34 | - task: Maven@3 35 | inputs: 36 | mavenPomFile: '$(System.DefaultWorkingDirectory)/Java/pom.xml' 37 | mavenOptions: '-Xmx3072m' 38 | javaHomeOption: 'JDKVersion' 39 | jdkVersionOption: '1.8' 40 | jdkArchitectureOption: 'x64' 41 | publishJUnitResults: false 42 | testResultsFiles: '**/TEST-*.xml' 43 | goals: 'package' 44 | 45 | - job: 'DotNetTest' 46 | pool: 47 | vmImage: 'windows-2019' 48 | steps: 49 | - task: DotNetCoreCLI@2 50 | inputs: 51 | command: 'restore' 52 | projects: '**/*.csproj' 53 | feedsToUse: 'select' 54 | - task: DotNetCoreCLI@2 55 | inputs: 56 | command: 'build' 57 | projects: '**/*.csproj' -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | param([string]$msbuildLogger="") 2 | 3 | Set-StrictMode -Version Latest 4 | $ErrorActionPreference = "Stop" 5 | 6 | $solutions = Get-ChildItem -Filter *.sln -Recurse 7 | $msbuildSolutions = $solutions | where {$_.Name -like "BatchExplorer.sln"} 8 | # Skip MultiInstanceTasks.sln due to native dependency 9 | $skippedSolutions = $solutions | where {$_.Name -like "MultiInstanceTasks.sln"} 10 | $dotnetBuildSolutions = $solutions | where {$msbuildSolutions -notcontains $_ -and $skippedSolutions -notcontains $_} 11 | 12 | foreach($sln in $dotnetBuildSolutions) 13 | { 14 | Write-Output $sln.FullName 15 | dotnet build $sln.FullName 16 | if ($LastExitCode -ne 0) 17 | { 18 | exit $LastExitCode 19 | } 20 | } 21 | 22 | foreach($sln in $msbuildSolutions) 23 | { 24 | Write-Output $sln.FullName 25 | $slnName = $sln.FullName 26 | if($msbuildLogger -ne "") 27 | { 28 | cmd /c "nuget restore $slnName && msbuild /m $slnName /logger:`"$msbuildLogger`"" 29 | } 30 | else 31 | { 32 | cmd /c "nuget restore $slnName && msbuild /m $slnName" 33 | } 34 | if ($LastExitCode -ne 0) 35 | { 36 | exit $LastExitCode 37 | } 38 | } --------------------------------------------------------------------------------