← Back to Blog

DevAIOPS workflow and what is an orchestration

DevAIOPS workflow and what is an orchestration Marianna question and answer > https://www.canva.com/design/DAF23OQVMms/lbhsNWtpi6U1BLwi4DRBWw/edit Systems erdem has build is failing > >> Blaze text speeding up the missed emails >>> causing Erdem to Answer ema

DevAIOPS workflow and what is an orchestration

Marianna question and answer > https://www.canva.com/design/DAF23OQVMms/lbhsNWtpi6U1BLwi4DRBWw/edit

devaiops workflow and 1

devaiops workflow and 2

Systems erdem has build is failing > >> Blaze text speeding up the missed emails >>> causing Erdem to Answer emails

devaiops workflow and 3

https://mail.google.com/mail/u/0/#advanced-search/is_unread=true&query=label%3A1_borrow_followup&isrefinement=true/FMfcgzGxTFdxcbDCwQcNVwTHzSHlbWQV

Waiting for me to send the e

devaiops workflow and 4

attachment on my side

devaiops workflow and 5

Operator Role did the orchestrator failed ?

devaiops workflow and 6

wow operator failed last time success 8 days ago

devaiops workflow and 7

todo > a report is needed on the daily responses.!

Implementer role in action

late fails

devaiops workflow and 8

Looks spotted as spam

devaiops workflow and 9

gpt step failed

devaiops workflow and 10

devaiops workflow and 11

error output

{ "error": { "code": "NoResponse", "message": "The server did not receive a response from an upstream server. Request tracking id '08584859739385369928285408313CU02'." } }

Operator runid >

08584859740438399253263762218CU22

  • Run Details

  • Resubmit

  • Cancel Run

  • Refresh

  • Info

  • Generally Available Designer

https://portal.azure.com/#view/Microsoft_Azure_EMA/LogicAppsMonitorBlade/runid/%2Fsubscriptions%2Fad744a08-2411-4d78-b417-1f1c83f4f741%2FresourceGroups%2FContractorMarketing%2Fproviders%2FMicrosoft.Logic%2Fworkflows%2Fcontractormarketing-replygmail-realtime%2Fruns%2F08584859740438399253263762218CU22

Designer Role > Daily report email

  • How many leads added

  • How many logic apps run

  • How many failed

  • How many successed

Planner Role > Find the previous automation what is the state and mention it

Similar report

devaiops workflow and 12

69 logic apps

devaiops workflow and 13

there are report related orchestrators

devaiops workflow and 14

report daily trigger becomes a favorite

devaiops workflow and 15

Trigger worked daily > Planner no miss > Operator know is know

Designer error did not think about this usecase >

devaiops workflow and 16

Task think and implement it so the operator sees it daily with planner to get the results

working with gpt anw writing it down

devaiops workflow and 17

To run this analysis directly from a Logic App, you can use the Azure Logic Apps and Azure Functions combination. Here's a step-by-step guide to achieve this:

  • Create an Azure Function: Write an Azure Function that performs the analysis.

  • Trigger the Azure Function from the Logic App: Use an HTTP trigger or a timer trigger in the Logic App to call the Azure Function.

  • Output the results in the Logic App: Handle the results from the Azure Function in the Logic App workflow.

Step 1: Create an Azure Function

First, create an Azure Function that performs the Logic App runs analysis.

Create a PowerShell Azure Function

  • Create the Azure Function App:

  • Navigate to the Azure portal.

  • Create a new Function App.

  • Choose the PowerShell Core runtime stack.

  • Create a PowerShell Function:

  • In the Function App, create a new function using the HTTP trigger template.

  • Write the Function Code:

  • Replace the template code with the following PowerShell code:

using namespace System.Net

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

Authenticate to Azure

Connect-AzAccount -Identity

Define variables

$resourceGroupName = "YourResourceGroupName"
$logicAppName = "YourLogicAppName"

Fetch the runs for the Logic App in the specified resource group

$startDate = (Get-Date).Date # Start from the beginning of today
$endDate = $startDate.AddDays(1) # End at the beginning of tomorrow

Get the Logic App runs for the specified date range

$logicAppRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -StartTime $startDate -EndTime $endDate

Initialize counters

$successCount = 0
$failureCount = 0
$skippedCount = 0

Loop through the runs and count the statuses

foreach ($run in $logicAppRuns) {
switch ($run.Status) {
"Succeeded" { $successCount++ }
"Failed" { $failureCount++ }
"Skipped" { $skippedCount++ }
}
}

Prepare the response

$response = @{
Date = (Get-Date -Format 'yyyy-MM-dd')
SucceededRuns = $successCount
FailedRuns = $failureCount
SkippedRuns = $skippedCount
}

Output the results

$responseBody = $response | ConvertTo-Json
Write-Output $responseBody

Create the response object with status code.

$Response = [HttpResponseMessage]::new([HttpStatusCode]::OK)
$Response.Content = [System.Net.Http.StringContent]::new($responseBody, [System.Text.Encoding]::UTF8, "application/json")
return $Response

Step 2: Create the Logic App

  • Create a Logic App:

  • Navigate to the Azure portal.

  • Create a new Logic App.

  • Add an HTTP Action:

  • In the Logic App Designer, add a new HTTP action.

  • Set the HTTP action to perform a GET request to the Azure Function URL.

Step 3: Configure the HTTP Action

  • HTTP Action Configuration:

  • Set the method to GET.

  • Set the URL to the Azure Function's URL (you can find this in the Function App's "Get function URL" option).

  • Parse the JSON Response:

  • Add a new action to parse the JSON response from the Azure Function.

  • Choose the "Parse JSON" action.

  • Set the content to the body of the HTTP response.

  • Define the schema based on the expected response from the Azure Function. You can generate the schema using the following JSON:
    json { "Date": "string", "SucceededRuns": "integer", "FailedRuns": "integer", "SkippedRuns": "integer" }

  • Add Actions to Handle the Results:

  • Add actions to handle the parsed results, such as sending an email or logging the results to a storage account.

Example Logic App Workflow

  • HTTP Action:

  • Method: GET

  • URL: https://<your-function-app>.azurewebsites.net/api/<your-function>?code=<your-function-key>

  • Parse JSON:

  • Content: @body('HTTP')

  • Schema:
    json { "type": "object", "properties": { "Date": { "type": "string" }, "SucceededRuns": { "type": "integer" }, "FailedRuns": { "type": "integer" }, "SkippedRuns": { "type": "integer" } } }

  • Log Results or Send Notification:

  • Use the parsed data to log results, send an email notification, or take any other action as needed.

