Skip to content

Commit

Permalink
WIP: start implementing azure web app logs retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
arstanaly committed Sep 25, 2023
1 parent 51539cf commit d19d215
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/kosli/snapshotAzureFunctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ func (o *snapshotAzureFunctionsOptions) run(args []string) error {
for _, host := range webapp.Properties.EnabledHostNames {
fmt.Printf("Webapp host: %s\n", *host)
}
}

err = o.azureCredentials.GetDockerLogs()
if err != nil {
return err
}

// envName := args[0]
Expand Down
26 changes: 26 additions & 0 deletions internal/azure/azure_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package azure

import (
"context"
"io"
"net/http"

"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appservice/armappservice/v2"
Expand Down Expand Up @@ -40,3 +42,27 @@ func (staticCreds *AzureStaticCredentials) GetWebAppsInfo() ([]*armappservice.Si
}
return webAppsInfo, nil
}

func (staticCreds *AzureStaticCredentials) GetDockerLogs() error {
client := &http.Client{}

req, err := http.NewRequest("GET", "https://tsha256.scm.azurewebsites.net/api/vfs/LogFiles/2023_09_14_10-30-0-8_docker.log", nil)
if err != nil {
return err
}
req.SetBasicAuth(staticCreds.ClientId, staticCreds.ClientSecret)
resp, err := client.Do(req)
if err != nil {
return err
}
if resp.Body != nil {
defer resp.Body.Close()
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
println(string(body))

return nil
}

0 comments on commit d19d215

Please sign in to comment.