Skip to content

Commit a551efa

Browse files
committed
fixing and testing deployments
1 parent b752fe3 commit a551efa

File tree

6 files changed

+165
-53
lines changed

6 files changed

+165
-53
lines changed

DEPLOYMENT.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,7 @@ The deployment creates:
9595
9696
![AZD Deployment](./azure-deploy/azd-deployment.png)
9797
98-
Before running `azd up`, configure GitHub variables:
99-
100-
```bash
101-
azd env set NUXT_PUBLIC_SCOPE <organization/enterprise>
102-
# when using organization
103-
azd env set NUXT_PUBLIC_GITHUB_ORG <org name>
104-
# when using enterprise
105-
azd env set NUXT_PUBLIC_GITHUB_ENT <ent name>
106-
azd env set NUXT_OAUTH_GITHUB_CLIENT_ID <client id>
107-
azd env set NUXT_OAUTH_GITHUB_CLIENT_SECRET <client secret for the GH App>
108-
```
98+
Run `azd up` and follow the prompts.
10999
110100
## Scenario 3: Deploying the container
111101
@@ -117,6 +107,7 @@ For GitHub App:
117107
docker run -it --rm -p 3000:3000 \
118108
-e NUXT_PUBLIC_SCOPE=organization \
119109
-e NUXT_PUBLIC_GITHUB_ORG=<org name> \
110+
-e NUXT_PUBLIC_USING_GITHUB_AUTH=true \
120111
-e NUXT_OAUTH_GITHUB_CLIENT_ID=<client id> \
121112
-e NUXT_OAUTH_GITHUB_CLIENT_SECRET=<client secret for the GH App> \
122113
-e NUXT_SESSION_PASSWORD=<random string - min 32 characters> \

app/components/MainComponent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export default defineNuxtComponent({
144144
if (error.statusCode) {
145145
switch (error.statusCode) {
146146
case 401:
147-
apiError.value = '401 Unauthorized access - check if your token in the .env file is correct.';
147+
apiError.value = '401 Unauthorized access returned by GitHub API - check if your token in the .env (for local runs). Check PAT token and GitHub permissions.';
148148
break;
149149
case 404:
150150
apiError.value = `404 Not Found - is the ${config.public.scope || ''} org:'${config.public.githubOrg || ''} ent:'${config.public.githubEnt || ''}' team:'${config.public.githubTeam}' correct? ${error.message}`;

azure-deploy/with-app-registration/azuredeploy.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
"name": "NUXT_PUBLIC_GITHUB_ENT",
108108
"value": "[parameters('github-enterprise')]"
109109
},
110+
{
111+
"name": "NUXT_PUBLIC_USING_GITHUB_AUTH",
112+
"value": "true"
113+
},
110114
{
111115
"name": "NUXT_OAUTH_GITHUB_CLIENT_ID",
112116
"value": "[parameters('github-client-id')]"
@@ -117,7 +121,7 @@
117121
},
118122
{
119123
"name": "NUXT_SESSION_PASSWORD",
120-
"value": "[uniqueString(resourceGroup().id)]"
124+
"value": "[concat(uniqueString(resourceGroup().id),'-',uniqueString(resourceGroup().id),'-',uniqueString(resourceGroup().id))]"
121125
}
122126
]
123127
}

azure-deploy/with-token/azuredeploy.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,17 @@
101101
"name": "NUXT_PUBLIC_GITHUB_ENT",
102102
"value": "[parameters('github-enterprise')]"
103103
},
104+
{
105+
"name": "NUXT_PUBLIC_USING_GITHUB_AUTH",
106+
"value": "false"
107+
},
104108
{
105109
"name": "NUXT_GITHUB_TOKEN",
106110
"value": "[parameters('github-pat-token')]"
107111
},
108112
{
109113
"name": "NUXT_SESSION_PASSWORD",
110-
"value": "[uniqueString(resourceGroup().id)]"
114+
"value": "[concat(uniqueString(resourceGroup().id),'-',uniqueString(resourceGroup().id),'-',uniqueString(resourceGroup().id))]"
111115
}
112116
]
113117
}

infra/main.bicep

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,28 @@ param environmentName string
1010
param location string
1111

1212
param copilotMetricsViewerExists bool
13+
14+
// Settings
15+
@secure()
16+
@description('GitHub App Client Id - required for GitHub OAuth')
17+
param githubClientId string
18+
@secure()
19+
@description('GitHub App Client Secret - required for GitHub OAuth')
20+
param githubClientSecret string
21+
@secure()
22+
param sessionPassword string
1323
@secure()
14-
param copilotMetricsViewerDefinition object
24+
param githubPAT string
25+
26+
@allowed(['enterprise', 'organization', 'team'])
27+
param githubScope string
28+
29+
@description('The name of the GitHub organization, required when scope is "organization"')
30+
param githubOrg string
31+
@description('The name of the GitHub team, required when scope is "team"')
32+
param githubTeam string
33+
@description('The name of the GitHub enterprise, required when scope is "enterprise"')
34+
param githubEnt string
1535

1636
@description('Id of the user or app to assign application roles')
1737
param principalId string
@@ -28,6 +48,111 @@ var tags = {
2848
var abbrs = loadJsonContent('./abbreviations.json')
2949
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
3050

51+
// "settings": [
52+
// {
53+
// "name": "NUXT_OAUTH_GITHUB_CLIENT_ID",
54+
// "value": "${NUXT_OAUTH_GITHUB_CLIENT_ID}",
55+
// "secret": true,
56+
// "_comment_name": "GitHub App Client id - The name of the environment variable when running in Azure."
57+
// },
58+
// {
59+
// "name": "NUXT_OAUTH_GITHUB_CLIENT_SECRET",
60+
// "value": "${NUXT_OAUTH_GITHUB_CLIENT_SECRET}",
61+
// "secret": true,
62+
// "_comment_name": "GitHub App Client Secret - The name of the environment variable when running in Azure."
63+
// },
64+
// {
65+
// "name": "NUXT_SESSION_PASSWORD",
66+
// "value": "$(secretOrRandomPassword)",
67+
// "secret": true,
68+
// "_comment_name": "Session Secret - The name of the environment variable when running in Azure."
69+
// },
70+
// {
71+
// "name": "NUXT_PUBLIC_SCOPE",
72+
// "value": "${NUXT_PUBLIC_SCOPE}",
73+
// "_comment_name": "GitHub App Scope - The name of the environment variable when running in Azure."
74+
// },
75+
// {
76+
// "name": "NUXT_PUBLIC_GITHUB_ORG",
77+
// "value": "${NUXT_PUBLIC_GITHUB_ORG}",
78+
// "_comment_name": "GitHub Organization - The name of the environment variable when running in Azure."
79+
// },
80+
// {
81+
// "name": "NUXT_PUBLIC_GITHUB_ENT",
82+
// "value": "${NUXT_PUBLIC_GITHUB_ENT}",
83+
// "_comment_name": "GitHub Enterprise - The name of the environment variable when running in Azure."
84+
// }
85+
// ]
86+
87+
var settings = concat(
88+
[
89+
{
90+
name: 'NUXT_SESSION_PASSWORD'
91+
value: '${sessionPassword}-${guid(sessionPassword)}-${guid(sessionPassword)}'
92+
secret: true
93+
}
94+
{
95+
name: 'NUXT_PUBLIC_SCOPE'
96+
value: githubScope
97+
}
98+
],
99+
!empty(githubPAT)
100+
? [
101+
{
102+
name: 'NUXT_GITHUB_TOKEN'
103+
value: githubPAT
104+
secret: true
105+
}
106+
{
107+
name: 'NUXT_PUBLIC_USING_GITHUB_AUTH'
108+
value: 'false'
109+
}
110+
]
111+
: [],
112+
!empty(githubClientId) && !empty(githubClientSecret)
113+
? [
114+
{
115+
name: 'NUXT_OAUTH_GITHUB_CLIENT_ID'
116+
value: githubClientId
117+
secret: true
118+
}
119+
{
120+
name: 'NUXT_OAUTH_GITHUB_CLIENT_SECRET'
121+
value: githubClientSecret
122+
secret: true
123+
}
124+
{
125+
name: 'NUXT_PUBLIC_USING_GITHUB_AUTH'
126+
value: 'true'
127+
}
128+
]
129+
: [],
130+
!empty(githubOrg)
131+
? [
132+
{
133+
name: 'NUXT_PUBLIC_GITHUB_ORG'
134+
value: githubOrg
135+
}
136+
]
137+
: [],
138+
!empty(githubTeam)
139+
? [
140+
{
141+
name: 'NUXT_PUBLIC_GITHUB_TEAM'
142+
value: githubTeam
143+
}
144+
]
145+
: [],
146+
!empty(githubEnt)
147+
? [
148+
{
149+
name: 'NUXT_PUBLIC_GITHUB_ENT'
150+
value: githubEnt
151+
}
152+
]
153+
: []
154+
)
155+
31156
resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
32157
name: 'rg-${environmentName}'
33158
location: location
@@ -100,7 +225,9 @@ module copilotMetricsViewer './app/copilot-metrics-viewer.bicep' = {
100225
containerAppsEnvironmentName: appsEnv.outputs.name
101226
containerRegistryName: registry.outputs.name
102227
exists: copilotMetricsViewerExists
103-
appDefinition: copilotMetricsViewerDefinition
228+
appDefinition: {
229+
settings: settings
230+
}
104231
}
105232
scope: rg
106233
}

