diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..314766e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf diff --git a/db/provision.cmd b/db/provision.cmd index 7aa375b..6ebd014 100644 --- a/db/provision.cmd +++ b/db/provision.cmd @@ -1,12 +1,14 @@ -az group create -l centralus -n PythonAzureExample-DB-rg +az group create --location southcentralus --name PythonAzureExample-DB-rg -az mysql server create -l westus -g PythonAzureExample-DB-rg -n PythonAzureExample-MySQL-12345 ^ - -u azureuser -p ChangePa$$w0rd24 --sku-name B_Gen5_1 +az mysql flexible-server create --location southcentralus --resource-group PythonAzureExample-DB-rg ^ + --name python-azure-example-mysql-12345 --admin-user azureuser --admin-password ChangePa$$w0rd24 ^ + --sku-name Standard_B1ms --version 5.7 --yes # Change the IP address to the public IP address of your workstation, that is, the address shown -# by a site like https://whatismyipaddress.com/. +# by a site like https://whatismyipaddress.com/. -az mysql server firewall-rule create -g PythonAzureExample-DB-rg --server PythonAzureExample-MySQL-12345 ^ - -n allow_ip --start-ip-address 10.11.12.13 --end-ip-address 10.11.12.13 +az mysql flexible-server firewall-rule create --resource-group PythonAzureExample-DB-rg --name python-azure-example-mysql-12345 ^ + --rule-name allow_ip --start-ip-address 10.11.12.13 --end-ip-address 10.11.12.13 -az mysql db create -g PythonAzureExample-DB-rg --server PythonAzureExample-MySQL-12345 -n example-db1 +az mysql flexible-server db create --resource-group PythonAzureExample-DB-rg --server-name python-azure-example-mysql-12345 ^ + --database-name example-db1 diff --git a/db/provision.sh b/db/provision.sh index 77ce0ac..c1f0536 100644 --- a/db/provision.sh +++ b/db/provision.sh @@ -1,12 +1,14 @@ -az group create -l centralus -n PythonAzureExample-DB-rg +az group create --location southcentralus --name PythonAzureExample-DB-rg -az mysql server create -l westus -g PythonAzureExample-DB-rg -n PythonAzureExample-MySQL-12345 \ - -u azureuser -p ChangePa$$w0rd24 --sku-name B_Gen5_1 +az mysql flexible-server create --location southcentralus --resource-group PythonAzureExample-DB-rg \ + --name python-azure-example-mysql-12345 --admin-user azureuser --admin-password ChangePa$$w0rd24 \ + --sku-name Standard_B1ms --version 5.7 --yes # Change the IP address to the public IP address of your workstation, that is, the address shown -# by a site like https://whatismyipaddress.com/. +# by a site like https://whatismyipaddress.com/. -az mysql server firewall-rule create -g PythonAzureExample-DB-rg --server PythonAzureExample-MySQL-12345 \ - -n allow_ip --start-ip-address 10.11.12.13 --end-ip-address 10.11.12.13 +az mysql flexible-server firewall-rule create --resource-group PythonAzureExample-DB-rg --name python-azure-example-mysql-12345 \ + --rule-name allow_ip --start-ip-address 10.11.12.13 --end-ip-address 10.11.12.13 -az mysql db create -g PythonAzureExample-DB-rg --server PythonAzureExample-MySQL-12345 -n example-db1 \ No newline at end of file +az mysql flexible-server db create --resource-group PythonAzureExample-DB-rg --server-name python-azure-example-mysql-12345 \ + --database-name example-db1 diff --git a/db/provision_db.py b/db/provision_db.py index 3d75b59..7062726 100644 --- a/db/provision_db.py +++ b/db/provision_db.py @@ -1,11 +1,11 @@ import random, os -from azure.identity import AzureCliCredential +from azure.identity import DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient -from azure.mgmt.rdbms.mysql import MySQLManagementClient -from azure.mgmt.rdbms.mysql.models import ServerForCreate, ServerPropertiesForDefaultCreate, ServerVersion +from azure.mgmt.rdbms.mysql_flexibleservers import MySQLManagementClient +from azure.mgmt.rdbms.mysql_flexibleservers.models import Server, ServerVersion # Acquire a credential object using CLI-based authentication. -credential = AzureCliCredential() +credential = DefaultAzureCredential() # Retrieve subscription ID from environment variable subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] @@ -13,7 +13,7 @@ # Constants we need in multiple places: the resource group name and the region # in which we provision resources. You can change these values however you want. RESOURCE_GROUP_NAME = 'PythonAzureExample-DB-rg' -LOCATION = "westus" +LOCATION = "southcentralus" # Step 1: Provision the resource group. resource_client = ResourceManagementClient(credential, subscription_id) @@ -35,7 +35,7 @@ # # Also set DB_USER_NAME and DB_USER_PASSWORD variables to avoid using the defaults. -db_server_name = os.environ.get("DB_SERVER_NAME", f"PythonAzureExample-MySQL-{random.randint(1,100000):05}") +db_server_name = os.environ.get("DB_SERVER_NAME", f"python-azure-example-mysql-{random.randint(1,100000):05}") db_admin_name = os.environ.get("DB_ADMIN_NAME", "azureuser") db_admin_password = os.environ.get("DB_ADMIN_PASSWORD", "ChangePa$$w0rd24") @@ -45,13 +45,11 @@ # Provision the server and wait for the result poller = mysql_client.servers.begin_create(RESOURCE_GROUP_NAME, db_server_name, - ServerForCreate( + Server( location=LOCATION, - properties=ServerPropertiesForDefaultCreate( - administrator_login=db_admin_name, - administrator_login_password=db_admin_password, - version=ServerVersion.FIVE7 - ) + administrator_login=db_admin_name, + administrator_login_password=db_admin_password, + version=ServerVersion.FIVE7 ) ) diff --git a/db/requirements.txt b/db/requirements.txt index 29d268b..766bf14 100644 --- a/db/requirements.txt +++ b/db/requirements.txt @@ -1,5 +1,4 @@ azure-mgmt-resource azure-mgmt-rdbms azure-identity -mysql -mysql-connector +mysql-connector-python diff --git a/db/use_db.py b/db/use_db.py index 82e7c72..d7c8683 100644 --- a/db/use_db.py +++ b/db/use_db.py @@ -8,7 +8,7 @@ db_name = os.getenv("DB_NAME", "example-db1") db_port = os.getenv("DB_PORT", 3306) -connection = mysql.connector.connect(user=f"{db_admin_name}@{db_server_name}", +connection = mysql.connector.connect(user=db_admin_name, password=db_admin_password, host=f"{db_server_name}.mysql.database.azure.com", port=db_port, database=db_name, ssl_ca='./BaltimoreCyberTrustRoot.crt.pem') diff --git a/managed_disk/create_image_from_blob.py b/managed_disk/create_image_from_blob.py index ce968e0..a3482fc 100644 --- a/managed_disk/create_image_from_blob.py +++ b/managed_disk/create_image_from_blob.py @@ -2,12 +2,12 @@ 'my_resource_group', 'myImage', { - 'location': 'westus', + 'location': 'eastus', 'storage_profile': { 'os_disk': { 'os_type': 'Linux', 'os_state': "Generalized", - 'blob_uri': 'https://bg09.blob.core.windows.net/vm-images/non-existent.vhd', + 'blob_uri': 'https://.blob.core.windows.net/vm-images/test.vhd', 'caching': "ReadWrite", } } diff --git a/managed_disk/create_snapshot.py b/managed_disk/create_snapshot.py index f95325a..7c4bf87 100644 --- a/managed_disk/create_snapshot.py +++ b/managed_disk/create_snapshot.py @@ -4,7 +4,7 @@ 'my_resource_group', 'mySnapshot', { - 'location': 'westus', + 'location': 'eastus', 'creation_data': { 'create_option': 'Copy', 'source_uri': managed_disk.id diff --git a/managed_disk/disk_from_blob.py b/managed_disk/disk_from_blob.py index 2551adf..c65ff14 100644 --- a/managed_disk/disk_from_blob.py +++ b/managed_disk/disk_from_blob.py @@ -6,9 +6,10 @@ { 'location': 'eastus', 'creation_data': { - 'create_option': DiskCreateOption.import_enum, - 'source_uri': 'https://bg09.blob.core.windows.net/vm-images/non-existent.vhd' + 'create_option': DiskCreateOption.IMPORT, + 'storage_account_id': '/subscriptions//resourceGroups//providers/Microsoft.Storage/storageAccounts/', + 'source_uri': 'https://.blob.core.windows.net/vm-images/test.vhd' } } ) -disk_resource = poller.result() +disk_resource = poller.result() \ No newline at end of file diff --git a/managed_disk/disk_from_image.py b/managed_disk/disk_from_image.py index 32b3314..72c4326 100644 --- a/managed_disk/disk_from_image.py +++ b/managed_disk/disk_from_image.py @@ -9,7 +9,7 @@ { 'location': 'eastus', 'creation_data': { - 'create_option': DiskCreateOption.copy, + 'create_option': DiskCreateOption.COPY, 'source_resource_id': managed_disk.id } } diff --git a/managed_disk/disk_image_from_blob.py b/managed_disk/disk_image_from_blob.py index 94b7394..bc75709 100644 --- a/managed_disk/disk_image_from_blob.py +++ b/managed_disk/disk_image_from_blob.py @@ -1,4 +1,4 @@ -from azure.mgmt.compute.models import DiskCreateOption +from azure.mgmt.compute.models import OperatingSystemStateTypes, HyperVGeneration poller = compute_client.images.begin_create_or_update( 'my_resource_group', @@ -8,11 +8,12 @@ 'storage_profile': { 'os_disk': { 'os_type': 'Linux', - 'os_state': "Generalized", - 'blob_uri': 'https://bg09.blob.core.windows.net/vm-images/non-existent.vhd', + 'os_state': OperatingSystemStateTypes.GENERALIZED, + 'blob_uri': 'https://.blob.core.windows.net/vm-images/test.vhd', 'caching': "ReadWrite", - } - } + }, + }, + 'hyper_v_generation': HyperVGeneration.V2, } ) -image_resource = poller.result() +image_resource = poller.result() \ No newline at end of file diff --git a/managed_disk/update_storage_type.py b/managed_disk/update_storage_type.py index d4155e7..6e65048 100644 --- a/managed_disk/update_storage_type.py +++ b/managed_disk/update_storage_type.py @@ -1,7 +1,7 @@ from azure.mgmt.compute.models import StorageAccountTypes managed_disk = compute_client.disks.get('my_resource_group', 'myDisk') -managed_disk.account_type = StorageAccountTypes.standard_lrs +managed_disk.account_type = StorageAccountTypes.STANDARD_LRS async_update = self.compute_client.disks.begin_create_or_update( 'my_resource_group', diff --git a/proxy/set_http_proxy.py b/proxy/set_http_proxy.py index f47d89c..01f9e4c 100644 --- a/proxy/set_http_proxy.py +++ b/proxy/set_http_proxy.py @@ -13,7 +13,7 @@ credential = DefaultAzureCredential() -storage_url = "your_url" +storage_url = "https://.blob.core.windows.net" blob_client = BlobClient(storage_url, container_name="blob-container-01", blob_name="sample-blob.txt", credential=credential, diff --git a/proxy/set_proxy.sh b/proxy/set_proxy.sh index dba926d..9004a1f 100644 --- a/proxy/set_proxy.sh +++ b/proxy/set_proxy.sh @@ -1,11 +1,11 @@ -# Non-authenticated HTTP server: -HTTP_PROXY=http://10.10.1.10:1180 +# Non-authenticated HTTP proxy for HTTPS requests: +export HTTPS_PROXY=http://10.10.1.10:1180 -# Authenticated HTTP server: -HTTP_PROXY=http://username:password@10.10.1.10:1180 +# Authenticated HTTP proxy for HTTPS requests: +export HTTPS_PROXY=http://username:password@10.10.1.10:1180 -# Non-authenticated HTTPS server: -HTTPS_PROXY=http://10.10.1.10:1180 +# Non-authenticated HTTP proxy for HTTP requests: +export HTTP_PROXY=http://10.10.1.10:1180 -# Authenticated HTTPS server: -HTTPS_PROXY=http://username:password@10.10.1.10:1180 \ No newline at end of file +# Authenticated HTTP proxy for HTTP requests: +export HTTP_PROXY=http://username:password@10.10.1.10:1180 diff --git a/resource_group/list_groups.py b/resource_group/list_groups.py index a6c3b02..0671c08 100644 --- a/resource_group/list_groups.py +++ b/resource_group/list_groups.py @@ -1,10 +1,10 @@ # Import the needed credential and management objects from the libraries. -from azure.identity import AzureCliCredential +from azure.identity import DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient import os -# Acquire a credential object using CLI-based authentication. -credential = AzureCliCredential() +# Acquire a credential object. +credential = DefaultAzureCredential() # Retrieve subscription ID from environment variable. subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] diff --git a/resource_group/list_resources.py b/resource_group/list_resources.py index a4a3d51..9d5372f 100644 --- a/resource_group/list_resources.py +++ b/resource_group/list_resources.py @@ -1,10 +1,10 @@ # Import the needed credential and management objects from the libraries. -from azure.identity import AzureCliCredential +from azure.identity import DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient import os -# Acquire a credential object using CLI-based authentication. -credential = AzureCliCredential() +# Acquire a credential object. +credential = DefaultAzureCredential() # Retrieve subscription ID from environment variable. subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] diff --git a/resource_group/provision_rg.py b/resource_group/provision_rg.py index 16e8e78..8448e5e 100644 --- a/resource_group/provision_rg.py +++ b/resource_group/provision_rg.py @@ -1,11 +1,11 @@ # Import the needed credential and management objects from the libraries. import os -from azure.identity import AzureCliCredential +from azure.identity import DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient -# Acquire a credential object using CLI-based authentication. -credential = AzureCliCredential() +# Acquire a credential object using DevaultAzureCredential. +credential = DefaultAzureCredential() # Retrieve subscription ID from environment variable. subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] @@ -30,8 +30,7 @@ # /azure-sdk-library-usage-patterns#inline-json-pattern-for-object-arguments print( - f"Provisioned resource group {rg_result.name} in \ - the {rg_result.location} region" + f"Provisioned resource group {rg_result.name} in the {rg_result.location} region" ) # The return value is another ResourceGroup object with all the details of the diff --git a/resource_group/requirements.txt b/resource_group/requirements.txt index 1bb9c64..9479f31 100644 --- a/resource_group/requirements.txt +++ b/resource_group/requirements.txt @@ -1,2 +1,2 @@ -azure-mgmt-resource>=18.0.0 -azure-identity>=1.5.0 +azure-mgmt-resource +azure-identity diff --git a/sovereign_domain/private_cloud.py b/sovereign_domain/private_cloud.py index d0b7d99..93621d9 100644 --- a/sovereign_domain/private_cloud.py +++ b/sovereign_domain/private_cloud.py @@ -1,5 +1,4 @@ import os -from msrestazure.azure_cloud import get_cloud_from_metadata_endpoint from azure.mgmt.resource import ResourceManagementClient, SubscriptionClient from azure.identity import DefaultAzureCredential from azure.profiles import KnownProfiles @@ -9,20 +8,23 @@ # https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#environment-variables subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] -stack_cloud = get_cloud_from_metadata_endpoint("https://contoso-azurestack-arm-endpoint.com") +authority = "" +endpoint = "" +audience = "" # When using a private cloud, you must use an authority with DefaultAzureCredential. # The active_directory endpoint should be a URL like https://login.microsoftonline.com. -credential = DefaultAzureCredential(authority=stack_cloud.endpoints.active_directory) +credential = DefaultAzureCredential(authority=authority) resource_client = ResourceManagementClient( credential, subscription_id, - base_url=stack_cloud.endpoints.resource_manager, + base_url=endpoint, profile=KnownProfiles.v2019_03_01_hybrid, - credential_scopes=[stack_cloud.endpoints.active_directory_resource_id + "/.default"]) + credential_scopes=[audience]) subscription_client = SubscriptionClient( credential, - base_url=stack_cloud.endpoints.resource_manager, + base_url=endpoint, profile=KnownProfiles.v2019_03_01_hybrid, - credential_scopes=[stack_cloud.endpoints.active_directory_resource_id + "/.default"]) + credential_scopes=[audience]) + \ No newline at end of file diff --git a/sovereign_domain/sovereign_cloud.py b/sovereign_domain/sovereign_cloud.py index bb53af0..c3dfdc0 100644 --- a/sovereign_domain/sovereign_cloud.py +++ b/sovereign_domain/sovereign_cloud.py @@ -1,8 +1,10 @@ import os -from msrestazure.azure_cloud import AZURE_CHINA_CLOUD as CLOUD from azure.mgmt.resource import ResourceManagementClient, SubscriptionClient from azure.identity import DefaultAzureCredential, AzureAuthorityHosts +authority = AzureAuthorityHosts.AZURE_CHINA +resource_manager = "https://management.chinacloudapi.cn" + # Set environment variable AZURE_SUBSCRIPTION_ID as well as environment variables # for DefaultAzureCredential. For combinations of environment variables, see # https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#environment-variables @@ -10,14 +12,15 @@ # When using sovereign domains (that is, any cloud other than AZURE_PUBLIC_CLOUD), # you must use an authority with DefaultAzureCredential. -credential = DefaultAzureCredential(authority=AzureAuthorityHosts.AZURE_CHINA) +credential = DefaultAzureCredential(authority=authority) resource_client = ResourceManagementClient( credential, subscription_id, - base_url=CLOUD.endpoints.resource_manager, - credential_scopes=[CLOUD.endpoints.resource_manager + "/.default"]) + base_url=resource_manager, + credential_scopes=[resource_manager + "/.default"]) subscription_client = SubscriptionClient( credential, - base_url=CLOUD.endpoints.resource_manager, - credential_scopes=[CLOUD.endpoints.resource_manager + "/.default"]) + base_url=resource_manager, + credential_scopes=[resource_manager + "/.default"]) + \ No newline at end of file diff --git a/storage/provision_blob.py b/storage/provision_blob.py index 281da02..b32c9f3 100644 --- a/storage/provision_blob.py +++ b/storage/provision_blob.py @@ -2,12 +2,12 @@ # Import the needed management objects from the libraries. The azure.common library # is installed automatically with the other libraries. -from azure.identity import AzureCliCredential +from azure.identity import DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient from azure.mgmt.storage import StorageManagementClient -# Acquire a credential object using CLI-based authentication. -credential = AzureCliCredential() +# Acquire a credential object. +credential = DefaultAzureCredential() # Retrieve subscription ID from environment variable. subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] @@ -35,9 +35,6 @@ storage_client = StorageManagementClient(credential, subscription_id) -# This example uses the CLI profile credentials because we assume the script -# is being used to provision the resource in the same way the Azure CLI would be used. - STORAGE_ACCOUNT_NAME = f"pythonazurestorage{random.randint(1,100000):05}" # You can replace the storage account here with any unique name. A random number is used diff --git a/storage/use_blob_auth_async.py b/storage/use_blob_auth_async.py new file mode 100644 index 0000000..e16894d --- /dev/null +++ b/storage/use_blob_auth_async.py @@ -0,0 +1,33 @@ +import os +import uuid +import asyncio + +from azure.identity.aio import DefaultAzureCredential + +# Import the client object from the SDK library +from azure.storage.blob.aio import BlobClient + +# Retrieve the storage blob service URL, which is of the form +# https://.blob.core.windows.net/ +storage_url = os.environ["AZURE_STORAGE_BLOB_URL"] + +credential = DefaultAzureCredential() + +async def run(): + + async with BlobClient( + storage_url, + container_name="blob-container-01", + blob_name=f"sample-blob-{str(uuid.uuid4())[0:5]}.txt", + credential=credential, + ) as blob_client: + + # Open a local file and upload its contents to Blob Storage + with open("./sample-source.txt", "rb") as data: + await blob_client.upload_blob(data) + print(f"Uploaded sample-source.txt to {blob_client.url}") + + # Close credential + await credential.close() + +asyncio.run(run()) diff --git a/storage/use_blob_auth_logging.py b/storage/use_blob_auth_logging.py index 66c21cd..2561a88 100644 --- a/storage/use_blob_auth_logging.py +++ b/storage/use_blob_auth_logging.py @@ -14,6 +14,11 @@ logger = logging.getLogger("azure.storage.blob") logger.setLevel(logging.DEBUG) +# Direct logging output to stdout. Without adding a handler, +# no logging output is visible. +handler = logging.StreamHandler(stream=sys.stdout) +logger.addHandler(handler) + print( f"Logger enabled for ERROR={logger.isEnabledFor(logging.ERROR)}, " f"WARNING={logger.isEnabledFor(logging.WARNING)}, " @@ -21,11 +26,6 @@ f"DEBUG={logger.isEnabledFor(logging.DEBUG)}" ) -# Direct logging output to stdout. Without adding a handler, -# no logging output is visible. -handler = logging.StreamHandler(stream=sys.stdout) -logger.addHandler(handler) - try: credential = DefaultAzureCredential() storage_url = os.environ["AZURE_STORAGE_BLOB_URL"] @@ -39,7 +39,7 @@ credential=credential, ) - with open("./sample-blob.txt", "rb") as data: + with open("./sample-source.txt", "rb") as data: blob_client.upload_blob(data, logging_body=True, logging_enable=True) except ( diff --git a/vm/provision_vm.py b/vm/provision_vm.py index 6bae4a7..703f918 100644 --- a/vm/provision_vm.py +++ b/vm/provision_vm.py @@ -1,7 +1,7 @@ # Import the needed credential and management objects from the libraries. import os -from azure.identity import AzureCliCredential +from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient from azure.mgmt.network import NetworkManagementClient from azure.mgmt.resource import ResourceManagementClient @@ -11,8 +11,8 @@ minute or two." ) -# Acquire a credential object using CLI-based authentication. -credential = AzureCliCredential() +# Acquire a credential object. +credential = DefaultAzureCredential() # Retrieve subscription ID from environment variable. subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] @@ -20,8 +20,7 @@ # Step 1: Provision a resource group -# Obtain the management object for resources, using the credentials -# from the CLI login. +# Obtain the management object for resources. resource_client = ResourceManagementClient(credential, subscription_id) # Constants we need in multiple places: the resource group name and diff --git a/webapp/provision.cmd b/webapp/provision.cmd index 19e7aa2..b885e3d 100644 --- a/webapp/provision.cmd +++ b/webapp/provision.cmd @@ -19,3 +19,10 @@ rem to match the sequence of the Python code. az webapp create -n %appName% -g PythonAzureExample-WebApp-rg ^ --plan PythonAzureExample-WebApp-plan --runtime "python|3.8" ^ --deployment-source-url %repoUrl% + +rem The previous command sets up External Git deployment from the specified repository. This +rem command triggers a pull from the repository. + +az webapp deployment source sync --name %appName% --resource-group PythonAzureExample-WebApp-rg + + diff --git a/webapp/provision.sh b/webapp/provision.sh index 69b1b91..79e6451 100644 --- a/webapp/provision.sh +++ b/webapp/provision.sh @@ -18,3 +18,8 @@ az webapp create -g PythonAzureExample-WebApp-rg -n $APP_NAME \ az webapp create -n $APP_NAME -g PythonAzureExample-WebApp-rg \ --plan PythonAzureExample-WebApp-plan --runtime "python|3.8" \ --deployment-source-url $REPO_URL + +# The previous command sets up External Git deployment from the specified repository. This +# command triggers a pull from the repository. + +az webapp deployment source sync --name $APP_NAME --resource-group PythonAzureExample-WebApp-rg diff --git a/webapp/provision_deploy_web_app.py b/webapp/provision_deploy_web_app.py index 57ef9fa..e7b0850 100644 --- a/webapp/provision_deploy_web_app.py +++ b/webapp/provision_deploy_web_app.py @@ -89,10 +89,21 @@ { "location": "GitHub", "repo_url": REPO_URL, - "branch": "master" + "branch": "master", + "is_manual_integration": True } ) sc_result = poller.result() print(f"Set source control on web app to {sc_result.branch} branch of {sc_result.repo_url}") + +# Step 5: Deploy the code using the repository and branch configured in the previous step. +# +# If you push subsequent code changes to the repo and branch, you must call this method again +# or use another Azure tool like the Azure CLI or Azure portal to redeploy. +# Note: By default, the method returns None. + +app_service_client.web_apps.sync_repository(RESOURCE_GROUP_NAME, WEB_APP_NAME) + +print(f"Deploy code") \ No newline at end of file