By following these steps, you can create a workflow in Azure Logic Apps that analyzes daily Logic App runs by invoking an Azure Function. The function will perform the analysis and return the results, which can then be processed further in the Logic App.

Why didnt i know this

devaiops workflow and 18

devaiops workflow and 19

and the function

devaiops workflow and 20

devaiops workflow and 21

devaiops workflow and 22

Powershell core looks like csharp>>> wow that is coming in

devaiops workflow and 23

Compare the paste

devaiops workflow and 24

code before

`using namespace System.Net

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."

Interact with query parameters or the body of the request.

$name = $Request.Query.Name
if (-not $name) {
$name = $Request.Body.Name
}

$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."

if ($name) {
$body = "Hello, $name. This HTTP triggered function executed successfully."
}

Associate values to output bindings by calling 'Push-OutputBinding'.

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body


well commented

devaiops workflow and 25

Linting in Azure is better now

devaiops workflow and 26

even first run has the action > probably i enable things in the back with connect identity

devaiops workflow and 27

The error message indicates that the Connect-AzAccount command is not recognized because the required Azure module (Az) is not available in the Azure Function environment. To fix this, you need to specify the required modules in the requirements.psd1 file of your Azure Function so that they are installed and imported automatically.

Step-by-Step Solution:

  1. Update requirements.psd1:
    Add the necessary modules to the requirements.psd1 file in your Azure Function App.

  2. Explicitly Import the Modules:
    Import the Az module explicitly in your function code.

Step 1: Update requirements.psd1

Add the Az module to the requirements.psd1 file. This file should be in the root directory of your function app. If it doesn't exist, create it and add the following content:

```powershell
@{
# The list of modules to import from the PowerShell Gallery.
# Ensure that the modules are compatible with PowerShell 7.
'Az' = '7.*' # Ensure you use the appropriate version of the Az module
}


                ### Step 2: Explicitly Import the Module in Your Function Code
                
                Modify your function code to explicitly import the `Az` module and then authenticate. Here's the updated code for the Azure Function:
                
                ```powershell
                using namespace System.Net
                
                # Input bindings are passed in via param block.
                param($Request, $TriggerMetadata)
                
                # Import the Az module explicitly
                Import-Module Az -UseWindowsPowerShell
                
                # Authenticate to Azure using managed identity
                Connect-AzAccount -Identity
                
                # Define variables
                $resourceGroupName = "YourResourceGroupName"
                $logicAppName = "YourLogicAppName"
                
                # Fetch the runs for the Logic App in the specified resource group
                $startDate = (Get-Date).Date  # Start from the beginning of today
                $endDate = $startDate.AddDays(1)  # End at the beginning of tomorrow
                
                # Get the Logic App runs for the specified date range
                $logicAppRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -StartTime $startDate -EndTime $endDate
                
                # Initialize counters
                $successCount = 0
                $failureCount = 0
                $skippedCount = 0
                
                # Loop through the runs and count the statuses
                foreach ($run in $logicAppRuns) {
                    switch ($run.Status) {
                        "Succeeded" { $successCount++ }
                        "Failed" { $failureCount++ }
                        "Skipped" { $skippedCount++ }
                    }
                }
                
                # Prepare the response
                $response = @{
                    Date = (Get-Date -Format 'yyyy-MM-dd')
                    SucceededRuns = $successCount
                    FailedRuns = $failureCount
                    SkippedRuns = $skippedCount
                }
                
                # Output the results
                $responseBody = $response | ConvertTo-Json
                Write-Output $responseBody
                
                # Create the response object with status code.
                $Response = [HttpResponseMessage]::new([HttpStatusCode]::OK)
                $Response.Content = [System.Net.Http.StringContent]::new($responseBody, [System.Text.Encoding]::UTF8, "application/json")
                return $Response
                

Explanation:

  1. requirements.psd1: Specifies the modules required by your function. The Az module version 7.x is specified, which is compatible with PowerShell 7.
  2. Import-Module Az -UseWindowsPowerShell: Explicitly imports the Az module within your function.
  3. Connect-AzAccount -Identity: Uses managed identity for authentication.

Deploy and Test:

  1. Deploy: Deploy your updated function with the requirements.psd1 file.
  2. Test: Trigger the function and ensure it runs without errors.

By following these steps, you should be able to resolve the issue and successfully run the analysis of Logic App runs from your Azure Function.

devaiops workflow and 28

updated

devaiops workflow and 29

Define variables

$resourceGroupName = "ContractorMarketing"

$logicAppName = "contractormarketing-replygmail-realtime"

explicit import scripts are coming in

devaiops workflow and 30

basic login and access has similar issues

devaiops workflow and 31

Consumption plans have a hard time

devaiops workflow and 32

there is also an optional one coming in

When using a consumption plan, you need to make sure the required modules are available and correctly imported. The consumption plan requires the modules to be listed in requirements.psd1 and does not support -UseWindowsPowerShell. Instead, modules need to be compatible with PowerShell 7. Here is a streamlined approach:

Step-by-Step Solution for Consumption Plan:

  • Ensure requirements.psd1 is Correct:
    Add the Az and Az.LogicApp modules to the requirements.psd1 file.

  • Explicitly Import the Modules in the Function Code:
    Modify your function code to import the Az and Az.LogicApp modules and handle authentication.

Step 1: Update requirements.psd1

Ensure the requirements.psd1 file includes the Az module and Az.LogicApp module.

@{
# The list of modules to import from the PowerShell Gallery.
# Ensure that the modules are compatible with PowerShell 7.
'Az' = '7.*' # Ensure you use the appropriate version of the Az module
}

Step 2: Explicitly Import the Modules in Your Function Code

Here's the updated code for the Azure Function with your specific configuration:

using namespace System.Net

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

Import the Az modules explicitly

Import-Module Az.Accounts
Import-Module Az.LogicApp

Authenticate to Azure using managed identity

Connect-AzAccount -Identity

Define variables

$resourceGroupName = "ContractorMarketing"
$logicAppName = "contractormarketing-replygmail-realtime"

Fetch the runs for the Logic App in the specified resource group

$startDate = (Get-Date).Date # Start from the beginning of today
$endDate = $startDate.AddDays(1) # End at the beginning of tomorrow

Get the Logic App runs for the specified date range

$logicAppRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -StartTime $startDate -EndTime $endDate

Initialize counters

$successCount = 0
$failureCount = 0
$skippedCount = 0

Loop through the runs and count the statuses

foreach ($run in $logicAppRuns) {
switch ($run.Status) {
"Succeeded" { $successCount++ }
"Failed" { $failureCount++ }
"Skipped" { $skippedCount++ }
}
}

Prepare the response

$response = @{
Date = (Get-Date -Format 'yyyy-MM-dd')
SucceededRuns = $successCount
FailedRuns = $failureCount
SkippedRuns = $skippedCount
}

Output the results

$responseBody = $response | ConvertTo-Json
Write-Output $responseBody

Create the response object with status code.

$Response = [HttpResponseMessage]::new([HttpStatusCode]::OK)
$Response.Content = [System.Net.Http.StringContent]::new($responseBody, [System.Text.Encoding]::UTF8, "application/json")
return $Response

Explanation:

  • requirements.psd1: Specifies the Az module required by your function. The Az.LogicApp module is part of the Az module.

  • Import-Module Az.Accounts: Imports the Az.Accounts module explicitly.

  • Import-Module Az.LogicApp: Imports the Az.LogicApp module explicitly.

  • Resource Group and Logic App: Uses your specified resource group name and logic app name.

Deploy and Test:

  • Deploy: Deploy your updated function with the requirements.psd1 file.

  • Test: Trigger the function and ensure it runs without errors.

This approach ensures that the required modules are available and correctly imported in the Azure Functions consumption plan environment.

to run one line it is taking time

devaiops workflow and 33

error

`2024-05-14T11:43:02Z [Information] INFORMATION: Loaded Module 'Az.Accounts'
2024-05-14T11:43:06Z [Information] INFORMATION: Loaded Module 'Az.Websites'
2024-05-14T11:43:07Z [Information] Executing 'Functions.GetLogsForLogicApp' (Reason='This function was programmatically called via the host APIs.', Id=1f2b2af4-5d35-40d4-9dbd-a105a5bfdfd5)
2024-05-14T11:43:07Z [Verbose] Sending invocation id: '1f2b2af4-5d35-40d4-9dbd-a105a5bfdfd5
2024-05-14T11:43:07Z [Verbose] Posting invocation id:1f2b2af4-5d35-40d4-9dbd-a105a5bfdfd5 on workerId:2d8e705d-28fa-4ad7-9c71-290466958f37
2024-05-14T11:43:09Z [Error] ERROR: Assembly with same name is already loaded

