Skip to content
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
4 changes: 4 additions & 0 deletions src/application-insights/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.2.1
++++++++++++++++++
* `az monitor app-insights component connect-webapp/connect-function`: Add `connection_string` auto setting for webapp/function.

1.2.0
++++++++++++++++++
* `az monitor app-insights`: Add new command group `workbook` to support managing workbook.
Expand Down
5 changes: 5 additions & 0 deletions src/application-insights/azext_applicationinsights/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def connect_webapp(cmd, client, resource_group_name, application, app_service, e
raise InvalidArgumentValueError(f"App Insights {application} under resource group {resource_group_name} was not found.")

settings = [f"APPINSIGHTS_INSTRUMENTATIONKEY={app_insights.instrumentation_key}"]
if app_insights.connection_string is not None:
settings.append(f"APPINSIGHTS_CONNECTIONSTRING={app_insights.connection_string}")
if enable_profiler is True:
settings.append("APPINSIGHTS_PROFILERFEATURE_VERSION=1.0.0")
elif enable_profiler is False:
Expand All @@ -191,6 +193,9 @@ def connect_function(cmd, client, resource_group_name, application, app_service)

settings = [f"APPINSIGHTS_INSTRUMENTATIONKEY={app_insights.instrumentation_key}"]

if app_insights.connection_string is not None:
settings.append(f"APPINSIGHTS_CONNECTIONSTRING={app_insights.connection_string}")

if is_valid_resource_id(app_service):
resource_id = parse_resource_id(app_service)
app_service = resource_id['name']
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ def test_connect_webapp(self, resource_group, location):
self.check('provisioningState', 'Succeeded')
])

app_insights_instrumentation_key = self.cmd('az monitor app-insights component show -g {resource_group} --app {ai_name}').get_output_in_json()['instrumentationKey']
app_config = self.cmd('az monitor app-insights component show -g {resource_group} --app {ai_name}').get_output_in_json()

app_insights_instrumentation_key = app_config['instrumentationKey']
app_insights_connection_string = app_config['connectionString']

# Create web app.
webapp_name = self.create_random_name('clitestwebapp', 24)
Expand All @@ -117,7 +120,8 @@ def test_connect_webapp(self, resource_group, location):
self.cmd('az webapp config appsettings list -g {resource_group} -n {webapp_name}', checks=[
self.check("[?name=='APPINSIGHTS_PROFILERFEATURE_VERSION']|[0].value", '1.0.0'),
self.check("[?name=='APPINSIGHTS_SNAPSHOTFEATURE_VERSION']|[0].value", '1.0.0'),
self.check("[?name=='APPINSIGHTS_INSTRUMENTATIONKEY']|[0].value", app_insights_instrumentation_key)
self.check("[?name=='APPINSIGHTS_INSTRUMENTATIONKEY']|[0].value", app_insights_instrumentation_key),
self.check("[?name=='APPINSIGHTS_CONNECTIONSTRING']|[0].value", app_insights_connection_string)
])

@ResourceGroupPreparer(name_prefix="webapp_cross_rg", parameter_name="resource_group", parameter_name_for_location="location")
Expand Down Expand Up @@ -193,7 +197,10 @@ def test_connect_function(self, resource_group, storage_account, location):
self.check('provisioningState', 'Succeeded')
])

app_insights_instrumentation_key = self.cmd('az monitor app-insights component show -g {resource_group} --app {ai_name}').get_output_in_json()['instrumentationKey']
app_config = self.cmd('az monitor app-insights component show -g {resource_group} --app {ai_name}').get_output_in_json()

app_insights_instrumentation_key = app_config['instrumentationKey']
app_insights_conenction_string = app_config["connectionString"]

# Create Azure function.
function_name = self.create_random_name('clitestfunction', 24)
Expand All @@ -204,7 +211,7 @@ def test_connect_function(self, resource_group, storage_account, location):
})

self.cmd('az appservice plan create -g {resource_group} -n {plan}')
self.cmd('az functionapp create -g {resource_group} -n {function_name} --plan {plan} -s {sa} --functions-version 3 --runtime node', checks=[
self.cmd('az functionapp create -g {resource_group} -n {function_name} --plan {plan} -s {sa} --functions-version 4 --runtime node', checks=[
self.check('state', 'Running'),
self.check('name', function_name)
])
Expand All @@ -214,7 +221,8 @@ def test_connect_function(self, resource_group, storage_account, location):

# Check if the settings are updated correctly.
self.cmd('az webapp config appsettings list -g {resource_group} -n {function_name}', checks=[
self.check("[?name=='APPINSIGHTS_INSTRUMENTATIONKEY']|[0].value", app_insights_instrumentation_key)
self.check("[?name=='APPINSIGHTS_INSTRUMENTATIONKEY']|[0].value", app_insights_instrumentation_key),
self.check("[?name=='APPINSIGHTS_CONNECTIONSTRING']|[0].value", app_insights_conenction_string)
])

@ResourceGroupPreparer(name_prefix="connect_function_cross_rg", parameter_name="resource_group", parameter_name_for_location="location")
Expand Down Expand Up @@ -252,7 +260,7 @@ def test_connect_function_cross_resource_groups(self, resource_group, resource_g
})

self.cmd('az appservice plan create -g {resource_group2} -n {plan}')
self.kwargs['functionapp_id'] = self.cmd('az functionapp create -g {resource_group2} -n {function_name} --plan {plan} -s {sa} --functions-version 3 --runtime node', checks=[
self.kwargs['functionapp_id'] = self.cmd('az functionapp create -g {resource_group2} -n {function_name} --plan {plan} -s {sa} --functions-version 4 --runtime node', checks=[
self.check('state', 'Running'),
self.check('name', function_name)
]).get_output_in_json()['id']
Expand Down
2 changes: 1 addition & 1 deletion src/application-insights/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from codecs import open
from setuptools import setup, find_packages

VERSION = "1.2.0"
VERSION = "1.2.1"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down