pulumi-azure-native
pulumi-azure-native copied to clipboard
ExportConfiguration resource requires a POST for creation
Hello!
- Vote on this issue by adding a 👍 reaction
- To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)
Issue details
When creating an ExportConfiguration resource we need to pass in the storage account SAS URL which we get from listStorageAccountSAS. However, it looks like when we're passing the URL to Azure in the ExportConfiguration resource we're encoding it incorrectly.
Steps to reproduce
- Clone repo here: https://github.com/pierskarsenbarg/export-config
- Run
pulumi up - Uncomment these lines
- Run
pulumi upagain
Error message:
error: autorest/azure: Service returned an error. Status=404 Code="NotFound" Message="Not Found" InnerError={"diagnosticcontext":"0a95e454-db5c-4da9-9cb9-fd7edb708dfa","time":"2021-11-09T13:17:16.0988585Z"}
If you look at the logs you'll see that this is the URL we send over as the DestinationAddress: https://sa19bcc911.blob.core.windows.net/appinsights?sv=2015-04-05\u0026ss=b\u0026srt=c\u0026sp=w\u0026se=2024-11-08T13%3A18%3A05.2440000Z\u0026sig=wiyt6mVUxblf6Mvn9wIYYhX32ezFiPx6YvyY4mAR600%3D which looks like we're encoding the URL as UTF-8 (?)
I think that encoding is by design, here is a comment from the json.Marshal function that is used by Go Autorest to encode the payload:
String values encode as JSON strings coerced to valid UTF-8, replacing invalid bytes with the Unicode replacement rune. So that the JSON will be safe to embed inside HTML
Unicode-encoded characters are valid JSON AFAIK. As this function is provided by Microsoft's SDK, I hope somebody would notice if it was problematic.
Now, the question is what actually goes wrong. Maybe, try doing this with the portal and then exporting the resulting ARM template to see what's different?
When I try to create the ExportConfiguration using powershell eg.
`$sastoken = New-AzStorageContainerSASToken -Name appinsights82a92963 -ExpiryTime (Get-Date).AddYears(50) -Permission w
$sasuri = "https://blahblah.blob.core.windows.net/appinsights82a92963" + $sastoken
New-AzApplicationInsightsContinuousExport -ResourceGroupName "resourcegroupname" -Name "appinsights8305d678" -DocumentType "Request","Trace", "Custom Event" -StorageAccountId "/subscriptions/sid/resourceGroups/resourcegroup/providers/Microsoft.Storage/storageAccounts/7e1f6cc" -StorageLocation "uksouth" -StorageSASUri $sasuri`
it all works fine, but fails in Pulumi as the SAS token has unescaped characters in it
@andyunsieso Could you please export the resulting ARM template? As you can see, Powershell is quite different in terms of parameter names etc.
I have tried exporting the ARM template for the app insights using Azure Portal and powershell. It exports a number of types but won't export the export coniguration and says -
"Could not get resources of the type 'components/exportconfiguration'. Resources of this type will not be exported."}]}
I managed to create a continuous export using the azure cli, but when I tried to inspect it I got the following message:

It seems that continuous export is being deprecated by Azure: https://docs.microsoft.com/en-us/azure/azure-monitor/app/export-telemetry which is probably why we can't get an export
Okay, I logged what the Azure CLI does and apparently if does POST to the .../exportconfiguration URL.
Instead, Pulumi sends a PUT to the .../exportconfiguration/{name} URL and the API doesn't support creation via PUT. It turns out this API is from 2015 and isn't compliant to ARM API standards (where PUT has to do both Create and Update and be idempotent).
Effectively, this resource is broken until we teach it to send POST requests.
You should be able to import an existing resource and manage it further, if that helps.
Thanks, will probably use power shell to create the ExportConfiguration in the first instance
On February 29, 2024, continuous export will be deprecated as part of the classic Application Insights deprecation. source
So it's probably not worth investing into this particular resource. See #3018.