Exception :
Type : System.IO.FileLoadException
Message : Assembly with same name is already loaded
TargetSite :
Name : LoadBinaryModule`


mAXINMIZE WINDOW

devaiops workflow and 34

packages in and out

The error message Assembly with same name is already loaded typically occurs when there is an attempt to load a module or assembly that has already been loaded into the current session. This can happen if multiple modules are trying to load the same assembly or if there's an explicit Import-Module that conflicts with an implicit load.

Step-by-Step Solution to Resolve Assembly Conflicts

  • Remove Redundant Imports:
    Ensure that modules are imported only once and there are no conflicting imports.

  • Use Specific Imports:
    Instead of importing the entire Az module, import only the necessary submodules.

  • Clear Loaded Modules:
    Clear any loaded modules if re-importing is necessary.

Here is an adjusted version of your Azure Function code:

using namespace System.Net

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

Clear any previously loaded modules if needed

Remove-Module Az -ErrorAction SilentlyContinue
Remove-Module Az.Accounts -ErrorAction SilentlyContinue
Remove-Module Az.LogicApp -ErrorAction SilentlyContinue

Import the necessary Az modules explicitly

Import-Module Az.Accounts
Import-Module Az.LogicApp

Authenticate to Azure using managed identity

Connect-AzAccount -Identity

Define variables

$resourceGroupName = "ContractorMarketing"
$logicAppName = "contractormarketing-replygmail-realtime"

Fetch the runs for the Logic App in the specified resource group

$startDate = (Get-Date).Date # Start from the beginning of today
$endDate = $startDate.AddDays(1) # End at the beginning of tomorrow

Get the Logic App runs for the specified date range

$logicAppRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -StartTime $startDate -EndTime $endDate

Initialize counters

$successCount = 0
$failureCount = 0
$skippedCount = 0

Loop through the runs and count the statuses

foreach ($run in $logicAppRuns) {
switch ($run.Status) {
"Succeeded" { $successCount++ }
"Failed" { $failureCount++ }
"Skipped" { $skippedCount++ }
}
}

Prepare the response

$response = @{
Date = (Get-Date -Format 'yyyy-MM-dd')
SucceededRuns = $successCount
FailedRuns = $failureCount
SkippedRuns = $skippedCount
}

Output the results

$responseBody = $response | ConvertTo-Json
Write-Output $responseBody

Create the response object with status code.

$Response = [HttpResponseMessage]::new([HttpStatusCode]::OK)
$Response.Content = [System.Net.Http.StringContent]::new($responseBody, [System.Text.Encoding]::UTF8, "application/json")
return $Response

Explanation:

  • Remove Redundant Imports:

  • Remove-Module Az -ErrorAction SilentlyContinue: Ensures any previously loaded Az module is removed.

  • Remove-Module Az.Accounts -ErrorAction SilentlyContinue: Ensures any previously loaded Az.Accounts module is removed.

  • Remove-Module Az.LogicApp -ErrorAction SilentlyContinue: Ensures any previously loaded Az.LogicApp module is removed.

  • Import Necessary Modules:

  • Import-Module Az.Accounts: Imports the Az.Accounts module.

  • Import-Module Az.LogicApp: Imports the Az.LogicApp module.

  • Authenticate:

  • Connect-AzAccount -Identity: Authenticates using managed identity.

Deploy and Test:

  • Deploy: Deploy your updated function.

  • Test: Trigger the function and ensure it runs without errors.

This approach ensures that the modules are correctly loaded and that no conflicting assemblies are causing the Assembly with same name is already loaded error. If the issue persists, you may need to check for any specific module versions or dependencies that might be conflicting and adjust accordingly.

devaiops workflow and 35

clear and rerun

devaiops workflow and 36

new error >

Connected! You are now viewing logs of Function runs in the current Code + Test panel. To see all the logs for this Function, please go to 'Monitor' from the Function menu.

2024-05-14T11:47:11Z [Warning] WARNING: Unable to acquire token for tenant 'organizations' with error 'ManagedIdentityCredential authentication unavailable. Multiple attempts failed to obtain a token from the managed identity endpoint.'

2024-05-14T11:47:12Z [Error] ERROR: ManagedIdentityCredential authentication unavailable. Multiple attempts failed to obtain a token from the managed identity endpoint. Exception : Type : Azure.Identity.CredentialUnavailableException TargetSite : Name : MoveNext DeclaringType : [Azure.Identity.ImdsManagedIdentitySource+d__15] MemberType : Method Module : Azure.Identity.dll Message : ManagedIdentityCredential authentication unavailable. Multiple attempts failed to obtain a token from the managed identity endpoint. InnerException : Type : System.AggregateException InnerExceptions : Type : Azure.RequestFailedException TargetSite : Name : MoveNext DeclaringType : [Azure.Core.Pipeline.HttpClientTransport+d__12] MemberType : Method Module : Azure.Core.dll Message : An attempt was made to access a socket in a way forbidden by its access permissions. (169.254.169.254:80) InnerException : Type : System.Net.Http.HttpRequestException HttpRequestError : ConnectionError TargetSite : Name : MoveNext DeclaringType : [System.Net.Http.HttpConnectionPool+d__104] MemberType : Method Module : System.Net.Http.dll Message : An attempt was made to access a socket in a way forbidden by its access permissions. (169.254.169.254:80) InnerException : Type : System.Net.Sockets.SocketException Message : An attempt was made to access a socket in a way forbidden by its access permissions. SocketErrorCode : AccessDenied ErrorCode : 10013 NativeErrorCode : 10013 TargetSite : Name : ThrowException DeclaringType : [System.Net.Sockets.Socket+AwaitableSocketAsyncEventArgs] MemberType : Method Module : System.Net.Sockets.dll Source : System.Net.Sockets HResult : -2147467259 StackTrace : at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at System.Net.Sockets.Socket.g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken) Source : System.Net.Http HResult : -2147467259 StackTrace :

The error message indicates that the managed identity authentication is failing, possibly due to issues with the managed identity configuration or permissions. To resolve this, ensure that the managed identity is correctly set up and has the necessary permissions to access Azure resources.

Steps to Fix Managed Identity Authentication Issues

  • Verify Managed Identity Configuration:
    Ensure that the managed identity is enabled for the Function App.

  • Assign Necessary Roles:
    Assign the necessary roles to the managed identity to access Azure resources, such as the Logic App.

  • Use Azure PowerShell with Service Principal (as an alternative to managed identity).

Step 1: Verify Managed Identity Configuration

  • Navigate to Your Function App:

  • In the Azure portal, go to your Function App.

  • Enable Managed Identity:

  • Under the "Settings" section, select "Identity".

  • Ensure that the "System assigned" managed identity is set to "On".

Step 2: Assign Necessary Roles

  • Assign Roles in the Resource Group:

  • Go to the resource group containing your Logic App.

  • Select "Access control (IAM)".

  • Click "Add" and then "Add role assignment".

  • Assign the "Logic App Contributor" role to the managed identity of your Function App.

  • Verify Role Assignment:

  • Ensure that the managed identity has the necessary roles assigned.

Step 3: Use Azure PowerShell with Service Principal (Alternative)

If managed identity continues to fail, you can use a service principal for authentication. Here's how to set it up:

  • Create a Service Principal:

  • Use the Azure CLI to create a service principal and get the client ID, secret, and tenant ID:
    sh az ad sp create-for-rbac --name "<your-service-principal-name>" --role contributor --scopes /subscriptions/<your-subscription-id>

  • Update Azure Function to Use Service Principal:

  • Store the client ID, client secret, and tenant ID in Azure Key Vault or as application settings in the Function App.

  • Modify the function code to authenticate using the service principal.

Example Code Using Service Principal

Here is the example code to use a service principal for authentication:

using namespace System.Net

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

Retrieve credentials from environment variables or Key Vault

$clientId = $env:AZURE_CLIENT_ID
$clientSecret = $env:AZURE_CLIENT_SECRET
$tenantId = $env:AZURE_TENANT_ID

Authenticate to Azure using service principal

$securePassword = ConvertTo-SecureString $clientSecret -AsPlainText -Force
$credentials = New-Object Microsoft.Azure.Commands.Common.Authentication.Abstractions.Authentication.Abstractions.ServicePrincipalLoginInformation -Property @{ClientId = $clientId; ClientSecret = $securePassword}
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$context.Login($tenantId, $credentials)

Import the Az modules explicitly

Import-Module Az.Accounts
Import-Module Az.LogicApp

Define variables

$resourceGroupName = "ContractorMarketing"
$logicAppName = "contractormarketing-replygmail-realtime"

Fetch the runs for the Logic App in the specified resource group

$startDate = (Get-Date).Date # Start from the beginning of today
$endDate = $startDate.AddDays(1) # End at the beginning of tomorrow

Get the Logic App runs for the specified date range

$logicAppRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -StartTime $startDate -EndTime $endDate

Initialize counters

$successCount = 0
$failureCount = 0
$skippedCount = 0

Loop through the runs and count the statuses

foreach ($run in $logicAppRuns) {
switch ($run.Status) {
"Succeeded" { $successCount++ }
"Failed" { $failureCount++ }
"Skipped" { $skippedCount++ }
}
}

Prepare the response

$response = @{
Date = (Get-Date -Format 'yyyy-MM-dd')
SucceededRuns = $successCount
FailedRuns = $failureCount
SkippedRuns = $skippedCount
}

Output the results

$responseBody = $response | ConvertTo-Json
Write-Output $responseBody

Create the response object with status code.

$Response = [HttpResponseMessage]::new([HttpStatusCode]::OK)
$Response.Content = [System.Net.Http.StringContent]::new($responseBody, [System.Text.Encoding]::UTF8, "application/json")
return $Response

Additional Steps:

  • Store Service Principal Credentials Securely:

  • Store the client ID, secret, and tenant ID in Azure Key Vault and reference them in the Function App.

  • Test and Verify:

  • Ensure the service principal has the required permissions and test the function to verify it works correctly.

By following these steps, you can resolve the managed identity authentication issue or alternatively use a service principal for authentication to access Azure resources from your Azure Function.

devaiops workflow and 37

Before

devaiops workflow and 38

after

devaiops workflow and 39

ok more meaningful errors

devaiops workflow and 40

parameter getting fixed

devaiops workflow and 41

Fixed run > https://portal.azure.com/#view/WebsitesExtension/FunctionMenuBlade/~/code/resourceId/%2Fsubscriptions%2Fad744a08-2411-4d78-b417-1f1c83f4f741%2FresourceGroups%2FContractorMarketing%2Fproviders%2FMicrosoft.Web%2Fsites%2Fcontractormarketing-logicappreporting%2Ffunctions%2FGetLogsForLogicApp

`using namespace System.Net

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

