Skip to content

Commit

Permalink
[Event Hubs] Disable local auth when not in the isolated sub (#32769)
Browse files Browse the repository at this point in the history
Otherwise, resource creation fails.
  • Loading branch information
deyaaeldeen authored Feb 6, 2025
1 parent f9eb331 commit 6353087
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sdk/eventhub/test-resources.bicep
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
param baseName string = resourceGroup().name
param location string = resourceGroup().location
param testApplicationOid string
param supportsSafeSecretStandard bool = false

var eventHubApiVersion = '2024-01-01'
var storageApiVersion = '2023-05-01'
var iotHubApiVersion = '2023-06-30'
var storageAccountName = 'storage${baseName}'
var containerName = 'container'
Expand Down Expand Up @@ -32,6 +32,7 @@ resource eventHubNamespace 'Microsoft.EventHub/namespaces@2024-01-01' = {
zoneRedundant: false
isAutoInflateEnabled: false
maximumThroughputUnits: 0
disableLocalAuth: supportsSafeSecretStandard
}
}

Expand Down Expand Up @@ -69,6 +70,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2023-05-01' = {
}
kind: 'StorageV2'
properties: {
allowSharedKeyAccess: false
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: []
Expand Down Expand Up @@ -105,7 +107,11 @@ resource iotHub 'Microsoft.Devices/IotHubs@2023-06-30' = {
name: 'S1'
capacity: 1
}
identity: {
type: 'SystemAssigned'
}
properties: {
disableLocalAuth: supportsSafeSecretStandard
ipFilterRules: []
eventHubEndpoints: {
events: {
Expand Down Expand Up @@ -134,7 +140,7 @@ resource iotHub 'Microsoft.Devices/IotHubs@2023-06-30' = {
storageEndpoints: {
'$default': {
sasTtlAsIso8601: 'PT1H'
connectionString: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};AccountKey=${listKeys(storageAccount.id, storageApiVersion).keys[0].value};EndpointSuffix=${environment().suffixes.storage}'
authenticationType: 'identityBased'
containerName: containerName
}
}
Expand Down Expand Up @@ -225,6 +231,15 @@ resource iotHubDataContributorRoleAssignment 'Microsoft.Authorization/roleAssign
}
}

resource iotHubStorageRoleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
name: guid(iotHub.id, 'Storage Blob Data Contributor')
scope: storageAccount
properties: {
roleDefinitionId: resourceId('Microsoft.Authorization/roleDefinitions', blobDataContributorRoleId)
principalId: iotHub.identity.principalId
}
}

output EVENTHUB_FQDN string = replace(replace(eventHubNamespace.properties.serviceBusEndpoint, ':443/', ''), 'https://', '')
output EVENTHUB_NAME string = eventHub.name
output EVENTHUB_CONSUMER_GROUP_NAME string = eventHubConsumerGroup.name
Expand Down

0 comments on commit 6353087

Please sign in to comment.