Skip to content

Commit

Permalink
Jmservera/conditionaldeployment (#19)
Browse files Browse the repository at this point in the history
* set appgw conditional deployment depending on having a domain name or not.

* feat: Update appGw to conditionally set the host property

The code changes in the appgw.bicep file update the host property of the appGw resource. It now checks the value of the isSecure variable and sets the host property accordingly. If isSecure is true, it uses the webHostName variable. Otherwise, it uses the defaultHostName property of the webApp resource. This change allows for more flexibility in configuring the host property based on the presence of a domain name.

* feat: Update Makefile to improve operation. Added a child makefile for the web app publishing that needs the resources to be already created in Azure. This allows to run the main makefile without having to retrieve the values with the az command when they are not needed

* feat: Add testvars target to Makefile for retrieving test variables

The code changes in the Makefile and webapp.mk files add a new target called "testvars" to retrieve test variables. This target allows developers to easily retrieve and display the test variables needed for running the OCPP server tests. It improves the development workflow by providing a convenient way to access the necessary test configuration.

* fix: npm vulnerabilities

* feat: Add support for User Assigned Managed Identity in web app deployment

The code changes in the main.bicep and webapp.bicep files add support for User Assigned Managed Identity in the deployment of the web app. This allows the web app to access the SSL certificate stored in the KeyVault.

* fix typo

* add flag for custom cert in internal app
  • Loading branch information
jmservera authored Aug 10, 2024
1 parent 22a5a87 commit 22f8f7d
Show file tree
Hide file tree
Showing 7 changed files with 11,055 additions and 9,907 deletions.
20,445 changes: 10,743 additions & 9,702 deletions ai/uxforai/fluent-app/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ai/uxforai/fluent-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"react-scripts": "^3.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
51 changes: 13 additions & 38 deletions ocpp-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ THIS_FILE := $(lastword $(MAKEFILE_LIST))
RG_NAME := OCPP
RG_LOCATION := switzerlandnorth
BICEP_PARAMS := main.parameters.bicepparam
WEBAPP_NAME := $(shell az webapp list -g $(RG_NAME) --query "[0].name" -o tsv)
STORAGE_NAME := $(shell az storage account list -g $(RG_NAME) --query "[?starts_with(name,'webdeploy')].name" -o tsv)
EXPIRY := $(shell date -u -d "15 minutes" '+%Y-%m-%dT%H:%MZ')
BASE_URI := $(shell cd infra && grep -Po "customDnsZoneName.*\K'(.+)'" $(BICEP_PARAMS) | grep -Po "[^']*")
WSSSUBDOMAIN := $(shell cd infra && grep -Po "pubsubARecordName.*\K'(.+)'" $(BICEP_PARAMS) | grep -Po "[^']*")
TEST_SERVER := $(WSSSUBDOMAIN).$(BASE_URI)
WEB_SERVER := www.$(BASE_URI)

export RG_NAME
export RG_LOCATION
export BICEP_PARAMS

preparecli:
az upgrade
Expand All @@ -27,11 +24,9 @@ test:
@echo "Testing"
dotnet test api/api.sln
test-client:
@echo "Testing a simple node client"
node client/index.js wss://$(TEST_SERVER) station2 goodpwd
@$(MAKE) -f make/webapp.mk test-client
test-client-badauth:
@echo "Testing a simple node client"
node client/index.js wss://$(TEST_SERVER) station1 badpwd
@$(MAKE) -f make/webapp.mk test-client-badauth
clean:
@echo "Cleaning"
dotnet clean api/api.sln
Expand Down Expand Up @@ -70,34 +65,14 @@ secrets:
CONNECTION_STRING='$(shell az webpubsub list -g $(RG_NAME) --query "[0].name" -o tsv | az webpubsub key show -g $(RG_NAME) -n @- --query "primaryConnectionString" -o tsv)'; \
dotnet user-secrets set 'WEBPUBSUB_SERVICE_CONNECTION_STRING' "$$CONNECTION_STRING" --project api/OcppServer/OcppServer.csproj
publish: $(wildcard api/**/*.cs) $(wildcard api/**/wwwroot/*)
@echo "Creating publish files"
dotnet publish api/OcppServer/OcppServer.csproj -c Release
@echo "Zip files"
cd api/OcppServer/bin/Release/net8.0/publish && zip -r /tmp/ocppserver.zip .
@echo "Publish files created"
az storage blob upload --account-name $(STORAGE_NAME) -c deployments -f /tmp/ocppserver.zip -n ocppserver.zip --overwrite;
APP_URL='$(shell az storage blob generate-sas --full-uri --permissions r --expiry '$(EXPIRY)' --account-name $(STORAGE_NAME) -c deployments -n ocppserver.zip -o tsv)'; \
if az webapp deploy -g $(RG_NAME) -n $(WEBAPP_NAME) --src-url $$APP_URL --type zip; then \
echo "Deployed to Azure"; \
else \
# todo: check status with the rest api https://management.azure.com/subscriptions/$$(az account show --query id -o tsv)/resourceGroups/RESOURCEGROUP/providers/Microsoft.Web/sites/WEBAPPNAME/deployments?api-version=2023-12-01 \
echo "Retry deployment, first time can fail with Gateway Timeout"; \
sleep 10; \
az webapp deploy -g $(RG_NAME) -n $(WEBAPP_NAME) --src-url $$APP_URL --type zip; \
fi
@echo "Waiting for webapp to be ready"
until [ $$(curl -s -o /dev/null -w "%{http_code}" https://$(WEB_SERVER)/health) -eq 200 ]; do echo -n . && sleep 5; done
@echo
@$(MAKE) -f make/webapp.mk publish
restart:
az webapp stop -g $(RG_NAME) -n $(WEBAPP_NAME)
sleep 5
az webapp start -g $(RG_NAME) -n $(WEBAPP_NAME)
@$(MAKE) -f make/webapp.mk restart
deploy:
@echo "Deploying all to Azure"
@$(MAKE) -f $(THIS_FILE) infra
@echo "Waiting for gateway to be ready"
# until [ $$(curl -s -o /dev/null -w "%{http_code}" https://$(WEB_SERVER)) -eq 502 ] || [ $$(curl -s -o /dev/null -w "%{http_code}" https://$(WEB_SERVER)) -eq 200 ]; do echo -n . && sleep 5; done
# @echo
@$(MAKE) -f $(THIS_FILE) restart
@$(MAKE) -f $(THIS_FILE) publish
.PHONY: test clean watch start secrets test-client infra clean-infra
@$(MAKE) -f make/webapp.mk restart
@$(MAKE) -f make/webapp.mk publish
testvars:
@$(MAKE) -f make/webapp.mk testvars
.PHONY: test clean watch start secrets test-client infra clean-infra restart testvars
4 changes: 3 additions & 1 deletion ocpp-server/infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ param dnsZoneRG string
param pubSubHubName string = 'OcppService'
@description('If you want to use a NAT Gateway for the outbound access of the vNet')
param useNATGateway bool = false
@description('Set it to false if you don\'t want to use the custom certificate and domain name in the internal web app. Useful for self-signed certificates.')
param useCertificateInWebApp bool = true

var pubsubHostName = '${pubsubARecordName}.${customDnsZoneName}'
var webHostName = '${webARecordName}.${customDnsZoneName}'
Expand Down Expand Up @@ -95,7 +97,7 @@ module webApp './modules/webapp.bicep' = {
// Assigns the custom web domain to the web app, this ensures
// that the cookies are set with the custom domain and do not
// have any issue with the Application Gateway cookie based affinity
module customDomain 'modules/customWebName.bicep' = if (customDnsZoneName != '') {
module customDomain 'modules/customWebName.bicep' = if (customDnsZoneName != '' && useCertificateInWebApp) {
name: '${deployment().name}-customDomain'
params: {
dnszoneName: customDnsZoneName
Expand Down
Loading

0 comments on commit 22f8f7d

Please sign in to comment.