Clear any previously loaded modules if needed

Remove-Module Az -ErrorAction SilentlyContinue
Remove-Module Az.Accounts -ErrorAction SilentlyContinue
Remove-Module Az.LogicApp -ErrorAction SilentlyContinue

Import the necessary Az modules explicitly

Import-Module Az.Accounts
Import-Module Az.LogicApp

Authenticate to Azure using managed identity

Connect-AzAccount -Identity

Define variables

$resourceGroupName = "ContractorMarketing"
$logicAppName = "contractormarketing-replygmail-realtime"

Fetch the runs for the Logic App in the specified resource group

$startDate = (Get-Date).Date # Start from the beginning of today
$endDate = $startDate.AddDays(1) # End at the beginning of tomorrow

Get the Logic App runs for the specified date range

$logicAppRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -TriggerTime $startDate -EndTime $endDate

Initialize counters

$successCount = 0
$failureCount = 0
$skippedCount = 0

Loop through the runs and count the statuses

foreach ($run in $logicAppRuns) {
switch ($run.Status) {
"Succeeded" { $successCount++ }
"Failed" { $failureCount++ }
"Skipped" { $skippedCount++ }
}
}

Prepare the response

$response = @{
Date = (Get-Date -Format 'yyyy-MM-dd')
SucceededRuns = $successCount
FailedRuns = $failureCount
SkippedRuns = $skippedCount
}

