Skip to content

Commit 41bcd78

Browse files
committed
trying to use env variable in maven functions plugin. this is still not working with azd
1 parent 78b4685 commit 41bcd78

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

app/indexer/functions/pom.xml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<java.version>17</java.version>
2121
<azure.functions.maven.plugin.version>1.29.0</azure.functions.maven.plugin.version>
2222
<azure.functions.java.library.version>3.0.0</azure.functions.java.library.version>
23-
<functionAppName>indexer-function</functionAppName>
2423
</properties>
2524

2625
<dependencies>
@@ -54,25 +53,11 @@
5453
<version>${azure.functions.maven.plugin.version}</version>
5554
<configuration>
5655
<!-- function app name -->
57-
<appName>${functionAppName}</appName>
56+
<!--suppress UnresolvedMavenProperty -->
57+
<appName>${env.INDEXER_FUNCTIONAPP_NAME}</appName>
5858
<!-- function app resource group -->
59-
<resourceGroup>java-functions-group</resourceGroup>
60-
<!-- function app service plan name -->
61-
<appServicePlanName>java-functions-app-service-plan</appServicePlanName>
62-
<!-- function app region-->
63-
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-regions for all valid values -->
64-
<region>westus</region>
65-
<!-- function pricingTier, default to be consumption if not specified -->
66-
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-pricing-tiers for all valid values -->
67-
<!-- <pricingTier></pricingTier> -->
68-
<!-- Whether to disable application insights, default is false -->
69-
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details for all valid configurations for application insights-->
70-
<!-- <disableAppInsights></disableAppInsights> -->
71-
<runtime>
72-
<!-- runtime os, could be windows, linux or docker-->
73-
<os>linux</os>
74-
<javaVersion>17</javaVersion>
75-
</runtime>
59+
<!--suppress UnresolvedMavenProperty -->
60+
<resourceGroup>${env.AZURE_RESOURCE_GROUP}</resourceGroup>
7661
<appSettings>
7762
<property>
7863
<name>FUNCTIONS_EXTENSION_VERSION</name>

infra/main.bicep

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ module storageRoleIndexer 'core/security/role.bicep' = {
421421
name: 'storage-role-indexer'
422422
params: {
423423
principalId: indexer.outputs.identityPrincipalId
424-
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1'
424+
roleDefinitionId: 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'
425425
principalType: 'ServicePrincipal'
426426
}
427427
}
@@ -485,3 +485,4 @@ output AZURE_STORAGE_CONTAINER string = storageContainerName
485485
output AZURE_STORAGE_RESOURCE_GROUP string = storageResourceGroup.name
486486

487487
output BACKEND_URI string = backend.outputs.uri
488+
output INDEXER_FUNCTIONAPP_NAME string = indexer.outputs.name

scripts/set-env.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Write-Host ""
2+
Write-Host "Loading azd .env file from current environment"
3+
Write-Host ""
4+
5+
$output = azd env get-values
6+
7+
foreach ($line in $output) {
8+
if (!$line.Contains('=')) {
9+
continue
10+
}
11+
12+
$name, $value = $line.Split("=")
13+
$value = $value -replace '^\"|\"$'
14+
[Environment]::SetEnvironmentVariable($name, $value)
15+
}
16+
17+
Write-Host "Environment variables set."

scripts/set-env.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
echo ""
4+
echo "Loading azd .env file from current environment"
5+
echo ""
6+
7+
while IFS='=' read -r key value; do
8+
value=$(echo "$value" | sed 's/^"//' | sed 's/"$//')
9+
export "$key=$value"
10+
done <<EOF
11+
$(azd env get-values)
12+
EOF

0 commit comments

Comments
 (0)