Skip to content

Conversation

@HowardWolosky
Copy link
Contributor

Description

In Azure Function Apps, the special MyDocuments folder resolves to an empty string, which means that the default logPath gets stored as an empty string.

# Create a configuration object with all the default values. We can then update the values
# with any that we find on disk.
$logPath = [String]::Empty
$documentsFolder = [System.Environment]::GetFolderPath('MyDocuments')
if (-not [System.String]::IsNullOrEmpty($documentsFolder))
{
$logPath = Join-Path -Path $documentsFolder -ChildPath 'PowerShellForGitHub.log'
}

'logPath' = $logPath

This causes problems when Write-Log is called by any other function, because we directly assign the current configuration value for LogPath as the parameter's default, which throws an exception when an empty string is assigned.

[IO.FileInfo] $Path = (Get-GitHubConfiguration -Name LogPath),

In this scenario, we'll fall back to using the LocalApplicationDataFolder folder and writing a warning out to the user letting them know this has happened.

Documentation has also been updated to reflect this behavior change.

Issues Fixed

Resolves #282

References

n/a

Checklist

  • You actually ran the code that you just wrote, especially if you did just "one last quick change".
  • Comment-based help added/updated, including examples.
  • Static analysis is reporting back clean.
  • New/changed code adheres to our coding guidelines.
  • Formatters were created for any new types being added.
  • New/changed code continues to support the pipeline.
  • ~~Changes to the manifest file follow the manifest guidance.~
  • Unit tests were added/updated and are all passing. See testing guidelines. This includes making sure that all pipeline input variations have been covered.
  • Relevant usage examples have been added/updated in USAGE.md.
  • If desired, ensure your name is added to our Contributors list

@HowardWolosky HowardWolosky added the bug This relates to a bug in the existing module. label Sep 9, 2020
@HowardWolosky
Copy link
Contributor Author

/azp run PowerShellForGitHub-CI

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

In Azure Function Apps, the special `MyDocuments` folder resolves to
an empty string, which means that the default `logPath` gets stored as
an empty string.  This causes problems when `Write-Log` attempts to
write anything out.

In this scenario, we'll fall back to using the temp folder and writing
a warning out to the user letting them know this has happened.

Resolves microsoft#282
@HowardWolosky
Copy link
Contributor Author

/azp run PowerShellForGitHub-CI

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@HowardWolosky HowardWolosky merged commit e9a6810 into microsoft:master Sep 9, 2020
@HowardWolosky HowardWolosky deleted the logPath branch September 9, 2020 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This relates to a bug in the existing module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issues when deploying to Azure Function App

1 participant