Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure blob in flat folder structure #25078

Closed
wants to merge 6 commits into from
Closed

Azure blob in flat folder structure #25078

wants to merge 6 commits into from

Conversation

yogigrantz
Copy link

@yogigrantz yogigrantz commented Aug 20, 2020

Added an option to output Azure blob in flat folder structure with custom filename prefix

Summary of the changes (Less than 80 chars)

  • Added internal static string to store the custom prefix
  • Added public overload to include the custom name parm
  • Modified existing nested folder creation to accept the flat folder option

Addresses #25885

previous discussion: dotnet/extensions#3391

@wtgodbe
Copy link
Member

wtgodbe commented Aug 20, 2020

@JunTaoLuo who owns this package now, since it's moved from Extensions?

@JunTaoLuo
Copy link
Contributor

Good question for @Pilchie

@BrennanConroy BrennanConroy added the feature-azure Issues related to integration with Azure components (Azure App Service Logging, App Insights, etc.) label Aug 21, 2020
@Pilchie
Copy link
Member

Pilchie commented Aug 24, 2020

@davidfowl do you know who knows about this package?

@shirhatti
Copy link
Contributor

Pavel created the package and no one has touched it since.

@Pilchie
Copy link
Member

Pilchie commented Aug 25, 2020

Also tagging @javiercn.

