-
-
Save ThomasPe/e27b33ed1159b0003801216e898a51e5 to your computer and use it in GitHub Desktop.
Bicep IaC to deploy An Azure Email Communication Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param isProd bool = false | |
param communicationServiceName string = 'cs-medienstudio-dev' | |
param emailServiceName string = 'es-medienstudio-dev' | |
// Email Communication Service | |
resource emailService 'Microsoft.Communication/emailServices@2023-03-31' = { | |
name: emailServiceName | |
location: 'global' | |
properties: { | |
dataLocation: 'Europe' | |
} | |
} | |
// Email Communication Services Domain (Azure Managed) | |
resource emailServiceAzureDomain 'Microsoft.Communication/emailServices/domains@2023-03-31' = if (!isProd) { | |
parent: emailService | |
name: 'AzureManagedDomain' | |
location: 'global' | |
properties: { | |
domainManagement: 'AzureManaged' | |
userEngagementTracking: 'Disabled' | |
} | |
} | |
// SenderUsername (Azure Managed Domain) | |
resource senderUserNameAzureDomain 'Microsoft.Communication/emailServices/domains/senderUsernames@2023-03-31' = if (!isProd) { | |
parent: emailServiceAzureDomain | |
name: 'donotreply' | |
properties: { | |
username: 'DoNotReply' | |
displayName: 'DoNotReply' | |
} | |
} | |
// Email Communication Services Domain (Customer Managed) | |
resource emailServiceCustomDomain 'Microsoft.Communication/emailServices/domains@2023-03-31' = if (isProd) { | |
parent: emailService | |
name: 'pentenrieder.dev' | |
location: 'global' | |
properties: { | |
domainManagement: 'CustomerManaged ' | |
userEngagementTracking: 'Disabled' | |
} | |
} | |
// SenderUsername (Customer Managed Domain) | |
resource senderUserNameCustomDomain 'Microsoft.Communication/emailServices/domains/senderUsernames@2023-03-31' = if (isProd) { | |
parent: emailServiceCustomDomain | |
name: 'donotreply' | |
properties: { | |
username: 'DoNotReply' | |
displayName: 'DoNotReply' | |
} | |
} | |
// Link the correct domain based on the environment | |
var emailServiceResource = isProd ? emailServiceCustomDomain.id : emailServiceAzureDomain.id | |
// Communication Service | |
resource communcationService 'Microsoft.Communication/communicationServices@2023-03-31' = { | |
name: communicationServiceName | |
location: 'global' | |
properties: { | |
dataLocation: 'Europe' | |
linkedDomains: [ | |
emailServiceResource | |
] | |
} | |
} | |
// put this connection string into a key vault or (even better) use a Managed Identity to access Communication Service | |
var communicationServiceConnectionString = communcationService.listKeys().primaryConnectionString |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment