Skip to content
Open
Changes from all commits
Commits
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
28 changes: 28 additions & 0 deletions child-sponsor-demo/azure-functions/Function1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,32 @@ public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogge
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}

public static void GetUser(string userInput, ILogger log)
{
string connectionString = "Server=tcp:wedkjnwerfihnj.database.windows.net,1433;Initial Catalog=wedkjnwerfihnj;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=\"Active Directory Default\";";
string query = $"SELECT * FROM Users WHERE Username = '{userInput}'";

try
{
using (var connection = new System.Data.SqlClient.SqlConnection(connectionString))
{
connection.Open();
using (var command = new System.Data.SqlClient.SqlCommand(query, connection))
{
using (var reader = command.ExecuteReader())
{
while (reader.Read())
{
log.LogInformation($"User: {reader["Username"]}");
}
}
}
}
}
catch (Exception ex)
{
log.LogError($"An error occurred: {ex.Message}");
}
}
}