foreach (var eventGroup in eventGroups)
{
var key = eventGroup.Key;
var blobName = $"{_appName}/{key.Year}/{key.Month:00}/{key.Day:00}/{key.Hour:00}/{_fileName}";
//var blobName = $"{_appName}/{key.Year}/{key.Month:00}/{key.Day:00}/{key.Hour:00}/{_fileName}";
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 commented out?

Copy link
Author

Choose a reason for hiding this comment

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

That code was replaced with the logic from line 66 - 74 because it forces nested folder in Azure blob. Line 71 produces a flat folder structure, while line 74 produces the original nested folder structure where the code was commented out.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it be removed then? Why did you leave the code in but commented out?

Copy link
Author

Choose a reason for hiding this comment

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

Yes you're right, it should be removed. I will remove it and commit my change

Copy link
Author

Choose a reason for hiding this comment

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

@davidfowl : I removed the commented out code, committed and pushed. This is my first time contributing, and I was not sure whether to leave commented out original code or to delete. But now I know to go ahead and delete when deemed not needed. Thank you.

Copy link
Author

Choose a reason for hiding this comment

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

@davidfowl : After removing the commented our code, it would not pass the checks. Could you please advise what might have gone wrong, could this be something on the CI side?

Copy link
Author

Choose a reason for hiding this comment

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

@davidfowl : The build is ready for your review. Could you please revisit this PR? Thank you!

@wtgodbe
Copy link
Member

wtgodbe commented Aug 26, 2020

We were having some issues with our selenium tests, they should be fixed now. This should pass on retry

@wtgodbe
Copy link
Member

wtgodbe commented Aug 26, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@yogigrantz
Copy link
Author

Azure Pipelines successfully started running 2 pipeline(s).

still failing? hmmm.... could we try again please?

@wtgodbe
Copy link
Member

wtgodbe commented Aug 27, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@wtgodbe
Copy link
Member

wtgodbe commented Aug 27, 2020

@yogigrantz the CI failures are unrelated, we're having some issues w/ our template tests at the moment. Should hopefully be resolved soon.

@yogigrantz
Copy link
Author

@yogigrantz the CI failures are unrelated, we're having some issues w/ our template tests at the moment. Should hopefully be resolved soon.

Thank you William!

@Pilchie Pilchie added the community-contribution Indicates that the PR has been added by a community member label Aug 27, 2020
@wtgodbe
Copy link
Member

wtgodbe commented Aug 27, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@yogigrantz
Copy link
Author

/azp run

still failing ... I should have deleted that line in the first place :(

@Pilchie
Copy link
Member

Pilchie commented Aug 29, 2020

/azp run

@Pilchie
Copy link
Member

Pilchie commented Aug 29, 2020

Let's give it another shot.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@Pilchie
Copy link
Member

Pilchie commented Aug 29, 2020

@davidfowl or @javiercn - can one of you review this?

@yogigrantz
Copy link
Author

Let's give it another shot.

All checks have passed now :) Thank you All!

@BrennanConroy BrennanConroy added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Sep 14, 2020
@yogigrantz
Copy link
Author

@davidfowl @javiercn @Pilchie @wtgodbe @JunTaoLuo @shirhatti
Could I please have this pull request approved before the CI automatically closes this issue. This feature is very important to our company to avoid workaround custom/duplicate Extension API.

I can put sample Azure application in GitHub if that helps?. Please do let me know. Thank you so much, appreciate your time!

@dougbu
Copy link
Member

dougbu commented Oct 15, 2020

@dougbu could you remind me how to do that?

I strongly recommend not trying to change the PublicAPI.Unshipped.txt files manually. The analyzer has fairly nice fixers that work only in Visual Studio. So,

  1. Open a (preferably small) *.slnf file containing the project with API changes in VS
  2. Build the solution
  3. Click on one of the errors
  4. Use the light bulb 💡 or right click to fix the error globally. I say globally because it's a pain to click on every error and fix it individually
  5. For errors at a lower level than added, changed, or removed surface area, you may need to either fix the API or suppress the error e.g. https://github.com/dotnet/aspnetcore/blob/master/src/Components/Components/src/EventCallbackFactoryBinderExtensions.cs#L35

@dougbu
Copy link
Member

dougbu commented Oct 15, 2020

Oh, it may be necessary to repeat the above in VS because the first round didn't get far enough to hit all of the public API issues

public static ILoggingBuilder AddAzureWebAppDiagnostics(this ILoggingBuilder builder)
/// <param name="customPrefix"></param>
/// <returns></returns>
public static ILoggingBuilder AddAzureWebAppDiagnostics(this ILoggingBuilder builder, string customPrefix = null)
Copy link
Member

Choose a reason for hiding this comment

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

@Pilchie is this a binary breaking change?

Copy link
Member

Choose a reason for hiding this comment

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

Absolutely.

Copy link
Member

Choose a reason for hiding this comment

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

Overloads are binary breaking safe, optional parameters are not - think about how they work, the method always receives two arguments, it's just that if you don't specify it, the compiler burns in the default value at the call-site.

Copy link
Author

Choose a reason for hiding this comment

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

My bad, I removed the optional parm and went ahead and created an overload instead. But CI still shows this optional parm error, even though I renamed the parameter.
@Pilchie @davidfowl
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple public overloads with optional parameters"

YogiGrantz added 2 commits October 16, 2020 11:02
Removed the optional parameter, created overload to handle the extra parameter
Gihub repository did not take my change for removig the optional = null, so I am renaming the parm
@yogigrantz
Copy link
Author

Please discard my version of AspNetCore.sln. It was inadvertently pushed to my repository

@yogigrantz
Copy link
Author

Could someone please help me out? I accidentally pushed AspnetCore.sln. Now it is in conflict. I'd appreciate if someone with write access can resolve conflicts by replacing my version with the current master version. Thank you!

@BrennanConroy
Copy link
Member

You should be able to fix it fairly easily:

git revert --hard HEAD~2
# redo the parameter naming change
git add <file>
git commit -m "param rename"
git push -f

@yogigrantz
Copy link
Author

@BrennanConroy when I typed git revert --hard HEAD~2 it would not take. it gave me the help menu, shown in this screenshot:
gitCapture

@BrennanConroy
Copy link
Member

Whoops, I meant reset. git reset --hard HEAD~2

@yogigrantz
Copy link
Author

Brennan: I followed your steps. Not sure if the .sln file was recovered? But could I have another rebuild please? I think the last build broke with #L39

Renamed the parm back. Hoping to get a clean build
@yogigrantz
Copy link
Author

@wtgodbe : is there anything I could do to fix this error ?src/Logging.AzureAppServices/src/AzureAppServicesLoggerFactoryExtensions.cs(39,39): error RS0016: (NETCORE_ENGINEERING_TELEMETRY=Build) Symbol 'AddAzureWebAppDiagnostics' is not part of the declared API.

@dougbu
Copy link
Member

dougbu commented Oct 21, 2020

is there anything I could do to fix this error ?

If you have Visual Studio 16.8 or later installed,

  1. .\restore.cmd to ensure the .dotnet/ folder is up-to-date
  2. .\startvs.cmd src\Logging.AzureAppServices\src\Microsoft.Extensions.Logging.AzureAppServices.csproj
  3. build the project e.g. [F6]
  4. click on the RS0016 message in the error window
  5. use the light bulb menu or right click the line and add the method to the public API files
  6. commit the change and update this branch 😺

@yogigrantz
Copy link
Author

yogigrantz commented Oct 21, 2020

Would this work in VS 16.7.6? because when I checked my VS it says 16.7.6 and that's the latest update.

When I followed your steps I did not get any errors. I took the screenshots below. I'm installing the 16.8 preview 3.1 version now ...

vs1676
prepOK
buildsOK

With VS 16.8 Preview 5.0 (from Visual Studio):

WithVS168RV5

@dougbu
Copy link
Member

dougbu commented Oct 21, 2020

Would this work in VS 16.7.6?

@mavasani @sharwell do the public API analyzers and fixers work correctly in 16.7.6❔ I'm surprised @yogigrantz's build was successful.

@yogigrantz it's possible VS thought the project was up-to-date. You may need to rebuild instead of build to get the error seen on the CI.

Another idea would be to use the public preview version of Visual Studio. Easy way to get that is .\eng\scripts\InstallVisualStudio.ps1 -Channel Preview -Edition Community.

@yogigrantz
Copy link
Author

@dougbu : The rebuild works both in 16.7.6 and 16.8 Preview 5.0. When I downloaded preview 3.1 it gave me version 5.0 btw so I could not get 3.1.

The .\restore.cmd failed on 16.8 preview 5.0.

Also, when I ran this script: .\eng\scripts\InstallVisualStudio.ps1 -Channel Preview -Edition Community it was pointing to version 16.7.6

@dougbu
Copy link
Member

dougbu commented Oct 21, 2020

The rebuild works both in 16.7.6 and 16.8 Preview 5.0.

I don't understand this and hope @mavasani or @sharwell can help out here.

When I downloaded preview 3.1 it gave me version 5.0 btw so I could not get 3.1

I didn't mention a specific preview of VS 16.8. Preview 5 is fine.

it was pointing to version 16.7.6

What pointed to version 16.7.6❔ If you mean the version of VS that startvs.cmd chose to start, That would mean the default is still your previous VS installation.

You can change the association for *.csproj files to use the Preview version of VS by default. Or, you can set $env:VSINSTALLDIR to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community_Pre" before using .\startvs.cmd. The InstallVisualStudio.ps1 command I provided should have installed VS 16.8 there.

@mavasani
Copy link

@dougbu @yogigrantz You are likely hitting dotnet/msbuild#3046, which is applicable to every MSBuild warning, not just analyzer warnings.

@yogigrantz
Copy link
Author

@dougbu : What pointed to version 16.7.6❔ Sorry for the confusion. when I copied your command line, it errored out. So I went ahead and opened InstallVisualStudio.ps1 with powershell and ran it manually. At that point it opened up the Installer option dialog for Enterprise edition, 16.7.6 . After that I changed the value for $Edition and $Channel as shown on the screenshot, but all it does is open the installer dialog with items that I already installed checked out. Is this step for verifying whether I have the correct Visual Studio?
VSInstaller

@yogigrantz
Copy link
Author

@mavasani : In our case we don't have any warning though. I build with --no-incremental and still, no warning

nowarning

@dougbu
Copy link
Member

dougbu commented Oct 22, 2020

@yogigrantz for the questions you asked me: The InstallVisualStudio.ps1 file is intended to run from within PowerShell and we don't have a .bat or .cmd file anywhere to make it easier to use from cmd. When run without -quiet or -passive, the script does indeed open the installer dialogue. You need to click Install, Modify, or Update to complete the installation or upgrade.

@yogigrantz
Copy link
Author

@dougbu ok I followed thru with update and everything went well. I did another build, it built successfully. 0 Warning 0 Error. There is no changed file in my repository, so there is nothing to commit or push. @mavasani : when there is no warning and no error, does this situation in dotnet/msbuild#304 still apply? Could you please advise how I should resolve it?

@yogigrantz
Copy link
Author

yogigrantz commented Oct 30, 2020

Hi, since my repository was too far behind I deleted it and reforked and recloned aspnetcore from the master branch. The current global.json says sdk "version": "6.0.100-alpha.1.20523.3". Should I download this sdk to build the solution, because I have 5.0-rc2 in my machine and it would not build this solution now. If I modify global.json chances are, when I try to merge it would fail the build again. Also I did not see SDK 6.0 being available to download. Please advise and give the link if I should use 6.0, thank you!
@dougbu @mavasani @wtgodbe

@dougbu
Copy link
Member

dougbu commented Oct 30, 2020

Should I download this sdk to build the solution, because I have 5.0-rc2 in my machine and it would not build this solution now.

Run the ./build.cmd script w/ pretty much any option to install the required SDK and runtimes in the .dotnet/ folder. The startvs.cmd ensures Visual Studio uses that folder and not the globally-installed dotnet. All command-line builds also ignore the globally-installed dotnet.

@yogigrantz
Copy link
Author

yogigrantz commented Oct 31, 2020

Started over from fresh copy of dotnetcore master branch 10/3/2020 -> pull request #27383. I updated / fixed the UnitTest and added the new method definition in src/Logging.AzureAppServices/src/PublicAPI.Unshipped.txt . Now getting only 3 failures
. Could you please let me know whether this failure come from the CI or from the application? Thank you!
@dougbu @wtgodbe

@dougbu
Copy link
Member

dougbu commented Oct 31, 2020

@yogigrantz you need to use Visual Studio to update the src/Logging.AzureAppServices/src/PublicAPI.Unshipped.txt file. It should include the added AddAzureWebAppDiagnostics overload.

You may need to remove the .\artifacts\bin\Microsoft.Extensions.Logging.AzureAppServices\ folder and perhaps .\artifacts\obj\Microsoft.Extensions.Logging.AzureAppServices\ to ensure the VS build actually hits the error.

@yogigrantz
Copy link
Author

Transferring to #27383 -> Fresh reclone

@yogigrantz yogigrantz closed this Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation community-contribution Indicates that the PR has been added by a community member feature-azure Issues related to integration with Azure components (Azure App Service Logging, App Insights, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants