Skip to content

Commit

Permalink
WIP - Add ARM template
Browse files Browse the repository at this point in the history
This commit adds an ARM template to create the following resources:

- Event Hubs namespace and Event Hub
- Storage Account and Storage Container

To simplify setup. In addition, the outputs it spits out are exactly
the values you'd need to set as environment varialbes (minus the app
registration stuff which will be done manually)
  • Loading branch information
maorleger committed Dec 19, 2020
1 parent 9fb8919 commit 8fe4fc7
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 13 deletions.
13 changes: 0 additions & 13 deletions samples/frameworks/react/ts/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
---
page_type: sample
languages:
- typescript
products:
- azure
- azure-event-hubs
- azure-service-bus
- azure-storage
urlFragment: react-typescript
---

# Azure SDK samples for React (TypeScript)

This sample application shows how to use the TypeScript client libraries for Azure in some common scenarios.
Expand All @@ -29,7 +17,6 @@ Before running the samples in Node, they must be compiled to JavaScript using th
You need [an Azure subscription][freesub] and the following resources created to run this sample:

- An Azure EventHubs namespace. Please refer to the [EventHubs documentation][eventhubs] for additional information on EventHubs
- An Azure ServiceBus namespace and queue. Please refer to the [ServiceBus documentation][servicebus] for additional information on ServiceBus.
- An Azure Storage Blob container, with a single text file uploaded called "todo.txt" to support the sample. Please refer to the [Storage Blob documentation][storageblob] for additional information on Azure Storage Blob. This file will be fetched from Azure Storage Blob and displayed on the screen.
- Finally, you'll need a way to authenticate the application with Azure. This requires some additional setup configuring the correct access permissions to the above resources using either a service principal or a role-based-authentication. Please refer to the [@azure/identity][identity] package for information on authentication.

Expand Down
154 changes: 154 additions & 0 deletions samples/frameworks/react/ts/arm-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"baseName": {
"type": "string",
"defaultValue": "[resourceGroup().name]",
"metadata": {
"description": "The base resource name."
}
},
"appPort": {
"type": "string",
"defaultValue": "3000",
"metadata": {
"description": "The port used for the React app. Defaults to 3000"
}
}
},
"variables": {
"eventHubsName": "events",
"eventHubsNamespace": "[concat(parameters('baseName'), 'reactEvents')]",
"storageAccount": "[concat(parameters('baseName'), 'reactstorage')]",
"storageContainer": "[concat(parameters('baseName'), 'reactstorage', '/default/blobs')]",
"location": "[resourceGroup().location]"
},
"resources": [
{
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "2018-01-01-preview",
"name": "[variables('eventHubsNamespace')]",
"location": "[variables('location')]",
"sku": {
"name": "Basic",
"tier": "Basic",
"capacity": 1
},
"properties": {
"zoneRedundant": false,
"isAutoInflateEnabled": false,
"maximumThroughputUnits": 0,
"kafkaEnabled": false
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2020-08-01-preview",
"name": "[variables('storageAccount')]",
"location": "[variables('location')]",
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [],
"ipRules": [],
"defaultAction": "Allow"
},
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
}
},
{
"type": "Microsoft.EventHub/namespaces/eventhubs",
"apiVersion": "2017-04-01",
"name": "[concat(variables('eventHubsNamespace'), '/', variables('eventHubsName'))]",
"location": "[variables('location')]",
"dependsOn": [
"[resourceId('Microsoft.EventHub/namespaces', variables('eventHubsNamespace'))]"
],
"properties": {
"messageRetentionInDays": 1,
"partitionCount": 2,
"status": "Active"
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices",
"apiVersion": "2020-08-01-preview",
"name": "[concat(variables('storageAccount'), '/default')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount'))]"
],
"sku": {
"name": "Standard_RAGRS",
"tier": "Standard"
},
"properties": {
"cors": {
"corsRules": [
{
"allowedOrigins": ["[concat('http://localhost:', parameters('appPort'))]"],
"allowedMethods": ["GET", "OPTIONS"],
"maxAgeInSeconds": 0,
"exposedHeaders": ["*"],
"allowedHeaders": ["*"]
}
]
},
"deleteRetentionPolicy": {
"enabled": false
}
}
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2020-08-01-preview",
"name": "[variables('storageContainer')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/blobServices', variables('storageAccount'), 'default')]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount'))]"
],
"properties": {
"defaultEncryptionScope": "$account-encryption-key",
"denyEncryptionScopeOverride": false,
"publicAccess": "None"
}
}
],
"outputs": {
"REACT_APP_BLOB_URI": {
"type": "string",
"value": "[reference(variables('storageAccount')).primaryEndpoints.blob]"
},
"REACT_APP_BLOB_CONTAINER": {
"type": "string",
"value": "[last(split(variables('storageContainer'), '/'))]"
},
"REACT_APP_EVENT_HUBS_NAMESPACE": {
"type": "string",
"value": "[concat(variables('eventHubsNamespace'), '.servicebus.windows.net')]"
},
"REACT_APP_EVENT_HUBS_NAME": {
"type": "string",
"value": "[variables('eventHubsName')]"
}
}
}

0 comments on commit 8fe4fc7

Please sign in to comment.