Skip to content

Commit 810b3f4

Browse files
committed
simpler deployment - true one click
Signed-off-by: Piotr Karpala <[email protected]>
1 parent 3d675e8 commit 810b3f4

File tree

7 files changed

+192
-17
lines changed

7 files changed

+192
-17
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,16 @@ Note the `Client ID` and `Private Key`.
212212

213213
### Azure Deployment
214214

215-
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fkarpikpl%2Fcopilot-metrics-viewer%2Fmain%2Fazure-deploy%2Fazuredeploy.json)
215+
1. Option 1 - with Personal Access Token used in the backend:
216+
217+
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fkarpikpl%2Fcopilot-metrics-viewer%2Fmain%2Fazure-deploy%2Fwith-app-registration%2Fazuredeploy.json)
218+
219+
2. Option 2 - with GitHub app registration and GitHub authentication:
220+
221+
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fkarpikpl%2Fcopilot-metrics-viewer%2Fmain%2Fazure-deploy%2Fwith-token%2Fazuredeploy.json)
216222

217223
**Important**
218-
After deployment redirect URI needs to be updated with the URL of the deployed container app.
224+
After deployment of Option 2 redirect URI needs to be updated with the URL of the deployed container app.
219225

220226
Go to: `https://github.com/organizations/<your-org>/settings/apps/<your app>` or in the UI to settings of the registered application and add following redirect URLs:
221227

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,32 @@
2525
"description": "GitHub Client Secret (key)from App Registration"
2626
}
2727
},
28-
"application-scope": {
28+
"github-organization": {
2929
"type": "string",
30-
"defaultValue": "organization",
31-
"allowedValues": [
32-
"organization",
33-
"enterprise"
34-
],
30+
"defaultValue":"",
3531
"metadata": {
36-
"description": "Scope for the application"
32+
"description": "GitHub Organization - provide only if application-scope is organization"
3733
}
3834
},
39-
"github-organization": {
35+
"github-enterprise": {
4036
"type": "string",
4137
"defaultValue":"",
4238
"metadata": {
43-
"description": "GitHub Organization or Enterprise"
39+
"description": "GitHub Enterprise - provide only if application-scope is enterprise"
4440
}
4541
},
46-
"github-enterprise": {
42+
"metrics-viewer-docker-image": {
4743
"type": "string",
48-
"defaultValue":"",
44+
"defaultValue": "ghcr.io/karpikpl/copilot-metrics-viewer-with-proxy:latest",
4945
"metadata": {
50-
"description": "GitHub Enterprise"
46+
"description": "Docker image for metrics viewer - use default or replace with your own"
5147
}
5248
}
5349
},
5450
"variables": {
5551
"environmentName": "[concat(parameters('name'),'-env')]",
56-
"workspaceName": "[concat(parameters('name'),'-ai')]"
52+
"workspaceName": "[concat(parameters('name'),'-ai')]",
53+
"app-scope": "[if(not(empty(parameters('github-organization'))), 'organization', if(not(empty(parameters('github-enterprise'))), 'enterprise', ''))]"
5754
},
5855
"resources": [
5956
{
@@ -84,7 +81,7 @@
8481
"containers": [
8582
{
8683
"name": "copilot-metrics",
87-
"image": "ghcr.io/karpikpl/copilot-metrics-viewer-with-proxy:latest",
84+
"image": "[parameters('metrics-viewer-docker-image')]",
8885
"command": [],
8986
"resources": {
9087
"cpu": 0.25,
@@ -93,7 +90,7 @@
9390
"env": [
9491
{
9592
"name": "VUE_APP_SCOPE",
96-
"value": "[parameters('application-scope')]"
93+
"value": "[variables('app-scope')]"
9794
},
9895
{
9996
"name": "VUE_APP_GITHUB_API",
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"name": {
6+
"type": "String",
7+
"defaultValue": "copilot-metrics"
8+
},
9+
"location": {
10+
"type": "String",
11+
"defaultValue": "[resourceGroup().location]",
12+
"metadata": {
13+
"description": "The Azure Container App Location"
14+
}
15+
},
16+
"github-pat-token": {
17+
"type": "SecureString",
18+
"metadata": {
19+
"description": "GitHub PAT token with manage_billing:copilot for ORGs or PAT (classic) with manage_billing:copilot or read:enterprise scopes for Enterprise"
20+
}
21+
},
22+
"github-organization": {
23+
"type": "string",
24+
"defaultValue":"",
25+
"metadata": {
26+
"description": "GitHub Organization - provide only if application-scope is organization"
27+
}
28+
},
29+
"github-enterprise": {
30+
"type": "string",
31+
"defaultValue":"",
32+
"metadata": {
33+
"description": "GitHub Enterprise - provide only if application-scope is enterprise"
34+
}
35+
},
36+
"metrics-viewer-docker-image": {
37+
"type": "string",
38+
"defaultValue": "ghcr.io/karpikpl/copilot-metrics-viewer-with-proxy:latest",
39+
"metadata": {
40+
"description": "Docker image for metrics viewer - use default or replace with your own"
41+
}
42+
}
43+
},
44+
"variables": {
45+
"environmentName": "[concat(parameters('name'),'-env')]",
46+
"workspaceName": "[concat(parameters('name'),'-ai')]",
47+
"app-scope": "[if(not(empty(parameters('github-organization'))), 'organization', if(not(empty(parameters('github-enterprise'))), 'enterprise', ''))]"
48+
},
49+
"resources": [
50+
{
51+
"type": "Microsoft.App/containerapps",
52+
"apiVersion": "2024-02-02-preview",
53+
"name": "[parameters('name')]",
54+
"location": "[parameters('location')]",
55+
"dependsOn": [
56+
"[concat('Microsoft.App/managedEnvironments/', variables('environmentName'))]"
57+
],
58+
"kind": "containerapps",
59+
"properties": {
60+
"environmentId": "[resourceId('Microsoft.App/managedEnvironments', variables('environmentName'))]",
61+
"configuration": {
62+
"activeRevisionsMode": "Single",
63+
"ingress": {
64+
"external": true,
65+
"transport": "Auto",
66+
"allowInsecure": false,
67+
"targetPort": 3000,
68+
"stickySessions": {
69+
"affinity": "none"
70+
},
71+
"additionalPortMappings": []
72+
}
73+
},
74+
"template": {
75+
"containers": [
76+
{
77+
"name": "copilot-metrics",
78+
"image": "[parameters('metrics-viewer-docker-image')]",
79+
"command": [],
80+
"resources": {
81+
"cpu": 0.25,
82+
"memory": ".5Gi"
83+
},
84+
"env": [
85+
{
86+
"name": "VUE_APP_SCOPE",
87+
"value": "[variables('app-scope')]"
88+
},
89+
{
90+
"name": "VUE_APP_GITHUB_API",
91+
"value": "/api/github"
92+
},
93+
{
94+
"name": "VUE_APP_GITHUB_ORG",
95+
"value": "[parameters('github-organization')]"
96+
},
97+
{
98+
"name": "VUE_APP_GITHUB_ENT",
99+
"value": "[parameters('github-enterprise')]"
100+
},
101+
{
102+
"name": "VUE_APP_GITHUB_TOKEN",
103+
"value": "[parameters('github-pat-token')]"
104+
},
105+
{
106+
"name": "SESSION_SECRET",
107+
"value": "[uniqueString(resourceGroup().id)]"
108+
}
109+
]
110+
}
111+
],
112+
"scale": {
113+
"minReplicas": 0
114+
}
115+
}
116+
}
117+
},
118+
{
119+
"apiVersion": "2024-02-02-preview",
120+
"name": "[variables('environmentName')]",
121+
"type": "Microsoft.App/managedEnvironments",
122+
"location": "[parameters('location')]",
123+
"dependsOn": [
124+
"[concat('Microsoft.OperationalInsights/workspaces/', variables('workspaceName'))]"
125+
],
126+
"properties": {
127+
"appLogsConfiguration": {
128+
"destination": "log-analytics",
129+
"logAnalyticsConfiguration": {
130+
"customerId": "[reference(concat('Microsoft.OperationalInsights/workspaces/', variables('workspaceName')), '2020-08-01').customerId]",
131+
"sharedKey": "[listKeys(concat('Microsoft.OperationalInsights/workspaces/', variables('workspaceName')), '2020-08-01').primarySharedKey]"
132+
}
133+
}
134+
}
135+
},
136+
{
137+
"apiVersion": "2020-08-01",
138+
"name": "[variables('workspaceName')]",
139+
"type": "Microsoft.OperationalInsights/workspaces",
140+
"location": "[parameters('location')]",
141+
"dependsOn": [],
142+
"properties": {
143+
"sku": {
144+
"name": "PerGB2018"
145+
},
146+
"retentionInDays": 30,
147+
"workspaceCapping": {}
148+
}
149+
}
150+
]
151+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {}
5+
}

azure-deploy/with-token/metadata.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://aka.ms/azure-quickstart-templates-metadata-schema#",
3+
"itemDisplayName": "Create a Azure Container App",
4+
"description": "This template creates a Azure Container App showing GitHub copilot metrics",
5+
"summary": "Create Azure Container App showing GitHub copilot metrics",
6+
"githubUsername": "karpikpl",
7+
"docOwner": "karpikpl",
8+
"dateUpdated": "2024-08-02",
9+
"type": "Application",
10+
"tags": {
11+
"subscriptiontype": "Azure4Student",
12+
"resource": "Azure Container Apps",
13+
"level": "Beginner",
14+
"cost": "$"
15+
}
16+
}

0 commit comments

Comments
 (0)