Output the results

$responseBody = $response | ConvertTo-Json
Write-Output $responseBody

Create the response object with status code.

$Response = [HttpResponseMessage]::new([HttpStatusCode]::OK)
$Response.Content = [System.Net.Http.StringContent]::new($responseBody, [System.Text.Encoding]::UTF8, "application/json")
return $Response
`

devaiops workflow and 42

use google for help

devaiops workflow and 43

devaiops workflow and 44

https://learn.microsoft.com/en-us/powershell/module/az.logicapp/get-azlogicapprunhistory?view=azps-11.6.0

i copy pasted and use from here

devaiops workflow and 45

$allRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName -FollowNextPageLink

devaiops workflow and 46

multiple locations have the issue

devaiops workflow and 47

Lacans world of errors

devaiops workflow and 48

first issue> modules

second issue > idendity

third issue > is all runs and filtering with signature

devaiops workflow and 49

devaiops workflow and 50

no follow page link

devaiops workflow and 51

devaiops workflow and 52

Here is the updated function code with the specific changes highlighted:

using namespace System.Net

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

Clear any previously loaded modules if needed

Remove-Module Az -ErrorAction SilentlyContinue
Remove-Module Az.Accounts -ErrorAction SilentlyContinue
Remove-Module Az.LogicApp -ErrorAction SilentlyContinue

Import the necessary Az modules explicitly

Import-Module Az.Accounts
Import-Module Az.LogicApp

Authenticate to Azure using managed identity

Connect-AzAccount -Identity

Define variables

$resourceGroupName = "ContractorMarketing"
$logicAppName = "contractormarketing-replygmail-realtime"

Fetch the runs for the Logic App in the specified resource group

$allRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName

Define the date range

$startDate = (Get-Date).Date # Start from the beginning of today
$endDate = $startDate.AddDays(1) # End at the beginning of tomorrow

Filter runs based on the date range

$filteredRuns = $allRuns | Where-Object { $.StartTime -ge $startDate -and $.StartTime -lt $endDate }

Initialize counters

$successCount = 0
$failureCount = 0
$skippedCount = 0

Loop through the filtered runs and count the statuses

foreach ($run in $filteredRuns) {
switch ($run.Status) {
"Succeeded" { $successCount++ }
"Failed" { $failureCount++ }
"Skipped" { $skippedCount++ }
}
}

Prepare the response

$response = @{
Date = (Get-Date -Format 'yyyy-MM-dd')
SucceededRuns = $successCount
FailedRuns = $failureCount
SkippedRuns = $skippedCount
}

Output the results

$responseBody = $response | ConvertTo-Json
Write-Output $responseBody

Ensure System.Net.Http.HttpResponseMessage is available

Add-Type -AssemblyName "System.Net.Http"

Create the response object with status code.

$responseMessage = New-Object System.Net.Http.HttpResponseMessage([System.Net.HttpStatusCode]::OK)
$responseMessage.Content = New-Object System.Net.Http.StringContent($responseBody, [System.Text.Encoding]::UTF8, "application/json")
return $responseMessage

Key Updates:

  • Module Import and Removal:

Remove-Module Az -ErrorAction SilentlyContinue
Remove-Module Az.Accounts -ErrorAction SilentlyContinue
Remove-Module Az.LogicApp -ErrorAction SilentlyContinue
Import-Module Az.Accounts
Import-Module Az.LogicApp

  • Fetching All Runs Without FollowNextPageLink:

$allRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName

  • Ensuring System.Net.Http.HttpResponseMessage is Available:

Add-Type -AssemblyName "System.Net.Http"

  • Creating the Response Object with HttpResponseMessage:

$responseMessage = New-Object System.Net.Http.HttpResponseMessage([System.Net.HttpStatusCode]::OK)
$responseMessage.Content = New-Object System.Net.Http.StringContent($responseBody, [System.Text.Encoding]::UTF8, "application/json")
return $responseMessage

Deploy and Test:

  • Deploy: Deploy the updated function to your Function App.

  • Test: Trigger the function to ensure it runs correctly and returns the expected results.

These changes address the issues with null references and type not found errors by ensuring the correct modules are imported and the response type is properly handled in the Azure Functions environment.

devaiops workflow and 53

gp[t based

devaiops workflow and 54

smart debuggers

devaiops workflow and 55

this needs to work as a forst principle

devaiops workflow and 56

devaiops workflow and 57

basiuc actions > error 4 semblance that is what you do > subs not set well

devaiops workflow and 58

more debugging

devaiops workflow and 59

checkled

devaiops workflow and 60

also target check

devaiops workflow and 61

error

`2024-05-14T12:16:48Z [Information] Executing 'Functions.GetLogsForLogicApp' (Reason='This function was programmatically called via the host APIs.', Id=6cbb6866-2d48-4f0c-8a10-2707523fced7)
2024-05-14T12:16:48Z [Verbose] Sending invocation id: '6cbb6866-2d48-4f0c-8a10-2707523fced7
2024-05-14T12:16:48Z [Verbose] Posting invocation id:6cbb6866-2d48-4f0c-8a10-2707523fced7 on workerId:1b0035f5-4846-43d4-8f23-c3d194d4fc30
2024-05-14T12:16:52Z [Error] EXCEPTION: The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found.

