Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 349604f

Browse files
Removing Remaining App Function References from Deployment Code. (#2682)
* Removing Remaining App Function References from Deployment Code. * Update src/deployment/deploy.py Co-authored-by: Adam <[email protected]> * Consolidating. * Updating function handles. * Removing copy. * Fixing. * Formatting. * Fixing array calls. * Adding json settings back. * Formatting. Co-authored-by: Adam <[email protected]>
1 parent 0fb8bc4 commit 349604f

File tree

3 files changed

+12
-249
lines changed

3 files changed

+12
-249
lines changed

src/deployment/azuredeploy.bicep

Lines changed: 0 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,6 @@ resource keyVault 'Microsoft.KeyVault/vaults@2021-10-01' = {
117117
]
118118
}
119119
}
120-
{
121-
objectId: netFunction.outputs.principalId
122-
tenantId: tenantId
123-
permissions: {
124-
secrets: [
125-
'get'
126-
'list'
127-
'set'
128-
'delete'
129-
]
130-
}
131-
}
132-
133120
]
134121
tenantId: tenantId
135122
}
@@ -192,21 +179,6 @@ resource roleAssignments 'Microsoft.Authorization/roleAssignments@2020-10-01-pre
192179
]
193180
}]
194181

195-
// try to make role assignments to deploy as late as possible in order to have principalId ready
196-
resource roleAssignmentsNet 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = [for r in roleAssignmentsParams: {
197-
name: guid('${resourceGroup().id}${r.suffix}-1f-net')
198-
properties: {
199-
roleDefinitionId: '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/${r.role}'
200-
principalId: netFunction.outputs.principalId
201-
}
202-
dependsOn: [
203-
eventGrid
204-
keyVault
205-
serverFarm
206-
featureFlags
207-
]
208-
}]
209-
210182
// try to make role assignments to deploy as late as possible in order to have principalId ready
211183
resource readBlobUserAssignment 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
212184
name: guid('${resourceGroup().id}-user_managed_idenity_read_blob')
@@ -250,27 +222,6 @@ module function 'bicep-templates/function.bicep' = {
250222
}
251223
}
252224