infra/main.parameters.json

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,31 @@
1111
"copilotMetricsViewerExists": {
1212
"value": "${SERVICE_COPILOT_METRICS_VIEWER_RESOURCE_EXISTS=false}"
1313
},
14-
"copilotMetricsViewerDefinition": {
15-
"value": {
16-
"settings": [
17-
{
18-
"name": "NUXT_OAUTH_GITHUB_CLIENT_ID",
19-
"value": "${NUXT_OAUTH_GITHUB_CLIENT_ID}",
20-
"secret": true,
21-
"_comment_name": "GitHub App Client id - The name of the environment variable when running in Azure."
22-
},
23-
{
24-
"name": "NUXT_OAUTH_GITHUB_CLIENT_SECRET",
25-
"value": "${NUXT_OAUTH_GITHUB_CLIENT_SECRET}",
26-
"secret": true,
27-
"_comment_name": "GitHub App Client Secret - The name of the environment variable when running in Azure."
28-
},
29-
{
30-
"name": "NUXT_SESSION_PASSWORD",
31-
"value": "$(secretOrRandomPassword)",
32-
"secret": true,
33-
"_comment_name": "Session Secret - The name of the environment variable when running in Azure."
34-
},
35-
{
36-
"name": "NUXT_PUBLIC_SCOPE",
37-
"value": "${NUXT_PUBLIC_SCOPE}",
38-
"_comment_name": "GitHub App Scope - The name of the environment variable when running in Azure."
39-
},
40-
{
41-
"name": "NUXT_PUBLIC_GITHUB_ORG",
42-
"value": "${NUXT_PUBLIC_GITHUB_ORG}",
43-
"_comment_name": "GitHub Organization - The name of the environment variable when running in Azure."
44-
},
45-
{
46-
"name": "NUXT_PUBLIC_GITHUB_ENT",
47-
"value": "${NUXT_PUBLIC_GITHUB_ENT}",
48-
"_comment_name": "GitHub Enterprise - The name of the environment variable when running in Azure."
49-
}
50-
]
14+
"githubClientId":{
15+
"value": "${NUXT_OAUTH_GITHUB_CLIENT_ID}",
16+
"metadata": {
17+
"description": "GitHub OAuth Client ID",
18+
"secure": true
5119
}
5220
},
21+
"githubClientSecret": {
22+
"value": "${NUXT_OAUTH_GITHUB_CLIENT_SECRET}"
23+
},
24+
"sessionPassword": {
25+
"value": "$(secretOrRandomPassword)"
26+
},
27+
"githubScope": {
28+
"value": "${NUXT_PUBLIC_SCOPE}"
29+
},
30+
"githubOrg": {
31+
"value": "${NUXT_PUBLIC_GITHUB_ORG}"
32+
},
33+
"githubTeam": {
34+
"value": "${NUXT_PUBLIC_GITHUB_TEAM}"
35+
},
36+
"githubEnt": {
37+
"value": "${NUXT_PUBLIC_GITHUB_ENT}"
38+
},
5339
"principalId": {
5440
"value": "${AZURE_PRINCIPAL_ID}"
5541
}

0 commit comments

Comments
 (0)