Exception :
Type : System.Management.Automation.RuntimeException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found.
HResult : -2146233087
CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : RuntimeException
WasThrownFromThrowStatement : True
Message : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found.
HResult : -2146233087
TargetObject : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found.
CategoryInfo : OperationStopped: (The specified subsc…4f741 is not found.:String) [], RuntimeException
FullyQualifiedErrorId : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found.
InvocationInfo :
ScriptLineNumber : 33
OffsetInLine : 5
HistoryId : 1
ScriptName : C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1
Line : throw "The specified subscription ID $subscriptionId is not found."

Statement        : throw "The specified subscription ID $subscriptionId is not found."
                PositionMessage  : At C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1:33 char:5
                                   +     throw "The specified subscription ID $subscriptionId is not found …
                                   +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                PSScriptRoot     : C:\home\site\wwwroot\GetLogsForLogicApp
                PSCommandPath    : C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1
                CommandOrigin    : Internal
                

ScriptStackTrace : at , C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1: line 33

2024-05-14T12:16:52Z [Error] Executed 'Functions.GetLogsForLogicApp' (Failed, Id=6cbb6866-2d48-4f0c-8a10-2707523fced7, Duration=3859ms)`

devaiops workflow and 62

devaiops workflow and 63

can not reach any

`Connected! You are now viewing logs of Function runs in the current Code + Test panel. To see all the logs for this Function, please go to 'Monitor' from the Function menu.
2024-05-14T12:19:29Z [Information] OUTPUT:
2024-05-14T12:19:29Z [Information] OUTPUT: Account SubscriptionName TenantId Environment
2024-05-14T12:19:29Z [Information] OUTPUT: ------- ---------------- -------- -----------
2024-05-14T12:19:29Z [Information] OUTPUT: MSI@50342 7f2f0518-2162-4290-bb93-ad03b676aba0 AzureCloud
2024-05-14T12:19:29Z [Information] OUTPUT:
2024-05-14T12:19:32Z [Error] EXCEPTION: The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found. Available subscriptions are:

Exception :
Type : System.Management.Automation.RuntimeException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found. Available subscriptions are:
HResult : -2146233087
CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : RuntimeException
WasThrownFromThrowStatement : True
Message : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found. Available subscriptions are:
HResult : -2146233087
TargetObject : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found. Available subscriptions are:
CategoryInfo : OperationStopped: (The specified subsc…subscriptions are: :String) [], RuntimeException
FullyQualifiedErrorId : The specified subscription ID ad744a08-2411-4d78-b417-1f1c83f4f741 is not found. Available subscriptions are:
InvocationInfo :
ScriptLineNumber : 33
OffsetInLine : 5
HistoryId : 1
ScriptName : C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1
Line : throw "The specified subscription ID $subscriptionId is not found. Available subscriptions are: $($subscriptions | Format-Table -Property Name, Id -AutoSize | Out-String)"

Statement        : throw "The specified subscription ID $subscriptionId is not found. Available subscriptions are: $($subscriptions | Format-Table -Property Name, Id -AutoSize | Out-String)"
                PositionMessage  : At C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1:33 char:5
                                   +     throw "The specified subscription ID $subscriptionId is not found …
                                   +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                PSScriptRoot     : C:\home\site\wwwroot\GetLogsForLogicApp
                PSCommandPath    : C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1
                CommandOrigin    : Internal
                

ScriptStackTrace : at , C:\home\site\wwwroot\GetLogsForLogicApp\run.ps1: line 33

