Hi @Jyoti Mallick
Sorry for the delay Response.
Based on your updated Go code and error details, the 401 Unauthorized error indicates that the access key being used for authentication is invalid or is not being applied correctly.
- Download the Publishing Profile from your App Service in the Azure Portal.
- Extract the
username
andpassword
from the.PublishSettings
file. - Encode the credentials as
username:password
in Base64auth := base64.StdEncoding.EncodeToString([]byte("<username>:<password>"))
- Use the
Authorization
header withBasic
authenticationreq.Header.Set("Authorization", "Basic "+auth)
- Use the correct Kudu API URL
https://<app-service-name>.scm.azurewebsites.net/api/vfs/site/wwwroot/logs/
- Updated Code .
package main import ( "encoding/base64" "fmt" "io/ioutil" "log" "net/http" ) func main() { username := "<username-from-publishing-profile>" password := "<password-from-publishing-profile>" url := "https://<app-service-name>.scm.azurewebsites.net/api/vfs/site/wwwroot/logs/" // Prepare Basic authentication header auth := base64.StdEncoding.EncodeToString([]byte(username + ":" + password)) // Create HTTP GET request req, err := http.NewRequest("GET", url, nil) if err != nil { log.Fatalf("Error creating request: %v", err) } req.Header.Set("Authorization", "Basic "+auth) // Execute the request client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatalf("Request failed: %v", err) } defer resp.Body.Close() // Handle response if resp.StatusCode != http.StatusOK { log.Fatalf("Error: %s", resp.Status) } body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalf("Error reading response body: %v", err) } // Print log files fmt.Println(string(body)) }
- Use
curl
to validatecurl -u <username>:<password> https://<app-service-name>.scm.azurewebsites.net/api/vfs/site/wwwroot/logs/
If the answer is helpful, please click Accept Answer and kindly upvote it so that other people who faces similar issue may get benefitted from it.