253-
module netFunction 'bicep-templates/function.bicep' = {
254-
name: 'netFunction'
255-
params: {
256-
linux_fx_version: 'DOTNET-ISOLATED|7.0'
257-
name: '${name}-net'
258-
259-
app_logs_sas_url: storage.outputs.FuncSasUrlBlobAppLogs
260-
app_func_audiences: app_func_audiences
261-
app_func_issuer: app_func_issuer
262-
client_id: clientId
263-
diagnostics_log_level: diagnosticsLogLevel
264-
location: location
265-
log_retention: log_retention
266-
owner: owner
267-
server_farm_id: serverFarm.outputs.id
268-
269-
use_windows: true
270-
enable_remote_debugging: enable_remote_debugging
271-
}
272-
}
273-
274225
module functionSettings 'bicep-templates/function-settings.bicep' = {
275226
name: 'functionSettings'
276227
params: {
@@ -291,118 +242,12 @@ module functionSettings 'bicep-templates/function-settings.bicep' = {
291242
multi_tenant_domain: multi_tenant_domain
292243
enable_profiler: enable_profiler
293244
app_config_endpoint: featureFlags.outputs.AppConfigEndpoint
294-
functions_disabled: '0'
295-
agent_function_names: [
296-
'AgentCanSchedule' //0
297-
'AgentCommands' //1
298-
'AgentEvents' //2
299-
'AgentRegistration' //3
300-
'Containers' //4
301-
'Download' //5
302-
'Info' //6
303-
'InstanceConfig' //7
304-
'Jobs' //8
305-
'JobTemplates' //9
306-
'JobTemplatesManage' //10
307-
'Negotiate' //11
308-
'Node' //12
309-
'NodeAddSshKey' //13
310-
'Notifications' //14
311-
'Pool' //15
312-
'Proxy' //16
313-
'QueueFileChanges' //17
314-
'QueueNodeHeartbeat' //18
315-
'QueueProxyUpdate' //19
316-
'QueueSignalrEvents' //20
317-
'QueueTaskHeartbeat' //21
318-
'QueueUpdates' //22
319-
'QueueWebhooks' //23
320-
'ReproVms' //24
321-
'Scaleset' //25
322-
'Tasks' //26
323-
'TimerDaily' //27
324-
'TimerProxy' //28
325-
'TimerRepro' //29
326-
'TimerRetention' //30
327-
'TimerTasks' //31
328-
'TimerWorkers' //32
329-
'Tools' //33
330-
'Webhooks' //34
331-
'WebhooksLogs' //35
332-
'WebhooksPing' //36
333-
]
334245
}
335246
dependsOn: [
336247
function
337248
]
338249
}
339250

340-
module netFunctionSettings 'bicep-templates/function-settings.bicep' = {
341-
name: 'netFunctionSettings'
342-
params: {
343-
owner: owner
344-
name: '${name}-net'
345-
functions_worker_runtime: 'dotnet-isolated'
346-
functions_extension_version: '~4'
347-
instance_name: name
348-
app_insights_app_id: operationalInsights.outputs.appInsightsAppId
349-
app_insights_key: operationalInsights.outputs.appInsightsInstrumentationKey
350-
client_secret: clientSecret
351-
signal_r_connection_string: signalR.outputs.connectionString
352-
func_sas_url: storage.outputs.FuncSasUrl
353-
func_storage_resource_id: storage.outputs.FuncId
354-
fuzz_storage_resource_id: storage.outputs.FuzzId
355-
keyvault_name: keyVaultName
356-
monitor_account_name: operationalInsights.outputs.monitorAccountName
357-
multi_tenant_domain: multi_tenant_domain
358-
enable_profiler: enable_profiler
359-
app_config_endpoint: featureFlags.outputs.AppConfigEndpoint
360-
functions_disabled: '1'
361-
agent_function_names: [
362-
'AgentCanSchedule' //0
363-
'AgentCommands' //1
364-
'AgentEvents' //2
365-
'AgentRegistration' //3
366-
'Containers' //4
367-
'Download' //5
368-
'Info' //6
369-
'InstanceConfig' //7
370-
'Jobs' //8
371-
'JobTemplates' //9
372-
'JobTemplatesManage' //10
373-
'Negotiate' //11
374-
'Node' //12
375-
'NodeAddSshKey' //13
376-
'Notifications' //14
377-
'Pool' //15
378-
'Proxy' //16
379-
'QueueFileChanges' //17
380-
'QueueNodeHeartbeat' //18
381-
'QueueProxyUpdate' //19
382-
'QueueSignalrEvents' //20
383-
'QueueTaskHeartbeat' //21
384-
'QueueUpdates' //22
385-
'QueueWebhooks' //23
386-
'ReproVms' //24
387-
'Scaleset' //25
388-
'Tasks' //26
389-
'TimerDaily' //27
390-
'TimerProxy' //28
391-
'TimerRepro' //29
392-
'TimerRetention' //30
393-
'TimerTasks' //31
394-
'TimerWorkers' //32
395-
'Tools' //33
396-
'Webhooks' //34
397-
'WebhookLogs' //35
398-
'WebhookPing' //36
399-
]
400-
}
401-
dependsOn: [
402-
netFunction
403-
]
404-
}
405-
406251
output fuzz_storage string = storage.outputs.FuzzId
407252
output fuzz_name string = storage.outputs.FuzzName
408253
output fuzz_key string = storage.outputs.FuzzKey

src/deployment/bicep-templates/function-settings.bicep

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,14 @@ param monitor_account_name string
2828
param functions_worker_runtime string
2929
param functions_extension_version string
3030

31-
param agent_function_names array
32-
param functions_disabled string
33-
3431
param enable_profiler bool
3532

36-
var disabledFunctionName = 'disabledFunctions-${name}'
37-
3833
var telemetry = 'd7a73cf4-5a1a-4030-85e1-e5b25867e45a'
3934

4035
resource function 'Microsoft.Web/sites@2021-02-01' existing = {
4136
name: name
4237
}
4338

44-
module disabledFunctions 'function-settings-disabled-apps.bicep' = {
45-
name: disabledFunctionName
46-
params:{
47-
functions_disabled_setting: functions_disabled
48-
allFunctions: agent_function_names
49-
}
50-
}
51-
5239
var enable_profilers = enable_profiler ? {
5340
APPINSIGHTS_PROFILERFEATURE_VERSION : '1.0.0'
5441
DiagnosticServices_EXTENSION_VERSION: '~3'
@@ -79,5 +66,5 @@ resource functionSettings 'Microsoft.Web/sites/config@2021-03-01' = {
7966
ONEFUZZ_KEYVAULT: keyvault_name
8067
ONEFUZZ_OWNER: owner
8168
ONEFUZZ_CLIENT_SECRET: client_secret
82-
}, disabledFunctions.outputs.appSettings, enable_profilers)
69+
}, enable_profilers)
8370
}

