Skip to content

Commit

Permalink
make improvements to the development container so it's easier to try …
Browse files Browse the repository at this point in the history
…out things localy
  • Loading branch information
paule96 committed Oct 8, 2023
1 parent 7f93be3 commit 4bfb79f
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 51 deletions.
12 changes: 10 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@
"version": "latest"
},
"ghcr.io/devcontainers/features/dotnet": {
"version": "7",
"version": "7.0",
"additionalVersions": "6.0",
"runtimeOnly": false
},
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools": {

},
"ghcr.io/devcontainers/features/docker-in-docker": {

}
},
"customizations": {
Expand All @@ -35,6 +42,7 @@
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp",
"ms-azuretools.vscode-azurefunctions",
"ms-azuretools.vscode-bicep",
"cschleiden.vscode-github-actions",
"ms-azure-devops.azure-pipelines",
Expand Down Expand Up @@ -68,7 +76,7 @@
// * If only using Remote - Containers with a local container, uncomment this line instead:
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "dotnet restore",
"postCreateCommand": "dotnet dev-certs https --trust",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
24 changes: 15 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange"
},
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"azureFunctions.projectSubpath": "src/CZ.Azure.FileExchange.Api",
"azureFunctions.deploySubpath": "src/CZ.Azure.FileExchange.Api/bin/Release/net7.0/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish (functions)"
}
155 changes: 115 additions & 40 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,117 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/src/CZ.Azure.FileExchange/CZ.Azure.FileExchange.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
}
]
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/CZ.Azure.FileExchange.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/CZ.Azure.FileExchange.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/CZ.Azure.FileExchange.sln"
],
"problemMatcher": "$msCompile"
},
{
"label": "clean (functions)",
"command": "dotnet",
"args": [
"clean",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange.Api"
}
},
{
"label": "build (functions)",
"command": "dotnet",
"args": [
"build",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean (functions)",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange.Api"
}
},
{
"label": "clean release (functions)",
"command": "dotnet",
"args": [
"clean",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange.Api"
}
},
{
"label": "publish (functions)",
"command": "dotnet",
"args": [
"publish",
"--configuration",
"Release",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"type": "process",
"dependsOn": "clean release (functions)",
"problemMatcher": "$msCompile",
"options": {
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange.Api"
}
},
{
"type": "func",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/src/CZ.Azure.FileExchange.Api/bin/Debug/net7.0"
},
"command": "host start",
"isBackground": true,
"problemMatcher": "$func-dotnet-watch"
}
]
}
25 changes: 25 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,31 @@ Pull and run [azurite](https://github.com/azure/azurite) on your local machine.
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 mcr.microsoft.com/azure-storage/azurite
```

after that you need to configure cors rules on the storage emulator. You can do this with the following powershell script:

```powershell
$accountKey = (Read-Host -MaskInput -Prompt "Storage Account Key");
$body = "<?xml version=`"1.0`" encoding=`"utf-8`"?>
<StorageServiceProperties>
<Cors>
<CorsRule>
<AllowedOrigins>*</AllowedOrigins>
<AllowedMethods>GET,PUT,OPTIONS,HEAD</AllowedMethods>
<AllowedHeaders>*</AllowedHeaders>
<ExposedHeaders>*</ExposedHeaders>
<MaxAgeInSeconds>200</MaxAgeInSeconds>
</CorsRule>
</Cors>
</StorageServiceProperties>"
$lenght = $body.Length;
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256;
$hmacsha.key = [Convert]::FromBase64String($accountKey);
$date = (Get-Date).ToUniversalTime().ToString("R");
$test = "PUT`n`n`n$lenght`n`n`n`n`n`n`n`n`nx-ms-date:$($date)`nx-ms-version:2018-03-28`n/devstoreaccount1/devstoreaccount1`ncomp:properties`nrestype:service";
$signature1 = $hmacsha.ComputeHash([Text.Encoding]::UTF8.GetBytes($test));
$auth = [System.Convert]::ToBase64String($signature1);
Invoke-WebRequest -Method Put "http://127.0.0.1:10000/devstoreaccount1?restype=service&comp=properties" -Headers @{"Authorization" = "SharedKey devstoreaccount1:$($auth)"; "x-ms-version"= "2018-03-28"; "x-ms-date" = $date } -Body $body
```


### Publish the App
Expand Down

0 comments on commit 4bfb79f

Please sign in to comment.