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

Feature/template #40

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2d01c2e
work in progress
Sep 22, 2022
2b2a39a
init commit for templates
Sep 23, 2022
0894f76
docker for template
Sep 23, 2022
54fa7da
settings and vs extensions
Sep 23, 2022
8d4557f
renaming database
Sep 23, 2022
aadaa48
renaming database
Sep 23, 2022
9f5e050
Fixes to DBName
Sep 23, 2022
3e59452
excluding conditions for now
Sep 23, 2022
c91d898
build for template
Sep 23, 2022
67a6955
rename database
Sep 26, 2022
774b2cf
dev container configured
Sep 26, 2022
5adf94f
adding features and function core tools
Sep 26, 2022
ad2e720
fixing connections tring in docker containers
Sep 27, 2022
5cc8b57
HTTP files
Sep 27, 2022
128301e
minor updates to infra stack
Sep 27, 2022
52e2e3f
Merge remote-tracking branch 'origin' into feature/template
Sep 27, 2022
42ea8a9
developer setup in Infra
Sep 28, 2022
0537c1d
remove infra from samples
Sep 28, 2022
a6f7632
fixing rename that happend by accident
Sep 28, 2022
813cfcd
fixing some comments
Sep 28, 2022
2819e08
fixign tests
Sep 28, 2022
eb6959d
fix my HR function test
Sep 28, 2022
ee65338
fix CI
Sep 28, 2022
5c1f2be
test fix
Sep 29, 2022
23d3715
moving to tools folder
Sep 29, 2022
71f4f47
update to CI
Sep 29, 2022
d53ab46
build template
Sep 29, 2022
aa81bbc
removing extra files
Sep 29, 2022
237cdd6
more generic names
Sep 29, 2022
08fbade
stack rename
Sep 29, 2022
a17e27d
infra deployments
Sep 30, 2022
9510833
replacing . with _ in deployment info
Oct 2, 2022
9d7af42
pipeline files
Oct 2, 2022
97120d8
templates
Oct 2, 2022
64bcf34
pipeline files
Oct 2, 2022
4946903
minor
Oct 2, 2022
942f83a
health check
Oct 2, 2022
510ec22
Template project file
Oct 3, 2022
8c7a7d3
preparing for template nuget
Oct 3, 2022
a51c384
merge with main
Oct 3, 2022
1b266d9
Update nuget publish powershell.
chullybun Oct 5, 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
6 changes: 6 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ jobs:

- name: Test Docker Build
run: docker-compose -f docker-compose.myHr.yml -f docker-compose.myHr.override.yml build --build-arg LOCAL=true

- name: Build Template
run: dotnet build src/Templates/content

- name: Test Template
run: dotnet test src/Templates/content --filter Category=!WithCosmos --no-build --verbosity normal /p:CollectCoverage=true /p:Exclude="[CoreEx.TestFunction]*" /p:CoverletOutputFormat=lcov /p:CoverletOutput=./coverage/lcov3.info
8 changes: 8 additions & 0 deletions Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ services:

Service Bus should have `pendingverifications` queue used by *My.Hr* sample.

## Running SQL database only

It's possible to run only DB container for local development with

```bash
docker-compose -f docker-compose.yml -f docker-compose.override.yml -f docker-compose.DB.only.yml up
```

## To build

