I have developed a web application that successfully executes PowerShell scripts on my local machine. However, upon deploying the application to Azure App Service, I encountered errors indicating that the PowerShell commands were not being executed. Despite my efforts, I couldn't find any C# code examples for creating an App registration and adding permissions programmatically.
Scenario 1: Create App registration in Microsoft Entra ID(AAD).
Scenario 2: Update Permissions, Authentication type, Adding Owners into above created App registration.
In essence, my objective is to accomplish the following tasks:
- Execute PowerShell scripts within the web application.
- Ensure that these PowerShell commands function correctly when the application is deployed to Azure App Service.
- Investigate potential alternatives, such as utilizing C# code, to programmatically create an App registration and add permissions.
Below Script used to create App registration
$appName = $PartnerName+$PartnerAppSuffix$redirectUris = @("https://mscloud.onmicrosoft.com/$appName")$secretName = "secretKey"$App = New-AzADApplication -DisplayName $appName ` -ReplyUrls $redirectUris ` -Homepage "https://mscloud.onmicrosoft.com/$appName" ` -IdentifierUris "https://mscloud.onmicrosoft.com/$appName" ` -Web @{ ImplicitGrantSetting = @{ EnableAccessTokenIssuance = $true EnableIdTokenIssuance = $true } }# Create a new service principal for the app$ServicePrincipal = New-AzADServicePrincipal -ApplicationId $App.AppId
I'm in search of C# code snippets that facilitate the creation of App registrations and the addition of permissions and owners programmatically.