Skip to content

Instantly share code, notes, and snippets.

function Get-AzureOpenAIToken1{
<# .SYNOPSIS
Get an azure token for user or managed identity thats required to authenticate to Azure OpenAI with Rest API.
Also construct the header if you are using an Azure OpenAI API key instead of Azure AD authentication.
.PARAMETER ManagedIdentity
Use this parameter if you want to use a managed identity to authenticate to Azure OpenAI.
.PARAMETER User
Use this parameter if you want to use a user to authenticate to Azure OpenAI.
.PARAMETER APIKey
Use this parameter if you want to use an API key to authenticate to Azure OpenAI.
,
"additionalLoginParams": [
"response_type=code id_token",
"https://graph.microsoft.com",
"(String)"
]
using namespace System.Net
using namespace System.IO
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
@AlexanderHolmeset
AlexanderHolmeset / VoiceNoStyle.ps1
Last active October 18, 2023 14:08
VoiceNoStyle
$AzureSpeechSubscriptionKey = 'enter your key here'
$AzureSpeechRegion = 'norwayeast'
$Language = 'en-IE'
$VoiceName = 'en-IE-EmilyNeural'
$FetchTokenHeader = @{
'Content-type'='application/x-www-form-urlencoded';
'Content-Length'= '0';
'Ocp-Apim-Subscription-Key' = $AzureSpeechSubscriptionKey
}
@AlexanderHolmeset
AlexanderHolmeset / VoiceStyle.ps1
Last active October 18, 2023 14:08
VoiceStyle
$AzureSpeechSubscriptionKey = 'enter your key here'
$AzureSpeechRegion = 'norwayeast'
$Language = 'en-us'
$VoiceName = 'en-US-JennyNeural'
$Style = 'whispering'
$FetchTokenHeader = @{
'Content-type'='application/x-www-form-urlencoded';
'Content-Length'= '0';
'Ocp-Apim-Subscription-Key' = $AzureSpeechSubscriptionKey
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Bot_User": {
"inputs": {
"variables": [
{
"name": "BotUserID",
"type": "string"
$csvFile = "C:\temp\teamslist.csv"
#List of team object IDs. Header in CSV is ID.
$table = Import-Csv $csvFile -Delimiter ","
$source = Connect-Tenant -Domain contoso.onmicrosoft.com -Browser
$destination = Connect-Tenant -Domain tailspin.onmicrosoft.com -Browser
foreach ($row in $table) {
$team = Get-Team -id $($row.id) -Tenant $source
$TenantID = "xxxxxx"
$LogicAppSeObjectID = "xxxxxxx"
$ServicePrincipalId = $LogicAppSeObjectID
$GraphResource = Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0000-c000-000000000000'"
$application_role_to_assign_name = "Chat.Read.All"
$Permission = $GraphResource.AppRoles | Where-Object {$_.value -in $application_role_to_assign_name}
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $ServicePrincipalId -PrincipalId $ServicePrincipalId -AppRoleId $Permission.Id -ResourceId $GraphResource.Id
{
"properties": {
"choices": {
"items": {
"properties": {
"content_filter_results": {
"properties": {
"hate": {
"properties": {
"filtered": {
{
"items": {
"properties": {
"content": {
"type": "string"
},
"role": {
"type": "string"
}
},