-
Notifications
You must be signed in to change notification settings - Fork 135
Add Azure Functions TypeScript deployment guidance for Event Hubs and enterprise policies #769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
6
commits into
main
Choose a base branch
from
copilot/update-azure-functions-deployment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6467969
Initial plan
Copilot c39e194
Add Azure Functions TypeScript deployment guidance and enterprise pol…
Copilot 41b0c3f
Refactor: move detailed guidance to separate reference files to reduc…
Copilot 1fefb91
Simplify error documentation and reduce token counts
Copilot eb05739
Fix: remove redundant enterprise policy row from security requirement…
Copilot a4ff5b9
Fix: add language identifiers to code blocks for proper syntax highli…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
75 changes: 75 additions & 0 deletions
75
plugin/skills/azure-prepare/references/recipes/azd/appinsights-auth.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Application Insights Identity-Based Authentication | ||
|
|
||
| When `DisableLocalAuth: true` is set on Application Insights (required by enterprise policies), you must configure identity-based authentication. | ||
|
|
||
| ## Requirements | ||
|
|
||
| 1. **Managed Identity**: Function App must have managed identity enabled | ||
| 2. **RBAC Role**: `Monitoring Metrics Publisher` role on Application Insights | ||
| 3. **App Setting**: `APPLICATIONINSIGHTS_AUTHENTICATION_STRING` | ||
|
|
||
| ## Bicep Configuration | ||
|
|
||
| ### System-Assigned Identity | ||
|
|
||
| ```bicep | ||
| // 1. Enable managed identity | ||
| resource functionApp 'Microsoft.Web/sites@2023-01-01' = { | ||
| name: functionAppName | ||
| identity: { type: 'SystemAssigned' } | ||
| } | ||
|
|
||
| // 2. Assign role | ||
| resource appInsightsRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| name: guid(functionApp.id, appInsights.id) | ||
| scope: appInsights | ||
| properties: { | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '3913510d-42f4-4e42-8a64-420c390055eb') | ||
| principalId: functionApp.identity.principalId | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| // 3. Add app setting | ||
| resource functionAppSettings 'Microsoft.Web/sites/config@2023-01-01' = { | ||
| name: 'appsettings' | ||
| parent: functionApp | ||
| properties: { | ||
| APPLICATIONINSIGHTS_AUTHENTICATION_STRING: 'Authorization=AAD' | ||
| APPLICATIONINSIGHTS_CONNECTION_STRING: appInsights.properties.ConnectionString | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### User-Assigned Identity | ||
|
|
||
| For user-assigned identity, include client ID in authentication string: | ||
|
|
||
| ```bicep | ||
| APPLICATIONINSIGHTS_AUTHENTICATION_STRING: 'ClientId=${userIdentity.properties.clientId};Authorization=AAD' | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **Symptom:** No traces in Application Insights | ||
|
|
||
| **Verify:** | ||
| ```bash | ||
| # Check identity | ||
| az functionapp identity show -g <rg> -n <app> | ||
|
|
||
| # Check app setting | ||
| az functionapp config appsettings list -g <rg> -n <app> \ | ||
| --query "[?name=='APPLICATIONINSIGHTS_AUTHENTICATION_STRING']" | ||
|
|
||
| # Check role | ||
| az role assignment list --scope <app-insights-resource-id> \ | ||
| --query "[?roleDefinitionName=='Monitoring Metrics Publisher']" | ||
| ``` | ||
|
|
||
| Wait 5-10 minutes for propagation after deployment. | ||
|
|
||
| ## See Also | ||
|
|
||
| - [enterprise-policy.md](enterprise-policy.md) - Policy compliance requirements | ||
| - [iac-rules.md](iac-rules.md) - IAC security rules |
This file contains hidden or 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
79 changes: 79 additions & 0 deletions
79
plugin/skills/azure-prepare/references/recipes/azd/enterprise-policy.md
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Enterprise Policy Compliance | ||
|
|
||
| Many Azure enterprise environments enforce security policies that require disabling local authentication methods. When generating infrastructure, **always include** these security properties to comply with common enterprise policies. | ||
|
|
||
| ## Event Hubs Namespace | ||
|
|
||
| ```bicep | ||
| resource eventHubNamespace 'Microsoft.EventHub/namespaces@2024-01-01' = { | ||
| name: eventHubNamespaceName | ||
| location: location | ||
| sku: { | ||
| name: 'Standard' | ||
| tier: 'Standard' | ||
| } | ||
| properties: { | ||
| disableLocalAuth: true // REQUIRED for enterprise policy compliance | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Storage Account | ||
|
|
||
| ```bicep | ||
| resource storage 'Microsoft.Storage/storageAccounts@2023-01-01' = { | ||
| name: storageAccountName | ||
| location: location | ||
| sku: { | ||
| name: 'Standard_LRS' | ||
| } | ||
| kind: 'StorageV2' | ||
| properties: { | ||
| allowSharedKeyAccess: false // REQUIRED for enterprise policy compliance | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Application Insights | ||
|
|
||
| ```bicep | ||
| resource appInsights 'Microsoft.Insights/components@2020-02-02' = { | ||
| name: appInsightsName | ||
| location: location | ||
| kind: 'web' | ||
| properties: { | ||
| Application_Type: 'web' | ||
| DisableLocalAuth: true // REQUIRED for enterprise policy compliance | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Service Bus Namespace | ||
|
|
||
| ```bicep | ||
| resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-10-01-preview' = { | ||
| name: serviceBusNamespaceName | ||
| location: location | ||
| sku: { | ||
| name: 'Standard' | ||
| } | ||
| properties: { | ||
| disableLocalAuth: true // REQUIRED for enterprise policy compliance | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Common Policy Errors | ||
|
|
||
| **Error:** | ||
| ``` | ||
| RequestDisallowedByPolicy: Resource 'evhns-xxx' was disallowed by policy. | ||
| Reasons: 'Local authentication methods are not allowed.' | ||
| ``` | ||
|
|
||
| **Solution:** Add `disableLocalAuth: true` (or `allowSharedKeyAccess: false` for Storage) to the resource properties in Bicep. | ||
|
|
||
| ## See Also | ||
|
|
||
| - [iac-rules.md](iac-rules.md) - Complete IAC rules including security requirements | ||
| - [appinsights-auth.md](appinsights-auth.md) - Application Insights identity-based authentication |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary --
azd packageis callingnpm run buildregardless