Skip to content

Commit 5739d56

Browse files
Init - Add nodejs example with AZD template (#1)
* init * update config * update readme * update * update * update * update readme * update * update * update app to use token credential * use system assigned identity * use latest package * update * update * update * update * not use inline createTelemetryPublisher
1 parent 4039564 commit 5739d56

28 files changed

+4833
-412
lines changed

.gitignore

Lines changed: 103 additions & 369 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,50 @@
1-
# Project Name
1+
# Quote of the Day - JavaScript
22

3-
(short, 1-3 sentenced, description of the project)
3+
## Prerequisites
44

5-
## Features
5+
- Clone this repository.
6+
- Install or update to Powershell 7 <https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4>
7+
- Install or update Azure CLI <https://learn.microsoft.com/en-us/cli/azure/install-azure-cli>
8+
- Ensure you have the required permissions to deploy into the target Azure subscription. Either of the below sets of roles can be used:
9+
- Owner
10+
- Contributor & User Access Administrator
611

7-
This project framework provides the following features:
12+
## Use Azure Developer CLI
813

9-
* Feature 1
10-
* Feature 2
11-
* ...
14+
This application can be run using the [Azure Developer CLI](https://aka.ms/azd), or `azd`, with very few commands:
1215

13-
## Getting Started
16+
- Navigate to the root of the repository.
17+
- Install [azd](https://aka.ms/azure-dev/install).
18+
- Log in `azd` (if you haven't done it before) to your Azure account:
1419

15-
### Prerequisites
20+
```sh
21+
azd auth login
22+
```
1623

17-
(ideally very short, if any)
24+
- Log in to the Azure CLI.
1825

19-
- OS
20-
- Library version
21-
- ...
26+
```sh
27+
az login
28+
```
2229

23-
### Installation
30+
- Initialize `azd` from the root of the repo.
2431

25-
(ideally very short)
32+
```sh
33+
azd init
34+
```
2635

27-
- npm install [package name]
28-
- mvn install
29-
- ...
36+
- Enter an environment name (e.g. quote-of-the-day-js-example) for this deployment when prompted.
37+
- Create Azure resources and deploy the sample by running:
3038

31-
### Quickstart
32-
(Add steps to get up and running quickly)
39+
```sh
40+
azd up
41+
```
3342

34-
1. git clone [repository clone url]
35-
2. cd [repository name]
36-
3. ...
43+
Notes:
3744

38-
39-
## Demo
40-
41-
A demo app is included to show how to use the project.
42-
43-
To run the demo, follow these steps:
44-
45-
(Add steps to start up the demo)
46-
47-
1.
48-
2.
49-
3.
50-
51-
## Resources
52-
53-
(Any additional resources or related projects)
54-
55-
- Link to supporting information
56-
- Link to similar sample
57-
- ...
45+
- The operation may take a few minutes when run for the first time in an environment.
46+
- Upon completion, `azd` will display the web application's `url`. Follow this link to test the sample.
47+
- To re-deploy and update the sample after making changes, run `azd up`.
48+
- Use `azd down` to easily delete the newly created resources.
49+
- Report any problems by opening an issue in [this repo](https://github.com/Azure-Samples/quote-of-the-day-dotnet/issues).
50+
- Refer to the [FAQ and troubleshoot](https://learn.microsoft.com/azure/developer/azure-developer-cli/troubleshoot) for `azd`.

azure.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2+
3+
name: quote-of-the-day-javascript
4+
metadata:
5+
template: quote-of-the-day-javascript@0.0.1-beta
6+
hooks:
7+
prepackage:
8+
shell: pwsh
9+
run: cd src && npm run build-client
10+
services:
11+
QuoteOfTheDay:
12+
project: src
13+
host: appservice
14+
language: js

infra/abbreviations.json

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"analysisServicesServers": "as",
3+
"apiManagementService": "apim-",
4+
"appConfigurationStores": "appcs-",
5+
"appManagedEnvironments": "cae-",
6+
"appContainerApps": "ca-",
7+
"authorizationPolicyDefinitions": "policy-",
8+
"automationAutomationAccounts": "aa-",
9+
"blueprintBlueprints": "bp-",
10+
"blueprintBlueprintsArtifacts": "bpa-",
11+
"cacheRedis": "redis-",
12+
"cdnProfiles": "cdnp-",
13+
"cdnProfilesEndpoints": "cdne-",
14+
"cognitiveServicesAccounts": "cog-",
15+
"cognitiveServicesFormRecognizer": "cog-fr-",
16+
"cognitiveServicesTextAnalytics": "cog-ta-",
17+
"computeAvailabilitySets": "avail-",
18+
"computeCloudServices": "cld-",
19+
"computeDiskEncryptionSets": "des",
20+
"computeDisks": "disk",
21+
"computeDisksOs": "osdisk",
22+
"computeGalleries": "gal",
23+
"computeSnapshots": "snap-",
24+
"computeVirtualMachines": "vm",
25+
"computeVirtualMachineScaleSets": "vmss-",
26+
"containerInstanceContainerGroups": "ci",
27+
"containerRegistryRegistries": "cr",
28+
"containerServiceManagedClusters": "aks-",
29+
"databricksWorkspaces": "dbw-",
30+
"dataFactoryFactories": "adf-",
31+
"dataLakeAnalyticsAccounts": "dla",
32+
"dataLakeStoreAccounts": "dls",
33+
"dataMigrationServices": "dms-",
34+
"dBforMySQLServers": "mysql-",
35+
"dBforPostgreSQLServers": "psql-",
36+
"devicesIotHubs": "iot-",
37+
"devicesProvisioningServices": "provs-",
38+
"devicesProvisioningServicesCertificates": "pcert-",
39+
"documentDBDatabaseAccounts": "cosmos-",
40+
"eventGridDomains": "evgd-",
41+
"eventGridDomainsTopics": "evgt-",
42+
"eventGridEventSubscriptions": "evgs-",
43+
"eventHubNamespaces": "evhns-",
44+
"eventHubNamespacesEventHubs": "evh-",
45+
"hdInsightClustersHadoop": "hadoop-",
46+
"hdInsightClustersHbase": "hbase-",
47+
"hdInsightClustersKafka": "kafka-",
48+
"hdInsightClustersMl": "mls-",
49+
"hdInsightClustersSpark": "spark-",
50+
"hdInsightClustersStorm": "storm-",
51+
"hybridComputeMachines": "arcs-",
52+
"insightsActionGroups": "ag-",
53+
"insightsComponents": "appi-",
54+
"keyVaultVaults": "kv-",
55+
"kubernetesConnectedClusters": "arck",
56+
"kustoClusters": "dec",
57+
"kustoClustersDatabases": "dedb",
58+
"logicIntegrationAccounts": "ia-",
59+
"logicWorkflows": "logic-",
60+
"machineLearningServicesWorkspaces": "mlw-",
61+
"managedIdentityUserAssignedIdentities": "id-",
62+
"managementManagementGroups": "mg-",
63+
"migrateAssessmentProjects": "migr-",
64+
"networkApplicationGateways": "agw-",
65+
"networkApplicationSecurityGroups": "asg-",
66+
"networkAzureFirewalls": "afw-",
67+
"networkBastionHosts": "bas-",
68+
"networkConnections": "con-",
69+
"networkDnsZones": "dnsz-",
70+
"networkExpressRouteCircuits": "erc-",
71+
"networkFirewallPolicies": "afwp-",
72+
"networkFirewallPoliciesWebApplication": "waf",
73+
"networkFirewallPoliciesRuleGroups": "wafrg",
74+
"networkFrontDoors": "fd-",
75+
"networkFrontdoorWebApplicationFirewallPolicies": "fdfp-",
76+
"networkLoadBalancersExternal": "lbe-",
77+
"networkLoadBalancersInternal": "lbi-",
78+
"networkLoadBalancersInboundNatRules": "rule-",
79+
"networkLocalNetworkGateways": "lgw-",
80+
"networkNatGateways": "ng-",
81+
"networkNetworkInterfaces": "nic-",
82+
"networkNetworkSecurityGroups": "nsg-",
83+
"networkNetworkSecurityGroupsSecurityRules": "nsgsr-",
84+
"networkNetworkWatchers": "nw-",
85+
"networkPrivateDnsZones": "pdnsz-",
86+
"networkPrivateLinkServices": "pl-",
87+
"networkPublicIPAddresses": "pip-",
88+
"networkPublicIPPrefixes": "ippre-",
89+
"networkRouteFilters": "rf-",
90+
"networkRouteTables": "rt-",
91+
"networkRouteTablesRoutes": "udr-",
92+
"networkTrafficManagerProfiles": "traf-",
93+
"networkVirtualNetworkGateways": "vgw-",
94+
"networkVirtualNetworks": "vnet-",
95+
"networkVirtualNetworksSubnets": "snet-",
96+
"networkVirtualNetworksVirtualNetworkPeerings": "peer-",
97+
"networkVirtualWans": "vwan-",
98+
"networkVpnGateways": "vpng-",
99+
"networkVpnGatewaysVpnConnections": "vcn-",
100+
"networkVpnGatewaysVpnSites": "vst-",
101+
"notificationHubsNamespaces": "ntfns-",
102+
"notificationHubsNamespacesNotificationHubs": "ntf-",
103+
"operationalInsightsWorkspaces": "log-",
104+
"portalDashboards": "dash-",
105+
"powerBIDedicatedCapacities": "pbi-",
106+
"purviewAccounts": "pview-",
107+
"recoveryServicesVaults": "rsv-",
108+
"resourcesResourceGroups": "rg-",
109+
"searchSearchServices": "srch-",
110+
"serviceBusNamespaces": "sb-",
111+
"serviceBusNamespacesQueues": "sbq-",
112+
"serviceBusNamespacesTopics": "sbt-",
113+
"serviceEndPointPolicies": "se-",
114+
"serviceFabricClusters": "sf-",
115+
"signalRServiceSignalR": "sigr",
116+
"sqlManagedInstances": "sqlmi-",
117+
"sqlServers": "sql-",
118+
"sqlServersDataWarehouse": "sqldw-",
119+
"sqlServersDatabases": "sqldb-",
120+
"sqlServersDatabasesStretch": "sqlstrdb-",
121+
"storageStorageAccounts": "st",
122+
"storageStorageAccountsVm": "stvm",
123+
"storSimpleManagers": "ssimp",
124+
"streamAnalyticsCluster": "asa-",
125+
"synapseWorkspaces": "syn",
126+
"synapseWorkspacesAnalyticsWorkspaces": "synw",
127+
"synapseWorkspacesSqlPoolsDedicated": "syndp",
128+
"synapseWorkspacesSqlPoolsSpark": "synsp",
129+
"timeSeriesInsightsEnvironments": "tsi-",
130+
"webServerFarms": "plan-",
131+
"webSitesAppService": "app-",
132+
"webSitesAppServiceEnvironment": "ase-",
133+
"webSitesFunctions": "func-",
134+
"webStaticSites": "stapp-"
135+
}

infra/app/QuoteOfTheDay.bicep

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
param name string
2+
param location string = resourceGroup().location
3+
param tags object = {}
4+
5+
param appConfigurationName string
6+
param applicationInsightsName string
7+
@secure()
8+
param appDefinition object
9+
param appServicePlanId string
10+
11+
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
12+
name: applicationInsightsName
13+
}
14+
15+
resource appService 'Microsoft.Web/sites@2023-01-01' = {
16+
name: name
17+
location: location
18+
tags: union(tags, {'azd-service-name': 'QuoteOfTheDay' })
19+
identity: {
20+
type: 'SystemAssigned'
21+
}
22+
properties: {
23+
serverFarmId: appServicePlanId
24+
siteConfig: {
25+
appCommandLine: 'npm start'
26+
linuxFxVersion: 'NODE|20-lts'
27+
alwaysOn: true
28+
}
29+
}
30+
}
31+
32+
@description('This is the built-in app configuration data reader role. See https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#app-configuration-data-reader')
33+
resource appConfigDataReaderDefinition 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
34+
name: '516239f1-63e1-4d78-a4de-a74fb236a071'
35+
}
36+
37+
resource appConfiguration 'Microsoft.AppConfiguration/configurationStores@2023-09-01-preview' existing = {
38+
name: appConfigurationName
39+
}
40+
41+
resource appConfigDataReaderRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
42+
name: guid(resourceGroup().id, appConfiguration.id, appConfigDataReaderDefinition.id)
43+
scope: appConfiguration
44+
properties: {
45+
roleDefinitionId: appConfigDataReaderDefinition.id
46+
principalId: appService.identity.principalId
47+
principalType: 'ServicePrincipal'
48+
}
49+
}
50+
51+
module configAppSettings '../shared/appservice-appsettings.bicep' = {
52+
name: '${name}-appSettings'
53+
params: {
54+
name: appService.name
55+
appSettings: union(
56+
{
57+
ENABLE_ORYX_BUILD: true
58+
},
59+
{
60+
SCM_DO_BUILD_DURING_DEPLOYMENT: true
61+
},
62+
{
63+
APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString
64+
},
65+
{
66+
APPCONFIG_ENDPOINT: appConfiguration.properties.endpoint
67+
},
68+
appDefinition.settings)
69+
}
70+
}
71+
72+
output name string = appService.name
73+
output uri string = 'https://${appService.properties.defaultHostName}'

0 commit comments

Comments
 (0)