Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update python version, and add required python packages to function app zip. #11135

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,16 @@

cs = os.environ.get('ConnectionString')

customer_id = os.environ.get('WorkspaceID')
shared_key = os.environ.get('WorkspaceKey')
customer_id = os.environ.get('AzureSentinelWorkspaceId','')
shared_key = os.environ.get('AzureSentinelSharedKey')
verify = False
logAnalyticsUri = 'https://' + customer_id + '.ods.opinsights.azure.com'

pattern = r'https:\/\/([\w\-]+)\.ods\.opinsights\.azure.([a-zA-Z\.]+)$'
match = re.match(pattern, str(logAnalyticsUri))
if (not match):
logging.info(f"Invalid url : {logAnalyticsUri}")
raise Exception("Lookout: Invalid Log Analytics Uri.")

key_vault_name = os.environ.get("KeyVaultName")
key_vault_name = os.environ.get("KeyVaultName","Commvault-Integration-KV")
uri = None
url = None
qsdk_token = None
headers = {
"authtoken": "QSDK " + qsdk_token,
"Content-Type": "application/json",
"Accept": "application/json",
}
Expand Down Expand Up @@ -99,8 +92,8 @@
"paths": [{"path": "/**/*"}],
}


@app.schedule(schedule="0 */5 * * * *", arg_name="myTimer", run_on_startup=False,
@app.function_name(name="AzureFunctionCommvaultSecurityIQ")
@app.schedule(schedule="0 */5 * * * *", arg_name="myTimer", run_on_startup=True,
use_monitor=False)
def myTimer(myTimer: func.TimerRequest) -> None:
global qsdk_token,url
Expand All @@ -110,7 +103,11 @@ def myTimer(myTimer: func.TimerRequest) -> None:

logging.info('Executing Python timer trigger function.')


pattern = r'https:\/\/([\w\-]+)\.ods\.opinsights\.azure.([a-zA-Z\.]+)$'
match = re.match(pattern, str(logAnalyticsUri))
if (not match):
logging.info(f"Invalid url : {logAnalyticsUri}")
raise Exception("Lookout: Invalid Log Analytics Uri.")
try:
credential = DefaultAzureCredential()
client = SecretClient(vault_url=f"https://{key_vault_name}.vault.azure.net", credential=credential)
Expand All @@ -119,7 +116,7 @@ def myTimer(myTimer: func.TimerRequest) -> None:
url = "https://" + uri + "/commandcenter/api"
secret_name = "access-token"
qsdk_token = client.get_secret(secret_name).value

headers["authtoken"] = "QSDK "+qsdk_token
ustring = "/events?level=10&showInfo=false&showMinor=false&showMajor=true&showCritical=false&showAnomalous=true"
f_url = url + ustring
current_date = datetime.utcnow()
Expand Down Expand Up @@ -657,4 +654,4 @@ def read_blob(connection_string, container_name, blob_name):

except Exception as e:
logging.error(f"An error occurred: {str(e)}")
raise e
raise e
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"type": "string",
"metadata": {
"description": "Migrate Classic Application Insights to Log Analytic Workspace which is retiring by 29 Febraury 2024. Use 'Log Analytic Workspace-->Properties' blade having 'Resource ID' property value. This is a fully qualified resourceId which is in format '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OperationalInsights/workspaces/{workspaceName}'"
}
}
}
},
"variables": {
Expand Down Expand Up @@ -139,7 +139,7 @@
"alwaysOn": true,
"reserved": true,
"siteConfig": {
"linuxFxVersion": "python|3.8"
"linuxFxVersion": "python|3.11"
}
},