2024-05-14T12:19:32Z [Error] Executed 'Functions.GetLogsForLogicApp' (Failed, Id=0035f5f6-4b83-409e-b084-c2ab387d166b, Duration=14061ms)`

devaiops workflow and 64

devaiops workflow and 65

I had to give role assignments > problem 5

devaiops workflow and 66

devaiops workflow and 67

this is something that can be used!

I never saw this email

devaiops workflow and 68

zero > planner has to check the objective reach!

devaiops workflow and 69

https://mail.google.com/mail/u/0/#search/%22daily+report+lead%22

bum

devaiops workflow and 70

at least i should have seen this

devaiops workflow and 71

Email at the end

devaiops workflow and 72

maybe [email protected] is having issues

devaiops workflow and 73

devaiops workflow and 74

fix other processes ( operator )

devaiops workflow and 75

gmail and hotmail as backup

devaiops workflow and 76

devaiops workflow and 77

email location is the issue

devaiops workflow and 78

m,ove the leads scope

devaiops workflow and 79

devaiops workflow and 80

devaiops workflow and 81

enabled forwarding for now

devaiops workflow and 82

at least the reports are landing now

devaiops-workflow-and-83.png

nbo content

devaiops workflow and 84

issue 6 no response in the funtion

The issue where the function logs the correct response body but still returns a 204 No Content status is often caused by the way the Azure Functions runtime handles the response. The Azure Functions runtime might be interpreting the response incorrectly if the return value isn't properly recognized as an HTTP response.

To address this, ensure that the HttpResponseMessage is correctly returned and formatted. Let's simplify the function to focus on constructing and returning the HttpResponseMessage correctly.

Simplified Function Code

using namespace System.Net
using namespace System.Net.Http
using namespace System.Text

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

try {
# Clear any previously loaded modules if needed
Remove-Module Az -ErrorAction SilentlyContinue
Remove-Module Az.Accounts -ErrorAction SilentlyContinue
Remove-Module Az.LogicApp -ErrorAction SilentlyContinue

# Import the necessary Az modules explicitly
                Import-Module Az.Accounts
                Import-Module Az.LogicApp
                
                # Authenticate to Azure using managed identity
                $context = Connect-AzAccount -Identity
                if (-not $context) {
                    Write-Error "Failed to authenticate using managed identity."
                    throw "Failed to authenticate using managed identity."
                }
                Write-Output "Successfully authenticated using managed identity."
                
                # List all available subscriptions to verify the subscription ID
                $subscriptions = Get-AzSubscription
                Write-Output "Available subscriptions:"
                $subscriptions | ForEach-Object {
                    Write-Output "Subscription: $($_.Name) - $($_.Id)"
                }
                
                # Set the subscription context
                $subscriptionId = "ad744a08-2411-4d78-b417-1f1c83f4f741"
                $subscriptionName = "Pay-As-You-Go-ContractorMarketing"
                $targetSubscription = $subscriptions | Where-Object { $_.Id -eq $subscriptionId }
                
                if (-not $targetSubscription) {
                    $errorMessage = "The specified subscription ID $subscriptionId is not found. Available subscriptions are: $($subscriptions | Format-Table -Property Name, Id -AutoSize | Out-String)"
                    Write-Error $errorMessage
                    throw $errorMessage
                }
                
                Set-AzContext -SubscriptionId $subscriptionId
                
                # Verify the context
                $currentContext = Get-AzContext
                Write-Output "Current context: SubscriptionName=$($currentContext.Subscription.Name), SubscriptionId=$($currentContext.Subscription.Id)"
                if ($currentContext.Subscription.Id -ne $subscriptionId -or $currentContext.Subscription.Name -ne $subscriptionName) {
                    Write-Error "Failed to set the subscription context to the correct subscription."
                    throw "Failed to set the subscription context to the correct subscription."
                }
                
                # Define variables
                $resourceGroupName = "ContractorMarketing"
                $logicAppName = "contractormarketing-replygmail-realtime"
                
                # Fetch the runs for the Logic App in the specified resource group
                $allRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName
                
                # Ensure that the $allRuns variable is not null
                if (-not $allRuns) {
                    Write-Error "Failed to retrieve Logic App run history."
                    throw "Failed to retrieve Logic App run history."
                }
                
                # Define the date range
                $startDate = (Get-Date).Date  # Start from the beginning of today
                $endDate = $startDate.AddDays(1)  # End at the beginning of tomorrow
                
                # Filter runs based on the date range
                $filteredRuns = $allRuns | Where-Object { $_.StartTime -ge $startDate -and $_.StartTime -lt $endDate }
                
                # Initialize counters
                $successCount = 0
                $failureCount = 0
                $skippedCount = 0
                
                # Loop through the filtered runs and count the statuses
                foreach ($run in $filteredRuns) {
                    switch ($run.Status) {
                        "Succeeded" { $successCount++ }
                        "Failed" { $failureCount++ }
                        "Skipped" { $skippedCount++ }
                    }
                }
                
                # Prepare the response
                $response = @{
                    Date = (Get-Date -Format 'yyyy-MM-dd')
                    SucceededRuns = $successCount
                    FailedRuns = $failureCount
                    SkippedRuns = $skippedCount
                }
                
                # Output the results
                $responseBody = $response | ConvertTo-Json
                Write-Output "Response Body: $responseBody"
                
                # Ensure System.Net.Http.HttpResponseMessage is available
                Add-Type -AssemblyName "System.Net.Http"
                
                # Create the response object with status code.
                $responseMessage = [HttpResponseMessage]::new([HttpStatusCode]::OK)
                $responseMessage.Content = [StringContent]::new($responseBody, [Encoding]::UTF8, "application/json")
                return $responseMessage
                

} catch {
Write-Error "An error occurred: $"
# Ensure System.Net.Http.HttpResponseMessage is available
Add-Type -AssemblyName "System.Net.Http"
$errorResponse = [HttpResponseMessage]::new([HttpStatusCode]::InternalServerError)
$errorResponse.Content = [StringContent]::new("An error occurred: $
", [Encoding]::UTF8, "text/plain")
return $errorResponse
}

Key Points:

  • Namespaces: Ensure you use System.Net.Http and System.Text namespaces correctly for response message handling.

  • Error Handling: Added detailed error messages with Write-Error for better debugging.

  • Response Construction: Use HttpResponseMessage correctly to construct and return the response.

Deploy and Test:

  • Deploy: Deploy the updated function to your Function App.

  • Test: Trigger the function and review the logs and response to ensure it runs correctly and returns the expected results.

This simplified version should help ensure that the function returns the correct HTTP response and avoid the 204 No Content issue.

go out of co pilot

devaiops workflow and 85

devaiops workflow and 86

use stack overflow answers

devaiops-workflow-and-87.png

devaiops workflow and 88

devaiops-workflow-and-89.png

devaiops workflow and 90

error 7 > type not correct

https://stackoverflow.com/questions/54858701/azure-function-returning-status-code-json-without-defining-return-in-every-p

devaiops-workflow-and-91.png

vm was not needed but need to help the ai

devaiops workflow and 92

text compare to help

devaiops workflow and 93

happiness

devaiops workflow and 94

`using namespace System.Net
using namespace System.Net.Http
using namespace System.Text

Input bindings are passed in via param block.

param($Request, $TriggerMetadata)

