Skip to content

Commit 89c91be

Browse files
committed
Merge branch 'main' into staging-nlm-update
2 parents 729045d + 4cd9ac5 commit 89c91be

8 files changed

+85
-58
lines changed

.github/workflows/healthcheck-app-existingVnet-Lin-Thurs.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
name: MATLAB Web App Server Ref Arch Azure Existing Virtual Network Health Check Test on linux in Japan East
77

88
on:
9+
workflow_dispatch:
910
schedule:
10-
- cron: '0 16 * * 4'
11+
- cron: '0 12 * * 4'
1112
jobs:
1213
build:
1314
runs-on: ubuntu-latest
1415

1516
steps:
1617
- uses: actions/checkout@v3
17-
- name: Set up Python 3.8
18+
- name: Set up Python 3.13
1819
uses: actions/setup-python@v4
1920
with:
20-
python-version: 3.8
21+
python-version: '3.13'
2122
- name: Install dependencies
2223
run: |
2324
python -m pip install --upgrade pip
@@ -33,5 +34,5 @@ jobs:
3334
- name: MWAS ref Arch Existing Virtual Network Health check test on linux in Japan East.
3435
run: |
3536
cd healthcheck
36-
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "japaneast" "Linux" "true"
37+
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "japaneast" "Linux" "true"
3738

.github/workflows/healthcheck-app-existingVnet-Win-Tue.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
name: MATLAB Web App Server Ref Arch Azure Existing Virtual Network Health Check Test on Windows in West Eu
77

88
on:
9+
workflow_dispatch:
910
schedule:
1011
- cron: '0 16 * * 2'
1112
jobs:
@@ -14,10 +15,10 @@ jobs:
1415

1516
steps:
1617
- uses: actions/checkout@v3
17-
- name: Set up Python 3.8
18+
- name: Set up Python 3.13
1819
uses: actions/setup-python@v4
1920
with:
20-
python-version: 3.8
21+
python-version: '3.13'
2122
- name: Install dependencies
2223
run: |
2324
python -m pip install --upgrade pip
@@ -33,5 +34,5 @@ jobs:
3334
- name: MWAS ref Arch Existing Virtual Network Health check test on Windows in West Eu
3435
run: |
3536
cd healthcheck
36-
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "westeurope" "Windows" "true"
37+
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "westeurope" "Windows" "true"
3738

.github/workflows/healthcheck-app-newVnet-Lin-Wed.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# This workflow will install Python dependencies, run tests and lint with a single version of Python
22
# For more information, see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
43
# The following workflow file triggers the New Virtual Network deployment test "test_refarch_new" every Wednesday with platform as "Linux" in "westus" region.
54

65
name: MATLAB Web App Server Ref Arch Azure Health Check Test on Linux in West US
76

87
on:
8+
workflow_dispatch:
99
schedule:
1010
- cron: '0 16 * * 3'
1111
jobs:
@@ -14,10 +14,10 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17-
- name: Set up Python 3.8
17+
- name: Set up Python 3.13
1818
uses: actions/setup-python@v4
1919
with:
20-
python-version: 3.8
20+
python-version: '3.13'
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
@@ -33,5 +33,5 @@ jobs:
3333
- name: Web App ref Arch New Virtual Network Health check test on Linux in West US
3434
run: |
3535
cd healthcheck
36-
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "westus" "Linux" "false"
36+
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "westus" "Linux" "false"
3737

.github/workflows/healthcheck-app-newVnet-Win-Mon.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
name: MATLAB Web App Server Ref Arch Azure Health Check Test on Windows in East US region
77

88
on:
9+
workflow_dispatch:
910
push:
1011
schedule:
1112
- cron: '0 16 * * 1'
@@ -15,10 +16,10 @@ jobs:
1516

1617
steps:
1718
- uses: actions/checkout@v3
18-
- name: Set up Python 3.8
19+
- name: Set up Python 3.13
1920
uses: actions/setup-python@v4
2021
with:
21-
python-version: 3.8
22+
python-version: '3.13'
2223
- name: Install dependencies
2324
run: |
2425
python -m pip install --upgrade pip
@@ -34,5 +35,5 @@ jobs:
3435
- name: Web App ref Arch New Virtual Network Health check test on Windows in East US region
3536
run: |
3637
cd healthcheck
37-
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.ipaddress }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "eastus" "Windows" "false"
38+
python healthcheck_webapps_refarch.py ${{ secrets.TenantId }} ${{ secrets.ClientId }} ${{ secrets.ClientSecret }} ${{ secrets.SubscriptionId }} ${{ secrets.username }} ${{ secrets.password }} ${{ secrets.sslcertificate }} ${{ secrets.sslkey }} "eastus" "Windows" "false"
3839

healthcheck/healthcheck_webapps_refarch.py

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
import testtools.AzureAuthentication as AzureAuth
1212
import testtools.deploy as DeployOp
1313
from azure.mgmt.network import NetworkManagementClient
14+
from azure.mgmt.network.models import ServiceEndpointPropertiesFormat, Subnet
1415

