Description
openedon Oct 16, 2024
Describe the bug
There appears to be several issues with the "SalesforceSentinelConnector".
- The default variable in the trigger "%schedule%" does not point to a value for the function to run out of the box.
- The current Python code sends authentication parameters in the header, but testing and Salesforce documentation indicate that these parameters should be sent in the body for successful authentication.
- The python code lists this variable "url = os.environ['SalesforceTokenUri']" but the salesforcetokenURI is not listed in the required application setting or environment variable. in the deployment guidelines.
Steps to Reproduce:
Schedule variable:
Create an Azure Function with a timer trigger.
Set the schedule in function.json to "0 0 * * * *".
Deploy the function to Azure.
Observe that the function does not trigger every hour.
Expected Behavior: The function should trigger every hour based on the schedule configuration.
Actual Behavior: The function does not trigger every hour.
Authentication:
Replacement authentication snitppit:
def _get_token():
data = {
"grant_type": "password",
"client_id": consumer_key,
"client_secret": consumer_secret,
"username": user,
"password": f'{password}{security_token}'
}
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
try:
r = requests.post(url, data=data, headers=headers)
r.raise_for_status()
response_json = r.json()
_token = response_json['access_token']
_instance_url = response_json['instance_url']
return _token, _instance_url
except requests.exceptions.RequestException as err:
logging.error(f'Token getting failed. Exiting program. {err}')
exit()
Actual Behavior: The function app does not authenticate.
Environment:
Azure Functions runtime version: Python 3.11
Development environment: Visual Studio Code, Azure Portal
Additional context
I think addressing the concerns listed would create a better experience for those customers that need or have to deploy this Data Connector for ingesting log data into Azure Sentinel.