src/deployment/deploy.py

Lines changed: 11 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@
9999
"specifying for this argument and retry."
100100
)
101101

102-
DOTNET_APPLICATION_SUFFIX = "-net"
103-
104102
logger = logging.getLogger("deploy")
105103

106104

@@ -301,49 +299,25 @@ def create_password(self, object_id: UUID) -> Tuple[str, str]:
301299
"cli_password", object_id, self.get_subscription_id()
302300
)
303301

304-
def get_instance_urls(self) -> List[str]:
302+
def get_instance_url(self) -> str:
305303
# The url to access the instance
306304
# This also represents the legacy identifier_uris of the application
307305
# registration
308306
if self.multi_tenant_domain:
309-
return [
310-
"https://%s/%s" % (self.multi_tenant_domain, name)
311-
for name in [
312-
self.application_name,
313-
self.application_name + DOTNET_APPLICATION_SUFFIX,
314-
]
315-
]
307+
return "https://%s/%s" % (self.multi_tenant_domain, self.application_name)
316308
else:
317-
return [
318-
"https://%s.azurewebsites.net" % name
319-
for name in [
320-
self.application_name,
321-
self.application_name + DOTNET_APPLICATION_SUFFIX,
322-
]
323-
]
309+
return "https://%s.azurewebsites.net" % self.application_name
324310

325-
def get_identifier_urls(self) -> List[str]:
311+
def get_identifier_url(self) -> str:
326312
# This is used to identify the application registration via the
327313
# identifier_uris field. Depending on the environment this value needs
328314
# to be from an approved domain The format of this value is derived
329315
# from the default value proposed by azure when creating an application
330316
# registration api://{guid}/...
331317
if self.multi_tenant_domain:
332-
return [
333-
"api://%s/%s" % (self.multi_tenant_domain, name)
334-
for name in [
335-
self.application_name,
336-
self.application_name + DOTNET_APPLICATION_SUFFIX,
337-
]
338-
]
318+
return "api://%s/%s" % (self.multi_tenant_domain, self.application_name)
339319
else:
340-
return [
341-
"api://%s.azurewebsites.net" % name
342-
for name in [
343-
self.application_name,
344-
self.application_name + DOTNET_APPLICATION_SUFFIX,
345-
]
346-
]
320+
return "api://%s.azurewebsites.net" % self.application_name
347321