Expand All @@ -152,6 +152,7 @@
"[concat('Microsoft.Web/sites/', variables('FunctionName'))]"
],
"properties": {

"FUNCTIONS_EXTENSION_VERSION": "~4",
"FUNCTIONS_WORKER_RUNTIME": "python",
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.insights/components', variables('FunctionName')), '2015-05-01').InstrumentationKey]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ azure-functions
azure-storage-blob
azure-identity
azure-keyvault-secrets
requests
requests
cryptography==41.0.3
Binary file modified Solutions/Commvault Security IQ/Package/3.0.1.zip
Binary file not shown.
3 changes: 0 additions & 3 deletions Solutions/Commvault Security IQ/Package/mainTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@
"location": "[parameters('location')]",
"subscriptionId": "[[subscription().subscriptionId]",
"tenantId": "[[subscription().tenantId]",
"keyvaultApiId": "[[concat('/subscriptions/', variables('subscriptionId'), '/providers/Microsoft.Web/locations/', variables('location'),'/managedApis/keyvault')]",
"AzureautomationConnectionName": "[[concat('Azureautomation-', parameters('PlaybookName'))]",
"MicrosoftSentinelConnectionName": "[[concat('MicrosoftSentinel-', parameters('PlaybookName'))]",
"KeyvaultConnectionName": "[[concat('Keyvault-', parameters('PlaybookName'))]",
Expand Down Expand Up @@ -930,7 +929,6 @@
"location": "[parameters('location')]",
"subscriptionId": "[[subscription().subscriptionId]",
"tenantId": "[[subscription().tenantId]",
"keyvaultApiId": "[[concat('/subscriptions/', variables('subscriptionId'), '/providers/Microsoft.Web/locations/', variables('location'),'/managedApis/keyvault')]",
"AzureautomationConnectionName": "[[concat('Azureautomation-', parameters('PlaybookName'))]",
"MicrosoftSentinelConnectionName": "[[concat('MicrosoftSentinel-', parameters('PlaybookName'))]",
"KeyvaultConnectionName": "[[concat('Keyvault-', parameters('PlaybookName'))]",
Expand Down Expand Up @@ -1274,7 +1272,6 @@
"location": "[parameters('location')]",
"subscriptionId": "[[subscription().subscriptionId]",
"tenantId": "[[subscription().tenantId]",
"keyvaultApiId": "[[concat('/subscriptions/', variables('subscriptionId'), '/providers/Microsoft.Web/locations/', variables('location'),'/managedApis/keyvault')]",
"AzureautomationConnectionName": "[[concat('Azureautomation-', parameters('PlaybookName'))]",
"MicrosoftSentinelConnectionName": "[[concat('MicrosoftSentinel-', parameters('PlaybookName'))]",
"KeyvaultConnectionName": "[[concat('Keyvault-', parameters('PlaybookName'))]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"location": "[resourceGroup().location]",
"subscriptionId": "[subscription().subscriptionId]",
"tenantId": "[subscription().tenantId]",
"keyvaultApiId": "[concat('/subscriptions/', variables('subscriptionId'), '/providers/Microsoft.Web/locations/', variables('location'),'/managedApis/keyvault')]",
"AzureautomationConnectionName": "[concat('Azureautomation-', parameters('PlaybookName'))]",
"MicrosoftSentinelConnectionName": "[concat('MicrosoftSentinel-', parameters('PlaybookName'))]",
"KeyvaultConnectionName": "[concat('Keyvault-', parameters('PlaybookName'))]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"location": "[resourceGroup().location]",
"subscriptionId": "[subscription().subscriptionId]",
"tenantId": "[subscription().tenantId]",
"keyvaultApiId": "[concat('/subscriptions/', variables('subscriptionId'), '/providers/Microsoft.Web/locations/', variables('location'),'/managedApis/keyvault')]",
"AzureautomationConnectionName": "[concat('Azureautomation-', parameters('PlaybookName'))]",
"MicrosoftSentinelConnectionName": "[concat('MicrosoftSentinel-', parameters('PlaybookName'))]",
"KeyvaultConnectionName": "[concat('Keyvault-', parameters('PlaybookName'))]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"location": "[resourceGroup().location]",
"subscriptionId": "[subscription().subscriptionId]",
"tenantId": "[subscription().tenantId]",
"keyvaultApiId": "[concat('/subscriptions/', variables('subscriptionId'), '/providers/Microsoft.Web/locations/', variables('location'),'/managedApis/keyvault')]",
"AzureautomationConnectionName": "[concat('Azureautomation-', parameters('PlaybookName'))]",
"MicrosoftSentinelConnectionName": "[concat('MicrosoftSentinel-', parameters('PlaybookName'))]",
"KeyvaultConnectionName": "[concat('Keyvault-', parameters('PlaybookName'))]"
Expand Down
Loading