Ref docs /// issue: CloudJob Class (Microsoft.Azure.Batch) Missing information about Bound/Unbound state of CloudJob
See original GitHub issue@marcelvb commented on Wed Apr 04 2018
Hi,
I have run into some issues with creating CloudJobs and CloudTasks from C#. I got errors such as:
System.InvalidOperationException: The property JobPreparationTask cannot be modified while the object is in the Bound state.
at Microsoft.Azure.Batch.PropertyAccessor`1.SetValue(T value, Boolean overrideReadOnly, Boolean overrideAccessControl)
System.InvalidOperationException: The property State cannot be read while the object is in the Unbound state.
at Microsoft.Azure.Batch.PropertyAccessController.ReadProperty[T](Func`1 propertyReadAction, BindingAccess allowedAccess, String propertyName)
at Microsoft.Azure.Batch.CloudJob.get_State()
System.InvalidOperationException: This object is in an invalid state. Write access is not allowed.
at Microsoft.Azure.Batch.PropertyAccessor`1.<>c__DisplayClass19_0.<SetValue>b__0()
at Microsoft.Azure.Batch.PropertyAccessor`1.SetValue(T value, Boolean overrideReadOnly, Boolean overrideAccessControl)
I’m confused when and when not I can read/write properties in relation to calls to:
JobOperations.ListJobs()
JobOperations.GetJob()
JobOperations.CreateJob()
Cloud.Job.Commit()
Cloud.Job.CommitChanges()
Cloud.Job.Refresh()
The errors thrown are not very helpful, nor is the documentation. Could you please clarify this subject a bit?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: ba097f44-6bcc-cb5a-208d-47db4415053e
- Version Independent ID: bafba85f-c12a-3396-aeee-71a3d08b8909
- Content: CloudJob Class (Microsoft.Azure.Batch)
- Content Source: xml/Microsoft.Azure.Batch/CloudJob.xml
- Service: batch
- GitHub Login: @erickson-doug
- Microsoft Alias: douge
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
CloudJob Class (Microsoft.Azure.Batch)
An Azure Batch job. ... CloudJob(). Default constructor to support mocking the CloudJob class. ... Gets the execution information for the job.
Read more >Azure Batch node gets stuck in the Unusable state due to ...
The symptom above means that the Batch service is unable to communicate with the nodes. In most cases, it's caused by VNet configuration...
Read more >Error handling and detection in Azure Batch
Learn about error handling in Batch service workflows from a development standpoint.
Read more >JobOperations.CreateJob Method - Batch
Creates an instance of CloudJob that is unbound and does not have a consistency relationship to any job in the Batch Service.
Read more >CloudJobExtensions.OutputStorageContainerName( ...
Gets the name of the Azure blob storage container for the outputs of a CloudJob.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@CamSoper - Sorry for the slow response on this.
The short answer is that this is somewhat a limitation of the design of the “Object model” layer of the Azure Batch SDK. Because we re-use the same object (for example
CloudJob
) to control multiple REST API calls, it isn’t necessarily immediately clear what mutations to theCloudJob
will/won’t be allowed to propagate to the server. That’s the reason why we have the exception related to bound/unbound state (so that at least you’ll get pushback at runtime when you try to update a property which cannot be updated). What I mean by that is, if for example you take a job and try to set theid
property after doing aGetJob
what you’re basically attempting to do is update theid
field of an existingCloudJob
in the Batch service, which isn’t allowed via the REST API.There are a few short term workarounds for you:
CloudJob
after doing aGET
you can only change properties which are “updatable” - which are listed here, specifically: constraints, metadata, onAllTasksComplete, poolInfo, priorityMicrosoft.Azure.Batch.Protocol
- see theBatchServiceClient
there. It’s APIs aren’t based on objects but rather on functions, so you’ll seeCloudJob job = batchServiceClient.GetJob()
and thenbatchServiceClient.UpdateJob(constraints, onAllTasksComplete, poolInfo, priority)
.Longer term action items for us:
///
comments which you can/can’t do. That’s pretty easy although I’m not sure it really solves the fundamental problem (can’t discover shape of API from shape of object clearly).BatchClient.JobOperations.UpdateJob(constraints, onAllTasksComplete, poolInfo, priority)
mirroring the one in the underlying protocol layer (and similarly for pool update/patch, etc). This doesn’t really solve the problem either, although it does at least give a concrete reference for what you can do in theMicrosoft.Azure.Batch
namespace. Thebound/unbound
exceptions would still be there if you chose to do update/patch via that mechanism though and tried something that wasn’t allowed.I’ll discuss this internally with my team as well and see what people think. If you have a preference between 1 and 2 above (or a better idea/feature request) feel free to let us know.
Closing this as there hasn’t been much action on it lately.