348322
def get_signin_audience(self) -> str:
349323
# https://docs.microsoft.com/en-us/azure/active-directory/develop/supported-accounts-validation
@@ -514,7 +488,7 @@ def update_existing_app_registration(
514488
# find any identifier URIs that need updating
515489
identifier_uris: List[str] = app["identifierUris"]
516490
updated_identifier_uris = list(
517-
set(identifier_uris) | set(self.get_identifier_urls())
491+
set(identifier_uris) | set([self.get_identifier_url()])
518492
)
519493
if len(updated_identifier_uris) > len(identifier_uris):
520494
update_properties["identifierUris"] = updated_identifier_uris
@@ -561,7 +535,7 @@ def create_new_app_registration(
561535

562536
params = {
563537
"displayName": self.application_name,
564-
"identifierUris": self.get_identifier_urls(),
538+
"identifierUris": [self.get_identifier_url()],
565539
"signInAudience": self.get_signin_audience(),
566540
"appRoles": app_roles,
567541
"api": {
@@ -583,10 +557,7 @@ def create_new_app_registration(
583557
"enableAccessTokenIssuance": False,
584558
"enableIdTokenIssuance": True,
585559
},
586-
"redirectUris": [
587-
f"{url}/.auth/login/aad/callback"
588-
for url in self.get_instance_urls()
589-
],
560+
"redirectUris": [f"{self.get_instance_url()}/.auth/login/aad/callback"],
590561
},
591562
"requiredResourceAccess": [
592563
{
@@ -662,8 +633,8 @@ def deploy_template(self) -> None:
662633
"%Y-%m-%dT%H:%M:%SZ"
663634
)
664635

665-
app_func_audiences = self.get_identifier_urls().copy()
666-
app_func_audiences.extend(self.get_instance_urls())
636+
app_func_audiences = [self.get_identifier_url()]
637+
app_func_audiences.extend([self.get_instance_url()])
667638

668639
if self.multi_tenant_domain:
669640
# clear the value in the Issuer Url field:
@@ -1135,45 +1106,6 @@ def deploy_app(self) -> None:
11351106
if error is not None:
11361107
raise error
11371108

1138-
def deploy_dotnet_app(self) -> None:
1139-
logger.info("deploying function app %s ", self.app_zip)
1140-
with tempfile.TemporaryDirectory() as tmpdirname:
1141-
with zipfile.ZipFile(self.app_zip, "r") as zip_ref:
1142-
func = shutil.which("func")
1143-
assert func is not None
1144-
1145-
zip_ref.extractall(tmpdirname)
1146-
error: Optional[subprocess.CalledProcessError] = None
1147-
max_tries = 5
1148-
for i in range(max_tries):
1149-
try:
1150-
subprocess.check_output(
1151-
[
1152-
func,
1153-
"azure",
1154-
"functionapp",
1155-
"publish",
1156-
self.application_name + DOTNET_APPLICATION_SUFFIX,
1157-
"--no-build",
1158-
"--dotnet-version",
1159-
"7.0",
1160-
],
1161-
env=dict(os.environ, CLI_DEBUG="1"),
1162-
cwd=tmpdirname,
1163-
)
1164-
return
1165-
except subprocess.CalledProcessError as err:
1166-
error = err
1167-
if i + 1 < max_tries:
1168-
logger.debug("func failure error: %s", err)
1169-
logger.warning(
1170-
"function failed to deploy, waiting 60 "
1171-
"seconds and trying again"
1172-
)
1173-
time.sleep(60)
1174-
if error is not None:
1175-
raise error
1176-
11771109
def update_registration(self) -> None:
11781110
if not self.create_registration:
11791111
return
@@ -1241,7 +1173,6 @@ def main() -> None:
12411173
("instance-specific-setup", Client.upload_instance_setup),
12421174
("third-party", Client.upload_third_party),
12431175
("api", Client.deploy_app),
1244-
("dotnet-api", Client.deploy_dotnet_app),
12451176
("export_appinsights", Client.add_log_export),
12461177
("update_registration", Client.update_registration),
12471178
]

0 commit comments

Comments
 (0)