Skip to content

Commit e661bfe

Browse files
Jandevjayendranarumugamgamereat
authored
Releasing 1.0.0 version (#16)
* Updated readme connectionstring * Added with simple logo (#9) * Latest fn runtime (#10) * Added with simple logo * migrated to dotnet core 3.1 * Added githubaction #4 (#11) * Added with simple logo * migrated to dotnet core 3.1 * Added GA workflows * Support managed identity (#12) * Added with simple logo * migrated to dotnet core 3.1 * Added GA workflows * added support for MI * Workflow update to gitflow (#14) Swaps from using a standard name for every merge to develop to use gitversion to add just use NuGetVersionV2 which by default should include beta on develop branch * Create codeql-analysis.yml * Package updates (#15) * Updated action versions * Added new icon and package details Co-authored-by: Jayendran Arumugam <[email protected]> Co-authored-by: Alan Yeats <[email protected]>
1 parent a2b2603 commit e661bfe

File tree

12 files changed

+296
-6
lines changed

12 files changed

+296
-6
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
# ******** NOTE ********
12+
13+
name: "CodeQL"
14+
15+
on:
16+
push:
17+
branches: [ master, develop ]
18+
pull_request:
19+
# The branches below must be a subset of the branches above
20+
branches: [ master, develop ]
21+
schedule:
22+
- cron: '36 8 * * 3'
23+
24+
jobs:
25+
analyze:
26+
name: Analyze
27+
runs-on: ubuntu-latest
28+
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
language: [ 'csharp' ]
33+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
34+
# Learn more...
35+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v2
40+
41+
# Initializes the CodeQL tools for scanning.
42+
- name: Initialize CodeQL
43+
uses: github/codeql-action/init@v1
44+
with:
45+
languages: ${{ matrix.language }}
46+
# If you wish to specify custom queries, you can do so here or in a config file.
47+
# By default, queries listed here will override any specified in a config file.
48+
# Prefix the list here with "+" to use these queries and those in the config file.
49+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
50+
51+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
52+
# If this step fails, then you should remove it and run the build manually (see below)
53+
- name: Autobuild
54+
uses: github/codeql-action/autobuild@v1
55+
56+
# ℹ️ Command-line programs to run using the OS shell.
57+
# 📚 https://git.io/JvXDl
58+
59+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
60+
# and modify them (or add more) to build your code if your project
61+
# uses a compiled language
62+
63+
#- run: |
64+
# make bootstrap
65+
# make release
66+
67+
- name: Perform CodeQL Analysis
68+
uses: github/codeql-action/analyze@v1
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build, Test and Release a Beta version
2+
3+
on:
4+
push:
5+
branches: [ develop ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Fetch all history for all tags and branches
15+
run: git fetch --unshallow || true
16+
17+
- name: Install GitVersion
18+
uses: gittools/actions/gitversion/[email protected]
19+
with:
20+
versionSpec: '5.x'
21+
22+
- name: Use GitVersion
23+
id: gitversion # step id used as reference for output values
24+
uses: gittools/actions/gitversion/[email protected]
25+
26+
- run: |
27+
echo "NuGetVersion: ${{ steps.gitversion.outputs.NuGetVersionV2 }}"
28+
29+
- uses: actions/checkout@v2
30+
- name: Setup .NET Core
31+
uses: actions/setup-dotnet@v1
32+
with:
33+
dotnet-version: 3.1.301
34+
35+
- name: Install dependencies
36+
run: dotnet restore ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj
37+
38+
- name: Build
39+
run: dotnet build ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj --configuration Release --no-restore
40+
41+
- name: Test
42+
run: dotnet test ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj --no-restore --verbosity normal
43+
44+
- name: Create Release
45+
id: create_release
46+
uses: actions/create-release@v1
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
49+
with:
50+
tag_name: ${{ steps.gitversion.outputs.NuGetVersionV2 }}
51+
release_name: Release ${{ steps.gitversion.outputs.NuGetVersionV2 }}
52+
prerelease: true
53+

.github/workflows/main.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build, Test & Release to Nuget from master branch
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Fetch all history for all tags and branches
15+
run: git fetch --unshallow || true
16+
17+
- name: Install GitVersion
18+
uses: gittools/actions/gitversion/[email protected]
19+
with:
20+
versionSpec: '5.x'
21+
22+
- name: Use GitVersion
23+
id: gitversion # step id used as reference for output values
24+
uses: gittools/actions/gitversion/[email protected]
25+
26+
- run: |
27+
echo "NuGetVersion: ${{ steps.gitversion.outputs.nuGetVersion }}"
28+
echo "NuGetPreReleaseTagV2: ${{ steps.gitversion.outputs.CommitsSinceVersionSourcePadded }}"
29+
30+
- name: Setup .NET Core
31+
uses: actions/setup-dotnet@v1
32+
with:
33+
dotnet-version: 3.1.301
34+
35+
- name: Install dependencies
36+
run: dotnet restore ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj
37+
38+
- name: Build
39+
run: dotnet build ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj --configuration Release --no-restore
40+
41+
- name: Test
42+
run: dotnet test ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj --no-restore --verbosity normal
43+
44+
- name: Publish NuGet
45+
uses: brandedoutcast/[email protected]
46+
with:
47+
PROJECT_FILE_PATH: ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj
48+
VERSION_STATIC: ${{ steps.gitversion.outputs.nuGetVersion }}-${{ steps.gitversion.outputs.CommitsSinceVersionSourcePadded }}
49+
NUGET_KEY: ${{secrets.NUGET_KEY}}
50+

.github/workflows/prbuild.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Build & Test
2+
3+
on:
4+
pull_request:
5+
branches: [ main, develop ]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Setup .NET Core
15+
uses: actions/setup-dotnet@v1
16+
with:
17+
dotnet-version: 3.1.301
18+
- name: Install dependencies
19+
run: dotnet restore ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj
20+
- name: Build
21+
run: dotnet build ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj --configuration Release --no-restore
22+
- name: Test
23+
run: dotnet test ./src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj --no-restore --verbosity normal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ the default name `SqlServerConnectionString` will be used.
4646
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
4747
},
4848
"ConnectionStrings": {
49-
"SqlServerConnectionString": "Server=(localdb)\\snelstart;Database=MySqlBindingDatabase;Trusted_Connection=True",
49+
"SqlServerConnectionString": "Server=(localdb)\\myInstance;Database=MySqlBindingDatabase;Trusted_Connection=True",
5050
"providerName": "System.Data.SqlClient"
5151
}
5252
}

icon-logo.png

29 KB
Loading

src/AzureFunctions.SqlBinding/AzureFunctions.SqlBinding.csproj

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,47 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
</PropertyGroup>
7+
<PropertyGroup>
8+
<!-- For local/debug builds -->
9+
<VersionSuffix Condition=" '$(Configuration)' == 'Debug' ">debug</VersionSuffix>
10+
<!-- This is using variables that are specific to Azure Dev Ops Pipelines -->
11+
<VersionSuffix Condition=" '$(Build_SourceBranch)' == 'refs/heads/develop' ">beta.$(Build_BuildID)</VersionSuffix>
12+
<PackageId>AzureFunctions.SqlBinding</PackageId>
513
<Authors>Jan de Vries</Authors>
14+
<Company />
615
<Description>A custom binding for MS SQL Server which can be used in an Azure Function project.</Description>
716
<PackageProjectUrl>https://github.com/Jandev/azurefunctions-sqlbinding</PackageProjectUrl>
817
<RepositoryUrl>https://github.com/Jandev/azurefunctions-sqlbinding</RepositoryUrl>
918
<RepositoryType>GitHub</RepositoryType>
10-
<PackageTags>AzureFunctions Bindings SQL</PackageTags>
11-
<PackageReleaseNotes>The initial version of a SQL Server input binding for usage in Azure Functions.</PackageReleaseNotes>
19+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
20+
<PackageTags>Azure Functions, Binding, SQL, C#</PackageTags>
21+
<PackageReleaseNotes>- The initial version of a SQL Server input binding for usage in Azure Functions.
22+
- Package added with logo
23+
- Added support for Managed Service Identities via the `ISqlBindingTokenProvider`
24+
</PackageReleaseNotes>
25+
<PackageIcon>icon-logo.png</PackageIcon>
26+
<IconUrl>https://github.com/Jandev/azurefunctions-sqlbinding/blob/main/icon-logo.png</IconUrl>
27+
<Version>1.0.0</Version>
28+
<FileVersion>1.0.0.0</FileVersion>
29+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
1230
</PropertyGroup>
1331

1432
<ItemGroup>
1533
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.8" />
1634
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
1735
</ItemGroup>
1836

37+
<ItemGroup>
38+
<None Include="..\..\icon-logo.png">
39+
<Pack>True</Pack>
40+
<PackagePath></PackagePath>
41+
</None>
42+
<None Include="..\..\LICENSE">
43+
<Pack>True</Pack>
44+
<PackagePath></PackagePath>
45+
</None>
46+
</ItemGroup>
47+
1948
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+

2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
5+
namespace AzureFunctions.SqlBinding
6+
{
7+
public interface ISqlBindingTokenProvider
8+
{
9+
Task<string> GetToken(CancellationToken cancellationToken);
10+
}
11+
}

src/AzureFunctions.SqlBinding/SqlServerBinding.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.Azure.WebJobs.Description;
22
using Microsoft.Azure.WebJobs.Host.Config;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using System;
35
using System.Collections.Generic;
46
using System.Data.SqlClient;
57
using System.Dynamic;
@@ -12,6 +14,13 @@ namespace AzureFunctions.SqlBinding
1214
[Extension(nameof(SqlServerBinding))]
1315
public class SqlServerBinding : IExtensionConfigProvider
1416
{
17+
private static ISqlBindingTokenProvider tokenProvider ;
18+
public SqlServerBinding(IServiceProvider services)
19+
{
20+
21+
tokenProvider = services.GetRequiredService<ISqlBindingTokenProvider>();
22+
}
23+
1524
public void Initialize(ExtensionConfigContext context)
1625
{
1726
var rule = context.AddBindingRule<SqlServerAttribute>();
@@ -27,6 +36,11 @@ private async Task<IEnumerable<SqlServerModel>> BuildCollectionFromAttribute(
2736
var collection = new List<SqlServerModel>();
2837
using (var connection = new SqlConnection(attribute.ConnectionString))
2938
{
39+
if (tokenProvider != null)
40+
{
41+
connection.AccessToken = await tokenProvider.GetToken(cancellationToken);
42+
}
43+
3044
connection.Open();
3145
using (var command = connection.CreateCommand())
3246
{
@@ -57,6 +71,10 @@ private async Task<SqlServerModel> BuildFromAttribute(
5771
{
5872
using (var connection = new SqlConnection(attribute.ConnectionString))
5973
{
74+
if (tokenProvider != null)
75+
{
76+
connection.AccessToken = await tokenProvider.GetToken(cancellationToken);
77+
}
6078
connection.Open();
6179
using (var command = connection.CreateCommand())
6280
{
@@ -80,4 +98,6 @@ private async Task<SqlServerModel> BuildFromAttribute(
8098
}
8199
}
82100
}
101+
102+
83103
}

src/FunctionApp/FunctionApp.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
4-
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
7+
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
8+
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.0" />
9+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.9" />
810
</ItemGroup>
911
<ItemGroup>
1012
<ProjectReference Include="..\AzureFunctions.SqlBinding\AzureFunctions.SqlBinding.csproj" />

0 commit comments

Comments
 (0)