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

Updates to feature/egressExtension Part 1 #2759

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
604cecf
Typo in comments
kkeirstead Jul 19, 2022
757b878
Broken; just doing some experimenting
kkeirstead Jul 21, 2022
419eb63
Now able to pull in extensions JSON files from expected locations, in…
kkeirstead Jul 22, 2022
66dc367
Create egress-extensibility.md
kkeirstead Aug 8, 2022
3820f0b
Update egress-extensibility.md
kkeirstead Aug 8, 2022
581a517
Update egress-extensibility.md
kkeirstead Aug 8, 2022
8815f2a
Create template.md
kkeirstead Aug 8, 2022
e750d13
Rename documentation/egress-extensibility.md to documentation/egress-…
kkeirstead Aug 8, 2022
ab949f8
Update template.md
kkeirstead Aug 8, 2022
0007678
Update template.md
kkeirstead Aug 10, 2022
fd43014
Update template.md
kkeirstead Aug 10, 2022
b75675c
Completely broke off Azure Blob Storage extension from dotnet monitor…
kkeirstead Aug 18, 2022
69d2db0
Minor changes
kkeirstead Aug 18, 2022
9781efe
Swapped logging system to Console output for AzureBlobStorage; starte…
kkeirstead Aug 30, 2022
ef898cd
Made the AzureBlobStorage csproj packable
kkeirstead Sep 1, 2022
ec05a23
Don't generate documentation
kkeirstead Sep 1, 2022
198c44c
Added tool command name
kkeirstead Sep 1, 2022
7a639cf
Experimenting
kkeirstead Sep 1, 2022
3ad0085
AzureBlobStorage is now buildable by dotnet tool
kkeirstead Sep 1, 2022
a863b3d
Added in pathways for special-case extension installed by dotnet tool
kkeirstead Sep 1, 2022
62dac41
Wired through scenario that allows the default location for dotnet to…
kkeirstead Sep 1, 2022
b6e7ad5
Small tweaks
kkeirstead Sep 2, 2022
13f2453
Pulled out provider name
kkeirstead Sep 7, 2022
0b0b5e9
Split unit tests out to be part of a solution with the azure provider…
kkeirstead Sep 13, 2022
5ed4a85
Fixes to get unit tests passing
kkeirstead Sep 13, 2022
78e4977
Removing some unused files; still works
kkeirstead Oct 11, 2022
0c9c4a8
Update egress-extensibility.md
kkeirstead Sep 16, 2022
df9d4e9
Create contributors.md
kkeirstead Sep 16, 2022
2759067
Rename contributors.md to contributing-guidelines.md
kkeirstead Sep 16, 2022
55edfe0
Create how-to-use.md
kkeirstead Sep 16, 2022
b28a04f
Update contributing-guidelines.md
kkeirstead Sep 16, 2022
b10da3f
Update contributing-guidelines.md
kkeirstead Sep 27, 2022
c72e188
Update template.md
kkeirstead Sep 27, 2022
62806a5
Update how-to-use.md
kkeirstead Sep 28, 2022
15398f5
Update contributing-guidelines.md
kkeirstead Sep 28, 2022
14761e8
Update how-to-use.md
kkeirstead Sep 28, 2022
f02916f
Update egress-extensibility.md
kkeirstead Sep 28, 2022
da9f8f4
Update how-to-use.md
kkeirstead Sep 28, 2022
54720a1
Tweaks
kkeirstead Oct 12, 2022
88d08f6
Default metadata wasn't being added (and custom metadata wasn't being…
kkeirstead Oct 13, 2022
da71da9
Removing some stray comments
kkeirstead Oct 13, 2022
8b7444c
Fixed namespaces, put logging back to using ILogger
kkeirstead Oct 17, 2022
719d8b1
More cleanup
kkeirstead Oct 17, 2022
70504eb
Added in a missing log statement, fixed namespace using for tests
kkeirstead Oct 18, 2022
90dd40c
Changes to logging, removed some unnecessary files and reorganization
kkeirstead Oct 18, 2022
02251b5
Fixing small breakages from rebase
kkeirstead Oct 19, 2022
17e8f87
Some cleanup; currently having an issue with UnitTests not building
kkeirstead Oct 19, 2022
113dd89
Pulling the UnitTests changes out of this PR
kkeirstead Oct 19, 2022
56e55c9
Some cleanup, refining some rough fixes
kkeirstead Oct 19, 2022
5527c81
Updated schema, removed passing metadata (custom) for now until can s…
kkeirstead Oct 20, 2022
ee05d54
More tweaks for PR
kkeirstead Oct 20, 2022
9da2d8b
Bug fixes
kkeirstead Oct 20, 2022
da0718a
Schema update
kkeirstead Oct 20, 2022
e78601c
Pulled out some commented code
kkeirstead Oct 20, 2022
bac794f
Ripping out functionality and rolling back changes
kkeirstead Oct 21, 2022
95650b9
Ripping out functionality and rolling back changes
kkeirstead Oct 21, 2022
43d3d7a
Ripping out functionality and rolling back changes
kkeirstead Oct 21, 2022
0f440c1
Ripping out functionality and rolling back changes
kkeirstead Oct 21, 2022
7631eac
Ripping out functionality and rolling back changes
kkeirstead Oct 21, 2022
fc056cf
Ripping out functionality and rolling back changes
kkeirstead Oct 21, 2022
88a2c50
Ripping out functionality and rolling back changes
kkeirstead Oct 21, 2022
c16e4f4
Ripping out functionality and rolling back changes
kkeirstead Oct 22, 2022
29fdd6b
Fixed configuration tests
kkeirstead Oct 22, 2022
900f45f
Changes for PR
kkeirstead Oct 24, 2022
f889f0b
Update src/Extensions/AzureBlobStorage/extension.json
kkeirstead Oct 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 0 additions & 121 deletions documentation/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -965,17 +965,6 @@
"type": "object",
"additionalProperties": false,
"properties": {
"AzureBlobStorage": {
"type": [
"null",
"object"
],
"description": "Mapping of Azure blob storage egress provider names to their options.",
"default": {},
"additionalProperties": {
"$ref": "#/definitions/AzureBlobEgressProviderOptions"
}
},
"FileSystem": {
"type": [
"null",
Expand All @@ -1000,116 +989,6 @@
}
}
},
"AzureBlobEgressProviderOptions": {
"type": "object",
"additionalProperties": false,
"required": [
"AccountUri",
"ContainerName"
],
"properties": {
"AccountUri": {
"type": "string",
"description": "The URI of the Azure blob storage account.",
"format": "uri",
"minLength": 1
},
"AccountKey": {
"type": [
"null",
"string"
],
"description": "The account key used to access the Azure blob storage account."
},
"AccountKeyName": {
"type": [
"null",
"string"
],
"description": "The name of the account key used to look up the value from the Egress options Properties map."
},
"SharedAccessSignature": {
"type": [
"null",
"string"
],
"description": "The shared access signature (SAS) used to access the Azure blob and optionally queue storage accounts."
},
"SharedAccessSignatureName": {
"type": [
"null",
"string"
],
"description": "The name of the shared access signature (SAS) used to look up the value from the Egress options Properties map."
},
"ManagedIdentityClientId": {
"type": [
"null",
"string"
],
"description": "Client id of the Managed Identity used for authentication. The identity must have permissions to create containers and write to blob storage."
},
"ContainerName": {
"type": "string",
"description": "The name of the container to which the blob will be egressed. If egressing to the root container, use the \"$root\" sentinel value.",
"minLength": 1
},
"BlobPrefix": {
"type": [
"null",
"string"
],
"description": "The prefix to prepend to the blob name."
},
"CopyBufferSize": {
"type": [
"integer",
"null"
],
"description": "Buffer size used when copying data from an egress callback returning a stream to the egress callback that is provided a stream to which data is written.",
"format": "int32"
},
"QueueName": {
"type": [
"null",
"string"
],
"description": "The name of the queue to which a message will be dispatched upon writing to a blob."
},
"QueueAccountUri": {
"type": [
"null",
"string"
],
"description": "The URI of the Azure queue storage account.",
"format": "uri"
},
"QueueSharedAccessSignature": {
"type": [
"null",
"string"
],
"description": "The shared access signature (SAS) used to access the Azure queue storage account."
},
"QueueSharedAccessSignatureName": {
"type": [
"null",
"string"
],
"description": "The name of the queue shared access signature (SAS) used to look up the value from the Egress options Properties map."
},
"Metadata": {
"type": [
"null",
"object"
],
"description": "A mapping of metadata keys to environment variable names. The values of the environment variables will be added as metadata for egressed artifacts.",
"additionalProperties": {
"type": "string"
}
}
}
},
"FileSystemEgressProviderOptions": {
"type": "object",
"additionalProperties": false,
Expand Down
1 change: 1 addition & 0 deletions dotnet-monitor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.ExecuteActionApp", "src\Tests\Microsoft.Diagnostics.Monitoring.ExecuteActionApp\Microsoft.Diagnostics.Monitoring.ExecuteActionApp.csproj", "{A5A0CAAB-C200-44D2-BC93-8445C6E748AD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AzureBlobStorage", "src\Extensions\AzureBlobStorage\AzureBlobStorage.csproj", "{5ED61A7B-F0AA-45F2-9E9A-8972FF7F7278}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.Profiler.UnitTests", "src\Tests\Microsoft.Diagnostics.Monitoring.Profiler.UnitTests\Microsoft.Diagnostics.Monitoring.Profiler.UnitTests.csproj", "{A25AC517-F7C6-43C6-B892-4A447914C42C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Diagnostics.Monitoring.Profiler.UnitTestApp", "src\Tests\Microsoft.Diagnostics.Monitoring.Profiler.UnitTestApp\Microsoft.Diagnostics.Monitoring.Profiler.UnitTestApp.csproj", "{1CA2284B-A3A0-476A-9A93-A95E665E78BE}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Diagnostics.Tools.Monitor.Egress.AzureBlob
namespace Microsoft.Diagnostics.Monitoring.AzureBlobStorage
{
partial class AzureBlobEgressProvider
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,28 @@
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using Azure.Storage.Queues;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.Diagnostics.Tools.Monitor.Egress.AzureBlob
namespace Microsoft.Diagnostics.Monitoring.AzureBlobStorage
{
/// <summary>
/// Egress provider for egressing stream data to an Azure blob storage account.
/// </summary>
/// <remarks>
/// Blobs created through this provider will overwrite existing blobs if they have the same blob name.
/// </remarks>
internal partial class AzureBlobEgressProvider :
EgressProvider<AzureBlobEgressProviderOptions>
internal partial class AzureBlobEgressProvider
{
private int BlobStorageBufferSize = 4 * 1024 * 1024;
private readonly ILogger _logger;

public AzureBlobEgressProvider(ILogger<AzureBlobEgressProvider> logger)
: base(logger)
public AzureBlobEgressProvider(ILogger logger)
{
_logger = logger;
}

public override async Task<string> EgressAsync(
public async Task<string> EgressAsync(
string providerType,
string providerName,
AzureBlobEgressProviderOptions options,
Expand All @@ -54,7 +48,7 @@ public override async Task<string> EgressAsync(

BlobClient blobClient = containerClient.GetBlobClient(blobName);

Logger?.EgressProviderInvokeStreamAction(EgressProviderTypes.AzureBlobStorage);
_logger.EgressProviderInvokeStreamAction(Constants.AzureBlobStorageProviderName);
using var stream = await action(token);

// Write blob content, headers, and metadata
Expand All @@ -63,7 +57,7 @@ public override async Task<string> EgressAsync(
await SetBlobClientMetadata(blobClient, artifactSettings, token);

string blobUriString = GetBlobUri(blobClient);
Logger?.EgressProviderSavedStream(EgressProviderTypes.AzureBlobStorage, blobUriString);
_logger.EgressProviderSavedStream(Constants.AzureBlobStorageProviderName, blobUriString);

if (CheckQueueEgressOptions(options))
{
Expand All @@ -86,7 +80,7 @@ public override async Task<string> EgressAsync(
}
}

public override async Task<string> EgressAsync(
public async Task<string> EgressAsync(
string providerType,
string providerName,
AzureBlobEgressProviderOptions options,
Expand Down Expand Up @@ -119,7 +113,7 @@ public override async Task<string> EgressAsync(
//3. After 4Gi of data has been staged, the data will be commited. This can be forced earlier by flushing
//the stream.
// Since we want the data to be readily available, we automatically flush (and therefore commit) every time we fill up the buffer.
Logger?.EgressProviderInvokeStreamAction(EgressProviderTypes.AzureBlobStorage);
_logger.EgressProviderInvokeStreamAction(Constants.AzureBlobStorageProviderName);
await action(flushStream, token);

await flushStream.FlushAsync(token);
Expand All @@ -131,7 +125,7 @@ public override async Task<string> EgressAsync(
await SetBlobClientMetadata(blobClient, artifactSettings, token);

string blobUriString = GetBlobUri(blobClient);
Logger?.EgressProviderSavedStream(EgressProviderTypes.AzureBlobStorage, blobUriString);
_logger.EgressProviderSavedStream(Constants.AzureBlobStorageProviderName, blobUriString);

if (CheckQueueEgressOptions(options))
{
Expand Down Expand Up @@ -166,7 +160,7 @@ public async Task SetBlobClientMetadata(BlobBaseClient blobClient, EgressArtifac
}
else
{
Logger.DuplicateKeyInMetadata(metadataPair.Key);
_logger.DuplicateKeyInMetadata(metadataPair.Key);
}
}

Expand All @@ -177,7 +171,7 @@ public async Task SetBlobClientMetadata(BlobBaseClient blobClient, EgressArtifac
}
catch (Exception ex) when (ex is InvalidOperationException || ex is RequestFailedException)
{
Logger.InvalidMetadata(ex);
_logger.InvalidMetadata(ex);
await blobClient.SetMetadataAsync(artifactSettings.Metadata, cancellationToken: token);
}
}
Expand All @@ -186,7 +180,7 @@ public void AddConfiguredMetadataAsync(AzureBlobEgressProviderOptions options, E
{
if (artifactSettings.EnvBlock.Count == 0)
{
Logger.EnvironmentBlockNotSupported();
_logger.EnvironmentBlockNotSupported();
return;
}

Expand All @@ -198,7 +192,7 @@ public void AddConfiguredMetadataAsync(AzureBlobEgressProviderOptions options, E
}
else
{
Logger.EnvironmentVariableNotFound(metadataPair.Value);
_logger.EnvironmentVariableNotFound(metadataPair.Value);
}
}
}
Expand All @@ -210,7 +204,7 @@ private bool CheckQueueEgressOptions(AzureBlobEgressProviderOptions options)

if (queueNameSet ^ queueAccountUriSet)
{
Logger.QueueOptionsPartiallySet();
_logger.QueueOptionsPartiallySet();
}

return queueNameSet && queueAccountUriSet;
Expand Down Expand Up @@ -249,11 +243,11 @@ private async Task EgressMessageToQueue(string blobName, AzureBlobEgressProvider
}
catch (RequestFailedException ex) when (ex.Status == ((int)HttpStatusCode.NotFound))
{
Logger.QueueDoesNotExist(options.QueueName);
_logger.QueueDoesNotExist(options.QueueName);
}
catch (Exception ex)
{
Logger.WritingMessageToQueueFailed(options.QueueName, ex);
_logger.WritingMessageToQueueFailed(options.QueueName, ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.Diagnostics.Monitoring.WebApi;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Microsoft.Diagnostics.Tools.Monitor.Egress.AzureBlob
namespace Microsoft.Diagnostics.Monitoring.AzureBlobStorage
{
internal sealed partial class AzureBlobEgressProviderOptions :
IValidatableObject
Expand All @@ -25,7 +23,7 @@ IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext vali
results.Add(
new ValidationResult(
string.Format(
OptionsDisplayStrings.ErrorMessage_CredentialsMissing,
Strings.ErrorMessage_CredentialsMissing,
nameof(AccountKey),
nameof(SharedAccessSignature),
nameof(ManagedIdentityClientId))));
Expand Down
47 changes: 47 additions & 0 deletions src/Extensions/AzureBlobStorage/AzureBlobEgressProviderOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Microsoft.Diagnostics.Monitoring.AzureBlobStorage
{
/// <summary>
/// Egress provider options for Azure blob storage.
/// </summary>
internal sealed partial class AzureBlobEgressProviderOptions
{
[Required]
public Uri AccountUri { get; set; }

public string AccountKey { get; set; }

public string AccountKeyName { get; set; }

public string SharedAccessSignature { get; set; }

public string SharedAccessSignatureName { get; set; }

public string ManagedIdentityClientId { get; set; }

[Required]
public string ContainerName { get; set; }

public string BlobPrefix { get; set; }

public int? CopyBufferSize { get; set; }

public string QueueName { get; set; }

public Uri QueueAccountUri { get; set; }

public string QueueSharedAccessSignature { get; set; }

public string QueueSharedAccessSignatureName { get; set; }

public IDictionary<string, string> Metadata { get; set; }
= new Dictionary<string, string>(0);
}
}
Loading