Skip to content

Commit 0368d1c

Browse files
Python updated to version 3.13
* updated the python version to latest * Changed the python version in all workflows * Added azure identity package to requirements * Changed the authentication type * Changed python version to 3.13 and enabled manual trigger * Changed vnet name * Changed vnet create function * Changed subnets create function * Changed subnet name to subnet list * Fixed subnet name * Changed the deletion of vnet resource group * Added existing VPC condition
1 parent 8481301 commit 0368d1c

8 files changed

+58
-45
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v3
18-
- name: Set up Python 3.8
18+
- name: Set up Python 3.13
1919
uses: actions/setup-python@v4
2020
with:
21-
python-version: 3.8
21+
python-version: '3.13'
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip

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

Lines changed: 3 additions & 2 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

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
name: MATLAB Web App Server Ref Arch Azure Health Check Test on Linux in West US
66

77
on:
8+
workflow_dispatch:
89
schedule:
910
- cron: '0 16 * * 3'
1011
jobs:
@@ -13,10 +14,10 @@ jobs:
1314

1415
steps:
1516
- uses: actions/checkout@v3
16-
- name: Set up Python 3.8
17+
- name: Set up Python 3.13
1718
uses: actions/setup-python@v4
1819
with:
19-
python-version: 3.8
20+
python-version: '3.13'
2021
- name: Install dependencies
2122
run: |
2223
python -m pip install --upgrade pip

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

Lines changed: 3 additions & 2 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

healthcheck/healthcheck_webapps_refarch.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
3535
resource_name_vnet = 'vnet_resource_group'
3636
# Deploy a resource group with a virtual network and specified number of subnets
3737
try:
38-
subnet_name, vnet_name = DeployOp.create_vnet(credentials,
38+
subnet_name_list, vnet_name = DeployOp.create_vnet(credentials,
3939
subscription_id,
4040
location,
4141
subnets_cidr,
4242
resource_name_vnet,
4343
vnet_cidr)
44+
subnet_name = subnet_name_list[0]
4445
network_client = NetworkManagementClient(credentials, subscription_id)
4546
# Add service endpoint to subnets
4647
subnet = network_client.subnets.get(resource_name_vnet, vnet_name, subnet_name)
@@ -49,7 +50,7 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
4950
subnet.service_endpoints.append(
5051
ServiceEndpointPropertiesFormat(service='Microsoft.Storage')
5152
)
52-
updated_subnet = network_client.subnets.create_or_update(
53+
updated_subnet = network_client.subnets.begin_create_or_update(
5354
resource_name_vnet,
5455
vnet_name,
5556
subnet_name,
@@ -73,7 +74,7 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
7374
"Deploy to New or Existing Virtual Network": "existing",
7475
"Name of Virtual Network Where MATLAB Web App Server Will Be Deployed": vnet_name,
7576
"Virtual Network CIDR Range": vnet_cidr,
76-
"Name of Subnet for MATLAB Web App Server": subnet_name[0],
77+
"Name of Subnet for MATLAB Web App Server": subnet_name,
7778
"Server Subnet CIDR Range": subnets_cidr[0],
7879
"Specify Private IP Address to VM Hosting MATLAB Web App Server": '10.1.0.4',
7980
"Resource Group Name Of Virtual Network": resource_name_vnet,
@@ -84,7 +85,10 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
8485
res = requests.get(
8586
f"https://github.com/mathworks-ref-arch/{ref_arch_name}/tree/main/releases/"
8687
)
87-
latest_releases = [re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-1], re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-2]]
88+
latest_releases = [
89+
re.findall(r"releases/(R\d{4}[ab]\b)", res.text)[-1],
90+
re.findall(r"releases/(R\d{4}[ab]\b)", res.text)[-2]
91+
]
8892
for i in range(2):
8993
matlab_release = latest_releases[i]
9094
print("Testing Health Check Release: " + matlab_release + "\n")
@@ -114,15 +118,17 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u
114118
print("Deleted the deployment which is deployed using existing virtual network:-",ct)
115119
# Wait for above deployment deletion
116120
time.sleep(900)
117-
# Delete deployment with virtual network
118-
DeployOp.delete_resourcegroup(credentials, subscription_id, resource_name_vnet)
119-
ct = datetime.datetime.now()
120-
print("Deleted the deployment which contains the virtual network:-",ct)
121121
else:
122122
# Delete the deployment
123123
deployment_deletion = DeployOp.delete_resourcegroup(credentials, subscription_id, resource_group_name)
124124
ct = datetime.datetime.now()
125125
print("Date time after deployment and deletion of stack:-", ct)
126126

127+
if existingVPC=='true':
128+
# Delete deployment with virtual network
129+
DeployOp.delete_resourcegroup(credentials, subscription_id, resource_name_vnet)
130+
ct = datetime.datetime.now()
131+
print("Deleted the deployment which contains the virtual network:-", ct)
132+
127133
if __name__ == '__main__':
128134
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])

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: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ def deploy_webapp_template(credentials,
4343
print("Beginning the deployment... \n\n")
4444
# Deploy template.
4545

46-
deployment = resource_client.deployments.create_or_update(
46+
deployment = resource_client.deployments.begin_create_or_update(
4747
resource_group_name,
4848
f'{ref_arch_name}-deployment',
49-
deployment_properties
49+
{
50+
"properties": deployment_properties
51+
}
5052
)
5153

5254
# Block because of VM quotas.
@@ -67,7 +69,7 @@ def create_vnet(credentials,
6769
vnet_cidr):
6870

6971
resource_client = getResourceClient.get_resource_client(credentials, subscription_id)
70-
vnet_name = 'my_vnet'
72+
vnet_name = "my_vnet-" + str(uuid.uuid4())
7173

7274
# Create resource group
7375
print("Creating a resource group with a virtual network... \n")
@@ -80,20 +82,19 @@ def create_vnet(credentials,
8082
print("Resource group created...\n")
8183

8284
# Create virtual network
83-
async_vnet_creation = network_client.virtual_networks.create_or_update(
84-
resource_name_vnet,
85-
vnet_name,
86-
{
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,
8790
'address_space': {
8891
'address_prefixes': [vnet_cidr]
89-
},
90-
'location': location
91-
92+
}
9293
}
9394
)
9495

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

9899
print("Added a virtual network... \n")
99100

@@ -104,12 +105,14 @@ def create_vnet(credentials,
104105

105106
# Create Subnet
106107
subnet_name = "subnet_" + str(i) + "-" + str(uuid.uuid4())
107-
async_subnet_creation = network_client.subnets.create_or_update(
108-
resource_name_vnet,
109-
vnet_name,
110-
subnet_name,
111-
{'address_prefix': subnets_cidr[i-1]}
112-
)
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+
)
113116
subnet_info = async_subnet_creation.result()
114117
# Add created subnet name to subnet_names array
115118
subnet_names.append(subnet_info.name)
@@ -121,6 +124,6 @@ def create_vnet(credentials,
121124
def delete_resourcegroup(credentials, subscription_id, resource_group_name) :
122125
resource_client = getResourceClient.get_resource_client(credentials, subscription_id)
123126
print("Deleting the deployment... \n\n")
124-
deployment_deletion = resource_client.resource_groups.delete(resource_group_name)
127+
deployment_deletion = resource_client.resource_groups.begin_delete(resource_group_name)
125128
print(deployment_deletion)
126129
#return deployment_deletion

0 commit comments

Comments
 (0)