diff --git a/.github/workflows/1-pr.yaml b/.github/workflows/1-pr.yaml
index c6d8f9f44..f6c635e81 100644
--- a/.github/workflows/1-pr.yaml
+++ b/.github/workflows/1-pr.yaml
@@ -11,7 +11,7 @@ env:
DLL_FILE_PATH: "./bin/Release/net6.0/CarbonAware.WebApi.dll"
DOTNET_SRC_DIR: "./src"
# console app packages
- DOTNET_SOLUTION: "src/GSF.CarbonAware/src/GSF.CarbonAware.csproj"
+ DOTNET_SOLUTION: "src/CarbonAwareSDK.sln"
OUTPUT_DIR: "packages"
CONSOLE_APP: "samples/lib-integration/ConsoleApp/ConsoleApp.csproj"
CREATE_PKGS: "scripts/package/create_packages.ps1"
diff --git a/.github/workflows/verify-azure-function-with-packages.yaml b/.github/workflows/verify-azure-function-with-packages.yaml
index d5faa3dba..b3a52e3d5 100644
--- a/.github/workflows/verify-azure-function-with-packages.yaml
+++ b/.github/workflows/verify-azure-function-with-packages.yaml
@@ -29,23 +29,28 @@ jobs:
- name: Docker Target Final
run: |
docker build --no-cache . -f ${{ env.DOCKERFILE_PATH }} -t ${{ env.CONTAINER_IMAGE_NAME }}
- docker rmi -f $(docker images -f "dangling=true" -q)
+ docker image prune -f
- name: Docker Run Container
- run: docker run -d --name ${{ env.CONTAINER_RUNTIME_NAME }} -p 8080:80 ${{ env.CONTAINER_IMAGE_NAME }}
+ run: |
+ docker run -d --name ${{ env.CONTAINER_RUNTIME_NAME }} -p 8080:80 ${{ env.CONTAINER_IMAGE_NAME }}
+ timeout 30 bash -c -- 'while [ -z "$(docker ps -q)" ]; do echo "waiting for container to start" && sleep 5s; done'
+ docker ps
# Request fails with authentication error. Expected
- name: Get Average Carbon Intensity
run: |
set +e
- ret_code=$(wget -S -t 5 --waitretry=5 "http://0.0.0.0:8080/api/GetAverageCarbonIntensity?startDate=2022-03-01T15:30:00Z&endDate=2022-03-01T18:30:00Z&location=eastus" 2>&1 | grep "HTTP/" | awk '{print $2}')
+ ret_code=$(wget --server-response "http://0.0.0.0:8080/api/GetAverageCarbonIntensity?startDate=2022-03-01T15:30:00Z&endDate=2022-03-01T18:30:00Z&location=eastus" 2>&1 | awk '/^ HTTP/{print $2}')
+ echo "Return Code: $ret_code"
set -e
- [ "401" == $ret_code ]
+ [ "401" = "$ret_code" ]
# Request fails with authentication error. Expected
- name: Get Current Forecast
run: |
set +e
- ret_code=$(wget -S -t 5 --waitretry=5 "http://0.0.0.0:8080/api/GetCurrentForecast" --header "Content-Type: application/json" --post-data '{"startDate":"2022-11-02T15:30:00Z","endDate":"2022-11-02T18:30:00Z","location":"eastus","duration":"15"}' 2>&1 | grep "HTTP/" | awk '{print $2}')
+ ret_code=$(wget --server-response "http://0.0.0.0:8080/api/GetCurrentForecast" --header "Content-Type: application/json" --post-data '{"startDate":"2022-11-02T15:30:00Z","endDate":"2022-11-02T18:30:00Z","location":"eastus","duration":"15"}' 2>&1 | awk '/^ HTTP/{print $2}')
+ echo "Return Code: $ret_code"
set -e
- [ "401" == $ret_code ]
+ [ "401" = "$ret_code" ]
diff --git a/.gitignore b/.gitignore
index 70926da57..376132234 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,6 @@ src/data/location-sources/custom-azure-zones.json
# exclude artifacts on java-client example
samples/java-client/target
+
+# exclude artifacts from default package builder
+/packages
\ No newline at end of file
diff --git a/docs/packaging.md b/docs/packaging.md
index 0ae684e22..2d36c3f93 100644
--- a/docs/packaging.md
+++ b/docs/packaging.md
@@ -18,21 +18,21 @@ showing how the package can be consumed.
- [Console App Sample](#console-app-sample)
- [Run the Sample Console App](#run-the-sample-console-app)
-## Included Projects
+## Included Packages
-The current package include 7 projects from the SDK:
+The current solution creates 5 packages from the SDK projects:
1. "GSF.CarbonAware"
-2. "CarbonAware"
-3. "CarbonAware.DataSources.ElectricityMapsFree"
-4. "CarbonAware.DataSources.ElectricityMaps"
-5. "CarbonAware.DataSources.Json"
-6. "CarbonAware.DataSources.WattTime"
-7. "CarbonAware.LocationSources"
-
-These 7 projects enable users of the library to consume the current endpoints
-exposed by the library. The package that needs to be added to a new C# project
-is `GSF.CarbonAware`.
+ 1. "CarbonAware"
+ 2. "CarbonAware.LocationSources"
+2. "CarbonAware.DataSources.ElectricityMapsFree"
+3. "CarbonAware.DataSources.ElectricityMaps"
+4. "CarbonAware.DataSources.Json"
+5. "CarbonAware.DataSources.WattTime"
+
+Adding the `GSF.CarbonAware` project to your C# projects gives you access to all
+CarbonAware SDK interfaces.
+Additionally, operators must add any data source packages they plan to use.
## Included Scripts
diff --git a/samples/azure/azure-function/Dockerfile b/samples/azure/azure-function/Dockerfile
index 53316cbf0..af8b9e9de 100644
--- a/samples/azure/azure-function/Dockerfile
+++ b/samples/azure/azure-function/Dockerfile
@@ -10,7 +10,9 @@ COPY ["scripts/", "data/scripts/"]
COPY ["samples/", "data/samples/"]
WORKDIR /data
-RUN pwsh -c scripts/package/create_packages.ps1 src/GSF.CarbonAware/src/GSF.CarbonAware.csproj /packages && \
+RUN pwsh -c scripts/package/create_packages.ps1 src/CarbonAwareSDK.sln /packages && \
+ dotnet nuget locals all --clear && \
+ dotnet nuget add source /packages -n carbonaware && \
dotnet restore "samples/azure/azure-function/function.csproj" && \
pwsh -c scripts/package/add_packages.ps1 samples/azure/azure-function/function.csproj /packages && \
dotnet build "samples/azure/azure-function/function.csproj" -c Release -o /app/build
@@ -20,4 +22,6 @@ RUN dotnet publish "samples/azure/azure-function/function.csproj" -c Release -o
FROM base AS final
WORKDIR /home/site/wwwroot
+ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
+ AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=publish /app/publish .
diff --git a/samples/azure/azure-function/function.csproj b/samples/azure/azure-function/function.csproj
index e48592f82..72030fea2 100644
--- a/samples/azure/azure-function/function.csproj
+++ b/samples/azure/azure-function/function.csproj
@@ -4,6 +4,9 @@
v4
+
+
+
diff --git a/samples/azure/azure-function/host.json b/samples/azure/azure-function/host.json
index beb2e4020..dd1b85a0d 100644
--- a/samples/azure/azure-function/host.json
+++ b/samples/azure/azure-function/host.json
@@ -6,6 +6,10 @@
"isEnabled": true,
"excludedTypes": "Request"
}
+ },
+ "logLevel": {
+ "default": "Information"
}
- }
+ },
+ "tracing": {"consoleLevel": "verbose"}
}
\ No newline at end of file
diff --git a/scripts/package/add_packages.ps1 b/scripts/package/add_packages.ps1
index 47978324d..957583c6c 100644
--- a/scripts/package/add_packages.ps1
+++ b/scripts/package/add_packages.ps1
@@ -13,6 +13,10 @@ if ([string]::IsNullOrEmpty($DOTNET_PROJECT) -or [string]::IsNullOrEmpty($PACKAG
$packages = @(
"GSF.CarbonAware"
+ "CarbonAware.DataSources.Json"
+ "CarbonAware.DataSources.WattTime"
+ "CarbonAware.DataSources.ElectricityMaps"
+ "CarbonAware.DataSources.ElectricityMapsFree"
)
# Remove packages from project
@@ -21,6 +25,7 @@ foreach ($pname in $packages) {
}
Remove-Item -Recurse -Force ~/.nuget/packages/gsf.carbonaware*
+Remove-Item -Recurse -Force ~/.nuget/packages/carbonaware.datasources*
# Add packages to project
foreach ($pname in $packages) {
diff --git a/scripts/package/create_packages.ps1 b/scripts/package/create_packages.ps1
index a07cc6e20..7bfa6e2cf 100644
--- a/scripts/package/create_packages.ps1
+++ b/scripts/package/create_packages.ps1
@@ -14,7 +14,7 @@ if ([string]::IsNullOrEmpty($DOTNET_SOLUTION) -or [string]::IsNullOrEmpty($DEST_
$REVISION = $(git rev-parse HEAD)
$BRANCH = "dev"
-New-Item -Path $DEST_PACKAGES -ItemType Directory
+New-Item -Path $DEST_PACKAGES -ItemType Directory -Force | Out-Null
# Remove existing packages
Get-ChildItem -Path $path -Recurse -Include *.nupkg, *.snupkg | Remove-Item
diff --git a/src/CarbonAware.CLI/src/CarbonAware.CLI.csproj b/src/CarbonAware.CLI/src/CarbonAware.CLI.csproj
index fcc1f9bfb..03ca3a85e 100644
--- a/src/CarbonAware.CLI/src/CarbonAware.CLI.csproj
+++ b/src/CarbonAware.CLI/src/CarbonAware.CLI.csproj
@@ -27,6 +27,14 @@
+
+
+
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/mock/CarbonAware.DataSources.ElectricityMaps.Mocks.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/mock/CarbonAware.DataSources.ElectricityMaps.Mocks.csproj
index ac0346757..c4a7c0ef9 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/mock/CarbonAware.DataSources.ElectricityMaps.Mocks.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/mock/CarbonAware.DataSources.ElectricityMaps.Mocks.csproj
@@ -13,6 +13,7 @@
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/CarbonAware.DataSources.ElectricityMaps.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/CarbonAware.DataSources.ElectricityMaps.csproj
index a8758481a..9218c1bdb 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/CarbonAware.DataSources.ElectricityMaps.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/CarbonAware.DataSources.ElectricityMaps.csproj
@@ -14,10 +14,21 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/CarbonAware.DataSources.ElectricityMaps.targets b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/CarbonAware.DataSources.ElectricityMaps.targets
new file mode 100644
index 000000000..e31895d33
--- /dev/null
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/src/CarbonAware.DataSources.ElectricityMaps.targets
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/test/CarbonAware.DataSources.ElectricityMaps.Tests.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/test/CarbonAware.DataSources.ElectricityMaps.Tests.csproj
index 34e343371..bf9eec8d7 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/test/CarbonAware.DataSources.ElectricityMaps.Tests.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMaps/test/CarbonAware.DataSources.ElectricityMaps.Tests.csproj
@@ -27,6 +27,7 @@
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/mock/CarbonAware.DataSources.ElectricityMapsFree.Mocks.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/mock/CarbonAware.DataSources.ElectricityMapsFree.Mocks.csproj
index ae28cd4a8..fbe7911eb 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/mock/CarbonAware.DataSources.ElectricityMapsFree.Mocks.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/mock/CarbonAware.DataSources.ElectricityMapsFree.Mocks.csproj
@@ -12,6 +12,7 @@
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/src/CarbonAware.DataSources.ElectricityMapsFree.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/src/CarbonAware.DataSources.ElectricityMapsFree.csproj
index b3a907bc4..8130d9c3e 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/src/CarbonAware.DataSources.ElectricityMapsFree.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/src/CarbonAware.DataSources.ElectricityMapsFree.csproj
@@ -12,7 +12,7 @@
-
+
@@ -21,7 +21,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/src/CarbonAware.DataSources.ElectricityMapsFree.targets b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/src/CarbonAware.DataSources.ElectricityMapsFree.targets
new file mode 100644
index 000000000..e31895d33
--- /dev/null
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/src/CarbonAware.DataSources.ElectricityMapsFree.targets
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/test/CarbonAware.DataSources.ElectricityMapsFree.Tests.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/test/CarbonAware.DataSources.ElectricityMapsFree.Tests.csproj
index 742632c0e..a09fbea23 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/test/CarbonAware.DataSources.ElectricityMapsFree.Tests.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.ElectricityMapsFree/test/CarbonAware.DataSources.ElectricityMapsFree.Tests.csproj
@@ -19,6 +19,7 @@
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/CarbonAware.DataSources.Json.Mocks.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/CarbonAware.DataSources.Json.Mocks.csproj
index a6f5e7724..0717377ca 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/CarbonAware.DataSources.Json.Mocks.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/mock/CarbonAware.DataSources.Json.Mocks.csproj
@@ -9,6 +9,7 @@
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj
index 1d0002f72..4c8c30d0a 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.csproj
@@ -4,7 +4,6 @@
enable
enable
true
- false
@@ -21,6 +20,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.targets b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.targets
new file mode 100644
index 000000000..925d6f9ab
--- /dev/null
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/src/CarbonAware.DataSources.Json.targets
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/CarbonAware.DataSources.Json.Tests.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/CarbonAware.DataSources.Json.Tests.csproj
index 1addeb0dd..b1eb7a3c4 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/CarbonAware.DataSources.Json.Tests.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.Json/test/CarbonAware.DataSources.Json.Tests.csproj
@@ -24,6 +24,7 @@
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/mock/CarbonAware.DataSources.WattTime.Mocks.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/mock/CarbonAware.DataSources.WattTime.Mocks.csproj
index 1adda21a9..a13b23221 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/mock/CarbonAware.DataSources.WattTime.Mocks.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/mock/CarbonAware.DataSources.WattTime.Mocks.csproj
@@ -13,6 +13,7 @@
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/src/CarbonAware.DataSources.WattTime.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/src/CarbonAware.DataSources.WattTime.csproj
index f9f3e6bcc..5503a37f0 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/src/CarbonAware.DataSources.WattTime.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/src/CarbonAware.DataSources.WattTime.csproj
@@ -5,7 +5,6 @@
enable
enable
true
- false
@@ -25,7 +24,18 @@
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/src/CarbonAware.DataSources.WattTime.targets b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/src/CarbonAware.DataSources.WattTime.targets
new file mode 100644
index 000000000..e31895d33
--- /dev/null
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/src/CarbonAware.DataSources.WattTime.targets
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/test/CarbonAware.DataSources.WattTime.Tests.csproj b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/test/CarbonAware.DataSources.WattTime.Tests.csproj
index 295fb782c..8157efbe5 100644
--- a/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/test/CarbonAware.DataSources.WattTime.Tests.csproj
+++ b/src/CarbonAware.DataSources/CarbonAware.DataSources.WattTime/test/CarbonAware.DataSources.WattTime.Tests.csproj
@@ -25,6 +25,7 @@
+
diff --git a/src/CarbonAware.WebApi/src/CarbonAware.WebApi.csproj b/src/CarbonAware.WebApi/src/CarbonAware.WebApi.csproj
index 356e23088..e6c315bfb 100644
--- a/src/CarbonAware.WebApi/src/CarbonAware.WebApi.csproj
+++ b/src/CarbonAware.WebApi/src/CarbonAware.WebApi.csproj
@@ -12,6 +12,7 @@
$(AssemblyName).xml
1591
+ false
@@ -29,6 +30,14 @@
+
+
+
+
diff --git a/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj b/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj
index d6bd80083..e90160bd1 100644
--- a/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj
+++ b/src/GSF.CarbonAware/src/GSF.CarbonAware.csproj
@@ -21,14 +21,6 @@
-
-
-
-
diff --git a/src/GSF.CarbonAware/test/GSF.CarbonAware.Tests.csproj b/src/GSF.CarbonAware/test/GSF.CarbonAware.Tests.csproj
index 64e74590c..93aecfffe 100644
--- a/src/GSF.CarbonAware/test/GSF.CarbonAware.Tests.csproj
+++ b/src/GSF.CarbonAware/test/GSF.CarbonAware.Tests.csproj
@@ -26,6 +26,10 @@
+
+
\ No newline at end of file