```bash
Expand Down
6 changes: 0 additions & 6 deletions docker-compose.myHr.override.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
version: '3.4'

# The default docker-compose.override file can use the "localhost" as the external name for testing web apps within the same dev machine.
# The ESHOP_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like:
# ESHOP_EXTERNAL_DNS_NAME_OR_IP=localhost
# but values present in the environment vars at runtime will always override those defined inside the .env file
# An external IP or DNS name has to be used (instead localhost and the 10.0.75.1 IP) when testing the Web apps and the Xamarin apps from remote machines/devices using the same WiFi, for instance.

services:

sqldata:
Expand Down
14 changes: 7 additions & 7 deletions samples/My.Hr/My.Hr.Functions/Functions/EmployeeFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,38 @@ public EmployeeFunction(WebApi webApi, EmployeeService service, IValidator<Emplo
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: MediaTypeNames.Application.Json, bodyType: typeof(Employee), Description = "Employee record")]
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Description = "Not found")]
public Task<IActionResult> GetAsync([HttpTrigger(AuthorizationLevel.Function, "get", Route = "api/employees/{id}")] HttpRequest request, Guid id)
public Task<IActionResult> GetAsync([HttpTrigger(AuthorizationLevel.Function, "get", Route = "employees/{id}")] HttpRequest request, Guid id)
=> _webApi.GetAsync(request, _ => _service.GetEmployeeAsync(id));

[FunctionName("GetAll")]
[OpenApiOperation(operationId: "GetAll", tags: new[] { "employee" })]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: MediaTypeNames.Application.Json, bodyType: typeof(List<Employee>), Description = "Employee records")]
public Task<IActionResult> GetAllAsync([HttpTrigger(AuthorizationLevel.Function, "get", Route = "api/employees")] HttpRequest request)
public Task<IActionResult> GetAllAsync([HttpTrigger(AuthorizationLevel.Function, "get", Route = "employees")] HttpRequest request)
=> _webApi.GetAsync(request, p => _service.GetAllAsync(p.RequestOptions.Paging));

[FunctionName("Create")]
[OpenApiOperation(operationId: "Create", tags: new[] { "employee" })]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.Created, Description = "Created employee record")]
public Task<IActionResult> CreateAsync([HttpTrigger(AuthorizationLevel.Function, "post", Route = "api/employees")] HttpRequest request)
public Task<IActionResult> CreateAsync([HttpTrigger(AuthorizationLevel.Function, "post", Route = "employees")] HttpRequest request)
=> _webApi.PostAsync(request, p => _service.AddEmployeeAsync(p.Value!),
statusCode: HttpStatusCode.Created, validator: _validator, locationUri: e => new Uri($"api/employees/{e.Id}", UriKind.RelativeOrAbsolute));
statusCode: HttpStatusCode.Created, validator: _validator, locationUri: e => new Uri($"employees/{e.Id}", UriKind.RelativeOrAbsolute));

[FunctionName("Update")]
[OpenApiOperation(operationId: "Update", tags: new[] { "employee" })]
[OpenApiParameter(name: "id", Description = "The employee id", Required = true, In = ParameterLocation.Path, Type = typeof(Guid))]
[OpenApiSecurity("function_key", SecuritySchemeType.ApiKey, Name = "code", In = OpenApiSecurityLocationType.Query)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: MediaTypeNames.Application.Json, bodyType: typeof(Employee), Description = "Employee record")]
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.NotFound, Description = "Not found")]
public Task<IActionResult> UpdateAsync([HttpTrigger(AuthorizationLevel.Function, "put", Route = "api/employees/{id}")] HttpRequest request, Guid id)
public Task<IActionResult> UpdateAsync([HttpTrigger(AuthorizationLevel.Function, "put", Route = "employees/{id}")] HttpRequest request, Guid id)
=> _webApi.PutAsync(request, p => _service.UpdateEmployeeAsync(p.Value!, id), validator: _validator);

[FunctionName("Patch")]
public Task<IActionResult> PatchAsync([HttpTrigger(AuthorizationLevel.Function, "patch", Route = "api/employees/{id}")] HttpRequest request, Guid id)
public Task<IActionResult> PatchAsync([HttpTrigger(AuthorizationLevel.Function, "patch", Route = "employees/{id}")] HttpRequest request, Guid id)
=> _webApi.PatchAsync(request, get: _ => _service.GetEmployeeAsync(id), put: p => _service.UpdateEmployeeAsync(p.Value!, id), validator: _validator);

[FunctionName("Delete")]
public Task<IActionResult> DeleteAsync([HttpTrigger(AuthorizationLevel.Function, "delete", Route = "api/employees/{id}")] HttpRequest request, Guid id)
public Task<IActionResult> DeleteAsync([HttpTrigger(AuthorizationLevel.Function, "delete", Route = "employees/{id}")] HttpRequest request, Guid id)
=> _webApi.DeleteAsync(request, _ => _service.DeleteEmployeeAsync(id));
}
1 change: 1 addition & 0 deletions samples/My.Hr/My.Hr.Functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Sample configuration for `local.settings.json`
"VerificationResultsQueueName": "verificationResults",

"ServiceBusConnection__fullyQualifiedNamespace": "coreex.servicebus.windows.net",
"AzureWebJobs.ServiceBusExecuteVerificationFunction.Disabled": true, // disable when service bus is not available

"HttpLogContent": "true",
"AzureFunctionsJobHost__logging__logLevel__CoreEx": "Debug",
Expand Down
57 changes: 0 additions & 57 deletions samples/My.Hr/My.Hr.Infra/Readme.md

This file was deleted.

12 changes: 0 additions & 12 deletions samples/My.Hr/My.Hr.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "My.Hr.Business", "My.Hr.Bus
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "My.Hr.Functions", "My.Hr.Functions\My.Hr.Functions.csproj", "{A62BAA55-0737-4671-BF31-89D4BE7C4097}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "My.Hr.Infra", "My.Hr.Infra\My.Hr.Infra.csproj", "{E448EFD6-5CA6-4C71-B575-1149DD7181C6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "My.Hr.Infra.Tests", "My.Hr.Infra.Tests\My.Hr.Infra.Tests.csproj", "{01B0FC8E-738D-47BB-AA57-F880532A501D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "My.Hr.UnitTest", "My.Hr.UnitTest\My.Hr.UnitTest.csproj", "{EE307518-D5FD-45B3-9A61-4451DFC44835}"
EndProject
Global
Expand Down Expand Up @@ -42,14 +38,6 @@ Global
{A62BAA55-0737-4671-BF31-89D4BE7C4097}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A62BAA55-0737-4671-BF31-89D4BE7C4097}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A62BAA55-0737-4671-BF31-89D4BE7C4097}.Release|Any CPU.Build.0 = Release|Any CPU
{E448EFD6-5CA6-4C71-B575-1149DD7181C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E448EFD6-5CA6-4C71-B575-1149DD7181C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E448EFD6-5CA6-4C71-B575-1149DD7181C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E448EFD6-5CA6-4C71-B575-1149DD7181C6}.Release|Any CPU.Build.0 = Release|Any CPU
{01B0FC8E-738D-47BB-AA57-F880532A501D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{01B0FC8E-738D-47BB-AA57-F880532A501D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{01B0FC8E-738D-47BB-AA57-F880532A501D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{01B0FC8E-738D-47BB-AA57-F880532A501D}.Release|Any CPU.Build.0 = Release|Any CPU
{EE307518-D5FD-45B3-9A61-4451DFC44835}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE307518-D5FD-45B3-9A61-4451DFC44835}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE307518-D5FD-45B3-9A61-4451DFC44835}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
26 changes: 26 additions & 0 deletions src/Templates/content/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/dotnet/.devcontainer/base.Dockerfile

# [Choice] .NET version: 6.0, 5.0, 3.1, 2.1
ARG VARIANT="6.0"
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}

# Set up machine requirements to build the repo
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends curl git

# install pulumi CLI
RUN curl -fsSL https://get.pulumi.com | sh
ENV PATH="${PATH}:/root/.pulumi/bin"

# install azure functions core tools v4
# https://github.com/Azure/azure-functions-core-tools#debian-9--10
# DEBIAN_VERSION=11
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg\
&& sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/ \
&& wget -q https://packages.microsoft.com/config/debian/11/prod.list \
&& sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list \
&& sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg \
&& sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list \
&& echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
&& sudo apt-get update \
&& sudo apt-get -y install azure-functions-core-tools-4
64 changes: 64 additions & 0 deletions src/Templates/content/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.140.1/containers/dotnetcore
{
"name": "C# (.NET 6)",
// Update the 'dockerComposeFile' list if you have more compose files or use different names.
// The .devcontainer/docker-compose.yml file contains any overrides you need/want to make.
"dockerComposeFile": "docker-compose.yml",

// The 'service' property is the name of the service for the container that VS Code should use.
"service": "dev",
"workspaceFolder": "/workspace",
"features": {
"github-cli": "2",
"azure-cli": "2.38",
"dotnet": "6.0",
"docker-from-docker": "20.10"
},
"settings": {
"files.associations": {
"*.csproj": "msbuild",
"*.fsproj": "msbuild",
"*.globalconfig": "ini",
"*.manifest": "xml",
"*.nuspec": "xml",
"*.pkgdef": "ini",
"*.projitems": "msbuild",
"*.props": "msbuild",
"*.resx": "xml",
"*.rsp": "Powershell",
"*.shproj": "msbuild",
"*.slnf": "json",
"*.targets": "msbuild",
"*.vbproj": "msbuild",
"*.vsixmanifest": "xml",
"*.vstemplate": "xml"
},
// ms-dotnettools.csharp settings
"omnisharp.disableMSBuildDiagnosticWarning": true,
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableImportCompletion": true,
"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.useModernNet": true,
"omnisharp.enableAsyncCompletion": true
},
"extensions": [
"ms-dotnettools.csharp",
"EditorConfig.EditorConfig",
"tintoy.msbuild-project-tools",
"ms-dotnettools.csharp",
"VisualStudioExptTeam.vscodeintellicode",
"ms-mssql.mssql",
"ms-vscode.azure-account",
"ms-azuretools.vscode-azureappservice",
"ms-azuretools.vscode-azurefunctions",
"ms-azuretools.vscode-docker",
"ms-dotnettools.vscode-dotnet-runtime",
"MS-vsliveshare.vsliveshare-pack",
"Azurite.azurite",
"humao.rest-client"
],
"postCreateCommand": "dotnet restore",
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [80, 1433, 7071, 7129]
}
Empty file.
49 changes: 49 additions & 0 deletions src/Templates/content/.devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: '3.8'

services:
dev:
build:
context: .
dockerfile: Dockerfile
args:
# Update 'VARIANT' to pick an NET VERSION
VARIANT: "6.0"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80
- ConnectionStrings__Database=Data Source=sqldata,1433;Initial Catalog=Company.AppName;User id=sa;Password=sAPWD23.^0;TrustServerCertificate=true
- PORT=80
volumes:
- ..:/workspace:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:sqldata

# Uncomment the next line to use a non-root user for all processes.
# user: node

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

sqldata:
build:
context: ../
dockerfile: Company.AppName.Database/Dockerfile
environment:
- ACCEPT_EULA=Y
- MSSQL_SA_PASSWORD=sAPWD23.^0
- MSSQL_TCP_PORT=1433
- MSSQL_AGENT_ENABLED=true
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionStrings__Database=Data Source=localhost,1433;Initial Catalog=Company.AppName;User id=sa;Password=sAPWD23.^0;TrustServerCertificate=true
volumes:
- app-sqldata:/var/opt/mssql

# Add "forwardPorts": ["1433"] to **devcontainer.json** to forward SQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
app-sqldata:
37 changes: 37 additions & 0 deletions src/Templates/content/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
Loading