public void submitJob ( final String applicationId , final String storageContainerSAS , final URI jobJarUri , final String command ) throws IOException { final ResourceFile jarResourceFile = new ResourceFile ( ) . withBlobSource ( jobJarUri . toString ( ) ) . withFilePath ( AzureBatchFileNames . getTaskJarFileName ( ) ) ; // This setting will signal Batch to generate an access token and pass it to the Job Manager Task (aka the Driver) // as an environment variable. // See https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.batch.cloudtask.authenticationtokensettings // for more info. final AuthenticationTokenSettings authenticationTokenSettings = new AuthenticationTokenSettings ( ) . withAccess ( Collections . singletonList ( AccessScope . JOB ) ) ; final EnvironmentSetting environmentSetting = new EnvironmentSetting ( ) . withName ( SharedAccessSignatureCloudBlobClientProvider . AZURE_STORAGE_CONTAINER_SAS_TOKEN_ENV ) . withValue ( storageContainerSAS ) ; final JobManagerTask jobManagerTask = new JobManagerTask ( ) . withRunExclusive ( false ) . withId ( applicationId ) . withResourceFiles ( Collections . singletonList ( jarResourceFile ) ) . withEnvironmentSettings ( Collections . singletonList ( environmentSetting ) ) . withAuthenticationTokenSettings ( authenticationTokenSettings ) . withKillJobOnCompletion ( true ) . withContainerSettings ( createTaskContainerSettings ( applicationId ) ) . withCommandLine ( command ) ; LOG . log ( Level . INFO , "Job Manager (aka driver) task command: {0}" , command ) ; final JobAddParameter jobAddParameter = new JobAddParameter ( ) . withId ( applicationId ) . withJobManagerTask ( jobManagerTask ) . withJobPreparationTask ( createJobPreparationTask ( ) ) . withPoolInfo ( poolInfo ) ; client . jobOperations ( ) . createJob ( jobAddParameter ) ; }
Create a job on Azure Batch .