15-
def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, username, password, ipAddress, sslCertificate, sslPrivateKey, location_arg, platform_arg, existingVPC):
16+
def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, username, password, sslCertificate, sslPrivateKey, location_arg, platform_arg, existingVPC):
1617

1718
# Deploy template
1819
# Reference architecture in production.
@@ -25,25 +26,40 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
2526
credentials = AzureAuth.authenticate_client_key(tenant_id, client_id, client_secret)
2627
subscription_id = subscription_id_arg
2728
location = location_arg
29+
ipAddress = requests.get("https://api.ipify.org").text + "/32"
2830

2931
if existingVPC=='true':
30-
print('yes')
3132
# Subnets & virtual network info
3233
subnets_cidr = ['10.1.0.0/24']
3334
vnet_cidr = '10.1.0.0/16'
3435
# Resource group where virtual network is created
3536
resource_name_vnet = 'vnet_resource_group'
3637
# Deploy a resource group with a virtual network and specified number of subnets
3738
try:
38-
subnet_name, vnet_name = DeployOp.create_vnet(credentials,
39+
subnet_name_list, vnet_name = DeployOp.create_vnet(credentials,
3940
subscription_id,
4041
location,
4142
subnets_cidr,
4243
resource_name_vnet,
4344
vnet_cidr)
45+
subnet_name = subnet_name_list[0]
46+
network_client = NetworkManagementClient(credentials, subscription_id)
47+
# Add service endpoint to subnets
48+
subnet = network_client.subnets.get(resource_name_vnet, vnet_name, subnet_name)
49+
if not subnet.service_endpoints:
50+
subnet.service_endpoints = []
51+
subnet.service_endpoints.append(
52+
ServiceEndpointPropertiesFormat(service='Microsoft.Storage')
53+
)
54+
updated_subnet = network_client.subnets.begin_create_or_update(
55+
resource_name_vnet,
56+
vnet_name,
57+
subnet_name,
58+
subnet
59+
).result()
60+
print(f"Enabled Microsoft.Storage service endpoint for subnet: {subnet_name}")
4461
except Exception as e:
4562
raise(e)
46-
print(subnet_name[0])
4763
# Parameters for deployment
4864
parameters = {
4965
"IP Addresses Permitted to Remote into Server VM in CIDR Notation": ipAddress,
@@ -59,20 +75,21 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
5975
"Deploy to New or Existing Virtual Network": "existing",
6076
"Name of Virtual Network Where MATLAB Web App Server Will Be Deployed": vnet_name,
6177
"Virtual Network CIDR Range": vnet_cidr,
62-
"Name of Subnet for MATLAB Web App Server": subnet_name[0],
78+
"Name of Subnet for MATLAB Web App Server": subnet_name,
6379
"Server Subnet CIDR Range": subnets_cidr[0],
6480
"Specify Private IP Address to VM Hosting MATLAB Web App Server": '10.1.0.4',
6581
"Resource Group Name Of Virtual Network": resource_name_vnet,
6682
"Operating System": platform_arg
6783
})
6884

69-
print(parameters)
70-
7185
# Find latest MATLAB release from Github page and get template json path.
7286
res = requests.get(
7387
f"https://github.com/mathworks-ref-arch/{ref_arch_name}/tree/main/releases/"
7488
)
75-
latest_releases = [re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-1], re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-2]]
89+
latest_releases = [
90+
re.findall(r"releases/(R\d{4}[ab]\b)", res.text)[-1],
91+
re.findall(r"releases/(R\d{4}[ab]\b)", res.text)[-2]
92+
]
7693
for i in range(2):
7794
matlab_release = latest_releases[i]
7895
print("Testing Health Check Release: " + matlab_release + "\n")
@@ -102,15 +119,17 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
102119
print("Deleted the deployment which is deployed using existing virtual network:-",ct)
103120
# Wait for above deployment deletion
104121
time.sleep(900)
105-
# Delete deployment with virtual network
106-
DeployOp.delete_resourcegroup(credentials, subscription_id, resource_name_vnet)
107-
ct = datetime.datetime.now()
108-
print("Deleted the deployment which contains the virtual network:-",ct)
109122
else:
110123
# Delete the deployment
111124
deployment_deletion = DeployOp.delete_resourcegroup(credentials, subscription_id, resource_group_name)
112125
ct = datetime.datetime.now()
113126
print("Date time after deployment and deletion of stack:-", ct)
114127

128+
if existingVPC=='true':
129+
# Delete deployment with virtual network
130+
DeployOp.delete_resourcegroup(credentials, subscription_id, resource_name_vnet)
131+
ct = datetime.datetime.now()
132+
print("Deleted the deployment which contains the virtual network:-", ct)
133+
115134
if __name__ == '__main__':
116-
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8], sys.argv[9], sys.argv[10], sys.argv[11], sys.argv[12])
135+
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5], sys.argv[6], sys.argv[7], sys.argv[8], sys.argv[9], sys.argv[10], sys.argv[11])

