diff --git a/.github/workflows/healthcheck-app-existingVnet-Lin-Thurs.yml b/.github/workflows/healthcheck-app-existingVnet-Lin-Thurs.yml index 927e9cf..940719f 100644 --- a/.github/workflows/healthcheck-app-existingVnet-Lin-Thurs.yml +++ b/.github/workflows/healthcheck-app-existingVnet-Lin-Thurs.yml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.13 uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.13' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/healthcheck-app-existingVnet-Win-Tue.yml b/.github/workflows/healthcheck-app-existingVnet-Win-Tue.yml index b2ab7c0..1dd75b5 100644 --- a/.github/workflows/healthcheck-app-existingVnet-Win-Tue.yml +++ b/.github/workflows/healthcheck-app-existingVnet-Win-Tue.yml @@ -6,6 +6,7 @@ name: MATLAB Web App Server Ref Arch Azure Existing Virtual Network Health Check Test on Windows in West Eu on: + workflow_dispatch: schedule: - cron: '0 16 * * 2' jobs: @@ -14,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.13 uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.13' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/healthcheck-app-newVnet-Lin-Wed.yml b/.github/workflows/healthcheck-app-newVnet-Lin-Wed.yml index db5b232..f5f491e 100644 --- a/.github/workflows/healthcheck-app-newVnet-Lin-Wed.yml +++ b/.github/workflows/healthcheck-app-newVnet-Lin-Wed.yml @@ -5,6 +5,7 @@ name: MATLAB Web App Server Ref Arch Azure Health Check Test on Linux in West US on: + workflow_dispatch: schedule: - cron: '0 16 * * 3' jobs: @@ -13,10 +14,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.13 uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.13' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/healthcheck-app-newVnet-Win-Mon.yml b/.github/workflows/healthcheck-app-newVnet-Win-Mon.yml index fe0e7b3..be89d01 100644 --- a/.github/workflows/healthcheck-app-newVnet-Win-Mon.yml +++ b/.github/workflows/healthcheck-app-newVnet-Win-Mon.yml @@ -6,6 +6,7 @@ name: MATLAB Web App Server Ref Arch Azure Health Check Test on Windows in East US region on: + workflow_dispatch: push: schedule: - cron: '0 16 * * 1' @@ -15,10 +16,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.13 uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: '3.13' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/healthcheck/healthcheck_webapps_refarch.py b/healthcheck/healthcheck_webapps_refarch.py index 6c46eaf..d7b1ccf 100644 --- a/healthcheck/healthcheck_webapps_refarch.py +++ b/healthcheck/healthcheck_webapps_refarch.py @@ -35,12 +35,13 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u resource_name_vnet = 'vnet_resource_group' # Deploy a resource group with a virtual network and specified number of subnets try: - subnet_name, vnet_name = DeployOp.create_vnet(credentials, + subnet_name_list, vnet_name = DeployOp.create_vnet(credentials, subscription_id, location, subnets_cidr, resource_name_vnet, vnet_cidr) + subnet_name = subnet_name_list[0] network_client = NetworkManagementClient(credentials, subscription_id) # Add service endpoint to subnets 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 subnet.service_endpoints.append( ServiceEndpointPropertiesFormat(service='Microsoft.Storage') ) - updated_subnet = network_client.subnets.create_or_update( + updated_subnet = network_client.subnets.begin_create_or_update( resource_name_vnet, vnet_name, subnet_name, @@ -73,7 +74,7 @@ def main(tenant_id_arg, client_id_arg, client_secret_arg, subscription_id_arg, u "Deploy to New or Existing Virtual Network": "existing", "Name of Virtual Network Where MATLAB Web App Server Will Be Deployed": vnet_name, "Virtual Network CIDR Range": vnet_cidr, - "Name of Subnet for MATLAB Web App Server": subnet_name[0], + "Name of Subnet for MATLAB Web App Server": subnet_name, "Server Subnet CIDR Range": subnets_cidr[0], "Specify Private IP Address to VM Hosting MATLAB Web App Server": '10.1.0.4', "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 res = requests.get( f"https://github.com/mathworks-ref-arch/{ref_arch_name}/tree/main/releases/" ) - latest_releases = [re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-1], re.findall("releases/(R\d{4}[ab]\\b)", res.text)[-2]] + latest_releases = [ + re.findall(r"releases/(R\d{4}[ab]\b)", res.text)[-1], + re.findall(r"releases/(R\d{4}[ab]\b)", res.text)[-2] + ] for i in range(2): matlab_release = latest_releases[i] 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 print("Deleted the deployment which is deployed using existing virtual network:-",ct) # Wait for above deployment deletion time.sleep(900) - # Delete deployment with virtual network - DeployOp.delete_resourcegroup(credentials, subscription_id, resource_name_vnet) - ct = datetime.datetime.now() - print("Deleted the deployment which contains the virtual network:-",ct) else: # Delete the deployment deployment_deletion = DeployOp.delete_resourcegroup(credentials, subscription_id, resource_group_name) ct = datetime.datetime.now() print("Date time after deployment and deletion of stack:-", ct) + if existingVPC=='true': + # Delete deployment with virtual network + DeployOp.delete_resourcegroup(credentials, subscription_id, resource_name_vnet) + ct = datetime.datetime.now() + print("Deleted the deployment which contains the virtual network:-", ct) + if __name__ == '__main__': 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]) diff --git a/healthcheck/requirements.txt b/healthcheck/requirements.txt index bf596d5..beea8b5 100644 --- a/healthcheck/requirements.txt +++ b/healthcheck/requirements.txt @@ -1,8 +1,9 @@ -azure-functions -azure-mgmt-resource==8.0.1 -azure-mgmt-marketplaceordering==0.1.0 -azure-mgmt-compute==4.6.2 -azure-mgmt-network==10.2.0 -azure-common==1.1.24 -adal==1.2.2 -msrestazure==0.6.2 \ No newline at end of file +azure-functions==1.23.0 +azure-identity==1.23.0 +azure-mgmt-resource==24.0.0 +azure-mgmt-marketplaceordering==1.1.0 +azure-mgmt-compute==34.1.0 +azure-mgmt-network==29.0.0 +azure-common==1.1.28 +adal==1.2.7 +msrestazure==0.6.4 \ No newline at end of file diff --git a/healthcheck/testtools/AzureAuthentication.py b/healthcheck/testtools/AzureAuthentication.py index 831029e..20619fb 100644 --- a/healthcheck/testtools/AzureAuthentication.py +++ b/healthcheck/testtools/AzureAuthentication.py @@ -1,6 +1,6 @@ from azure.common import credentials from azure.common.credentials import ServicePrincipalCredentials -from msrestazure.azure_active_directory import AADTokenCredentials +from azure.identity import ClientSecretCredential import adal def authenticate_client_key(tenant_id, client_id, client_secret): @@ -14,6 +14,6 @@ def authenticate_client_key(tenant_id, client_id, client_secret): context = adal.AuthenticationContext(authority_uri, api_version=None) mgmt_token = context.acquire_token_with_client_credentials(resource_uri, client_id, client_secret) - credentials = AADTokenCredentials(mgmt_token, client_id) + credentials = ClientSecretCredential(tenant_id, client_id, client_secret) return credentials \ No newline at end of file diff --git a/healthcheck/testtools/deploy.py b/healthcheck/testtools/deploy.py index 734d451..30fb7eb 100644 --- a/healthcheck/testtools/deploy.py +++ b/healthcheck/testtools/deploy.py @@ -43,10 +43,12 @@ def deploy_webapp_template(credentials, print("Beginning the deployment... \n\n") # Deploy template. - deployment = resource_client.deployments.create_or_update( + deployment = resource_client.deployments.begin_create_or_update( resource_group_name, f'{ref_arch_name}-deployment', - deployment_properties + { + "properties": deployment_properties + } ) # Block because of VM quotas. @@ -67,7 +69,7 @@ def create_vnet(credentials, vnet_cidr): resource_client = getResourceClient.get_resource_client(credentials, subscription_id) - vnet_name = 'my_vnet' + vnet_name = "my_vnet-" + str(uuid.uuid4()) # Create resource group print("Creating a resource group with a virtual network... \n") @@ -80,20 +82,19 @@ def create_vnet(credentials, print("Resource group created...\n") # Create virtual network - async_vnet_creation = network_client.virtual_networks.create_or_update( - resource_name_vnet, - vnet_name, - { + async_vnet_creation = network_client.virtual_networks.begin_create_or_update( + resource_group_name=resource_name_vnet, + virtual_network_name=vnet_name, + parameters={ + 'location': location, 'address_space': { 'address_prefixes': [vnet_cidr] - }, - 'location': location - + } } ) - # Wait for the virtual network creation - async_vnet_creation.wait() + # Wait for the virtual network creation to complete + async_vnet_creation.result() print("Added a virtual network... \n") @@ -104,12 +105,14 @@ def create_vnet(credentials, # Create Subnet subnet_name = "subnet_" + str(i) + "-" + str(uuid.uuid4()) - async_subnet_creation = network_client.subnets.create_or_update( - resource_name_vnet, - vnet_name, - subnet_name, - {'address_prefix': subnets_cidr[i-1]} - ) + async_subnet_creation = network_client.subnets.begin_create_or_update( + resource_group_name=resource_name_vnet, + virtual_network_name=vnet_name, + subnet_name=subnet_name, + subnet_parameters={ + 'address_prefix': subnets_cidr[i - 1] + } + ) subnet_info = async_subnet_creation.result() # Add created subnet name to subnet_names array subnet_names.append(subnet_info.name) @@ -121,6 +124,6 @@ def create_vnet(credentials, def delete_resourcegroup(credentials, subscription_id, resource_group_name) : resource_client = getResourceClient.get_resource_client(credentials, subscription_id) print("Deleting the deployment... \n\n") - deployment_deletion = resource_client.resource_groups.delete(resource_group_name) + deployment_deletion = resource_client.resource_groups.begin_delete(resource_group_name) print(deployment_deletion) #return deployment_deletion