Skip to content

Conversation

chunyu3
Copy link
Member

@chunyu3 chunyu3 commented Jan 3, 2024

Contributing to the Azure SDK

This is a prototype for end-to-end multipart/form-data support. It contains the libraries and APIs needed in System.CodeModel and Azure.Core.

  • Add Mutipart helper MultipartFormData to help construct a multipart/form-data request content (RequestContent for Azure, and RequestBody to others) and Deserialize a Mulitpart/form-data response body (BinaryData) to Model

Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.

For specific information about pull request etiquette and best practices, see this section.

@chunyu3 chunyu3 marked this pull request as draft January 3, 2024 06:36
@chunyu3 chunyu3 changed the title multipart [Draft] multipart Jan 3, 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of Request is mispelled in this file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be added in Azure.Core 2.0. Do we need it before that ships?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the options be defaulted/optional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annelo-msft This method is needed for multipart feature. I added there for current prototyping. When Azure.Core 2.0 released and I will remove the duplicate one. Thanks

And I think we can provide a default value ModelReaderWriterOptions.Json for options parameter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't ship betas of Azure.Core. Please add any beta features to Azure.Core.Experimental first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will put all Azure.Core library files in Azure.Core.Experimental first.

Great! You should also be able to put any System.ClientModel files in Azure.Core.Experimental as well in order to beta them before shipping them GA in one of the GA Core libraries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot arbitrarily upgrade package dependencies - we have to be aware of the versions Functions and PowerShell use to prevent runtime errors from trying to load multiple versions into the same environment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider adding a comment above these package references that links to the specific guidance for vetting interactions with Functions, PowerShell, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea @christothes - would you be willing to put up a PR for it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #40978 to track this. I think we have some folks that have recently investigated this that might be better suited to pick it up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @annelo-msft @christothes . But we need to use the 'MediaType' property of BinaryData which is released in latest System.Memory.Data version 8.0.0.
So what's the process to upgrade the dependency library? Thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I don't have any context around this PR but just wanted to check - this is changing the reference in the Track 1 dependencies list, was that intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @m-redding!! Super helpful. I may see if I can do this change in the new System.ClientModel PR given @KrzysztofCwalina's comment: #41016 (comment)

@JoshLove-msft, do you know how we can understand if this would be a problem for Functions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions runs against net6.0 and, for the in-proc model, will silently downgrade dependencies that the host has. We should stick with a package in the 6.0 line, if possible. If we need this, we'll have to run it past Fabio Cavalante to ensure that it won't conflict with the host.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be bumping the T1 libraries section regardless. These bumps should be made only in the T2 sections.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this in Azure.Core.Experimental for first beta release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annelo-msft This is in System.ClientModel library which will be common library for both azure and non-azure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Types in the System. namespace can also be added to Azure.Core.Experimental in order to beta them prior to GA.

Copy link
Member

@annelo-msft annelo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this feature in Azure.Core.Experimental for a first beta release.

@KrzysztofCwalina
Copy link
Member

Please add a description to this PR.

Copy link
Member

@KrzysztofCwalina KrzysztofCwalina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I realize that lot's of this code was just copied from ASP.NET, but the code is internal in ASP.NET (probably for a reason). If we want to make the APIs public, we need to do proper cleanup and review with the BCL/ASP.NET team.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this hear and not on the base type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the options be defaulted/optional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use ToMemory? It does not allocate but ToArray might. I think, you will have to multitraget to do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Please use ToMemory.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the right namespace?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this throw?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many substrings. Please use slicing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the warning disabled?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

@chunyu3 chunyu3 changed the title [Draft] multipart [Draft, DO-NOT-Merge] multipart Jan 4, 2024
@chunyu3 chunyu3 changed the title [Draft, DO-NOT-Merge] multipart [Draft, DO-Not-Merge] multipart Jan 4, 2024
@chunyu3
Copy link
Member Author

chunyu3 commented Jan 4, 2024

Please put this feature in Azure.Core.Experimental for a first beta release.

Yes. I will put all Azure.Core library files in Azure.Core.Experimental first.

@chunyu3
Copy link
Member Author

chunyu3 commented Jan 4, 2024

Please add a description to this PR.

This is a prototype of End-to-End Multipart support. I added this in the description. Thanks.

}
private BinaryData GetData()
{
BinaryData data = ModelReaderWriter.Write(_model, _options); // will call the write function in serialization file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our ModelReaderWriter can write to a sequence of buffers. But this Write method (returning BinaryData) forces the sequence to be copied to one contiguous buffer. Can we avoid that? Can we keep a sequence of buffers in ModelReadWriteRequestContent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @KrzysztofCwalina I only can find the api public static BinaryData Write<T>(T model, ModelReaderWriterOptions? options = default) where T : IPersistableModel<T> in ModelReaderWriter.cs. And I don't see a API which return a sequence of buffers.
Is it a new API which will be released in later version?

<PackageReference Update="System.Text.Encodings.Web" Version="4.5.1" />
<PackageReference Update="System.Text.Json" Version="4.7.2" />
<PackageReference Update="System.Text.Encodings.Web" Version="8.0.0" />
<PackageReference Update="System.Text.Json" Version="8.0.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know that these are not safe to upgrade past the 6.0 line due to conflicts with Functions. We also know that 6.0 is good with the currently supported versions of PowerShell.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be bumping the T1 libraries section regardless. These bumps should be made only in the T2 sections.

Copy link

github-actions bot commented May 3, 2024

Hi @chunyu3. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label May 3, 2024
@chunyu3 chunyu3 closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Core Do Not Merge no-recent-activity There has been no recent activity on this issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants