-
Notifications
You must be signed in to change notification settings - Fork 197
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
Remove redundant project config, add file-scoped namespaces #1611
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,23 +3,22 @@ | |||||
using Microsoft.Azure.Functions.Worker; | ||||||
using Microsoft.Extensions.Logging; | ||||||
|
||||||
namespace Company.Function | ||||||
namespace Company.Function; | ||||||
|
||||||
public class BlobTriggerCSharp | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could also use primary constructors.
Suggested change
Then don't even have the |
||||||
{ | ||||||
public class BlobTriggerCSharp | ||||||
{ | ||||||
private readonly ILogger<BlobTriggerCSharp> _logger; | ||||||
private readonly ILogger<BlobTriggerCSharp> _logger; | ||||||
|
||||||
public BlobTriggerCSharp(ILogger<BlobTriggerCSharp> logger) | ||||||
{ | ||||||
_logger = logger; | ||||||
} | ||||||
public BlobTriggerCSharp(ILogger<BlobTriggerCSharp> logger) | ||||||
{ | ||||||
_logger = logger; | ||||||
} | ||||||
|
||||||
[Function(nameof(BlobTriggerCSharp))] | ||||||
public async Task Run([BlobTrigger("PathValue/{name}", Connection = "ConnectionValue")] Stream stream, string name) | ||||||
{ | ||||||
using var blobStreamReader = new StreamReader(stream); | ||||||
var content = await blobStreamReader.ReadToEndAsync(); | ||||||
_logger.LogInformation($"C# Blob trigger function Processed blob\n Name: {name} \n Data: {content}"); | ||||||
} | ||||||
[Function(nameof(BlobTriggerCSharp))] | ||||||
public async Task Run([BlobTrigger("PathValue/{name}", Connection = "ConnectionValue")] Stream stream, string name) | ||||||
{ | ||||||
using var blobStreamReader = new StreamReader(stream); | ||||||
var content = await blobStreamReader.ReadToEndAsync(); | ||||||
_logger.LogInformation($"C# Blob trigger function Processed blob\n Name: {name} \n Data: {content}"); | ||||||
} | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,41 +3,40 @@ | |
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Company.Function | ||
namespace Company.Function; | ||
|
||
public class CosmosDBTriggerCSharp | ||
{ | ||
public class CosmosDBTriggerCSharp | ||
{ | ||
private readonly ILogger _logger; | ||
private readonly ILogger _logger; | ||
|
||
public CosmosDBTriggerCSharp(ILoggerFactory loggerFactory) | ||
{ | ||
_logger = loggerFactory.CreateLogger<CosmosDBTriggerCSharp>(); | ||
} | ||
public CosmosDBTriggerCSharp(ILoggerFactory loggerFactory) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend primary constructor and also switching to |
||
{ | ||
_logger = loggerFactory.CreateLogger<CosmosDBTriggerCSharp>(); | ||
} | ||
|
||
[Function("CosmosDBTriggerCSharp")] | ||
public void Run([CosmosDBTrigger( | ||
databaseName: "DatabaseValue", | ||
containerName: "ContainerValue", | ||
Connection = "ConnectionValue", | ||
LeaseContainerName = "leases", | ||
CreateLeaseContainerIfNotExists = true)] IReadOnlyList<MyDocument> input) | ||
[Function("CosmosDBTriggerCSharp")] | ||
public void Run([CosmosDBTrigger( | ||
databaseName: "DatabaseValue", | ||
containerName: "ContainerValue", | ||
Connection = "ConnectionValue", | ||
LeaseContainerName = "leases", | ||
CreateLeaseContainerIfNotExists = true)] IReadOnlyList<MyDocument> input) | ||
{ | ||
if (input != null && input.Count > 0) | ||
{ | ||
if (input != null && input.Count > 0) | ||
{ | ||
_logger.LogInformation("Documents modified: " + input.Count); | ||
_logger.LogInformation("First document Id: " + input[0].id); | ||
} | ||
_logger.LogInformation("Documents modified: " + input.Count); | ||
_logger.LogInformation("First document Id: " + input[0].id); | ||
} | ||
} | ||
} | ||
|
||
public class MyDocument | ||
{ | ||
public string id { get; set; } | ||
public class MyDocument | ||
{ | ||
public string id { get; set; } | ||
|
||
public string Text { get; set; } | ||
public string Text { get; set; } | ||
|
||
public int Number { get; set; } | ||
public int Number { get; set; } | ||
|
||
public bool Boolean { get; set; } | ||
} | ||
} | ||
public bool Boolean { get; set; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,23 +3,22 @@ | |
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Company.Function | ||
namespace Company.Function; | ||
|
||
public class EventGridBlobTriggerCSharp | ||
{ | ||
public class EventGridBlobTriggerCSharp | ||
{ | ||
private readonly ILogger<EventGridBlobTriggerCSharp> _logger; | ||
private readonly ILogger<EventGridBlobTriggerCSharp> _logger; | ||
|
||
public EventGridBlobTriggerCSharp(ILogger<EventGridBlobTriggerCSharp> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
public EventGridBlobTriggerCSharp(ILogger<EventGridBlobTriggerCSharp> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[Function(nameof(EventGridBlobTriggerCSharp))] | ||
public async Task Run([BlobTrigger("PathValue/{name}", Source = BlobTriggerSource.EventGrid, Connection = "ConnectionValue")] Stream stream, string name) | ||
{ | ||
using var blobStreamReader = new StreamReader(stream); | ||
var content = await blobStreamReader.ReadToEndAsync(); | ||
_logger.LogInformation($"C# Blob Trigger (using Event Grid) processed blob\n Name: {name} \n Data: {content}"); | ||
} | ||
[Function(nameof(EventGridBlobTriggerCSharp))] | ||
public async Task Run([BlobTrigger("PathValue/{name}", Source = BlobTriggerSource.EventGrid, Connection = "ConnectionValue")] Stream stream, string name) | ||
{ | ||
using var blobStreamReader = new StreamReader(stream); | ||
var content = await blobStreamReader.ReadToEndAsync(); | ||
_logger.LogInformation($"C# Blob Trigger (using Event Grid) processed blob\n Name: {name} \n Data: {content}"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably not encourage bad logging practices in our samples (but not sure if that is in the scope of this PR) |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can also be removed.