Closed raunaknarooka closed 12 months ago
Hi @raunaknarooka, thanks for logging this issue.
The framework is replacing the connectionRuntimeUrl
value with a URL that points to the mock HTTP server. It does this by replacing the host name in the URL with the mock server's host name. But this assumes that the value of connectionRuntimeUrl
is a valid URL in the first place. In your case it is not because you are referencing an app setting so that you can deploy the same connection file across multiple environments.
I can think of a few ways to fix this:
connectionRuntimeUrl
is @appsetting('<setting name>')
then get the value of the referenced app setting, then replace the host name with the mock server's host name.connectionRuntimeUrl
is more complex, for example something like https://@appsetting('CONN_HOSTNAME').common.logic-uksouth.azure-apihub.net/apim/outlook/@appsetting('CONN_SOMETHING_ELSE')/
then things get a little more complex to handle because you potentially need to find each instance of the app settings and hope that replacing with the app setting value gives you a valid URL.Do all of your values of connectionRuntimeUrl
fall into the first category?
Hi Mark, thanks for reaching out. The connectionRuntimeurl is different for every logic app. It looks somewhat like: https://
{
name: 'EVENTGRID_CONNECTION_RUNTIMEURL'
value: reference(azureEventGridConnection.id, azureEventGridConnection.apiVersion, 'full').properties.connectionRuntimeUrl
}
The azureEventGridConnection
is created using the following bicep resource:
resource azureEventGridConnection 'Microsoft.Web/connections@2016-06-01' = {
name: eventGridConnectionName
location: location
kind: 'V2'
properties: {
displayName: eventGridConnectionName
statuses: [
{
status: 'Ready'
}
]
parameterValueSet: {
name: 'managedIdentityAuth'
values: {}
}
customParameterValues: {}
api: {
name: 'azureeventgrid'
id: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Web/locations/westeurope/managedApis/azureeventgrid'
type: 'Microsoft.Web/locations/managedApis'
}
}
}
Hi @raunaknarooka , I've had a think about this and I propose the following change when handling connection runtime URLs for managed connectors:
@appsettings
then validate that the value is a URL and replace the host name with the mock HTTP server name. This is essentially what the framework does at the moment, but I've added (i) explicit validation of the runtime URL and (ii) a check for any @appsettings
.@appsettings
then replace the app settings values with those from local.settings.json
. Then validate that the value is a URL and replace the host name with the mock HTTP server name. Point 2 covers your scenario and will fix your issue.
Hi @raunaknarooka , I've completed this change, please download package version 1.4.0 from Nuget: https://www.nuget.org/packages/LogicAppUnit/1.4.0.
Please let me know if this fixes your issue.
I have the following connection.json file which has a managed api connection
{ "managedApiConnections": {
As i understand, the testing framework looks at all built in and managed connections and replaces them with a localhost url. When i use the appsetting in the connectionRuntimeurl of the eventgrid api connection, it tells its an invalid url. I get the following error: Error Message: Initialization method INT0313.Iver.Products.Tests.Products.Products.TestInitialize threw exception. System.UriFormatException: Invalid URI: The format of the URI could not be determined.. Stack Trace: at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions) at System.Uri..ctor(String uriString) at LogicAppUnit.InternalHelper.ConnectionHelper.<>c.b__3_0(JProperty connection)
at System.Collections.Generic.List
1.ForEach(Action
1 action) at LogicAppUnit.InternalHelper.ConnectionHelper.ReplaceManagedApiConnectionUrlsWithMockServer() at LogicAppUnit.WorkflowTestBase.Initialize(String logicAppBasePath, String workflowName, String localSettingsFilename) at LogicAppUnit.WorkflowTestBase.Initialize(String logicAppBasePath, String workflowName) at INT0313.Iver.Products.Tests.Products.Products.TestInitialize() in C:\Users\PSRAUNAR\OneDrive - Peab\Dokument\INT0313.Iver.Products\INT0313.Iver.Products.Tests\Products\Products.cs:line 21And the output stops here: Standard Output Messages:
INITIALIZING TEST -
Azurite is listening on ports 10000 (Blob service), 10001 (Queue service) and 10002 (Table service). Workflow 'Products_Source' is Stateful Replacing workflow trigger 'When_a_file_is_added_or_updated' with a HTTP Request trigger. Replacing workflow actions using a built-in connector with a HTTP action for the mock test server: Copy_file_to_error_folder: Connector Type: /serviceProviders/Sftp/copyFile Mocked URL: http://pw02cvvv:7075/Copy_file_to_error_folder Delete_file_from_source_folder: Connector Type: /serviceProviders/Sftp/deleteFile Mocked URL: http://pw02cvvv:7075/Delete_file_from_source_folder Copy_file_to_processed_folder: Connector Type: /serviceProviders/Sftp/copyFile Mocked URL: http://pw02cvvv:7075/Copy_file_to_processed_folder Delete_file: Connector Type: /serviceProviders/Sftp/deleteFile Mocked URL: http://pw02cvvv:7075/Delete_file Upload_blob_to_storage_container-Logging: Connector Type: /serviceProviders/AzureBlob/uploadBlob Mocked URL: http://pw02cvvv:7075/Upload_blob_to_storage_container-Logging Updating connections file for managed API connectors:
when i put a valid dummy url in connectionruntimeurl it works. But this is not what i want. The connections are deployed in the azure devops pipeline and i need this to be an app setting.