try {
# Clear any previously loaded modules if needed
Remove-Module Az -ErrorAction SilentlyContinue
Remove-Module Az.Accounts -ErrorAction SilentlyContinue
Remove-Module Az.LogicApp -ErrorAction SilentlyContinue

# Import the necessary Az modules explicitly
                Import-Module Az.Accounts
                Import-Module Az.LogicApp
                
                # Authenticate to Azure using managed identity
                $context = Connect-AzAccount -Identity
                if (-not $context) {
                    Write-Error "Failed to authenticate using managed identity."
                    throw "Failed to authenticate using managed identity."
                }
                Write-Output "Successfully authenticated using managed identity."
                
                # List all available subscriptions to verify the subscription ID
                $subscriptions = Get-AzSubscription
                Write-Output "Available subscriptions:"
                $subscriptions | ForEach-Object {
                    Write-Output "Subscription: $($_.Name) - $($_.Id)"
                }
                
                # Set the subscription context
                $subscriptionId = "ad744a08-2411-4d78-b417-1f1c83f4f741"
                $subscriptionName = "Pay-As-You-Go-ContractorMarketing"
                $targetSubscription = $subscriptions | Where-Object { $_.Id -eq $subscriptionId }
                
                if (-not $targetSubscription) {
                    $errorMessage = "The specified subscription ID $subscriptionId is not found. Available subscriptions are: $($subscriptions | Format-Table -Property Name, Id -AutoSize | Out-String)"
                    Write-Error $errorMessage
                    throw $errorMessage
                }
                
                Set-AzContext -SubscriptionId $subscriptionId
                
                # Verify the context
                $currentContext = Get-AzContext
                Write-Output "Current context: SubscriptionName=$($currentContext.Subscription.Name), SubscriptionId=$($currentContext.Subscription.Id)"
                if ($currentContext.Subscription.Id -ne $subscriptionId -or $currentContext.Subscription.Name -ne $subscriptionName) {
                    Write-Error "Failed to set the subscription context to the correct subscription."
                    throw "Failed to set the subscription context to the correct subscription."
                }
                
                # Define variables
                $resourceGroupName = "ContractorMarketing"
                $logicAppName = "contractormarketing-replygmail-realtime"
                
                # Fetch the runs for the Logic App in the specified resource group
                $allRuns = Get-AzLogicAppRunHistory -ResourceGroupName $resourceGroupName -Name $logicAppName
                
                # Ensure that the $allRuns variable is not null
                if (-not $allRuns) {
                    Write-Error "Failed to retrieve Logic App run history."
                    throw "Failed to retrieve Logic App run history."
                }
                
                # Define the date range
                $startDate = (Get-Date).Date  # Start from the beginning of today
                $endDate = $startDate.AddDays(1)  # End at the beginning of tomorrow
                
                # Filter runs based on the date range
                $filteredRuns = $allRuns | Where-Object { $_.StartTime -ge $startDate -and $_.StartTime -lt $endDate }
                
                # Initialize counters
                $successCount = 0
                $failureCount = 0
                $skippedCount = 0
                
                # Loop through the filtered runs and count the statuses
                foreach ($run in $filteredRuns) {
                    switch ($run.Status) {
                        "Succeeded" { $successCount++ }
                        "Failed" { $failureCount++ }
                        "Skipped" { $skippedCount++ }
                    }
                }
                
                # Prepare the response
                $response = @{
                    Date = (Get-Date -Format 'yyyy-MM-dd')
                    SucceededRuns = $successCount
                    FailedRuns = $failureCount
                    SkippedRuns = $skippedCount
                }
                
                # Output the results
                $responseBody = $response | ConvertTo-Json
                Write-Output "Response Body: $responseBody"
                
                Push-OutputBinding -Name Response -Value (&#091;HttpResponseContext]@{
                    StatusCode = &#091;System.Net.HttpStatusCode]::OK
                    Body = $responseBody
                

} catch {
Write-Error "An error occurred: $"
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [System.Net.HttpStatusCode]::InternalServerError
Body = "An error occurred: $
"
}
`

backup > https://github.com/rifaterdemsahin/contractormarketing/blob/main/logicappreporting.ps1

before and after

devaiops workflow and 95

now planner worked and the i can fix the issue in the system i know that there is 30 failed runs today and noting got created

make email better which logic app is this

devaiops workflow and 96

we will fail at here

devaiops workflow and 97

add the condition

devaiops workflow and 98

base logic fix

devaiops workflow and 99

resubmit > 08584859140044853858849547692CU25

devaiops workflow and 100

waiting there now

devaiops workflow and 101

moved one

devaiops workflow and 102

devaiops workflow and 103

i is there

devaiops workflow and 104

inline fast if

devaiops workflow and 105

The error message you’re encountering indicates that the action Initialize_variable_openaioutput is trying to access a property result from the output of a previous action named contractormarketing-gpt-coverletter. However, the result property doesn’t exist in the output of that action, and instead, it contains an error property.

Here’s how you can troubleshoot and resolve this issue:

  • Inspect the Output of the Previous Action:
    Check the output of the contractormarketing-gpt-coverletter action to understand its structure. Make sure it has a result property. If it doesn't, you might need to handle the error condition properly.

  • Update the Expression:
    If the result property is not available, update the expression to handle the scenario correctly. For example, you can check if the error property exists and handle it accordingly.

  • Error Handling in Logic Apps:
    Implement error handling to manage cases where the result property is not present. You can use a combination of conditions and error handling scopes to manage these cases.

Here’s a step-by-step guide:

Step 1: Inspect the Output

  • Go to the Logic Apps Designer.

  • Run the Logic App (or check a previous run).

  • Click on the contractormarketing-gpt-coverletter action to expand its details.

  • Check the output to see if result or error properties exist.

Step 2: Update the Expression

  • If the output contains an error property, update the expression in the Initialize_variable_openaioutput action to handle this case.

Example:

@if(equals(body('contractormarketing-gpt-coverletter')['error'], null), body('contractormarketing-gpt-coverletter')['result'], 'Error occurred')

Step 3: Implement Error Handling

  • Use a Scope or Condition to handle errors gracefully.

Example using a condition:

  • Add a Condition action after the contractormarketing-gpt-coverletter action.

  • In the condition, check if the error property is null:

equals(body('contractormarketing-gpt-coverletter')['error'], null)

  • In the true branch, initialize the variable with the result property:

body('contractormarketing-gpt-coverletter')['result']

  • In the false branch, handle the error, for example by logging the error message or setting the variable to an error state:

body('contractormarketing-gpt-coverletter')['error']

Example Logic App Workflow

  • Action: contractormarketing-gpt-coverletter

  • Condition:

  • If yes: Initialize_variable_openaioutput with body('contractormarketing-gpt-coverletter')['result']

  • If no: Handle error (e.g., Initialize_variable_openaioutput with body('contractormarketing-gpt-coverletter')['error'] or a custom error message)

By implementing these steps, you can ensure your Logic App handles the absence of the result property properly and avoids the InvalidTemplate error.

runner > https://portal.azure.com/#view/Microsoft_Azure_EMA/LogicAppsMonitorBlade/runid/%2Fsubscriptions%2Fad744a08-2411-4d78-b417-1f1c83f4f741%2Fresourcegroups%2FContractorMarketing%2Fproviders%2FMicrosoft.Logic%2Fworkflows%2Fcontractormarketing-replygmail-realtime%2Fruns%2F08584859135975153124258575898CU30

other issues

devaiops workflow and 106

just removed it

devaiops workflow and 107

and resubmit > https://portal.azure.com/#view/Microsoft_Azure_EMA/LogicAppsMonitorBlade/runid/%2Fsubscriptions%2Fad744a08-2411-4d78-b417-1f1c83f4f741%2Fresourcegroups%2FContractorMarketing%2Fproviders%2FMicrosoft.Logic%2Fworkflows%2Fcontractormarketing-replygmail-realtime%2Fruns%2F08584859129737812156873809323CU18

devaiops workflow and 108


Imported from rifaterdemsahin.com · 2024