Skip to content

Commit de8a4d4

Browse files
authored
Merge pull request #3 from karpikpl/feature/deployment
Azure Deployment
2 parents af8a5af + 1d32f6e commit de8a4d4

File tree

4 files changed

+202
-3
lines changed

4 files changed

+202
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,26 @@ Replace <your org> with your organization name in the link:
179179
3. Add Callback URL for `http://localhost:3000`
180180
4. Uncheck Webhook -> Active checkbox.
181181
5. Set the scopes -> select **Organization permissions** -> **GitHub Copilot Business** -> select **Access: Read-only**
182-
6. Create a private key - it will get downloaded to your machine.
182+
6. Create a client secret.
183183
7. Install the app in the org -> Install App -> select your org
184184

185-
Note the `application ID` and `Private Key`.
185+
Note the `Client ID` and `Private Key`.
186186

187-
### Azure Deployment
187+
### Azure Deployment
188+
189+
[![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%2Ffeature%2Fdeployment%2Fazure-deploy%2Fazuredeploy.json)
190+
191+
**Important**
192+
After deployment redirect URI needs to be updated with the URL of the deployed container app.
193+
194+
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:
195+
196+
```
197+
http://<YOUR Container APP URL>.azurecontainerapps.io/callback
198+
https://<YOUR Container APP URL>.azurecontainerapps.io/callback
199+
```
200+
201+
### Azure Deployment with azd
188202

189203
Application can be deployed using [Azure Developer CLI](https://aka.ms/azd) (azd).
190204

azure-deploy/azuredeploy.json

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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-client-id": {
17+
"type": "SecureString",
18+
"metadata": {
19+
"description": "GitHub Client ID from App Installation"
20+
}
21+
},
22+
"github-client-secret": {
23+
"type": "securestring",
24+
"metadata": {
25+
"description": "GitHub Client Secret (key)from App Registration"
26+
}
27+
},
28+
"application-scope": {
29+
"type": "string",
30+
"defaultValue": "organization",
31+
"allowedValues": [
32+
"organization",
33+
"enterprise"
34+
],
35+
"metadata": {
36+
"description": "Scope for the application"
37+
}
38+
},
39+
"github-organization": {
40+
"type": "string",
41+
"defaultValue":"",
42+
"metadata": {
43+
"description": "GitHub Organization or Enterprise"
44+
}
45+
},
46+
"github-enterprise": {
47+
"type": "string",
48+
"defaultValue":"",
49+
"metadata": {
50+
"description": "GitHub Enterprise"
51+
}
52+
}
53+
},
54+
"variables": {
55+
"environmentName": "[concat(parameters('name'),'-env')]",
56+
"workspaceName": "[concat(parameters('name'),'-ai')]"
57+
},
58+
"resources": [
59+
{
60+
"type": "Microsoft.App/containerapps",
61+
"apiVersion": "2024-02-02-preview",
62+
"name": "[parameters('name')]",
63+
"location": "[parameters('location')]",
64+
"dependsOn": [
65+
"[concat('Microsoft.App/managedEnvironments/', variables('environmentName'))]"
66+
],
67+
"kind": "containerapps",
68+
"properties": {
69+
"environmentId": "[resourceId('Microsoft.App/managedEnvironments', variables('environmentName'))]",
70+
"configuration": {
71+
"activeRevisionsMode": "Single",
72+
"ingress": {
73+
"external": true,
74+
"transport": "Auto",
75+
"allowInsecure": false,
76+
"targetPort": 3000,
77+
"stickySessions": {
78+
"affinity": "none"
79+
},
80+
"additionalPortMappings": []
81+
}
82+
},
83+
"template": {
84+
"containers": [
85+
{
86+
"name": "copilot-metrics",
87+
"image": "ghcr.io/karpikpl/copilot-metrics-viewer-with-proxy:latest",
88+
"command": [],
89+
"resources": {
90+
"cpu": 0.25,
91+
"memory": ".5Gi"
92+
},
93+
"env": [
94+
{
95+
"name": "VUE_APP_SCOPE",
96+
"value": "[parameters('application-scope')]"
97+
},
98+
{
99+
"name": "VUE_APP_GITHUB_API",
100+
"value": "/api/github"
101+
},
102+
{
103+
"name": "VUE_APP_GITHUB_ORG",
104+
"value": "[parameters('github-organization')]"
105+
},
106+
{
107+
"name": "VUE_APP_GITHUB_ENT",
108+
"value": "[parameters('github-enterprise')]"
109+
},
110+
{
111+
"name": "GITHUB_CLIENT_ID",
112+
"value": "[parameters('github-client-id')]"
113+
},
114+
{
115+
"name": "GITHUB_CLIENT_SECRET",
116+
"value": "[parameters('github-client-secret')]"
117+
},
118+
{
119+
"name": "SESSION_SECRET",
120+
"value": "[uniqueString(resourceGroup().id)]"
121+
}
122+
]
123+
}
124+
],
125+
"scale": {
126+
"minReplicas": 0
127+
}
128+
}
129+
}
130+
},
131+
{
132+
"apiVersion": "2024-02-02-preview",
133+
"name": "[variables('environmentName')]",
134+
"type": "Microsoft.App/managedEnvironments",
135+
"location": "[parameters('location')]",
136+
"dependsOn": [
137+
"[concat('Microsoft.OperationalInsights/workspaces/', variables('workspaceName'))]"
138+
],
139+
"properties": {
140+
"appLogsConfiguration": {
141+
"destination": "log-analytics",
142+
"logAnalyticsConfiguration": {
143+
"customerId": "[reference(concat('Microsoft.OperationalInsights/workspaces/', variables('workspaceName')), '2020-08-01').customerId]",
144+
"sharedKey": "[listKeys(concat('Microsoft.OperationalInsights/workspaces/', variables('workspaceName')), '2020-08-01').primarySharedKey]"
145+
}
146+
}
147+
}
148+
},
149+
{
150+
"apiVersion": "2020-08-01",
151+
"name": "[variables('workspaceName')]",
152+
"type": "Microsoft.OperationalInsights/workspaces",
153+
"location": "[parameters('location')]",
154+
"dependsOn": [],
155+
"properties": {
156+
"sku": {
157+
"name": "PerGB2018"
158+
},
159+
"retentionInDays": 30,
160+
"workspaceCapping": {}
161+
}
162+
}
163+
]
164+
}
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/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)