healthcheck/requirements.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
azure-functions
2-
azure-mgmt-resource==8.0.1
3-
azure-mgmt-marketplaceordering==0.1.0
4-
azure-mgmt-compute==4.6.2
5-
azure-mgmt-network==10.2.0
6-
azure-common==1.1.24
7-
adal==1.2.2
8-
msrestazure==0.6.2
1+
azure-functions==1.23.0
2+
azure-identity==1.23.0
3+
azure-mgmt-resource==24.0.0
4+
azure-mgmt-marketplaceordering==1.1.0
5+
azure-mgmt-compute==34.1.0
6+
azure-mgmt-network==29.0.0
7+
azure-common==1.1.28
8+
adal==1.2.7
9+
msrestazure==0.6.4

healthcheck/testtools/AzureAuthentication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from azure.common import credentials
22
from azure.common.credentials import ServicePrincipalCredentials
3-
from msrestazure.azure_active_directory import AADTokenCredentials
3+
from azure.identity import ClientSecretCredential
44
import adal
55

66
def authenticate_client_key(tenant_id, client_id, client_secret):
@@ -14,6 +14,6 @@ def authenticate_client_key(tenant_id, client_id, client_secret):
1414

1515
context = adal.AuthenticationContext(authority_uri, api_version=None)
1616
mgmt_token = context.acquire_token_with_client_credentials(resource_uri, client_id, client_secret)
17-
credentials = AADTokenCredentials(mgmt_token, client_id)
17+
credentials = ClientSecretCredential(tenant_id, client_id, client_secret)
1818

1919
return credentials

healthcheck/testtools/deploy.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import urllib.request, json
22
import azure.functions as func
3+
import uuid
34

45
from azure.mgmt.resource.resources.models import DeploymentMode
56
from azure.mgmt.compute import ComputeManagementClient
@@ -42,10 +43,12 @@ def deploy_webapp_template(credentials,
4243
print("Beginning the deployment... \n\n")
4344
# Deploy template.
4445

45-
deployment = resource_client.deployments.create_or_update(
46+
deployment = resource_client.deployments.begin_create_or_update(
4647
resource_group_name,
4748
f'{ref_arch_name}-deployment',
48-
deployment_properties
49+
{
50+
"properties": deployment_properties
51+
}
4952
)
5053

5154
# Block because of VM quotas.
@@ -66,7 +69,7 @@ def create_vnet(credentials,
6669
vnet_cidr):
6770

6871
resource_client = getResourceClient.get_resource_client(credentials, subscription_id)
69-
vnet_name = 'my_vnet'
72+
vnet_name = "my_vnet-" + str(uuid.uuid4())
7073

7174
# Create resource group
7275
print("Creating a resource group with a virtual network... \n")
@@ -79,20 +82,19 @@ def create_vnet(credentials,
7982
print("Resource group created...\n")
8083

8184
# Create virtual network
82-
async_vnet_creation = network_client.virtual_networks.create_or_update(
83-
resource_name_vnet,
84-
vnet_name,
85-
{
85+
async_vnet_creation = network_client.virtual_networks.begin_create_or_update(
86+
resource_group_name=resource_name_vnet,
87+
virtual_network_name=vnet_name,
88+
parameters={
89+
'location': location,
8690
'address_space': {
8791
'address_prefixes': [vnet_cidr]
88-
},
89-
'location': location
90-
92+
}
9193
}
9294
)
9395

94-
# Wait for the virtual network creation
95-
async_vnet_creation.wait()
96+
# Wait for the virtual network creation to complete
97+
async_vnet_creation.result()
9698

9799
print("Added a virtual network... \n")
98100

@@ -102,13 +104,15 @@ def create_vnet(credentials,
102104
for i in range(1, len(subnets_cidr) + 1):
103105

104106
# Create Subnet
105-
subnet_name = "subnet" + str(i)
106-
async_subnet_creation = network_client.subnets.create_or_update(
107-
resource_name_vnet,
108-
vnet_name,
109-
subnet_name,
110-
{'address_prefix': subnets_cidr[i-1]}
111-
)
107+
subnet_name = "subnet_" + str(i) + "-" + str(uuid.uuid4())
108+
async_subnet_creation = network_client.subnets.begin_create_or_update(
109+
resource_group_name=resource_name_vnet,
110+
virtual_network_name=vnet_name,
111+
subnet_name=subnet_name,
112+
subnet_parameters={
113+
'address_prefix': subnets_cidr[i - 1]
114+
}
115+
)
112116
subnet_info = async_subnet_creation.result()
113117
# Add created subnet name to subnet_names array
114118
subnet_names.append(subnet_info.name)
@@ -120,6 +124,6 @@ def create_vnet(credentials,
120124
def delete_resourcegroup(credentials, subscription_id, resource_group_name) :
121125
resource_client = getResourceClient.get_resource_client(credentials, subscription_id)
122126
print("Deleting the deployment... \n\n")
123-
deployment_deletion = resource_client.resource_groups.delete(resource_group_name)
127+
deployment_deletion = resource_client.resource_groups.begin_delete(resource_group_name)
124128
print(deployment_deletion)
125-
#return deployment_deletion
129+
#return deployment_deletion

0 commit comments

Comments
 (0)